l radio: show recent tracks at https://radio.lassul.us/recent
This commit is contained in:
parent
260b757fee
commit
a374a45211
@ -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 = {
|
||||
nickname = "the_playlist|r";
|
||||
channels = [
|
||||
@ -157,7 +181,19 @@ in {
|
||||
})
|
||||
];
|
||||
};
|
||||
services.nginx.virtualHosts."lassul.us".locations."/the_playlist".extraConfig = let
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts."radio.lassul.us" = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
locations."/".extraConfig = ''
|
||||
proxy_pass http://localhost:8000;
|
||||
'';
|
||||
locations."/recent".extraConfig = ''
|
||||
alias /tmp/played;
|
||||
'';
|
||||
};
|
||||
virtualHosts."lassul.us".locations."/the_playlist".extraConfig = let
|
||||
html = pkgs.writeText "index.html" ''
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@ -180,4 +216,5 @@ in {
|
||||
default_type "text/html";
|
||||
alias ${html};
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user