Some small bits

This commit is contained in:
Nox Sluijtman 2024-04-04 15:54:37 +02:00
parent ababcae988
commit bc942a3432

View file

@ -1,18 +1,27 @@
#!/usr/bin/env nu #!/usr/bin/env nu
def get_url [url: string] { def main [url: string, --return(-r)] {
let parsed_url = $url | url parse let parsed_url = $url | url parse
if ($parsed_url.path | str contains '/watch') {
let yt_url = if ($parsed_url.path | str contains '/watch') {
if $parsed_url.host != "youtube.com" { if $parsed_url.host != "youtube.com" {
$url | str replace $parsed_url.host "youtube.com" $url | str replace $parsed_url.host "youtube.com"
} else { } else {
$url $url
} }
} else { } else {
"Not a YouTube/Invidious/Piped URL" error make {
msg: "Not a YouTube/Invidious/Piped URL"
label: {
text: "Expects a YouTube/Invidious/Piped URL"
span: (metadata $url).span
}
} }
} }
def main [--url: string] { match $return {
yt-dlp --embed-chapters --embed-metadata --embed-subs (get_url $url) true => $yt_url
false => { yt-dlp --embed-chapters --embed-metadata --embed-subs $yt_url }
}
} }