mirror of
https://github.com/DigitalDevices/octonet.git
synced 2023-10-10 11:36:52 +00:00
browsertv migrated to json format
This commit is contained in:
parent
04ad8103ca
commit
7b8627b7a8
@ -121,7 +121,7 @@ if tl.SourceList then
|
|||||||
end
|
end
|
||||||
print(line)
|
print(line)
|
||||||
if line == "END" then
|
if line == "END" then
|
||||||
local channel = { Title=sname, Service=sid, Request = Request.."&pids=0,"..pids, Tracks=tracks }
|
local channel = { Title=sname, Service=sid, Request = '?'..Request.."&pids=0,"..pids, Tracks=tracks }
|
||||||
local cname = pname
|
local cname = pname
|
||||||
if isradio then
|
if isradio then
|
||||||
cname = "Radio - "..pname
|
cname = "Radio - "..pname
|
||||||
|
@ -74,7 +74,7 @@ if file then
|
|||||||
vi.id = f.id.."$"..tostring(#f.VideoItems)
|
vi.id = f.id.."$"..tostring(#f.VideoItems)
|
||||||
vi.src = f.src
|
vi.src = f.src
|
||||||
vi.parentID = f.id
|
vi.parentID = f.id
|
||||||
vi.request = string.gsub(channel.Request,'&','&')
|
vi.request = string.gsub(channel.Request:sub(2),'&','&')
|
||||||
vi.title = string.gsub(channel.Title,'&','&')
|
vi.title = string.gsub(channel.Title,'&','&')
|
||||||
vi.title = string.gsub(vi.title,'<','&lt;')
|
vi.title = string.gsub(vi.title,'<','&lt;')
|
||||||
vi.title = string.gsub(vi.title,'>','&gt;')
|
vi.title = string.gsub(vi.title,'>','&gt;')
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
<script type="text/javascript" src="/systeminfo.lua"></script>
|
<script type="text/javascript" src="/systeminfo.lua"></script>
|
||||||
<script type="text/javascript">Octoserve = false;</script>
|
<script type="text/javascript">Octoserve = false;</script>
|
||||||
<script type="text/javascript" src="/octoserve/serverinfo.js"></script>
|
<script type="text/javascript" src="/octoserve/serverinfo.js"></script>
|
||||||
<script type="text/javascript" src="/btvchannels.lua"></script>
|
|
||||||
|
|
||||||
<!-- Add page scripts here -->
|
<!-- Add page scripts here -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -128,25 +127,96 @@ function AddRow(table,name,request,tracks)
|
|||||||
table.appendChild(row);
|
table.appendChild(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
function NameCompare(a,b)
|
function TitleCompare(a,b)
|
||||||
{
|
{
|
||||||
if( a.name.toUpperCase() < b.name.toUpperCase() ) return -1;
|
if( a.Title.toUpperCase() < b.Title.toUpperCase() ) return -1;
|
||||||
if( a.name.toUpperCase() > b.name.toUpperCase() ) return 1;
|
if( a.Title.toUpperCase() > b.Title.toUpperCase() ) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var xmlhttp = new XMLHttpRequest();
|
||||||
|
var url = "/channellist.lua?select=json";
|
||||||
|
|
||||||
|
xmlhttp.onreadystatechange=function()
|
||||||
|
{
|
||||||
|
if (xmlhttp.readyState == 4 )
|
||||||
|
{
|
||||||
|
if( xmlhttp.status == 200 )
|
||||||
|
myFunction(xmlhttp.responseText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var hasCable = false;
|
||||||
|
var hasSat = false;
|
||||||
|
var hasTer = false;
|
||||||
|
var LastSourceName = "";
|
||||||
|
var LastChannelName = "";
|
||||||
|
|
||||||
|
function myFunction(response) {
|
||||||
|
var ChannelList = JSON.parse(response);
|
||||||
|
|
||||||
|
var LastSource = 0;
|
||||||
|
var Index = 0;
|
||||||
|
|
||||||
|
if(typeof(Storage) !== "undefined")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LastSourceName = localStorage.getItem("LastSourceName");
|
||||||
|
LastChannelName = localStorage.getItem("LastChannelName");
|
||||||
|
if( !LastSourceName ) LastSourceName = "";
|
||||||
|
if( !LastChannelName ) LastChannelName = "";
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.Source.Select.length = 0;
|
||||||
|
for(var i = 0; i < ChannelList.GroupList.length; i++)
|
||||||
|
{
|
||||||
|
var newChannelList = new Array();
|
||||||
|
for(var j = 0; j < ChannelList.GroupList[i].ChannelList.length; j++ )
|
||||||
|
{
|
||||||
|
if( ( hasSat && ChannelList.GroupList[i].ChannelList[j].Request.indexOf("dvbs") > 0 ) ||
|
||||||
|
( hasCable && ChannelList.GroupList[i].ChannelList[j].Request.indexOf("dvbc") > 0 ) ||
|
||||||
|
( hasTer && ChannelList.GroupList[i].ChannelList[j].Request.indexOf("dvbt") > 0 ) )
|
||||||
|
{
|
||||||
|
newChannelList.push(ChannelList.GroupList[i].ChannelList[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if( newChannelList.length > 0 )
|
||||||
|
{
|
||||||
|
SourceList[Index] = new Object();
|
||||||
|
SourceList[Index].ChannelList = newChannelList;
|
||||||
|
SourceList[Index].Title = ChannelList.GroupList[i].Title;
|
||||||
|
document.Source.Select.options[Index] = new Option(SourceList[Index].Title,Index, false, true);
|
||||||
|
|
||||||
|
if( LastSourceName.length > 0 )
|
||||||
|
{
|
||||||
|
if( LastSourceName == SourceList[Index].Title ) LastSource = Index;
|
||||||
|
}
|
||||||
|
Index = Index + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(var i = 0; i < SourceList.length; i++ )
|
||||||
|
{
|
||||||
|
SourceList[i].ChannelList.sort(TitleCompare);
|
||||||
|
}
|
||||||
|
document.Source.Select.selectedIndex = LastSource;
|
||||||
|
SetSource(LastSource);
|
||||||
|
}
|
||||||
|
|
||||||
function OnLoad()
|
function OnLoad()
|
||||||
{
|
{
|
||||||
|
|
||||||
if( !RTSPLink )
|
if( !RTSPLink )
|
||||||
{
|
{
|
||||||
document.getElementById("Play").style.display = "none";
|
document.getElementById("Play").style.display = "none";
|
||||||
}
|
}
|
||||||
if( VLCPluginValid || RTSPLink )
|
if( VLCPluginValid || RTSPLink )
|
||||||
{
|
{
|
||||||
var hasCable = false;
|
|
||||||
var hasSat = false;
|
|
||||||
|
|
||||||
for(var i = 0; i < Octoserve.TunerList.length; i++ )
|
for(var i = 0; i < Octoserve.TunerList.length; i++ )
|
||||||
{
|
{
|
||||||
if( Octoserve.TunerList[i] )
|
if( Octoserve.TunerList[i] )
|
||||||
@ -156,39 +226,11 @@ function OnLoad()
|
|||||||
if( Octoserve.TunerList[i].Desc.indexOf("S/S2") >= 0 ) hasSat = true;
|
if( Octoserve.TunerList[i].Desc.indexOf("S/S2") >= 0 ) hasSat = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO: differentiate between dvbc and dvbt
|
||||||
|
hasTer = hasCable;
|
||||||
|
|
||||||
document.Source.Select.length = 0;
|
xmlhttp.open("GET", url, true);
|
||||||
var index = 0
|
xmlhttp.send();
|
||||||
if( hasSat )
|
|
||||||
{
|
|
||||||
SourceListSat.sort(NameCompare);
|
|
||||||
for(var i = 0; i < SourceListSat.length; i++ )
|
|
||||||
{
|
|
||||||
SourceList[index] = SourceListSat[i];
|
|
||||||
document.Source.Select.options[index] = new Option(SourceListSat[i].name,index, false, true);
|
|
||||||
index = index + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( hasCable )
|
|
||||||
{
|
|
||||||
SourceListCable.sort(NameCompare);
|
|
||||||
for(var i = 0; i < SourceListCable.length; i++ )
|
|
||||||
{
|
|
||||||
SourceList[index] = SourceListCable[i];
|
|
||||||
document.Source.Select.options[index] = new Option(SourceListCable[i].name,index, false, true);
|
|
||||||
index = index + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(var i = 0; i < SourceList.length; i++ )
|
|
||||||
{
|
|
||||||
SourceList[i].ChannelList.sort(NameCompare);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
document.Source.Select.selectedIndex = 0;
|
|
||||||
SetSource(0);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -238,12 +280,40 @@ function CreatePlugin()
|
|||||||
function SetSource(SourceIndex)
|
function SetSource(SourceIndex)
|
||||||
{
|
{
|
||||||
SelectedSource = SourceIndex;
|
SelectedSource = SourceIndex;
|
||||||
|
if( SourceList[SourceIndex].Title != LastSourceName )
|
||||||
|
{
|
||||||
|
LastSourceName = SourceList[SourceIndex].Title;
|
||||||
|
LastChannelName = "";
|
||||||
|
if(typeof(Storage) !== "undefined")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
localStorage.setItem("LastSourceName",LastSourceName);
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
document.Channel.Select.length = 0;
|
document.Channel.Select.length = 0;
|
||||||
var i = -1;
|
var i = -1;
|
||||||
for( j = 0; j < SourceList[SourceIndex].ChannelList.length; j++ )
|
for( j = 0; j < SourceList[SourceIndex].ChannelList.length; j++ )
|
||||||
{
|
{
|
||||||
document.Channel.Select.options[j] = new Option(SourceList[SourceIndex].ChannelList[j].name,j, false, true);
|
document.Channel.Select.options[j] = new Option(SourceList[SourceIndex].ChannelList[j].Title,j, false, true);
|
||||||
if( i < 0 && SourceList[SourceIndex].ChannelList[j].name.toUpperCase() >= "DAS ERSTE" ) i = j;
|
if( i < 0 )
|
||||||
|
{
|
||||||
|
if( LastChannelName.length > 0 )
|
||||||
|
{
|
||||||
|
if( SourceList[SourceIndex].ChannelList[j].Title == LastChannelName ) i = j;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( SourceList[SourceIndex].ChannelList[j].Title.toUpperCase() >= "DAS ERSTE" ) i = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if( i < 0 ) i = 0;
|
if( i < 0 ) i = 0;
|
||||||
document.Channel.Select.selectedIndex = i;
|
document.Channel.Select.selectedIndex = i;
|
||||||
@ -253,23 +323,38 @@ function SetSource(SourceIndex)
|
|||||||
function SetChannel(ChannelIndex)
|
function SetChannel(ChannelIndex)
|
||||||
{
|
{
|
||||||
SelectedChannel = ChannelIndex;
|
SelectedChannel = ChannelIndex;
|
||||||
|
if( SourceList[SelectedSource].ChannelList[ChannelIndex].Title != LastChannelName )
|
||||||
|
{
|
||||||
|
LastChannelName = SourceList[SelectedSource].ChannelList[ChannelIndex].Title;
|
||||||
|
if(typeof(Storage) !== "undefined")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
localStorage.setItem("LastChannelName",LastChannelName);
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var a = document.getElementById("Play");
|
var a = document.getElementById("Play");
|
||||||
if( RTSPLink )
|
if( RTSPLink )
|
||||||
{
|
{
|
||||||
var t = "rtsp://"+host+"/"+SourceList[SelectedSource].ChannelList[ChannelIndex].request;
|
var t = "rtsp://"+host+"/"+SourceList[SelectedSource].ChannelList[ChannelIndex].Request;
|
||||||
a.href = t;
|
a.href = t;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var t = "rtsp://"+host+"/"+SourceList[SelectedSource].ChannelList[ChannelIndex].request;
|
var t = "rtsp://"+host+"/"+SourceList[SelectedSource].ChannelList[ChannelIndex].Request;
|
||||||
var vlc = vlcplayer;
|
var vlc = vlcplayer;
|
||||||
var options = new Array();
|
var options = new Array();
|
||||||
vlc.playlist.clear();
|
vlc.playlist.clear();
|
||||||
var id = vlc.playlist.add(t, SourceList[SelectedSource].ChannelList[ChannelIndex].name, options);
|
var id = vlc.playlist.add(t, SourceList[SelectedSource].ChannelList[ChannelIndex].Title, options);
|
||||||
vlc.playlist.playItem(id);
|
vlc.playlist.playItem(id);
|
||||||
CurTracks = SourceList[SelectedSource].ChannelList[ChannelIndex].tracks;
|
CurTracks = SourceList[SelectedSource].ChannelList[ChannelIndex].Tracks;
|
||||||
|
|
||||||
document.getElementById("nowplaying").firstChild.nodeValue = SourceList[SelectedSource].ChannelList[ChannelIndex].name;
|
document.getElementById("nowplaying").firstChild.nodeValue = SourceList[SelectedSource].ChannelList[ChannelIndex].Title;
|
||||||
document.getElementById("ac0").disabled = CurTracks.length < 1;
|
document.getElementById("ac0").disabled = CurTracks.length < 1;
|
||||||
document.getElementById("ac1").disabled = CurTracks.length < 2;
|
document.getElementById("ac1").disabled = CurTracks.length < 2;
|
||||||
document.getElementById("ac2").disabled = CurTracks.length < 3;
|
document.getElementById("ac2").disabled = CurTracks.length < 3;
|
||||||
|
@ -48,7 +48,7 @@ function CreateM3U(host)
|
|||||||
for _,group in ipairs(channellist.GroupList) do
|
for _,group in ipairs(channellist.GroupList) do
|
||||||
for _,channel in ipairs(group.ChannelList) do
|
for _,channel in ipairs(group.ChannelList) do
|
||||||
table.insert(m3u,"#EXTINF:0,"..group.Title.." - "..channel.Title.."\n")
|
table.insert(m3u,"#EXTINF:0,"..group.Title.." - "..channel.Title.."\n")
|
||||||
table.insert(m3u,"rtsp://"..host..":554/?"..channel.Request.."\n")
|
table.insert(m3u,"rtsp://"..host..":554/"..channel.Request.."\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -121,7 +121,7 @@ function CreateJSON(host)
|
|||||||
local json = {}
|
local json = {}
|
||||||
table.insert(json,"{\n")
|
table.insert(json,"{\n")
|
||||||
|
|
||||||
table.insert(json,JSONSource(host,SourceList,"GroupList",nil) .. ",\n")
|
table.insert(json,JSONSource(host,SourceList,"GroupList",nil) .. "\n")
|
||||||
--~ table.insert(json,JSONSource(host,SourceList,"SourceListSat","dvbs") .. ",\n")
|
--~ table.insert(json,JSONSource(host,SourceList,"SourceListSat","dvbs") .. ",\n")
|
||||||
--~ table.insert(json,JSONSource(host,SourceList,"SourceListCable","dvbc") .. ",\n")
|
--~ table.insert(json,JSONSource(host,SourceList,"SourceListCable","dvbc") .. ",\n")
|
||||||
--~ table.insert(json,JSONSource(host,SourceList,"SourceListTer","dvbt") .. "\n")
|
--~ table.insert(json,JSONSource(host,SourceList,"SourceListTer","dvbt") .. "\n")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user