Nonoo ddaf5ad2fa Add the NoInfoDownload option
Set it to true if you don't want to use the result.Info structure.

If it is set to true, then the New() call won't call youtube-dl to request info
about the source in JSON format, and result.Info structure will not be
populated. The given URL will be downloaded in a single pass in the Download()
call.
2023-08-17 11:18:47 +02:00
2021-01-20 00:52:07 +01:00
2023-06-15 14:51:18 +02:00
2021-01-03 18:47:11 +01:00
2023-08-09 16:02:16 +00:00
2021-05-07 21:52:13 +02:00
2021-01-03 18:47:11 +01:00
2023-08-16 17:19:03 +02:00
2023-08-17 11:18:47 +02:00
2019-07-23 21:39:07 +02:00

goutubedl

Go wrapper for youtube-dl and yt-dlp, currently 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 youtube-dl.

goutubedl default uses PATH to find youtube-dl but it can be configured with the goutubedl.Path variable. Default is currently youtube-dl for backwards compability. If your using yt-dlp you probably want to set it to yt-dlp.

Due to the nature and frequent updates of youtube-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.

Development

docker build --target dev -t goutubedl-dev .
docker run --rm -ti -v "$PWD:$PWD" -w "$PWD" goutubedl-dev
go test -v -race -cover
Description
Go wrapper for youtube-dl and yt-dlp
Readme MIT 478 KiB
Languages
Go 98.1%
Dockerfile 1.9%