From 3b84db382c8688912e3659f5002b0652da39b092 Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Thu, 24 Jun 2021 23:06:27 +0200 Subject: [PATCH] attempt using aria2c for some servers --- ip_manager/throttle.go | 4 +++- sources/youtubeVideo.go | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ip_manager/throttle.go b/ip_manager/throttle.go index 7d12bc9..6289dee 100644 --- a/ip_manager/throttle.go +++ b/ip_manager/throttle.go @@ -2,6 +2,7 @@ package ip_manager import ( "net" + "os" "sort" "sync" "time" @@ -45,7 +46,8 @@ func GetIPPool(stopGrp *stop.Group) (*IPPool, error) { var pool []throttledIP for _, address := range addrs { if ipnet, ok := address.(*net.IPNet); ok && ipnet.IP.IsGlobalUnicast() { - if ipnet.IP.To16() != nil && govalidator.IsIPv6(ipnet.IP.String()) { + ipv6Disabled := os.Getenv("DISABLE_IPV6") != "" + if ipnet.IP.To16() != nil && govalidator.IsIPv6(ipnet.IP.String()) && !ipv6Disabled { pool = append(pool, throttledIP{ IP: ipnet.IP.String(), LastUse: time.Now().Add(-5 * time.Minute), diff --git a/sources/youtubeVideo.go b/sources/youtubeVideo.go index 9c8d867..734bfda 100644 --- a/sources/youtubeVideo.go +++ b/sources/youtubeVideo.go @@ -279,7 +279,15 @@ func (v *YoutubeVideo) download() error { "--load-info-json", metadataPath, } - + ipv6Disabled := os.Getenv("DISABLE_IPV6") != "" + if ipv6Disabled { + ytdlArgs = append(ytdlArgs, + "--external-downloader", + "aria2c", + "--external-downloader-args", + "aria2c:-j 16 -x 16 -s 16 -k 1M", + ) + } userAgent := []string{"--user-agent", downloader.ChromeUA} if v.maxVideoSize > 0 { ytdlArgs = append(ytdlArgs,