fix stop pattern
fix noretry string fix youtube-dl param
This commit is contained in:
parent
a3fcd67611
commit
6f486717da
3 changed files with 10 additions and 18 deletions
|
@ -22,14 +22,12 @@ var ipLastUsed map[string]time.Time
|
||||||
var ipMutex sync.Mutex
|
var ipMutex sync.Mutex
|
||||||
var stopper = stop.New()
|
var stopper = stop.New()
|
||||||
|
|
||||||
func SignalShutdown() {
|
|
||||||
stopper.Stop()
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetNextIP(ipv6 bool) (string, error) {
|
func GetNextIP(ipv6 bool) (string, error) {
|
||||||
ipMutex.Lock()
|
ipMutex.Lock()
|
||||||
defer ipMutex.Unlock()
|
defer ipMutex.Unlock()
|
||||||
if len(ipv4Pool) < 1 || len(ipv6Pool) < 1 {
|
if len(ipv4Pool) < 1 || len(ipv6Pool) < 1 {
|
||||||
|
throttledIPs = make(map[string]bool)
|
||||||
|
ipLastUsed = make(map[string]time.Time)
|
||||||
addrs, err := net.InterfaceAddrs()
|
addrs, err := net.InterfaceAddrs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Err(err)
|
return "", errors.Err(err)
|
||||||
|
@ -94,18 +92,12 @@ func SetIpThrottled(ip string, stopGrp *stop.Group) {
|
||||||
go func() {
|
go func() {
|
||||||
defer stopper.Done()
|
defer stopper.Done()
|
||||||
unbanTimer := time.NewTimer(unbanTimeout)
|
unbanTimer := time.NewTimer(unbanTimeout)
|
||||||
for {
|
select {
|
||||||
select {
|
case <-unbanTimer.C:
|
||||||
case <-unbanTimer.C:
|
throttledIPs[ip] = false
|
||||||
throttledIPs[ip] = false
|
log.Printf("%s set back to not throttled", ip)
|
||||||
log.Printf("%s set back to not throttled", ip)
|
case <-stopGrp.Ch():
|
||||||
return
|
unbanTimer.Stop()
|
||||||
case <-stopGrp.Ch():
|
|
||||||
unbanTimer.Stop()
|
|
||||||
return
|
|
||||||
default:
|
|
||||||
time.Sleep(5 * time.Second)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
|
@ -667,7 +667,7 @@ func (s *Sync) startWorker(workerNum int) {
|
||||||
} else if s.MaxTries > 1 {
|
} else if s.MaxTries > 1 {
|
||||||
errorsNoRetry := []string{
|
errorsNoRetry := []string{
|
||||||
"non 200 status code received",
|
"non 200 status code received",
|
||||||
" reason: 'This video contains content from",
|
"This video contains content from",
|
||||||
"dont know which claim to update",
|
"dont know which claim to update",
|
||||||
"uploader has not made this video available in your country",
|
"uploader has not made this video available in your country",
|
||||||
"download error: AccessDenied: Access Denied",
|
"download error: AccessDenied: Access Denied",
|
||||||
|
|
|
@ -196,7 +196,7 @@ func (v *YoutubeVideo) download(useIPv6 bool) error {
|
||||||
"--max-filesize",
|
"--max-filesize",
|
||||||
fmt.Sprintf("%dM", v.maxVideoSize),
|
fmt.Sprintf("%dM", v.maxVideoSize),
|
||||||
"--match-filter",
|
"--match-filter",
|
||||||
fmt.Sprintf("'duration <= %d'", int(math.Round(v.maxVideoLength*3600))),
|
fmt.Sprintf("duration <= %d", int(math.Round(v.maxVideoLength*3600))),
|
||||||
"-fbestvideo[ext=mp4][height<=1080]+bestaudio[ext!=webm]",
|
"-fbestvideo[ext=mp4][height<=1080]+bestaudio[ext!=webm]",
|
||||||
"-o" + strings.TrimRight(v.getFullPath(), ".mp4"),
|
"-o" + strings.TrimRight(v.getFullPath(), ".mp4"),
|
||||||
"--merge-output-format",
|
"--merge-output-format",
|
||||||
|
|
Loading…
Reference in a new issue