From f5935177a85b9738e1fb48df3a0b1e1245a03ff2 Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Wed, 8 May 2024 09:51:47 +0200 Subject: [PATCH] Ramdisk --- invyt.nu | 32 ++++++++++++++++++++++---------- ramdisk.nu | 5 +++++ 2 files changed, 27 insertions(+), 10 deletions(-) create mode 100755 ramdisk.nu diff --git a/invyt.nu b/invyt.nu index 6e0a312..1b3fb6b 100755 --- a/invyt.nu +++ b/invyt.nu @@ -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) } diff --git a/ramdisk.nu b/ramdisk.nu new file mode 100755 index 0000000..0d09f7e --- /dev/null +++ b/ramdisk.nu @@ -0,0 +1,5 @@ +#!/usr/bin/env nu + +def main [--size(-s): string] { + sudo mount -o size=($size | default "8G") -t tmpfs none /mnt/ +}