Documentation
¶
Overview ¶
Package youtube-dl-go wraps youtube-dl's Python API.
youtube-dl-go is a simple wrapper to the popular youtube-dl application for Python. This allows you to access the youtube-dl binary programmatically in any application that you write.
Index ¶
- Constants
- type Downloader
- func (d *Downloader) Format(format string) *Downloader
- func (d Downloader) GetExtractor() (string, error)
- func (d Downloader) GetInfo() (Info, error)
- func (d *Downloader) NoPlaylist()
- func (d *Downloader) Output(path string) *Downloader
- func (d Downloader) Run() (string, error)
- func (d Downloader) RunProgress() (chan float64, chan Result, error)
- type Info
- type Result
Constants ¶
const (
// Represents the ID of the video.
ID = "%(id)s"
)
Represents format templates that can be used for Downloader output paths.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Represents a youtube-dl command instance for downloading a track. Do not instantiate this yourself. Use NewDownloader to create an instance.
func NewDownloader ¶
func NewDownloader(url string) *Downloader
Creates a new Downloader instance set to download the provided url.
func (*Downloader) Format ¶
func (d *Downloader) Format(format string) *Downloader
Sets the video/audio format for the downloader.
func (Downloader) GetExtractor ¶
func (d Downloader) GetExtractor() (string, error)
Gets the name of the extractor that would be used to handle a given URL.
URLs not matching any extractors result in a "generic" extractor being returned.
func (Downloader) GetInfo ¶
func (d Downloader) GetInfo() (Info, error)
Gets the info of the video, akin to calling youtube-dl with the --dump-json flag.
This will return either an Info instance representing the video info or the encountered error.
func (*Downloader) NoPlaylist ¶
func (d *Downloader) NoPlaylist()
Sets the downloader to avoid downloading playlists, instead downloading the first item, if any.
func (*Downloader) Output ¶
func (d *Downloader) Output(path string) *Downloader
Sets the output path for the downloader.
func (Downloader) Run ¶
func (d Downloader) Run() (string, error)
Runs the downloader. This method blocks until complete. For a channel-based solution, use RunProgress.
This will return the path of the downloaded file as a string or any errors that were encountered.
func (Downloader) RunProgress ¶
func (d Downloader) RunProgress() (chan float64, chan Result, error)
Runs the downloader. This method returns channels that allow to track a download's progress and receive the result once the download is done. For a simpler solution, use Run.
The float64 channel returns percent progress of the download, the Result channel returns a Result struct representing the command's result and contains the command's path or any encountered errors, and the error indicates an error when setting up the command call.
type Info ¶
type Info struct { // The duration of the video, in seconds. Duration float64 `json:"duration"` // The extractor used for the video. Extractor string `json:"extractor"` // The ID of the video. ID string `json:"id"` // The title of the video. Title string `json:"title"` // The default video codec of the video, if any. VCodec string `json:"vcodec"` // The main URL the media is accessible from. WebpageURL string `json:"webpage_url"` }
Represents the information about a video.