diff --git a/radiomanifest.js b/radiomanifest.js index b3d2b33..4ee3fa1 100644 --- a/radiomanifest.js +++ b/radiomanifest.js @@ -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} @@ -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 diff --git a/ui.js b/ui.js index da40f07..0410ab9 100644 --- a/ui.js +++ b/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 () {