forked from boyska/radiomanifest.js
supports description and logo
This commit is contained in:
parent
0e27a5d599
commit
303819879d
2 changed files with 52 additions and 10 deletions
|
@ -32,6 +32,8 @@ class Radio {
|
|||
this.showsURL = showsURL
|
||||
this.feed = feed
|
||||
this.name = ''
|
||||
this.description = ''
|
||||
this.logo = null
|
||||
this.shows = []
|
||||
this.schedule = null
|
||||
}
|
||||
|
@ -43,13 +45,43 @@ class Radio {
|
|||
return this.streaming
|
||||
}
|
||||
|
||||
/**
|
||||
* Change radio name
|
||||
*/
|
||||
setName (name) {
|
||||
this.name = name
|
||||
}
|
||||
|
||||
/**
|
||||
* The radio name, as inferred by stream-meta
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
getName() {
|
||||
return this.name
|
||||
}
|
||||
|
||||
setDescription(desc) {
|
||||
this.description = desc
|
||||
}
|
||||
|
||||
/**
|
||||
* The description of the radio, as inferred by stream-meta
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
getDescription() {
|
||||
return this.description
|
||||
}
|
||||
|
||||
setLogo(logo) {
|
||||
this.logo = logo
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} the URL of the logo, or `null` if not found
|
||||
*/
|
||||
getLogo() {
|
||||
return this.logo
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {Array<RadioShow>}
|
||||
|
@ -251,11 +283,20 @@ async function get (siteurl, options) {
|
|||
try {
|
||||
text = await resp.text()
|
||||
|
||||
const data = JSON.parse(text)
|
||||
const name = data['icy-name']
|
||||
if (name !== undefined) {
|
||||
manifest.setName(name)
|
||||
}
|
||||
const data = JSON.parse(text)
|
||||
const name = data['icy-name']
|
||||
if (name !== undefined) {
|
||||
manifest.setName(name)
|
||||
}
|
||||
const desc = data['icy-description']
|
||||
if (desc !== undefined) {
|
||||
manifest.setDescription(desc)
|
||||
}
|
||||
|
||||
const logo = data['icy-logo']
|
||||
if (desc !== undefined) {
|
||||
manifest.setLogo(logo)
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof SyntaxError) {
|
||||
true
|
||||
|
|
5
ui.js
5
ui.js
|
@ -4,10 +4,11 @@ function updateNow(radio) {
|
|||
var box = document.querySelector('#now-info')
|
||||
const show = radio.getSchedule().getNowShow()
|
||||
try {
|
||||
var text = show.getName() + '\nfeed: ' + show.getWebsite()
|
||||
var showText = show.getName() + '\nfeed: ' + show.getWebsite()
|
||||
} catch (e) {
|
||||
var text = String(show)
|
||||
var showText = String(show)
|
||||
}
|
||||
var text = radio.getName() + ' - ' + radio.getDescription() + ' -- ' + showText
|
||||
box.textContent = text
|
||||
}
|
||||
async function fai () {
|
||||
|
|
Loading…
Reference in a new issue