Fix quickSync && maxVideos
This commit is contained in:
parent
1369ed0b48
commit
e926a2c1f6
3 changed files with 18 additions and 5 deletions
|
@ -9,9 +9,20 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"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"}
|
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) {
|
func run(args []string) ([]string, error) {
|
||||||
|
|
|
@ -9,12 +9,11 @@ import (
|
||||||
func TestRun(t *testing.T) {
|
func TestRun(t *testing.T) {
|
||||||
//args := []string{"--skip-download", "https://www.youtube.com/c/Electroboom", "--get-id", "--flat-playlist"}
|
//args := []string{"--skip-download", "https://www.youtube.com/c/Electroboom", "--get-id", "--flat-playlist"}
|
||||||
//videoIDs, err := GetPlaylistVideoIDs("Electroboom")
|
//videoIDs, err := GetPlaylistVideoIDs("Electroboom")
|
||||||
videoIDs, err := GetPlaylistVideoIDs("UCJ0-OtVpF0wOKEqT2Z1HEtA")
|
videoIDs, err := GetPlaylistVideoIDs("UCJ0-OtVpF0wOKEqT2Z1HEtA", 50)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
}
|
}
|
||||||
for _, id := range videoIDs {
|
for _, id := range videoIDs {
|
||||||
println(id)
|
println(id)
|
||||||
}
|
}
|
||||||
t.Error("just stop")
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
func GetVideosToSync(apiKey, channelID string, syncedVideos map[string]sdk.SyncedVideo, quickSync bool, maxVideos int, videoParams VideoParams) ([]Video, error) {
|
||||||
|
|
||||||
var videos []Video
|
var videos []Video
|
||||||
videoIDs, err := downloader.GetPlaylistVideoIDs(channelID)
|
if quickSync {
|
||||||
|
maxVideos = 50
|
||||||
|
}
|
||||||
|
videoIDs, err := downloader.GetPlaylistVideoIDs(channelID, maxVideos)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Err(err)
|
return nil, errors.Err(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue