From 5d450a90daa3e6fcab823d31ddc0558c63acfbff Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Mon, 29 Apr 2024 19:42:03 +0200 Subject: [PATCH] things --- invyt.nu | 44 +++++++++++++++++++++++--------------------- port.nu | 5 +++++ reddit-image.nu | 2 +- 3 files changed, 29 insertions(+), 22 deletions(-) create mode 100755 port.nu diff --git a/invyt.nu b/invyt.nu index 39add1f..6e0a312 100755 --- a/invyt.nu +++ b/invyt.nu @@ -1,27 +1,29 @@ #!/usr/bin/env nu -def main [url: string, --return(-r)] { - let parsed_url = $url | url parse +def main [url: string + , --return(-r) # Returns given url as YouTube url + ] { + let parsed_url = $url | url parse - 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 { - error make { - msg: "Not a YouTube/Invidious/Piped URL" - label: { - text: "Expects a YouTube/Invidious/Piped URL" - span: (metadata $url).span - } - } - } + 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 { + 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 } - } + match $return { + true => $yt_url + false => { yt-dlp --embed-chapters --embed-metadata --embed-subs $yt_url } + } } diff --git a/port.nu b/port.nu new file mode 100755 index 0000000..561d5ed --- /dev/null +++ b/port.nu @@ -0,0 +1,5 @@ +#!/usr/bin/env nu + +def main [] { + random int 0..65535 +} diff --git a/reddit-image.nu b/reddit-image.nu index 9dc462e..12b2fd9 100755 --- a/reddit-image.nu +++ b/reddit-image.nu @@ -26,4 +26,4 @@ def get_url [] { true => ( ($decoded | parse "{reddit}={imageUrl}?{params}").imageUrl.0 | str replace "preview" "i" ) false => ($decoded | parse "{reddit}={imageUrl}").imageUrl.0 } -} \ No newline at end of file +}