l radio: show recent tracks at https://radio.lassul.us/recent

This commit is contained in:
lassulus 2018-09-25 14:53:53 +02:00
parent 260b757fee
commit a374a45211

View File

@ -131,6 +131,30 @@ in {
}; };
}; };
systemd.services.radio-recent = let
recentlyPlayed = pkgs.writeDash "recentlyPlayed" ''
LIMIT=1000 #how many tracks to keep in the history
HISTORY_FILE=/tmp/played
while :; do
${pkgs.mpc_cli}/bin/mpc idle player > /dev/null
${pkgs.mpc_cli}/bin/mpc current -f %file%
done | while read track; do
echo "$(date -Is)" "$track" | tee -a "$HISTORY_FILE"
echo "$(tail -$LIMIT "$HISTORY_FILE")" > "$HISTORY_FILE"
done
'';
in {
description = "radio recently played";
after = [ "mpd.service" "network.target" ];
wantedBy = [ "multi-user.target" ];
restartIfChanged = true;
serviceConfig = {
ExecStart = recentlyPlayed;
};
};
krebs.Reaktor.playlist = { krebs.Reaktor.playlist = {
nickname = "the_playlist|r"; nickname = "the_playlist|r";
channels = [ channels = [
@ -157,27 +181,40 @@ in {
}) })
]; ];
}; };
services.nginx.virtualHosts."lassul.us".locations."/the_playlist".extraConfig = let services.nginx = {
html = pkgs.writeText "index.html" '' enable = true;
<!DOCTYPE html> virtualHosts."radio.lassul.us" = {
<html lang="en"> forceSSL = true;
<head> enableACME = true;
<meta charset="utf-8"> locations."/".extraConfig = ''
<title>lassulus playlist</title> proxy_pass http://localhost:8000;
</head> '';
<body> locations."/recent".extraConfig = ''
<div style="display:inline-block;margin:0px;padding:0px;overflow:hidden"> alias /tmp/played;
<iframe src="https://kiwiirc.com/client/irc.freenode.org/?nick=kiwi_test|?&theme=cli#the_playlist" frameborder="0" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:95%;width:100%;position:absolute;top:0px;left:0px;right:0px;bottom:0px" height="95%" width="100%"></iframe> '';
</div> };
<div style="position:absolute;bottom:1px;display:inline-block;background-color:red;"> virtualHosts."lassul.us".locations."/the_playlist".extraConfig = let
<audio controls autoplay="autoplay"><source src="http://lassul.us:8000/radio.ogg" type="audio/ogg">Your browser does not support the audio element.</audio> html = pkgs.writeText "index.html" ''
</div> <!DOCTYPE html>
<!-- page content --> <html lang="en">
</body> <head>
</html> <meta charset="utf-8">
<title>lassulus playlist</title>
</head>
<body>
<div style="display:inline-block;margin:0px;padding:0px;overflow:hidden">
<iframe src="https://kiwiirc.com/client/irc.freenode.org/?nick=kiwi_test|?&theme=cli#the_playlist" frameborder="0" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:95%;width:100%;position:absolute;top:0px;left:0px;right:0px;bottom:0px" height="95%" width="100%"></iframe>
</div>
<div style="position:absolute;bottom:1px;display:inline-block;background-color:red;">
<audio controls autoplay="autoplay"><source src="http://lassul.us:8000/radio.ogg" type="audio/ogg">Your browser does not support the audio element.</audio>
</div>
<!-- page content -->
</body>
</html>
'';
in ''
default_type "text/html";
alias ${html};
''; '';
in '' };
default_type "text/html";
alias ${html};
'';
} }