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

20 lines
778 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-11-03 10:07:12 +01:00
let streamIndex = (random int ..(($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
2023-11-03 10:07:12 +01:00
}