From 0725700708417bba28cc65465970538d877ee8ff Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Tue, 13 Mar 2018 17:48:01 -0400 Subject: [PATCH] update youtube download library --- sources/youtubeVideo.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sources/youtubeVideo.go b/sources/youtubeVideo.go index b70a510..52c871c 100644 --- a/sources/youtubeVideo.go +++ b/sources/youtubeVideo.go @@ -14,7 +14,7 @@ import ( "github.com/lbryio/lbry.go/errors" "github.com/lbryio/lbry.go/jsonrpc" - ytdl "github.com/kkdai/youtube" + "github.com/nikooo777/ytdl" log "github.com/sirupsen/logrus" "google.golang.org/api/youtube/v3" ) @@ -103,16 +103,21 @@ func (v YoutubeVideo) download() error { return nil } - downloader := ytdl.NewYoutube(false) - err = downloader.DecodeURL("https://www.youtube.com/watch?v=" + v.id) + videoUrl := "https://www.youtube.com/watch?v=" + v.id + videoInfo, err := ytdl.GetVideoInfo(videoUrl) if err != nil { return err } - err = downloader.StartDownload(videoPath) + + var downloadedFile *os.File + downloadedFile, err = os.Create(v.getFilename()) if err != nil { return err } - return nil + + defer downloadedFile.Close() + + return videoInfo.Download(videoInfo.Formats.Best(ytdl.FormatAudioEncodingKey)[0], downloadedFile) } func (v YoutubeVideo) triggerThumbnailSave() error {