attempt using aria2c for some servers

This commit is contained in:
Niko Storni 2021-06-24 23:06:27 +02:00
parent 4fe6840a4e
commit 3b84db382c
2 changed files with 12 additions and 2 deletions

View file

@ -2,6 +2,7 @@ package ip_manager
import ( import (
"net" "net"
"os"
"sort" "sort"
"sync" "sync"
"time" "time"
@ -45,7 +46,8 @@ func GetIPPool(stopGrp *stop.Group) (*IPPool, error) {
var pool []throttledIP var pool []throttledIP
for _, address := range addrs { for _, address := range addrs {
if ipnet, ok := address.(*net.IPNet); ok && ipnet.IP.IsGlobalUnicast() { 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{ pool = append(pool, throttledIP{
IP: ipnet.IP.String(), IP: ipnet.IP.String(),
LastUse: time.Now().Add(-5 * time.Minute), LastUse: time.Now().Add(-5 * time.Minute),

View file

@ -279,7 +279,15 @@ func (v *YoutubeVideo) download() error {
"--load-info-json", "--load-info-json",
metadataPath, 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} userAgent := []string{"--user-agent", downloader.ChromeUA}
if v.maxVideoSize > 0 { if v.maxVideoSize > 0 {
ytdlArgs = append(ytdlArgs, ytdlArgs = append(ytdlArgs,