1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
Files
niveum/packages/scripts/pls.nix
2021-12-29 17:41:53 +01:00

63 lines
1.6 KiB
Nix
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{ lib, pkgs }:
let
playlistAPI = "https://radio.lassul.us";
sendIRC = pkgs.writers.writeDash "send-irc" ''
${pkgs.ircaids}/bin/ircsink \
--nick musikkritiker \
--server irc.hackint.org \
--port 6697 \
--secure \
--target '#the_playlist' >/dev/null 2>&1
'';
messages.good = [
"what a banger"
"ooh i love this song"
"this is top notch stuff!"
"nice!"
"noice!"
"yesss!"
"cool song!"
"i like this"
"that just sounds awesome!"
"that's a good song!"
"👍"
"vibin'"
];
messages.bad = [
"how can anyone listen to this?"
"(°° "
"skip this!"
"next, please! i'm suffering!"
"that's just bad music"
"nope"
"that sucks!"
"👎"
"turn that down"
"make it stooop"
"noooo"
];
in
pkgs.writers.writeDashBin "pls" ''
case "$1" in
good|like|cool|nice|noice|top|yup|yass|yes|+)
${pkgs.curl}/bin/curl -sS -XPOST "${playlistAPI}/good"
echo ${lib.escapeShellArg (lib.concatStringsSep "\n" messages.good)} | shuf -n1 | ${sendIRC}
;;
skip|next|bad|sucks|no|nope|flop|-)
${pkgs.curl}/bin/curl -sS -XPOST "${playlistAPI}/skip"
echo ${lib.escapeShellArg (lib.concatStringsSep "\n" messages.bad)} | shuf -n1 | ${sendIRC}
;;
recent)
${pkgs.curl}/bin/curl -sS -XGET "${playlistAPI}/recent" | tac | head
;;
*)
${pkgs.curl}/bin/curl -sS -XGET "${playlistAPI}/current" \
| ${pkgs.miller}/bin/mlr --ijson --oxtab cat \
| ${pkgs.gnused}/bin/sed -n '/artist\|title\|youtube/p'
;;
esac
wait
''