nixos-config/home-manager/modules/nushell/scripts/kink.nu

19 lines
No EOL
775 B
Text

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
}