Compare commits

...

3 commits

View file

@ -10,7 +10,7 @@ import (
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
) )
var FileExtensions = []string {".webm",".mp4",".mkv"} var FileExtensions = []string {"webm","mp4","mkv"}
func getRedirectURL(input string) (string, error) { func getRedirectURL(input string) (string, error) {
request, err := http.NewRequest("GET", input, nil) request, err := http.NewRequest("GET", input, nil)
@ -97,14 +97,14 @@ func getLargestDashFormat(input goutubedl.Result, sizeLimit float64) (videoForma
func getLargestYTFormat(input goutubedl.Result, sizeLimit float64) (format goutubedl.Format, err error) { func getLargestYTFormat(input goutubedl.Result, sizeLimit float64) (format goutubedl.Format, err error) {
for i := len(input.Formats())-1; i >= 0; i-- { for i := len(input.Formats())-1; i >= 0; i-- {
if input.Formats()[i].VBR > 0 && input.Formats()[i].ASR > 0 { if input.Formats()[i].VBR > 0 && input.Formats()[i].ASR > 0 && slices.Contains(FileExtensions, input.Formats()[i].Ext) {
var size float64 var size float64
if input.Formats()[i].FilesizeApprox > 0 { if input.Formats()[i].FilesizeApprox > 0 {
size = input.Formats()[i].FilesizeApprox size = input.Formats()[i].FilesizeApprox
} else { } else {
size = input.Formats()[i].Filesize size = input.Formats()[i].Filesize
} }
if size <= sizeLimit && input.Formats()[i].FormatID != "17" { if size <= sizeLimit {
return input.Formats()[i], nil return input.Formats()[i], nil
} }
} }