ydls

package
v0.0.0-...-2e474ae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MediaAudio mediaType = iota
	MediaVideo
	MediaUnknown
)

Variables

This section is empty.

Functions

func RSSFromYDLSInfo

func RSSFromYDLSInfo(options DownloadOptions, info goutubedl.Info, linkIconRawURL string) rss.RSS

Types

type Codec

type Codec struct {
	Name        string
	Flags       []string
	FormatFlags []string
}

Codec codec name and ffmpeg args

func (*Codec) UnmarshalJSON

func (c *Codec) UnmarshalJSON(b []byte) (err error)

type Config

type Config struct {
	InputFlags      []string
	OutputFlags     []string
	GoutubeDL       GoutubeDLOptions
	CodecMap        map[string]string
	Formats         Formats
	DownloadRetries int
}

YDLS config

type DownloadOptions

type DownloadOptions struct {
	RequestOptions RequestOptions
	BaseURL        *url.URL
	DebugLog       Printer
	HTTPClient     *http.Client
	Retries        int
}

DownloadOptions dowload options

type DownloadResult

type DownloadResult struct {
	Media    io.ReadCloser
	Filename string
	MIMEType string
	// contains filtered or unexported fields
}

DownloadResult download result

func (DownloadResult) Wait

func (dr DownloadResult) Wait()

Wait for download resources to cleanup

type Format

type Format struct {
	Name           string
	Formats        stringprioset.Set
	FormatFlags    []string
	Streams        []Stream
	SubtitleCodecs stringprioset.Set
	Ext            string
	Prepend        string
	MIMEType       string

	// used by rss feeds etc
	EnclosureFormat         string
	EnclosureFormatOptions  []string
	EnclosureRequestOptions RequestOptions `json:"-"`
}

Format media container format, possible codecs, extension and mime

func (Format) String

func (f Format) String() string

func (*Format) UnmarshalJSON

func (f *Format) UnmarshalJSON(b []byte) (err error)

type Formats

type Formats map[string]Format

Formats map name to Format

func (Formats) FindByFormatCodecs

func (fs Formats) FindByFormatCodecs(format string, codecs []string) (Format, string)

FindByFormatCodecs find format by format and codecs prioritize formats with less codecs (more specific) return format and format name, format name is empty if not found

func (Formats) FindByName

func (fs Formats) FindByName(name string) (Format, bool)

FindByName find format by name

func (*Formats) UnmarshalJSON

func (f *Formats) UnmarshalJSON(b []byte) (err error)

type GoutubeDLOptions

type GoutubeDLOptions struct {
	Downloader string
}

type Handler

type Handler struct {
	YDLS      YDLS
	IndexTmpl *template.Template
	InfoLog   Printer
	DebugLog  Printer
}

Handler is a http.Handler using ydls

func (*Handler) ServeHTTP

func (yh *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Printer

type Printer interface {
	Print(v ...interface{})
	Printf(format string, v ...interface{})
}

Printer used for log and debug

type RequestOptions

type RequestOptions struct {
	MediaRawURL string              // youtubedl media URL
	Format      *Format             // output format
	Codecs      []string            // force codecs
	Retranscode bool                // force retranscode even if same input codec
	TimeRange   timerange.TimeRange // time range limit
	Items       uint                // feed item count limit
}

RequestOptions request options

func NewRequestOptionsFromOpts

func NewRequestOptionsFromOpts(opts []string, formats Formats) (RequestOptions, error)

func NewRequestOptionsFromPath

func NewRequestOptionsFromPath(url *url.URL, formats Formats) (RequestOptions, error)

NewRequestOptionsFromPath /format+opt+opt.../schema://host.domin/path?query /format+opt+opt.../host.domain/path?query /schema://host.domain/path?query /host.domain/path?query

func NewRequestOptionsFromQuery

func NewRequestOptionsFromQuery(v url.Values, formats Formats) (RequestOptions, error)

NewRequestOptionsFromQuery /?url=...&format=...

func (RequestOptions) QueryValues

func (r RequestOptions) QueryValues() url.Values

type Stream

type Stream struct {
	Required  bool
	Specifier string
	Codecs    []Codec

	Media      mediaType         `json:"-"`
	CodecNames stringprioset.Set `json:"-"`
}

func (*Stream) UnmarshalJSON

func (s *Stream) UnmarshalJSON(b []byte) (err error)

type YDLS

type YDLS struct {
	Config Config // parsed config
}

YDLS youtubedl downloader with some extras

func NewFromFile

func NewFromFile(configPath string) (YDLS, error)

NewFromFile new YDLs using config file

func (*YDLS) Download

func (ydls *YDLS) Download(ctx context.Context, options DownloadOptions) (DownloadResult, error)

Download downloads media from URL using context and makes sure output is in specified format

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL