Compare commits
3 Commits
v2.0.0
...
bump-yt-dl
Author | SHA1 | Date | |
---|---|---|---|
0f1ca5fc1d | |||
64f5dfc85b | |||
4046d6dc4b |
@ -3,7 +3,7 @@
|
|||||||
ARG GOLANG_VERSION=1.20.5
|
ARG GOLANG_VERSION=1.20.5
|
||||||
# bump: yt-dlp /YT_DLP=([\d.-]+)/ https://github.com/yt-dlp/yt-dlp.git|/^\d/|sort
|
# bump: yt-dlp /YT_DLP=([\d.-]+)/ https://github.com/yt-dlp/yt-dlp.git|/^\d/|sort
|
||||||
# bump: yt-dlp link "Release notes" https://github.com/yt-dlp/yt-dlp/releases/tag/$LATEST
|
# bump: yt-dlp link "Release notes" https://github.com/yt-dlp/yt-dlp/releases/tag/$LATEST
|
||||||
ARG YT_DLP=2023.03.04
|
ARG YT_DLP=2023.06.21
|
||||||
|
|
||||||
FROM golang:$GOLANG_VERSION AS base
|
FROM golang:$GOLANG_VERSION AS base
|
||||||
ARG YT_DLP
|
ARG YT_DLP
|
||||||
|
@ -31,7 +31,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if *dumpFlag {
|
if *dumpFlag {
|
||||||
json.NewEncoder(os.Stdout).Encode(result.Info)
|
_ = json.NewEncoder(os.Stdout).Encode(result.Info)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
goutubedl.go
11
goutubedl.go
@ -204,6 +204,7 @@ type Options struct {
|
|||||||
Type Type
|
Type Type
|
||||||
PlaylistStart uint // --playlist-start
|
PlaylistStart uint // --playlist-start
|
||||||
PlaylistEnd uint // --playlist-end
|
PlaylistEnd uint // --playlist-end
|
||||||
|
Downloader string // --downloader
|
||||||
DownloadThumbnail bool
|
DownloadThumbnail bool
|
||||||
DownloadSubtitles bool
|
DownloadSubtitles bool
|
||||||
ProxyUrl string // --proxy URL http://host:port or socks5://host:port
|
ProxyUrl string // --proxy URL http://host:port or socks5://host:port
|
||||||
@ -264,6 +265,10 @@ func infoFromURL(ctx context.Context, rawURL string, options Options) (info Info
|
|||||||
cmd.Args = append(cmd.Args, "--proxy", options.ProxyUrl)
|
cmd.Args = append(cmd.Args, "--proxy", options.ProxyUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if options.Downloader != "" {
|
||||||
|
cmd.Args = append(cmd.Args, "--downloader", options.Downloader)
|
||||||
|
}
|
||||||
|
|
||||||
if options.Type == TypePlaylist {
|
if options.Type == TypePlaylist {
|
||||||
cmd.Args = append(cmd.Args, "--yes-playlist")
|
cmd.Args = append(cmd.Args, "--yes-playlist")
|
||||||
|
|
||||||
@ -465,6 +470,10 @@ func (result Result) Download(ctx context.Context, filter string) (*DownloadResu
|
|||||||
cmd.Args = append(cmd.Args, "--proxy", result.Options.ProxyUrl)
|
cmd.Args = append(cmd.Args, "--proxy", result.Options.ProxyUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if result.Options.Downloader != "" {
|
||||||
|
cmd.Args = append(cmd.Args, "--downloader", result.Options.Downloader)
|
||||||
|
}
|
||||||
|
|
||||||
cmd.Dir = tempPath
|
cmd.Dir = tempPath
|
||||||
var w io.WriteCloser
|
var w io.WriteCloser
|
||||||
dr.reader, w = io.Pipe()
|
dr.reader, w = io.Pipe()
|
||||||
@ -483,7 +492,7 @@ func (result Result) Download(ctx context.Context, filter string) (*DownloadResu
|
|||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
cmd.Wait()
|
_ = cmd.Wait()
|
||||||
w.Close()
|
w.Close()
|
||||||
os.RemoveAll(tempPath)
|
os.RemoveAll(tempPath)
|
||||||
close(dr.waitCh)
|
close(dr.waitCh)
|
||||||
|
@ -187,7 +187,7 @@ func TestPlaylist(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTestUnsupportedURL(t *testing.T) {
|
func TestUnsupportedURL(t *testing.T) {
|
||||||
defer leaktest.Check(t)()
|
defer leaktest.Check(t)()
|
||||||
|
|
||||||
_, ydlResultErr := goutubedl.New(context.Background(), "https://www.google.com", goutubedl.Options{})
|
_, ydlResultErr := goutubedl.New(context.Background(), "https://www.google.com", goutubedl.Options{})
|
||||||
@ -273,6 +273,31 @@ func TestErrorNotASingleEntry(t *testing.T) {
|
|||||||
DownloadThumbnail: false,
|
DownloadThumbnail: false,
|
||||||
})
|
})
|
||||||
if ydlResultErr != goutubedl.ErrNotASingleEntry {
|
if ydlResultErr != goutubedl.ErrNotASingleEntry {
|
||||||
t.Errorf("expected is single entry error, got %s", ydlResultErr)
|
t.Fatalf("expected is single entry error, got %s", ydlResultErr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestOptionDownloader(t *testing.T) {
|
||||||
|
defer leakChecks(t)()
|
||||||
|
|
||||||
|
ydlResult, ydlResultErr := goutubedl.New(
|
||||||
|
context.Background(),
|
||||||
|
testVideoRawURL,
|
||||||
|
goutubedl.Options{
|
||||||
|
Downloader: "ffmpeg",
|
||||||
|
})
|
||||||
|
|
||||||
|
if ydlResultErr != nil {
|
||||||
|
t.Fatalf("failed to download: %s", ydlResultErr)
|
||||||
|
}
|
||||||
|
dr, err := ydlResult.Download(context.Background(), ydlResult.Info.Formats[0].FormatID)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
downloadBuf := &bytes.Buffer{}
|
||||||
|
_, err = io.Copy(downloadBuf, dr)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
dr.Close()
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user