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

19 lines
781 B
Text
Raw Normal View History

2023-05-30 15:35:45 +02:00
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
2023-07-14 10:40:10 +02:00
let streamIndex = (random integer ..(($playlist | length) - 1))
2023-05-30 15:35:45 +02:00
echo $"Playing stream ($streamIndex)"
let stream = ($playlist | get $streamIndex)
mpc add $stream
mpc play
}