-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
86 lines (82 loc) · 2.57 KB
/
index.html
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="line-navigator.js"></script>
<script src="file-navigator.js"></script>
</head>
<body>
<input type="file" id="input" onchange="readFile()">
</body>
<script>
var mainTemplate = {
"channels": [],
"modified": 0,
"possibleGenres": ["ANIMAL_WILDLIFE", "ANIMAL_WILDLIFE", "ARTS", "COMEDY", "DRAMA", "EDUCATION", "ENTERTAINMENT", "FAMILY_KIDS", "GAMING", "LIFE_STYLE", "MOVIES", "MUSIC", "NEWS", "PREMIER", "SHOPPING", "SPORTS", "TECH_SCIENCE", "TRAVEL"]
};
var readFile = function () {
var file = document.getElementById('input').files[0];
var navigator = new FileNavigator(file);
var allLines;
navigator.readSomeLines(0, function (err, index, lines, eof) {
allLines = lines;
var z = 1;
if (allLines[2].indexOf("#EXTGRP") != -1) {
for (var i = 1; i < allLines.length; i = i + 3) {
var buf = allLines[i].split('group-title="');
if (buf[1]) {
var finalBuf = buf[1].split('",');
var genres = finalBuf[0];
var name = finalBuf[1];
} else {
buf = allLines[i].split(',');
var genres = "";
var name = buf[1];
}
var bufGenres = allLines[i + 1].split("#EXTGRP:")
var channel = {};
channel.number = z;
channel.name = name;
channel.url = allLines[i + 2];
channel.genres = bufGenres[1];
channel.splashscreen = "";
channel.logo = "";
mainTemplate.channels.push(channel);
z++;
}
} else {
for (var i = 0; i < allLines.length; i = i + 2) {
if (allLines[i] == "#EXTM3U") {
i = i - 1;
} else {
var buf = allLines[i].split('group-title="');
if (buf[1]) {
var finalBuf = buf[1].split('",');
var genres = finalBuf[0];
var name = finalBuf[1];
} else {
buf = allLines[i].split(',');
var genres = "";
var name = buf[1];
}
var channel = {};
channel.number = z;
channel.name = name;
channel.url = allLines[i + 1];
channel.genres = genres;
channel.splashscreen = "";
channel.logo = "";
mainTemplate.channels.push(channel);
z++;
}
}
}
var data = "text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(mainTemplate));
$('<br><a href="data:' + data + '" download="cumulustv_channels.json">download JSON</a>').appendTo('body');
}
);
}
</script>
</html>