Categorygithub.com/wader/goutubedl
modulepackage
2.2.0+incompatible
Repository: https://github.com/wader/goutubedl.git
Documentation: pkg.go.dev

# README

goutubedl

Go wrapper for youtube-dl and yt-dlp. Currently only tested and developed using yt-dlp. API documentation can be found at godoc.org.

See yt-dlp documentation for how to install and what is recommended to install in addition to yt-dl.

goutubedl default uses PATH to find youtube-dl or yt-dlp (in that order) but can be configured with the goutubedl.Path variable.

Due to the nature of and frequent updates of yt-dl only the latest version is tested. But it seems to work well with older versions also.

Usage

From cmd/example/main.go

package main

import (
	"context"
	"io"
	"log"
	"os"

	"github.com/wader/goutubedl"
)

func main() {
	result, err := goutubedl.New(context.Background(), "https://www.youtube.com/watch?v=jgVhBThJdXc", goutubedl.Options{})
	if err != nil {
		log.Fatal(err)
	}
	downloadResult, err := result.Download(context.Background(), "best")
	if err != nil {
		log.Fatal(err)
	}
	defer downloadResult.Close()
	f, err := os.Create("output")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()
	io.Copy(f, downloadResult)
}

See goutubedl cmd tool or ydls for usage examples.

Default options and cache

.netrc

goutubedl by default uses --netrc to use ~/.netrc authentication data.

Cache directory

yt-dlp stores various extractor session data to speed up things in ${XDG_CACHE_HOME}/yt-dlp (usually ~/.cache/yt-dlp). You might want to preverse this directory if your running things in ephemeral conatiners etc.

Development

docker build --target dev -t goutubedl-dev .
docker run --rm -ti -v "$PWD:$PWD" -w "$PWD" goutubedl-dev
go test -v -race -cover

# Packages

No description provided by the author

# Functions

Downloads given URL using the given options and filter (usually a format id or quality designator).
New downloads metadata for URL.
No description provided by the author
Version of youtube-dl.

# Constants

TypeAny single or playlist (default).
TypeChannel channel containing one or more playlists, which will be flattened.
TypePlaylist playlist with multiple tracks, files etc.
TypeSingle single track, file etc.

# Variables

ErrNotAPlaylist error when single entry when expected a playlist.
ErrNotASingleEntry error when playlist when expected a single entry.
Path to youtube-dl binary.
No description provided by the author

# Structs

No description provided by the author
DownloadResult download result.
Format youtube-dl downloadable format.
Info youtube-dl info.
Options for New().
Result metadata for a URL.
Subtitle youtube-dl subtitle.
No description provided by the author

# Interfaces

Printer is something that can print.

# Type aliases

Type of response you want.
YoutubedlError is a error from youtube-dl.