From bc942a343225178e7ea52d13a37a2143ccaf4426 Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Thu, 4 Apr 2024 15:54:37 +0200 Subject: [PATCH] Some small bits --- invyt.nu | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/invyt.nu b/invyt.nu index 1a093a6..39add1f 100755 --- a/invyt.nu +++ b/invyt.nu @@ -1,18 +1,27 @@ #!/usr/bin/env nu -def get_url [url: string] { +def main [url: string, --return(-r)] { 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" { $url | str replace $parsed_url.host "youtube.com" } else { $url } } 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 + } + } + } + + match $return { + true => $yt_url + false => { yt-dlp --embed-chapters --embed-metadata --embed-subs $yt_url } } -} -def main [--url: string] { - yt-dlp --embed-chapters --embed-metadata --embed-subs (get_url $url) }