Fix quickSync && maxVideos

This commit is contained in:
Mark Beamer Jr 2020-07-27 15:57:19 -04:00
parent 1369ed0b48
commit e926a2c1f6
No known key found for this signature in database
GPG key ID: 1C314FB89AD76973
3 changed files with 18 additions and 5 deletions

View file

@ -9,9 +9,20 @@ import (
"github.com/sirupsen/logrus"
)
func GetPlaylistVideoIDs(channelName string) ([]string, error) {
func GetPlaylistVideoIDs(channelName string, maxVideos int) ([]string, error) {
args := []string{"--skip-download", "https://www.youtube.com/channel/" + channelName, "--get-id", "--flat-playlist"}
return run(args)
ids, err := run(args)
if err != nil {
return nil, errors.Err(err)
}
videoIDs := make([]string, maxVideos)
for i, v := range ids {
if i >= maxVideos {
break
}
videoIDs[i] = v
}
return videoIDs, nil
}
func run(args []string) ([]string, error) {

View file

@ -9,12 +9,11 @@ import (
func TestRun(t *testing.T) {
//args := []string{"--skip-download", "https://www.youtube.com/c/Electroboom", "--get-id", "--flat-playlist"}
//videoIDs, err := GetPlaylistVideoIDs("Electroboom")
videoIDs, err := GetPlaylistVideoIDs("UCJ0-OtVpF0wOKEqT2Z1HEtA")
videoIDs, err := GetPlaylistVideoIDs("UCJ0-OtVpF0wOKEqT2Z1HEtA", 50)
if err != nil {
logrus.Error(err)
}
for _, id := range videoIDs {
println(id)
}
t.Error("just stop")
}

View file

@ -52,7 +52,10 @@ var mostRecentlyFailedChannel string // TODO: fix this hack!
func GetVideosToSync(apiKey, channelID string, syncedVideos map[string]sdk.SyncedVideo, quickSync bool, maxVideos int, videoParams VideoParams) ([]Video, error) {
var videos []Video
videoIDs, err := downloader.GetPlaylistVideoIDs(channelID)
if quickSync {
maxVideos = 50
}
videoIDs, err := downloader.GetPlaylistVideoIDs(channelID, maxVideos)
if err != nil {
return nil, errors.Err(err)
}