Added alien radio
This commit is contained in:
parent
904b697574
commit
e260ebc135
1 changed files with 23 additions and 3 deletions
20
index.js
20
index.js
|
@ -88,10 +88,30 @@ 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)
|
||||||
|
|
||||||
|
switch (process.env.STREAM_TYPE) {
|
||||||
|
case 'json':
|
||||||
currentSong = {
|
currentSong = {
|
||||||
title: res.title,
|
title: res.title,
|
||||||
artist: res.artist
|
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) {
|
||||||
checkCurrentSong()
|
checkCurrentSong()
|
||||||
|
|
Loading…
Reference in a new issue