This commit is contained in:
Nox Sluijtman 2024-05-08 09:51:47 +02:00
parent 5d450a90da
commit f5935177a8
2 changed files with 27 additions and 10 deletions

View file

@ -1,11 +1,9 @@
#!/usr/bin/env nu
def main [url: string
, --return(-r) # Returns given url as YouTube url
] {
def parse_url [url: string] {
let parsed_url = $url | url parse
let yt_url = if ($parsed_url.path | str contains '/watch') {
if ($parsed_url.path | str contains '/watch') {
if $parsed_url.host != "youtube.com" {
$url | str replace $parsed_url.host "youtube.com"
} else {
@ -20,10 +18,24 @@ def main [url: string
}
}
}
match $return {
true => $yt_url
false => { yt-dlp --embed-chapters --embed-metadata --embed-subs $yt_url }
}
def main [ url: string
, --copy(-c)
] {
let $url = parse_url $url
match $copy {
true => { $url | xclip -sel clip }
false => $url
}
}
def "main download" [url: string] {
yt-dlp --embed-chapters --embed-metadata --embed-subs (parse_url $url)
}
def "main dl" [url: string] {
yt-dlp --embed-chapters --embed-metadata --embed-subs (parse_url $url)
}

5
ramdisk.nu Executable file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env nu
def main [--size(-s): string] {
sudo mount -o size=($size | default "8G") -t tmpfs none /mnt/
}