-
Notifications
You must be signed in to change notification settings - Fork 4
/
txt_DPL_vlc_convert.htm
206 lines (194 loc) · 6.34 KB
/
txt_DPL_vlc_convert.htm
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<html>
<head>
<title>txt dpl vlc convert</title>
<script>
function DPLbtnClick() {
var sourceStr = sourceText.value.split("\n");
if (sourceStr[0])
var i = 0; //计行变量
var ii = 1; //序列号变量
aimText.value = '';
aimText.value += 'DAUMPLAYLIST\nplayname=UN\ntopindex=0\n';
while (i < sourceStr.length) {
if (sourceStr[i].indexOf(",") > -1) { //如果含有逗号
var TvUrl = sourceStr[i].split(",");
if (TvUrl[1].indexOf("#") > -1) { //含有#号
var t = TvUrl[1].split("#");
for (j = 0; j < t.length; j++) {
aimText.value += ii + "*file*" + t[j] + "\n";
aimText.value += ii + "*title*" + TvUrl[0] + (j + 1) + "\n";
aimText.value += ii + "*played*0\n";
++ii;
}
} else { //不含#号
aimText.value += ii + "*file*" + TvUrl[1] + "\n";
aimText.value += ii + "*title*" + TvUrl[0] + "\n";
aimText.value += ii + "*played*0\n";
++ii;
}
}
++i
}
}
function VLCplayListClick() {
var sourceStr = sourceText.value.split("\n");
var i = 0;
var ii = 0;
aimText.value = '';
aimText.value += '<?xml version="1.0" encoding="UTF-8"?>\n';
aimText.value += '<playlist xmlns="http://xspf.org/ns/0/" xmlns:vlc="http://www.videolan.org/vlc/playlist/ns/0/" version="1">\n';
aimText.value += ' <title>PlayList</title>\n';
aimText.value += ' <trackList>\n';
while (i < sourceStr.length) {
if (sourceStr[i].indexOf(",") > -1) {
var TvUrl = sourceStr[i].split(",");
if (TvUrl[1].indexOf("#") > -1) {
var t = TvUrl[1].split("#");
for (j = 0; j < t.length; j++) {
aimText.value += " <track>\n";
aimText.value += " <location>" + t[j] + "</location>\n";
aimText.value += " <title>" + TvUrl[0] + (j + 1) + "</title>\n";
aimText.value += ' <extension application="http://www.videolan.org/vlc/playlist/0">\n';
aimText.value += " <vlc:id>" + ii + "</vlc:id>\n";
aimText.value += " <vlc:option>network-caching=1000</vlc:option>\n";
aimText.value += " </extension>\n";
aimText.value += " </track>\n";
++ii;
}
} else {
aimText.value += " <track>\n";
aimText.value += " <location>" + TvUrl[1] + "</location>\n";
aimText.value += " <title>" + TvUrl[0] + "</title>\n";
aimText.value += ' <extension application="http://www.videolan.org/vlc/playlist/0">\n';
aimText.value += " <vlc:id>" + ii + "</vlc:id>\n";
aimText.value += " <vlc:option>network-caching=1000</vlc:option>\n";
aimText.value += " </extension>\n";
aimText.value += " </track>\n";
++ii;
}
}
++i;
}
aimText.value += ' </trackList>\n';
aimText.value += ' <extension application="http://www.videolan.org/vlc/playlist/0">\n';
for (a = 0; a < ii; a++) {
aimText.value += ' <vlc:item tid="' + a + '"/>\n';
}
aimText.value += ' </extension>\n';
aimText.value += '</playlist>\n';
}
function dpl2txt() {
var sourceStr = aimText.value.split("\n");
sourceText.value = "";
var i = 0;
aimFile = "";
aimName = "";
while (i < sourceStr.length) {
if (sourceStr[i].indexOf("1*") >= 0) { break; }
i++;
}
for (; i < sourceStr.length; i += 3) {
for (j = i; j < i + 3; j++) {
if (sourceStr[j].indexOf("*file*") > -1) {
aimFile = sourceStr[j].substring(sourceStr[j].indexOf("*file*") + 6) + "\n";
}
if (sourceStr[j].indexOf("*title*") > -1) {
aimName = sourceStr[j].substring(sourceStr[j].indexOf("*title*") + 7) + ",";
}
}
sourceText.value += aimName + aimFile;
}
}
function vlc2txt() {
var sourceStr = aimText.value.split("\n");
sourceText.value = "";
var i = 0;
var aimFile = "";
var aimName = "";
while (i < sourceStr.length) {
if (sourceStr[i].indexOf("<location>") > -1) {
aimFile = sourceStr[i].substring(sourceStr[i].indexOf("<location>") + 10);
aimFile = aimFile.substring(0, aimFile.indexOf("</location>")) + "\n";
aimName = sourceStr[i + 1].substring(sourceStr[i + 1].indexOf("<title>") + 7);
aimName = aimName.substring(0, aimName.indexOf("</title>")) + ",";
sourceText.value += aimName + aimFile;
}
i++;
}
}
</script>
</head>
<body>
<p>
<center>
<input type="button" value="TXT->PotPlayer" onclick="DPLbtnClick()" />---------<input id="outText" type="button" value="TXT->VLC" onclick=" VLCplayListClick()" />---------<input type="file" id="inputBrow">
文件编码:
<select id="encoding">
<option value="gbk" selected>GBK</option>
<option value="utf-8">UTF-8</option>
<option value="gbk">GB2312</option>
<option value="big5">BIG5</option>
<option value="korean">EUC-KR(韩文)</option>
<option value="euc-jp">EUC-JP(日文)</option>
<option value="utf-16be">UTF-16BE</option>
<option value="utf-16le">UTF-16LE</option>
</select>
<br />
</p>
<textarea style="height:300px; width:900px;" id="sourceText"></textarea><br /><br />
<hr width=70%><br />
<textarea style="height:300px; width:900px;" id="aimText"></textarea>
<p>
<input type="button" value="PotPlayer->TxT" onclick="dpl2txt()" />---------<input type="button" value="VLC->TXT" onclick=" vlc2txt()" /><br />
</p>
</center>
</body>
<script>
function importTxt() {
}
// 支持文件拖放
function dragenter(e) {
e.stopPropagation();
e.preventDefault();
}
function dragover(e) {
e.stopPropagation();
e.preventDefault();
}
function drop(e) {
e.stopPropagation();
e.preventDefault();
var dt = e.dataTransfer;
var files = dt.files;
if (files.length) {
var file = files[0];
var reader = new FileReader();
reader.onload = function () {
document.getElementById("sourceText").value = this.result;
};
reader.readAsText(file, document.getElementById("encoding").value);
reader = null;
}
}
var dropbox = document.getElementById("sourceText");
dropbox.addEventListener("dragenter", dragenter, false);
dropbox.addEventListener("dragover", dragover, false);
dropbox.addEventListener("drop", drop, false);
(function () {
var input = document.querySelector('#inputBrow');
var span = document.querySelector('#sourceText');
input.addEventListener('change', function (e) {
handFile(e.target.files[0]);
});
function handFile(file) {
console.log('hand');
var reader = new FileReader();
reader.onload = function (e) {
span.value = e.target.result;
};
reader.readAsText(file, document.getElementById("encoding").value);
reader = null;
}
})();
</script>
</html>