ytdlwrapper

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: AGPL-3.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DownloadProgress added in v0.0.3

type DownloadProgress struct {
	Downloaded uint64
	TotalSize  uint64
	Speed      uint64
	Percent    string
}

type Entry

type Entry struct {
	ID          string `json:"id"`
	Title       string `json:"title"`
	UploadDate  string `json:"upload_date"`
	UploaderID  string `json:"uploader_id"`
	ChannelID   string `json:"channel_id"`
	Description string `json:"description"`
	Extractor   string `json:"extractor"`
	WebpageURL  string `json:"webpage_url"` // sometimes not set

	// these are set for "URL"-type objects, returned from --flat-playlist
	RawURL string `json:"url"`
	IEKey  string `json:"ie_key"`
}

An Entry is a single video

func (*Entry) BestURL

func (entry *Entry) BestURL() string

BestURL returns the most appropriate URL for an entry

type InfoOutput

type InfoOutput struct {
	Entry      Entry
	Playlist   Playlist
	IsPlaylist bool
}

InfoOutput represents the JSON returned by `youtube-dl -J`. It changes format depending on if the target is a video or an entire playlist, which is why the struct looks like this:

func (*InfoOutput) GetAllEntries

func (infoOutput *InfoOutput) GetAllEntries() []Entry

GetAllEntries returns an array of all entries, even if InfoOutput is just for a single video.

type Playlist

type Playlist struct {
	ID        string  `json:"id"`
	Extractor string  `json:"extractor"`
	Entries   []Entry `json:"entries"`
}

A Playlist is a list of entries

type Wrapper

type Wrapper struct {
	BinPath string
}

A Wrapper for the youtube-dl binary

func Make

func Make() *Wrapper

Make a default instance of the youtube-dl wrapper

func (*Wrapper) Download

func (wrapper *Wrapper) Download(ctx context.Context, url string, args ...string) ([]byte, error)

Download the given URL using youtube-dl

func (*Wrapper) DownloadWithProgress added in v0.0.3

func (wrapper *Wrapper) DownloadWithProgress(ctx context.Context, callback func(*DownloadProgress), url string, args ...string) error

DownloadWithProgress downloads the given URL using youtube-dl and provides progress updates

func (*Wrapper) Info

func (wrapper *Wrapper) Info(ctx context.Context, url string) (*InfoOutput, error)

Info returns information about the URL, like if it is a playlist or a single video.

func (*Wrapper) Update

func (wrapper *Wrapper) Update(ctx context.Context) error

Update youtube-dl

Jump to

Keyboard shortcuts

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