Removed debug prints. Removed unnecessary convert to utc. Removed title and description vars.
This commit is contained in:
parent
86182d2d85
commit
77e1adb674
@ -36,17 +36,15 @@ async function getRadioStatus() {
|
|||||||
async function getLastPlayedSongs(count, tz) {
|
async function getLastPlayedSongs(count, tz) {
|
||||||
try {
|
try {
|
||||||
const { stdout, _ } = await exec(`tail -n${count} /var/log/icecast/playlist.log | head -n-1 | cut -d"|" -f1,4`);
|
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");
|
let songs = stdout.trim().split("\n");
|
||||||
for (let i = 0; i < songs.length; ++i) {
|
for (let i = 0; i < songs.length; ++i) {
|
||||||
let [t, s] = songs[i].split('|');
|
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(' - ');
|
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;
|
return songs;
|
||||||
} catch(err) {
|
} catch {
|
||||||
console.log(err);
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,8 +52,6 @@ async function getLastPlayedSongs(count, tz) {
|
|||||||
function setRoutes() {
|
function setRoutes() {
|
||||||
return koaRouter().get('/', async ctx => {
|
return koaRouter().get('/', async ctx => {
|
||||||
await ctx.render('index', {
|
await ctx.render('index', {
|
||||||
title: "/ Radio",
|
|
||||||
description: "Internet-radio broadcasting from under my desk.",
|
|
||||||
main_site: util.getServiceByHost(ctx.header.host),
|
main_site: util.getServiceByHost(ctx.header.host),
|
||||||
radio_status: await getRadioStatus(),
|
radio_status: await getRadioStatus(),
|
||||||
last_songs: await getLastPlayedSongs(11, util.getClientTimezone(ctx))
|
last_songs: await getLastPlayedSongs(11, util.getClientTimezone(ctx))
|
||||||
|
Loading…
Reference in New Issue
Block a user