nushell: Add kink module

This commit is contained in:
Erwin Boskma 2023-05-30 15:35:45 +02:00
parent 2983121a35
commit 56e1c03098
Signed by: erwin
SSH key fingerprint: SHA256:9LmFDe1C6jSrEyqxxvX8NtJBmcbB105XoqyUZF092bg
2 changed files with 25 additions and 0 deletions

View file

@ -33,9 +33,15 @@ in
register ${pkgs.nushellPlugins.query}/bin/nu_plugin_query
register ${nushell_plugin_formats}/bin/nu_plugin_formats
use kink.nu
'';
};
xdg.configFile."nushell/scripts/kink.nu" = {
source = ./scripts/kink.nu;
};
home.packages = with pkgs; [
carapace
];

View file

@ -0,0 +1,19 @@
export def main [channel?: string] {
let playlist = (if ($channel == null) {
http get https://playerservices.streamtheworld.com/pls/KINKAAC.pls | from ini
} else if ($channel == "80s") {
http get https://playerservices.streamtheworld.com/pls/KINK_DNAAAC.pls | from ini
} else if ($channel == "distortion") {
http get https://playerservices.streamtheworld.com/pls/KINK_DISTORTIONAAC.pls | from ini
} else {
echo "Unknown channel"
exit
})
let playlist = ($playlist.playlist | transpose | where {|x| ($x.column0 | str starts-with "File") } | get column1)
mpc clear
let streamIndex = (random integer ..($playlist | length))
echo $"Playing stream ($streamIndex)"
let stream = ($playlist | get $streamIndex)
mpc add $stream
mpc play
}