Skip to content

Commit

Permalink
增加生成m3u txt内容的功能
Browse files Browse the repository at this point in the history
  • Loading branch information
lucifersun committed Apr 22, 2018
1 parent 993db87 commit 314da81
Showing 1 changed file with 45 additions and 52 deletions.
97 changes: 45 additions & 52 deletions iptvplayseek.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
<h2>上海电信IPTV视频流地址</h2>
<p>开始日期: <input type="date" id="start_user_date" />开始时间: <input type="time" id="start_user_time" /></p>
<p>结束日期: <input type="date" id="end_user_date" />结束时间: <input type="time" id="end_user_time" /></p>
<p><button type="button" onclick="reload()">更新链接</button></p>
<p><button type="button" onclick="timenow()">当前时间+4小时</button></p>
<p><button type="button" onclick="reload()">更新链接</button> &emsp; <button type="button" onclick="timenow(4),reload()">当前时间+4小时</button> &emsp;注:带palyseek</p>
<p><button type="button" onclick="noplayseek()">生成纯链接</button> &emsp;注:不带palyseek</p>
<p><button type="button" onclick="m3u()">生成M3U内容</button> &emsp; <button type="button" onclick="txt()">生成txt内容</button></p>
<br>
<p id="demo"></p>
<script>
var iptvlist = '{"iptv":['+
Expand Down Expand Up @@ -142,8 +144,8 @@ <h2>上海电信IPTV视频流地址</h2>
'{"url":"rtsp://124.75.34.37/PLTV/88888888/224/3221226313/10000100000000060000000001865656_0.smil", "name":"东方购物-3HD"},'+
'{"url":"rtsp://124.75.34.37/PLTV/88888888/224/3221226308/10000100000000060000000001865657_0.smil", "name":"东方购物-4HD"},'+
'{"url":"rtsp://124.75.34.37/PLTV/88888888/224/3221226315/10000100000000060000000001865658_0.smil", "name":"东方购物-5HD"}]}';
timenow()
reload()
timenow(4);
reload();

function reload()
{
Expand All @@ -162,63 +164,54 @@ <h2>上海电信IPTV视频流地址</h2>
}
}

function timenow()
function timenow(offset)
{
var nowtime =new Date();
var sdate,stime;
sdate=nowtime.getDate().toString();
if (sdate.length<2)
{
sdate="0"+sdate;
}
sdate=(nowtime.getMonth()+1).toString() + "-"+sdate;
if (sdate.length<5)
{
sdate="0"+sdate;
}
sdate=nowtime.getFullYear().toString() + "-" + sdate;

stime=nowtime.getMinutes().toString();
if (stime.length<2)
{
stime="0"+stime;
}
stime=nowtime.getHours().toString() + ":" + stime;
if (stime.length<5)
{
stime="0"+stime;
}
document.getElementById("start_user_date").value=nowtime.getFullYear().toString() + "-" + pad((nowtime.getMonth()+1).toString(),2) + "-" + pad((nowtime.getDate()).toString(),2);
document.getElementById("start_user_time").value=pad(nowtime.getHours().toString(),2) + ":" + pad(nowtime.getMinutes().toString(),2);

document.getElementById("start_user_date").value=sdate;
document.getElementById("start_user_time").value=stime;
nowtime.setHours(nowtime.getHours() + offset);

document.getElementById("end_user_date").value=nowtime.getFullYear().toString() + "-" + pad((nowtime.getMonth()+1).toString(),2) + "-" + pad((nowtime.getDate()).toString(),2);
document.getElementById("end_user_time").value=pad(nowtime.getHours().toString(),2) + ":" + pad(nowtime.getMinutes().toString(),2);
}

nowtime.setHours(nowtime.getHours()+4)
sdate=nowtime.getDate().toString();
if (sdate.length<2)
{
sdate="0"+sdate;
}
sdate=(nowtime.getMonth()+1).toString() + "-"+sdate;
if (sdate.length<5)
{
sdate="0"+sdate;
function pad(num, n) {
var len = num.toString().length;
while(len < n) {
num = "0" + num;
len++;
}
return num;
}

function m3u() {
obj = JSON.parse(iptvlist);
document.getElementById("demo").innerHTML = "#EXTM3U <br>";
for (var i=0;i<obj.iptv.length;i++){
document.getElementById("demo").innerHTML = document.getElementById("demo").innerHTML + "#EXTINF:" + pad(i.toString(),3) + ", " + obj.iptv[i].name + "<br>";
document.getElementById("demo").innerHTML = document.getElementById("demo").innerHTML + obj.iptv[i].url + "<br>";
}
sdate=nowtime.getFullYear().toString() + "-" + sdate;


stime=nowtime.getMinutes().toString();
if (stime.length<2)
{
stime="0"+stime;
}
stime=nowtime.getHours().toString() + ":" + stime;
if (stime.length<5)
{
stime="0"+stime;
}

function txt() {
obj = JSON.parse(iptvlist);
document.getElementById("demo").innerHTML = "";
for (var i=0;i<obj.iptv.length;i++){
document.getElementById("demo").innerHTML = document.getElementById("demo").innerHTML + obj.iptv[i].name + "," + obj.iptv[i].url + "<br>";
}

}

document.getElementById("end_user_date").value=sdate;
document.getElementById("end_user_time").value=stime;
function noplayseek() {
obj = JSON.parse(iptvlist);
document.getElementById("demo").innerHTML = "";
for (var i=0;i<obj.iptv.length;i++){
document.getElementById("demo").innerHTML = document.getElementById("demo").innerHTML +"<p><a href=\"" + obj.iptv[i].url + "\">" + obj.iptv[i].name + "</a></p>";
}

}
</script>

Expand Down

0 comments on commit 314da81

Please sign in to comment.