feat: only use '-f 22' on yt links
This commit is contained in:
parent
8fd3811a72
commit
2dee4917d0
25
yt.go
25
yt.go
@ -4,13 +4,32 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
||||
// yt-dlp flags and options for all links
|
||||
var ytdlpParams []string = []string{
|
||||
"--no-playlist",
|
||||
}
|
||||
|
||||
// yt-dlp flags and options only for youtube links
|
||||
var ytlinkParams []string = []string{
|
||||
"--get-url",
|
||||
"-f 22",
|
||||
}
|
||||
|
||||
func getYoutubeDownloadURL(link string) (string, error) {
|
||||
|
||||
var dlLink string
|
||||
cmd := exec.Command("yt-dlp", "--get-url", "-f 22", link)
|
||||
params := make([]string, 0)
|
||||
params = append(params, ytdlpParams...)
|
||||
|
||||
if isProbablyYT(link) {
|
||||
params = append(params, ytlinkParams...)
|
||||
}
|
||||
|
||||
cmd := exec.Command("yt-dlp", link)
|
||||
result, err := cmd.Output()
|
||||
|
||||
if err != nil {
|
||||
@ -49,3 +68,7 @@ func isValidURL(data string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func isProbablyYT(link string) bool {
|
||||
return strings.Contains(link, "youtube")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user