Removed debug prints. Removed unnecessary convert to utc. Removed title and description vars.

This commit is contained in:
Alexander Andreev 2022-01-23 21:02:31 +04:00
parent 86182d2d85
commit 77e1adb674
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

View File

@ -36,17 +36,15 @@ async function getRadioStatus() {
async function getLastPlayedSongs(count, tz) {
try {
const { stdout, _ } = await exec(`tail -n${count} /var/log/icecast/playlist.log | head -n-1 | cut -d"|" -f1,4`);
console.log(tz);
let songs = stdout.trim().split("\n");
for (let i = 0; i < songs.length; ++i) {
let [t, s] = songs[i].split('|');
t = moment(t, "DD/MMM/YYYY:HH:mm:ss ZZ").utc(false).tz(tz).format("HH:mm");
t = moment(t, "DD/MMM/YYYY:HH:mm:ss ZZ").tz(tz).format("HH:mm");
let song = s.split(' - ');
songs[i] = { "start_time_local": t,"artist": song[0], "title": song[1] };
songs[i] = { "start_time_local": t, "artist": song[0], "title": song[1] };
}
return songs;
} catch(err) {
console.log(err);
} catch {
return [];
}
}
@ -54,8 +52,6 @@ async function getLastPlayedSongs(count, tz) {
function setRoutes() {
return koaRouter().get('/', async ctx => {
await ctx.render('index', {
title: "/ Radio",
description: "Internet-radio broadcasting from under my desk.",
main_site: util.getServiceByHost(ctx.header.host),
radio_status: await getRadioStatus(),
last_songs: await getLastPlayedSongs(11, util.getClientTimezone(ctx))