Fixed bug for CosmicFuzzFM radio

This commit is contained in:
Damien Broqua 2021-10-26 15:35:25 +02:00
parent af307b5888
commit c0f6dea24a

View file

@ -106,8 +106,6 @@ if (!process.env.STREAM_TYPE || process.env.STREAM_TYPE === 'radio') {
// Listener on new song // Listener on new song
stream.on('metadata', function (data) { stream.on('metadata', function (data) {
console.info('RAW DATA:', data)
// let song = data.replace(/[^A-Za-z 0-9 .,?""!@#$%^&*()-_=+;:<>/\\|}{[\]`~]*/g, '')
const song = data.substring(13, data.length - 1).replace(/\0/g, '').replace('\';', '') const song = data.substring(13, data.length - 1).replace(/\0/g, '').replace('\';', '')
// Extract artist = title from song // Extract artist = title from song
@ -130,7 +128,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 { try {
const res = JSON.parse(process.env.STREAM_PARSE ? body.replace('updateFromMediaItem(', '').replace(');', '') : body) const res = JSON.parse(process.env.STREAM_PARSE ? body.substr(body.indexOf('{')).replace(');', '') : body)
let title = null let title = null
let artist = null let artist = null