diff --git a/ip_manager/throttle.go b/ip_manager/throttle.go index c7f3878..b8251f1 100644 --- a/ip_manager/throttle.go +++ b/ip_manager/throttle.go @@ -13,7 +13,7 @@ import ( log "github.com/sirupsen/logrus" ) -const IPCooldownPeriod = 35 * time.Second +const IPCooldownPeriod = 20 * time.Second const unbanTimeout = 3 * time.Hour var stopper = stop.New() diff --git a/manager/ytsync.go b/manager/ytsync.go index 04d0b1c..ac96bd4 100644 --- a/manager/ytsync.go +++ b/manager/ytsync.go @@ -872,6 +872,7 @@ func (s *Sync) startWorker(workerNum int) { "giving up after 0 fragment retries", "Sorry about that", "This video is not available", + "requested format not available", } if util.SubstringInSlice(err.Error(), errorsNoRetry) { log.Println("This error should not be retried at all") diff --git a/sources/youtubeVideo.go b/sources/youtubeVideo.go index b386369..be48a39 100644 --- a/sources/youtubeVideo.go +++ b/sources/youtubeVideo.go @@ -178,7 +178,7 @@ func (v *YoutubeVideo) getAbbrevDescription() string { return description + "\n..." + additionalDescription } -func (v *YoutubeVideo) download(useIPv6 bool) error { +func (v *YoutubeVideo) download() error { videoPath := v.getFullPath() err := os.Mkdir(v.videoDir(), 0777) @@ -281,7 +281,7 @@ runcmd: v.pool.SetThrottled(sourceAddress, v.stopGroup) } else if strings.Contains(string(errorLog), "giving up after 0 fragment retries") && qualityIndex < len(qualities)-1 { qualityIndex++ - goto runcmd + goto runcmd //this bypasses the yt throttling IP redistribution... TODO: don't } return errors.Err(string(errorLog)) } @@ -426,21 +426,18 @@ func (v *YoutubeVideo) Sync(daemon *jsonrpc.Client, params SyncParams, existingV return v.downloadAndPublish(daemon, params) } -var isThrottled bool - func (v *YoutubeVideo) downloadAndPublish(daemon *jsonrpc.Client, params SyncParams) (*SyncSummary, error) { - err := v.download(isThrottled) - if err != nil { - if strings.Contains(err.Error(), "HTTP Error 429") && !isThrottled { - isThrottled = true - err = v.download(isThrottled) - if err != nil { - return nil, errors.Prefix("download error", err) - } - } else { + var err error + for { + err = v.download() + if err != nil && strings.Contains(err.Error(), "HTTP Error 429") { + continue + } else if err != nil { return nil, errors.Prefix("download error", err) } + break } + log.Debugln("Downloaded " + v.id) err = v.triggerThumbnailSave()