Fixed bug on json parse
This commit is contained in:
parent
b6beab9a71
commit
d2ebf282aa
1 changed files with 41 additions and 36 deletions
5
index.js
5
index.js
|
@ -99,6 +99,7 @@ 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) {
|
||||||
|
try {
|
||||||
const res = JSON.parse(process.env.STREAM_PARSE ? body.replace('updateFromMediaItem(', '').replace(');', '') : body)
|
const res = JSON.parse(process.env.STREAM_PARSE ? body.replace('updateFromMediaItem(', '').replace(');', '') : body)
|
||||||
|
|
||||||
let title = null
|
let title = null
|
||||||
|
@ -140,6 +141,10 @@ if (!process.env.STREAM_TYPE || process.env.STREAM_TYPE === 'radio') {
|
||||||
if (previousSong.title !== currentSong.title && previousSong.artist !== currentSong.artist) {
|
if (previousSong.title !== currentSong.title && previousSong.artist !== currentSong.artist) {
|
||||||
checkCurrentSong()
|
checkCurrentSong()
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
error = e
|
||||||
|
console.error('getStream error:', error)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error('ERR:', error)
|
console.error('ERR:', error)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue