-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistBuilder.js
40 lines (36 loc) · 1.08 KB
/
listBuilder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function loadChannels(lm, res) {
for(let i = 0; i < res.length; i++){
if(res[i].name !== undefined)
{
lm.append({
name: res[i].name,
image: "https://devel.uniqcast.com/samples/logos/"+res[i].id+".png",
itemUrl: extractMediaPlaylist(res[i].url)
});
}
}
}
function extractMediaPlaylist(masterUrl) {
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
var res = ""
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
try {
var lines = xhr.responseText.split('\n');
for(var line = 0; line < lines.length; line++){
if (lines[line].includes("RESOLUTION")) {
res = lines[line + 1]
break
}
}
}
catch (err) {
console.log(err)
}
}
}
xhr.open("GET", masterUrl, false);
xhr.send(data);
return res;
}