forked from boyska/radiomanifest.js
make it ESM ready
This commit is contained in:
parent
1a78e2344c
commit
baa181354f
3 changed files with 12 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
|||
const ICAL = require('ical.js')
|
||||
const shows = require('./shows.js')
|
||||
import ICAL from 'ical.js'
|
||||
import shows from './shows'
|
||||
|
||||
function max(a, b) {
|
||||
if (a<b) return b
|
||||
|
@ -204,7 +204,7 @@ async function get(manifest) {
|
|||
}
|
||||
if (resp !== null) {
|
||||
try {
|
||||
text = await resp.text()
|
||||
const text = await resp.text()
|
||||
return parse(text)
|
||||
} catch (e) {
|
||||
console.error('Error while parsing schedule', e)
|
||||
|
@ -228,7 +228,7 @@ function parse(text) {
|
|||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
get: get,
|
||||
parse: parse,
|
||||
RadioSchedule: RadioSchedule,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"version": "0.1.0",
|
||||
"description": "",
|
||||
"main": "radiomanifest.js",
|
||||
"module": "radiomanifest.js",
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
|
@ -20,10 +21,10 @@
|
|||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"jsdoc": "^3.6.10",
|
||||
"docdash": "^1.2.0",
|
||||
"chai": "^4.3.4",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"docdash": "^1.2.0",
|
||||
"jsdoc": "^3.6.10",
|
||||
"karma": "^6.3.9",
|
||||
"karma-chrome-launcher": "^3.1.0",
|
||||
"karma-firefox-launcher": "^2.1.2",
|
||||
|
|
8
shows.js
8
shows.js
|
@ -2,6 +2,8 @@
|
|||
* Represents a single show. This show could be defined in the shows.xml file, or could be inferred from the
|
||||
* schedule.
|
||||
*/
|
||||
|
||||
|
||||
class RadioShow {
|
||||
constructor(name, description, website, feed, schedule, radio_calendar) {
|
||||
this.name = name
|
||||
|
@ -44,7 +46,7 @@ function parseRadioShows(xml) {
|
|||
}
|
||||
let website = doc.evaluate('./info/metadata/show:website', bm, showsNamespaceResolver, XPathResult.STRING_TYPE).stringValue
|
||||
if (website === '') {
|
||||
website = getAttribute(bm, 'href', null)
|
||||
website = bm.getAttribute('href')
|
||||
}
|
||||
const feed = doc.evaluate('./info/metadata/show:feed', bm, showsNamespaceResolver, XPathResult.STRING_TYPE).stringValue
|
||||
const schedule = doc.evaluate('./info/metadata/show:schedule', bm, showsNamespaceResolver, XPathResult.STRING_TYPE).stringValue
|
||||
|
@ -70,7 +72,7 @@ async function getShows(manifest) {
|
|||
}
|
||||
if (resp !== null) {
|
||||
try {
|
||||
text = await resp.text()
|
||||
const text = await resp.text()
|
||||
const parser = new DOMParser()
|
||||
const showsDom = parser.parseFromString(text, 'text/xml')
|
||||
return parseRadioShows(showsDom)
|
||||
|
@ -90,7 +92,7 @@ function showsNamespaceResolver(prefix) {
|
|||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
get: getShows,
|
||||
parse: parseRadioShows,
|
||||
RadioShow: RadioShow,
|
||||
|
|
Loading…
Reference in a new issue