Compare commits

...
2 Commits
Author SHA1 Message Date
Niko Storni 8fb1e2ead0 fix empty thumbnails 2021-06-25 19:04:40 +02:00
Niko Storni 3b84db382c attempt using aria2c for some servers 2021-06-24 23:06:27 +02:00
4 changed files with 20 additions and 8 deletions

No files matched your search

+3 -1
View File
@@ -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),
+1
View File
@@ -90,6 +90,7 @@ var ErrorsNoRetry = []string{
"This video has been removed by the uploader",
"Premiere will begin shortly",
"cannot unmarshal number 0.0",
"default youtube thumbnail found",
}
var WalletErrors = []string{
"Not enough funds to cover this transaction",
+12 -1
View File
@@ -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,
@@ -675,6 +683,9 @@ func (v *YoutubeVideo) delete(reason string) error {
func (v *YoutubeVideo) triggerThumbnailSave() (err error) {
thumbnail := thumbs.GetBestThumbnail(v.youtubeInfo.Thumbnails)
if thumbnail.Width == 0 {
return errors.Err("default youtube thumbnail found")
}
v.thumbnailURL, err = thumbs.MirrorThumbnail(thumbnail.URL, v.ID(), v.awsConfig)
return err
}
+4 -6
View File
@@ -117,13 +117,11 @@ func MirrorThumbnail(url string, name string, s3Config aws.Config) (string, erro
}
func GetBestThumbnail(thumbnails []ytdl.Thumbnail) *ytdl.Thumbnail {
var bestWidth *ytdl.Thumbnail
var bestWidth ytdl.Thumbnail
for _, thumbnail := range thumbnails {
if bestWidth == nil {
bestWidth = &thumbnail
} else if bestWidth.Width < thumbnail.Width {
bestWidth = &thumbnail
if bestWidth.Width < thumbnail.Width {
bestWidth = thumbnail
}
}
return bestWidth
return &bestWidth
}