Added alien radio
This commit is contained in:
parent
904b697574
commit
e260ebc135
1 changed files with 23 additions and 3 deletions
26
index.js
26
index.js
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue