things
This commit is contained in:
parent
bc942a3432
commit
5d450a90da
44
invyt.nu
44
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 }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
5
port.nu
Executable file
5
port.nu
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env nu
|
||||
|
||||
def main [] {
|
||||
random int 0..65535
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue