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
|
||||||
|
@ -56,7 +56,7 @@ if file then
|
|||||||
local newdecoder = require("lunajson.decoder")
|
local newdecoder = require("lunajson.decoder")
|
||||||
local decode = newdecoder()
|
local decode = newdecoder()
|
||||||
local channellist = decode(json)
|
local channellist = decode(json)
|
||||||
|
|
||||||
for _,group in ipairs(channellist.GroupList) do
|
for _,group in ipairs(channellist.GroupList) do
|
||||||
local f = {}
|
local f = {}
|
||||||
f.id = "$"..tostring(#Folders)
|
f.id = "$"..tostring(#Folders)
|
||||||
@ -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;')
|
||||||
@ -121,7 +121,7 @@ AllFolders[f.id] = f
|
|||||||
for i = 1,4,1 do
|
for i = 1,4,1 do
|
||||||
vi = { id = f.id.."$"..tostring(i-1), parentID = f.id, title = "Stream "..tostring(i), stream = tostring(i) }
|
vi = { id = f.id.."$"..tostring(i-1), parentID = f.id, title = "Stream "..tostring(i), stream = tostring(i) }
|
||||||
table.insert(f.VideoItems,vi)
|
table.insert(f.VideoItems,vi)
|
||||||
AllItems[vi.id] = vi
|
AllItems[vi.id] = vi
|
||||||
end
|
end
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -145,10 +145,10 @@ local function VideoItem(Host,Item,nCompat)
|
|||||||
else
|
else
|
||||||
-- Some clients don't like a long request url, or an url with '&' in it
|
-- Some clients don't like a long request url, or an url with '&' in it
|
||||||
-- Fail them for now
|
-- Fail them for now
|
||||||
-- if nCompat then
|
-- if nCompat then
|
||||||
-- rtspreq = "stream_99"
|
-- rtspreq = "stream_99"
|
||||||
-- elseif Item.src then
|
-- elseif Item.src then
|
||||||
if Item.src then
|
if Item.src then
|
||||||
rtspreq = '?src='..Item.src..'&amp;'..Item.request
|
rtspreq = '?src='..Item.src..'&amp;'..Item.request
|
||||||
else
|
else
|
||||||
rtspreq = '?'..Item.request
|
rtspreq = '?'..Item.request
|
||||||
@ -158,17 +158,17 @@ local function VideoItem(Host,Item,nCompat)
|
|||||||
local didl = '<item id="'..Item.id..'" parentID="'..Item.parentID
|
local didl = '<item id="'..Item.id..'" parentID="'..Item.parentID
|
||||||
didl = didl .. '" restricted="1">'
|
didl = didl .. '" restricted="1">'
|
||||||
..'<dc:title>'..Item.title..'</dc:title>'
|
..'<dc:title>'..Item.title..'</dc:title>'
|
||||||
..'<upnp:class>object.item.videoItem.videoBroadcast</upnp:class>'
|
..'<upnp:class>object.item.videoItem.videoBroadcast</upnp:class>'
|
||||||
if Item.channelNr then
|
if Item.channelNr then
|
||||||
didl = didl ..'<upnp:channelNr>'..Item.channelNr..'</upnp:channelNr>'
|
didl = didl ..'<upnp:channelNr>'..Item.channelNr..'</upnp:channelNr>'
|
||||||
end
|
end
|
||||||
didl = didl ..'<res'
|
didl = didl ..'<res'
|
||||||
..' protocolInfo="rtsp-rtp-udp:*:video/mpeg:'..dlnaprofile..'">'
|
..' protocolInfo="rtsp-rtp-udp:*:video/mpeg:'..dlnaprofile..'">'
|
||||||
..'rtsp://'..Host..':554/'..rtspreq
|
..'rtsp://'..Host..':554/'..rtspreq
|
||||||
..'</res>'
|
..'</res>'
|
||||||
didl = didl ..'</item>'
|
didl = didl ..'</item>'
|
||||||
return didl
|
return didl
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -186,9 +186,9 @@ local function BrowseChildren(client,Host,Request,nCompat)
|
|||||||
local TotalMatches = 0
|
local TotalMatches = 0
|
||||||
local UpdateID = SystemUpdateID
|
local UpdateID = SystemUpdateID
|
||||||
local f,vi,ai
|
local f,vi,ai
|
||||||
|
|
||||||
if ObjectID == "0" then
|
if ObjectID == "0" then
|
||||||
if nCompat then
|
if nCompat then
|
||||||
for _,f in ipairs(RootFolders) do
|
for _,f in ipairs(RootFolders) do
|
||||||
didl = didl..Folder(f.title,f.id,ObjectID,tostring(#f.VideoItems + #f.AudioItems + #f.ChildFolders))
|
didl = didl..Folder(f.title,f.id,ObjectID,tostring(#f.VideoItems + #f.AudioItems + #f.ChildFolders))
|
||||||
NumberReturned = NumberReturned + 1
|
NumberReturned = NumberReturned + 1
|
||||||
@ -201,11 +201,11 @@ local function BrowseChildren(client,Host,Request,nCompat)
|
|||||||
TotalMatches = TotalMatches +1
|
TotalMatches = TotalMatches +1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
local f = AllFolders[ObjectID]
|
local f = AllFolders[ObjectID]
|
||||||
if f then
|
if f then
|
||||||
|
|
||||||
local Index = 0
|
local Index = 0
|
||||||
for i,cf in ipairs(f.ChildFolders) do
|
for i,cf in ipairs(f.ChildFolders) do
|
||||||
if Index >= StartingIndex and (RequestedCount == 0 or NumberReturned < RequestedCount) then
|
if Index >= StartingIndex and (RequestedCount == 0 or NumberReturned < RequestedCount) then
|
||||||
@ -215,7 +215,7 @@ local function BrowseChildren(client,Host,Request,nCompat)
|
|||||||
Index = Index + 1
|
Index = Index + 1
|
||||||
TotalMatches = TotalMatches +1
|
TotalMatches = TotalMatches +1
|
||||||
end
|
end
|
||||||
|
|
||||||
for i,vi in ipairs(f.VideoItems) do
|
for i,vi in ipairs(f.VideoItems) do
|
||||||
if Index >= StartingIndex and (RequestedCount == 0 or NumberReturned < RequestedCount) then
|
if Index >= StartingIndex and (RequestedCount == 0 or NumberReturned < RequestedCount) then
|
||||||
didl = didl..VideoItem(Host,vi,nCompat)
|
didl = didl..VideoItem(Host,vi,nCompat)
|
||||||
@ -224,7 +224,7 @@ local function BrowseChildren(client,Host,Request,nCompat)
|
|||||||
Index = Index + 1
|
Index = Index + 1
|
||||||
TotalMatches = TotalMatches +1
|
TotalMatches = TotalMatches +1
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
Error = 710
|
Error = 710
|
||||||
end
|
end
|
||||||
@ -232,15 +232,15 @@ local function BrowseChildren(client,Host,Request,nCompat)
|
|||||||
|
|
||||||
didl = didl..DIDLEnd
|
didl = didl..DIDLEnd
|
||||||
print("Returned",StartingIndex,NumberReturned,TotalMatches,Error)
|
print("Returned",StartingIndex,NumberReturned,TotalMatches,Error)
|
||||||
|
|
||||||
if Error == 0 then
|
if Error == 0 then
|
||||||
local Args = { { n = "Result", v = didl }, { n = "NumberReturned", v = tostring(NumberReturned)},
|
local Args = { { n = "Result", v = didl }, { n = "NumberReturned", v = tostring(NumberReturned)},
|
||||||
{ n = "TotalMatches", v = tostring(TotalMatches)}, { n = "UpdateID", v = tostring(UpdateID) } }
|
{ n = "TotalMatches", v = tostring(TotalMatches)}, { n = "UpdateID", v = tostring(UpdateID) } }
|
||||||
UPnP:SendResponse(client,UPnP:CreateResponse(Schema,"Browse",Args))
|
UPnP:SendResponse(client,UPnP:CreateResponse(Schema,"Browse",Args))
|
||||||
else
|
else
|
||||||
UPnP:SendSoapError(client,Error)
|
UPnP:SendSoapError(client,Error)
|
||||||
end
|
end
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -259,21 +259,21 @@ local function BrowseMetaData(client,Host,Request,nCompat)
|
|||||||
..'</container>'
|
..'</container>'
|
||||||
else
|
else
|
||||||
local f = AllFolders[ObjectID]
|
local f = AllFolders[ObjectID]
|
||||||
if f then
|
if f then
|
||||||
didl = didl..Folder(f.title,f.id,ObjectID,tostring(#f.VideoItems + #f.AudioItems + #f.ChildFolders))
|
didl = didl..Folder(f.title,f.id,ObjectID,tostring(#f.VideoItems + #f.AudioItems + #f.ChildFolders))
|
||||||
else
|
else
|
||||||
local item = AllItems[ObjectID]
|
local item = AllItems[ObjectID]
|
||||||
if item then
|
if item then
|
||||||
didl = didl..VideoItem(Host,item,nCompat)
|
didl = didl..VideoItem(Host,item,nCompat)
|
||||||
else
|
else
|
||||||
Error = 710
|
Error = 710
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
didl = didl..DIDLEnd
|
didl = didl..DIDLEnd
|
||||||
|
|
||||||
if Error == 0 then
|
if Error == 0 then
|
||||||
local Args = { { n = "Result", v = didl }, { n = "NumberReturned", v = "1"},
|
local Args = { { n = "Result", v = didl }, { n = "NumberReturned", v = "1"},
|
||||||
{ n = "TotalMatches", v = "1"}, { n = "UpdateID", v = tostring(UpdateID) } }
|
{ n = "TotalMatches", v = "1"}, { n = "UpdateID", v = tostring(UpdateID) } }
|
||||||
UPnP:SendResponse(client,UPnP:CreateResponse(Schema,"Browse",Args))
|
UPnP:SendResponse(client,UPnP:CreateResponse(Schema,"Browse",Args))
|
||||||
@ -281,7 +281,7 @@ local function BrowseMetaData(client,Host,Request,nCompat)
|
|||||||
UPnP:SendSoapError(client,Error)
|
UPnP:SendSoapError(client,Error)
|
||||||
end
|
end
|
||||||
|
|
||||||
didl = DIDLEnd;
|
didl = DIDLEnd;
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Search(client,Host,Request,nCompat)
|
local function Search(client,Host,Request,nCompat)
|
||||||
@ -298,9 +298,9 @@ local function Search(client,Host,Request,nCompat)
|
|||||||
local NumberReturned = 0
|
local NumberReturned = 0
|
||||||
local TotalMatches = 0
|
local TotalMatches = 0
|
||||||
local UpdateID = SystemUpdateID
|
local UpdateID = SystemUpdateID
|
||||||
|
|
||||||
if string.match(SearchCriteria,"videoItem") then
|
if string.match(SearchCriteria,"videoItem") then
|
||||||
|
|
||||||
if ContainerID == "0" then
|
if ContainerID == "0" then
|
||||||
if not nCompat or nCompat ~= "WMP" then
|
if not nCompat or nCompat ~= "WMP" then
|
||||||
local Index = 0
|
local Index = 0
|
||||||
@ -314,13 +314,13 @@ local function Search(client,Host,Request,nCompat)
|
|||||||
-- if nCompat and TotalMatches > 19 then break end
|
-- if nCompat and TotalMatches > 19 then break end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
local f = AllFolders[ContainerID]
|
local f = AllFolders[ContainerID]
|
||||||
if f then
|
if f then
|
||||||
local src = f.src
|
local src = f.src
|
||||||
if src then src = "src="..src.."&" else src = "" end
|
if src then src = "src="..src.."&" else src = "" end
|
||||||
|
|
||||||
local Index = 0
|
local Index = 0
|
||||||
for _,vi in ipairs(f.VideoItems) do
|
for _,vi in ipairs(f.VideoItems) do
|
||||||
if Index >= StartingIndex and (RequestedCount == 0 or NumberReturned < RequestedCount) then
|
if Index >= StartingIndex and (RequestedCount == 0 or NumberReturned < RequestedCount) then
|
||||||
@ -337,20 +337,20 @@ local function Search(client,Host,Request,nCompat)
|
|||||||
end
|
end
|
||||||
|
|
||||||
didl = didl..DIDLEnd
|
didl = didl..DIDLEnd
|
||||||
-- didl = TestDidl
|
-- didl = TestDidl
|
||||||
-- NumberReturned = 1
|
-- NumberReturned = 1
|
||||||
-- TotalMatches = 1
|
-- TotalMatches = 1
|
||||||
print("Returned",StartingIndex,NumberReturned,TotalMatches,Error)
|
print("Returned",StartingIndex,NumberReturned,TotalMatches,Error)
|
||||||
|
|
||||||
|
|
||||||
if Error == 0 then
|
if Error == 0 then
|
||||||
local Args = { { n = "Result", v = didl }, { n = "NumberReturned", v = tostring(NumberReturned)},
|
local Args = { { n = "Result", v = didl }, { n = "NumberReturned", v = tostring(NumberReturned)},
|
||||||
{ n = "TotalMatches", v = tostring(TotalMatches)}, { n = "UpdateID", v = tostring(UpdateID) } }
|
{ n = "TotalMatches", v = tostring(TotalMatches)}, { n = "UpdateID", v = tostring(UpdateID) } }
|
||||||
UPnP:SendResponse(client,UPnP:CreateResponse(Schema,"Search",Args))
|
UPnP:SendResponse(client,UPnP:CreateResponse(Schema,"Search",Args))
|
||||||
else
|
else
|
||||||
UPnP:SendSoapError(client,Error)
|
UPnP:SendSoapError(client,Error)
|
||||||
end
|
end
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -362,35 +362,35 @@ end
|
|||||||
function ContentDirectory:Invoke(client,Attributes,Request)
|
function ContentDirectory:Invoke(client,Attributes,Request)
|
||||||
local Action = string.match(Attributes["SOAPACTION"],".+%#([%a%d%-_]+)")
|
local Action = string.match(Attributes["SOAPACTION"],".+%#([%a%d%-_]+)")
|
||||||
local Host = tostring(Attributes["host"])
|
local Host = tostring(Attributes["host"])
|
||||||
|
|
||||||
local Compability = nil
|
local Compability = nil
|
||||||
if Attributes["USER-AGENT"] then
|
if Attributes["USER-AGENT"] then
|
||||||
if string.match(Attributes["USER-AGENT"],"Windows%-Media%-Player") then Compability = "WMP"
|
if string.match(Attributes["USER-AGENT"],"Windows%-Media%-Player") then Compability = "WMP"
|
||||||
elseif string.match(Attributes["USER-AGENT"],"IPI%/1%.0") then Compability = "IPI"
|
elseif string.match(Attributes["USER-AGENT"],"IPI%/1%.0") then Compability = "IPI"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
print("Compability=",Compability)
|
print("Compability=",Compability)
|
||||||
|
|
||||||
print(Host,"ContentDirectory",Action)
|
print(Host,"ContentDirectory",Action)
|
||||||
if Action == "Browse" then
|
if Action == "Browse" then
|
||||||
local BrowseFlag = tostring(UPnP:GetRequestParam(Request,"BrowseFlag"))
|
local BrowseFlag = tostring(UPnP:GetRequestParam(Request,"BrowseFlag"))
|
||||||
if BrowseFlag == "BrowseDirectChildren" then
|
if BrowseFlag == "BrowseDirectChildren" then
|
||||||
BrowseChildren(client,Host,Request,Compability)
|
BrowseChildren(client,Host,Request,Compability)
|
||||||
elseif BrowseFlag == "BrowseMetadata" then
|
elseif BrowseFlag == "BrowseMetadata" then
|
||||||
BrowseMetaData(client,Host,Request,Compability)
|
BrowseMetaData(client,Host,Request,Compability)
|
||||||
else
|
else
|
||||||
UPnP:SendSoapError(client,710)
|
UPnP:SendSoapError(client,710)
|
||||||
end
|
end
|
||||||
elseif Action == "Search" then
|
elseif Action == "Search" then
|
||||||
Search(client,Host,Request,Compability)
|
Search(client,Host,Request,Compability)
|
||||||
-- elseif Action == "X_GetRemoteSharingStatus" then
|
-- elseif Action == "X_GetRemoteSharingStatus" then
|
||||||
-- SendResult(client,Action,"0")
|
-- SendResult(client,Action,"0")
|
||||||
elseif Action == "GetSortCapabilities" then
|
elseif Action == "GetSortCapabilities" then
|
||||||
SendResult(client,Action,"SortCaps","dc:title,upnp:class,upnp:originalTrackNumber")
|
SendResult(client,Action,"SortCaps","dc:title,upnp:class,upnp:originalTrackNumber")
|
||||||
elseif Action == "GetSearchCapabilities" then
|
elseif Action == "GetSearchCapabilities" then
|
||||||
SendResult(client,Action,"SearchCaps","dc:title")
|
SendResult(client,Action,"SearchCaps","dc:title")
|
||||||
elseif Action == "GetSystemUpdateID" then
|
elseif Action == "GetSystemUpdateID" then
|
||||||
SendResult(client,Action,"Id","1")
|
SendResult(client,Action,"Id","1")
|
||||||
else
|
else
|
||||||
UPnP:SendSoapError(client,401)
|
UPnP:SendSoapError(client,401)
|
||||||
end
|
end
|
||||||
@ -406,12 +406,12 @@ function ContentDirectory:Subscribe(client,callback,timeout)
|
|||||||
.. "Connection: close\r\n"
|
.. "Connection: close\r\n"
|
||||||
.. "EXT:\r\n"
|
.. "EXT:\r\n"
|
||||||
.. "\r\n"
|
.. "\r\n"
|
||||||
client:send(r)
|
client:send(r)
|
||||||
|
|
||||||
local ipaddr,port = client:getpeername()
|
local ipaddr,port = client:getpeername()
|
||||||
local Args = { { n = "TransferIDs", v = "" }, { n = "SystemUpdateID", v = tostring(SystemUpdateID) } }
|
local Args = { { n = "TransferIDs", v = "" }, { n = "SystemUpdateID", v = tostring(SystemUpdateID) } }
|
||||||
UPnP:SendEvent(callback,"50c95800-e839-4b96-b7ae-779d989e1399",0,Args)
|
UPnP:SendEvent(callback,"50c95800-e839-4b96-b7ae-779d989e1399",0,Args)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function ContentDirectory:Renew(client,sid,timeout)
|
function ContentDirectory:Renew(client,sid,timeout)
|
||||||
@ -424,7 +424,7 @@ function ContentDirectory:Renew(client,sid,timeout)
|
|||||||
.. "Connection: close\r\n"
|
.. "Connection: close\r\n"
|
||||||
.. "EXT:\r\n"
|
.. "EXT:\r\n"
|
||||||
.. "\r\n"
|
.. "\r\n"
|
||||||
client:send(r)
|
client:send(r)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ContentDirectory:Unsubscribe(client,sid)
|
function ContentDirectory:Unsubscribe(client,sid)
|
||||||
@ -435,7 +435,7 @@ function ContentDirectory:Unsubscribe(client,sid)
|
|||||||
.. "Connection: close\r\n"
|
.. "Connection: close\r\n"
|
||||||
.. "EXT:\r\n"
|
.. "EXT:\r\n"
|
||||||
.. "\r\n"
|
.. "\r\n"
|
||||||
client:send(r)
|
client:send(r)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -446,7 +446,7 @@ function ContentDirectory:Description()
|
|||||||
while true do
|
while true do
|
||||||
local line = f:read()
|
local line = f:read()
|
||||||
if not line then break end
|
if not line then break end
|
||||||
t = t .. line .. "\r\n"
|
t = t .. line .. "\r\n"
|
||||||
end
|
end
|
||||||
f:close()
|
f:close()
|
||||||
return t
|
return t
|
||||||
|
@ -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">
|
||||||
@ -29,7 +28,7 @@ if( browserType == "Netscape" )
|
|||||||
for(var i = 0; i < navigator.plugins.length; i++ )
|
for(var i = 0; i < navigator.plugins.length; i++ )
|
||||||
{
|
{
|
||||||
var t = navigator.plugins[i].name + " " + navigator.plugins[i].version;
|
var t = navigator.plugins[i].name + " " + navigator.plugins[i].version;
|
||||||
|
|
||||||
if( navigator.plugins[i].name == "VLC Web Plugin" )
|
if( navigator.plugins[i].name == "VLC Web Plugin" )
|
||||||
{
|
{
|
||||||
VLCPlugin = navigator.plugins[i];
|
VLCPlugin = navigator.plugins[i];
|
||||||
@ -41,7 +40,7 @@ if( browserType == "Netscape" )
|
|||||||
{
|
{
|
||||||
VLCPluginValid = true;
|
VLCPluginValid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,7 +65,7 @@ function PlayEvent()
|
|||||||
var id = vlc.playlist.add(t, this.PlayName, options);
|
var id = vlc.playlist.add(t, this.PlayName, options);
|
||||||
vlc.playlist.playItem(id);
|
vlc.playlist.playItem(id);
|
||||||
CurTracks = this.PlayTracks;
|
CurTracks = this.PlayTracks;
|
||||||
|
|
||||||
document.getElementById("nowplaying").firstChild.nodeValue = this.PlayName;
|
document.getElementById("nowplaying").firstChild.nodeValue = this.PlayName;
|
||||||
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;
|
||||||
@ -90,19 +89,19 @@ function MuteAudio()
|
|||||||
function AddRow(table,name,request,tracks)
|
function AddRow(table,name,request,tracks)
|
||||||
{
|
{
|
||||||
var row = document.createElement("tr");
|
var row = document.createElement("tr");
|
||||||
|
|
||||||
var col = document.createElement("td");
|
var col = document.createElement("td");
|
||||||
var txt = document.createTextNode(name);
|
var txt = document.createTextNode(name);
|
||||||
col.appendChild(txt);
|
col.appendChild(txt);
|
||||||
row.appendChild(col);
|
row.appendChild(col);
|
||||||
|
|
||||||
col = document.createElement("td");
|
col = document.createElement("td");
|
||||||
if( RTSPLink )
|
if( RTSPLink )
|
||||||
{
|
{
|
||||||
var t = "rtsp://"+host+"/"+request;
|
var t = "rtsp://"+host+"/"+request;
|
||||||
var a = document.createElement("a");
|
var a = document.createElement("a");
|
||||||
a.setAttribute("href",t);
|
a.setAttribute("href",t);
|
||||||
a.appendChild(document.createTextNode("Play"));
|
a.appendChild(document.createTextNode("Play"));
|
||||||
col.appendChild(a);
|
col.appendChild(a);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -119,34 +118,105 @@ function AddRow(table,name,request,tracks)
|
|||||||
field.PlayRequest = request;
|
field.PlayRequest = request;
|
||||||
field.PlayTracks = tracks;
|
field.PlayTracks = tracks;
|
||||||
field.addEventListener("click",PlayEvent);
|
field.addEventListener("click",PlayEvent);
|
||||||
form.appendChild(field);
|
form.appendChild(field);
|
||||||
|
|
||||||
col.appendChild(form);
|
col.appendChild(form);
|
||||||
}
|
}
|
||||||
row.appendChild(col);
|
row.appendChild(col);
|
||||||
|
|
||||||
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,40 +226,12 @@ 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
|
||||||
document.Source.Select.length = 0;
|
hasTer = hasCable;
|
||||||
var index = 0
|
|
||||||
if( hasSat )
|
xmlhttp.open("GET", url, true);
|
||||||
{
|
xmlhttp.send();
|
||||||
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
|
||||||
{
|
{
|
||||||
@ -213,7 +255,7 @@ function CreatePlugin()
|
|||||||
document.write('Check for new Version on <a href="http://www.videolan.org">VLC Mediaplayer</a>');
|
document.write('Check for new Version on <a href="http://www.videolan.org">VLC Mediaplayer</a>');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( VLCPluginValid )
|
if( VLCPluginValid )
|
||||||
{
|
{
|
||||||
document.getElementById("ControlPlugin").style.display = "block";
|
document.getElementById("ControlPlugin").style.display = "block";
|
||||||
@ -238,13 +280,41 @@ 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;
|
||||||
SetChannel(i);
|
SetChannel(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;
|
||||||
@ -301,7 +386,7 @@ function SetChannel(ChannelIndex)
|
|||||||
<!-- Begin Content -->
|
<!-- Begin Content -->
|
||||||
<table cellpadding="2px" align="center">
|
<table cellpadding="2px" align="center">
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<div id="ControlPlugin">
|
<div id="ControlPlugin">
|
||||||
<table width="100%">
|
<table width="100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td><div align="left" id="nowplaying"> </div></td>
|
<td><div align="left" id="nowplaying"> </div></td>
|
||||||
@ -322,10 +407,10 @@ function SetChannel(ChannelIndex)
|
|||||||
|
|
||||||
|
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<script type="text/javascript">CreatePlugin();</script></td>
|
<script type="text/javascript">CreatePlugin();</script></td>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<div id="channeltable">
|
<div id="channeltable">
|
||||||
<table cellpadding="2px" align="center">
|
<table cellpadding="2px" align="center">
|
||||||
<tr>
|
<tr>
|
||||||
<td>Source</td>
|
<td>Source</td>
|
||||||
@ -350,12 +435,12 @@ function SetChannel(ChannelIndex)
|
|||||||
</div>
|
</div>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<div id="playlink" align="center" >
|
<div id="playlink" align="center" >
|
||||||
<a id="Play" href="">Play</a>
|
<a id="Play" href="">Play</a>
|
||||||
</div>
|
</div>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<!-- End Content -->
|
<!-- End Content -->
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
@ -37,7 +37,7 @@ end
|
|||||||
function CreateM3U(host)
|
function CreateM3U(host)
|
||||||
local m3u = {}
|
local m3u = {}
|
||||||
table.insert(m3u,"#EXTM3U".."\n")
|
table.insert(m3u,"#EXTM3U".."\n")
|
||||||
|
|
||||||
local file = io.open("/config/ChannelList.json")
|
local file = io.open("/config/ChannelList.json")
|
||||||
if file then
|
if file then
|
||||||
local json = file:read("*a")
|
local json = file:read("*a")
|
||||||
@ -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