1
0
Fork 0

fetching streaminfo is more tolerant

This commit is contained in:
boyska 2021-12-05 17:40:17 +01:00
parent 6544f023e5
commit b21596d1d7

View file

@ -108,24 +108,27 @@ async function get (siteurl, options) {
resp = null
try {
resp = await fetch(getStreaminfoUrl(siteurl))
text = await resp.text()
const data = JSON.parse(text)
const name = data['icy-name']
if (name !== undefined) {
manifest.setName(name)
}
} catch (e) {
if (e instanceof TypeError && e.message.startsWith('NetworkError')) {
// the fetch has failed
true
} else if (e instanceof SyntaxError && e.message.startsWith('JSON.parse')) {
true
} else {
console.error('Error', e)
throw e
}
true
}
if(resp !== null) {
try {
text = await resp.text()
const data = JSON.parse(text)
const name = data['icy-name']
if (name !== undefined) {
manifest.setName(name)
}
} catch (e) {
if (e instanceof SyntaxError) {
true
} else {
console.error('Error', e)
throw e
}
}
}
// XXX: in base alle options fai fetch anche di altra roba
return manifest