1
0
Fork 0

FIX document parsing and setting priorities

This commit is contained in:
boyska 2021-12-05 17:39:52 +01:00
parent cec6cb9101
commit 6544f023e5

View file

@ -34,11 +34,12 @@ class Radio {
}
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 = []
while (true) {
const src = res.iterateNext()
if (src === null) break
for (let i = 0; i < res.snapshotLength; i++) {
const src = res.snapshotItem(i)
if (!src.hasAttribute('priority')) {
src.setAttribute('priority', '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))
})
res = xml.evaluate('/radio-manifest/schedule', xml)
res = doc.evaluate('/radio-manifest/schedule', doc)
const scheduleEl = res.iterateNext()
let schedule = null
if (scheduleEl !== null) {