Added alien radio

This commit is contained in:
dbroqua 2020-01-02 09:51:01 +01:00
parent 904b697574
commit e260ebc135

View file

@ -88,9 +88,29 @@ if (!process.env.STREAM_TYPE || process.env.STREAM_TYPE === 'radio') {
(error, response, body) => { (error, response, body) => {
if (!error && response.statusCode === 200) { if (!error && response.statusCode === 200) {
const res = JSON.parse(body) const res = JSON.parse(body)
currentSong = {
title: res.title, switch (process.env.STREAM_TYPE) {
artist: res.artist case 'json':
currentSong = {
title: res.title,
artist: res.artist
}
break
case 'alien':
try {
for (let i = 0; i < res.length; i += 1) {
if (res[i].name === 'Cult') {
currentSong = {
title: res[i].nowPlaying.track.title,
artist: res[i].nowPlaying.track.artist
}
break
}
}
} catch (e) {
console.error('ERR:', e)
}
break
} }
if (previousSong.title !== currentSong.title && previousSong.artist !== currentSong.artist) { if (previousSong.title !== currentSong.title && previousSong.artist !== currentSong.artist) {