diff --git a/sources/youtubeVideo.go b/sources/youtubeVideo.go index fe54101..7fad3e1 100644 --- a/sources/youtubeVideo.go +++ b/sources/youtubeVideo.go @@ -108,7 +108,7 @@ func (v *YoutubeVideo) download() error { _, err = os.Stat(videoPath) if err != nil && !os.IsNotExist(err) { - return err + return errors.Err(err) } else if err == nil { log.Debugln(v.id + " already exists at " + videoPath) return nil @@ -117,7 +117,7 @@ func (v *YoutubeVideo) download() error { videoUrl := "https://www.youtube.com/watch?v=" + v.id videoInfo, err := ytdl.GetVideoInfo(videoUrl) if err != nil { - return err + return errors.Err(err) } codec := []string{"H.264"} @@ -153,7 +153,7 @@ func (v *YoutubeVideo) download() error { var downloadedFile *os.File downloadedFile, err = os.Create(videoPath) if err != nil { - return err + return errors.Err(err) } err = videoInfo.Download(formats[formatIndex], downloadedFile) downloadedFile.Close() @@ -164,7 +164,7 @@ func (v *YoutubeVideo) download() error { } fi, err := os.Stat(v.getFullPath()) if err != nil { - return err + return errors.Err(err) } videoSize := fi.Size() v.size = &videoSize @@ -178,7 +178,7 @@ func (v *YoutubeVideo) download() error { break } } - return err + return errors.Err(err) } func (v *YoutubeVideo) videoDir() string { diff --git a/ytsync.go b/ytsync.go index 5dd3a30..41f9c6d 100644 --- a/ytsync.go +++ b/ytsync.go @@ -672,6 +672,12 @@ func (s *Sync) enqueueYoutubeVideos() error { } if len(playlistResponse.Items) < 1 { + // If there are 50+ videos in a playlist but less than 50 are actually returned by the API, youtube will still redirect + // clients to a next page. Such next page will however be empty. This logic prevents ytsync from failing. + youtubeIsLying := len(videos) > 0 + if youtubeIsLying { + break + } return errors.Err("playlist items not found") }