forked from boyska/radiomanifest.js
FIX document parsing and setting priorities
This commit is contained in:
parent
cec6cb9101
commit
6544f023e5
1 changed files with 6 additions and 5 deletions
|
@ -34,11 +34,12 @@ class Radio {
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromDOM (xml) {
|
static fromDOM (xml) {
|
||||||
let res = xml.evaluate('/radio-manifest/streaming/source', xml)
|
const doc = xml.cloneNode(true)
|
||||||
|
let res = doc.evaluate('/radio-manifest/streaming/source', doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
|
||||||
const sources = []
|
const sources = []
|
||||||
while (true) {
|
for (let i = 0; i < res.snapshotLength; i++) {
|
||||||
const src = res.iterateNext()
|
const src = res.snapshotItem(i)
|
||||||
if (src === null) break
|
|
||||||
if (!src.hasAttribute('priority')) {
|
if (!src.hasAttribute('priority')) {
|
||||||
src.setAttribute('priority', '0')
|
src.setAttribute('priority', '0')
|
||||||
} else if (parseInt(src.getAttribute('priority'), 10) < 0) {
|
} else if (parseInt(src.getAttribute('priority'), 10) < 0) {
|
||||||
|
@ -50,7 +51,7 @@ class Radio {
|
||||||
return parseInt(a.getAttribute('priority', 10)) < parseInt(b.getAttribute('priority', 10))
|
return parseInt(a.getAttribute('priority', 10)) < parseInt(b.getAttribute('priority', 10))
|
||||||
})
|
})
|
||||||
|
|
||||||
res = xml.evaluate('/radio-manifest/schedule', xml)
|
res = doc.evaluate('/radio-manifest/schedule', doc)
|
||||||
const scheduleEl = res.iterateNext()
|
const scheduleEl = res.iterateNext()
|
||||||
let schedule = null
|
let schedule = null
|
||||||
if (scheduleEl !== null) {
|
if (scheduleEl !== null) {
|
||||||
|
|
Loading…
Reference in a new issue