1
0
mirror of https://github.com/DigitalDevices/octonet.git synced 2023-10-10 13:36:52 +02:00

Channel/EPG scanning speedup and improved reporting

This commit is contained in:
mvoelkel 2016-02-01 18:50:50 +01:00
parent d1e97185a7
commit 3e15f9e651
4 changed files with 50 additions and 17 deletions

View File

@ -68,6 +68,7 @@ local Max = 999999
local Count = 0 local Count = 0
local ChannelCount = 0 local ChannelCount = 0
local EventCount = 0 local EventCount = 0
local ReportInterval = 1000
Report(ChannelCount,"*") Report(ChannelCount,"*")
@ -82,7 +83,7 @@ else
local Group local Group
for _,Group in ipairs(cl.GroupList) do for _,Group in ipairs(cl.GroupList) do
for _,Channel in ipairs(Group.ChannelList) do for _,Channel in ipairs(Group.ChannelList) do
if Channel.ID then if Channel.ID and not Channel.NoEPG then
local Params = "" local Params = ""
local p,v local p,v
for p,v in Channel.Request:gmatch("(%a+)=([%w%.]+)") do for p,v in Channel.Request:gmatch("(%a+)=([%w%.]+)") do
@ -113,6 +114,7 @@ else
end end
end end
end end
cl = nil
os.execute("rm "..outfile) os.execute("rm "..outfile)
local gzip = io.popen('gzip >'..outfile..".tmp","w") local gzip = io.popen('gzip >'..outfile..".tmp","w")
@ -121,22 +123,21 @@ else
local newline = "\n " local newline = "\n "
local Params local Params
local Key, t local Key, t
local encode = newencoder()
for Params,t in pairs(tl) do for Params,t in pairs(tl) do
Report(Count,"of "..ChannelCount.." transponders, "..EventCount.." events") Report(Count,"of "..ChannelCount.." transponders, "..EventCount.." events")
Count = Count + 1
Key = t.Key Key = t.Key
print("--------------------------------------------------------------") print("--------------------------------------------------------------")
collectgarbage();
local cmd = 'octoscan --eit_sid '..t.Sids..' '..Options..Params..' '..ipAddr local cmd = 'octoscan --eit_sid '..t.Sids..' '..Options..Params..' '..ipAddr
print(cmd) print(cmd)
local octoscan = io.popen(cmd,"r") local octoscan = io.popen(cmd,"r")
if octoscan then if octoscan then
tmp_count = ReportInterval
while true do while true do
local line = octoscan:read("*l") local line = octoscan:read("*l")
if not line then if not line then
break break
end end
--~ print(line)
local eid = nil local eid = nil
local name = nil local name = nil
local text = nil local text = nil
@ -149,7 +150,6 @@ else
if not line then if not line then
break break
end end
--~ print(line)
if line == "END" then if line == "END" then
if eid then if eid then
local event = { ID = Key..":"..eid } local event = { ID = Key..":"..eid }
@ -169,13 +169,17 @@ else
-- event.Language = language -- event.Language = language
-- end -- end
local encode = newencoder()
local e = encode(event) local e = encode(event)
gzip:write(newline..e) gzip:write(newline..e)
newline = ",\n " newline = ",\n "
EventCount = EventCount + 1 EventCount = EventCount + 1
tmp_count = tmp_count - 1
if tmp_count == 0 then
Report(Count,"of "..ChannelCount.." transponders, "..EventCount.." events")
tmp_count = ReportInterval
end
end end
collectgarbage();
break break
end end
@ -198,6 +202,7 @@ else
end end
octoscan:close() octoscan:close()
end end
Count = Count + 1
end end
gzip:write("\n]}") gzip:write("\n]}")
gzip:close() gzip:close()

View File

@ -216,8 +216,9 @@ if tl.SourceList then
local sid = 0 local sid = 0
local pids = "" local pids = ""
local tracks= { } local tracks= { }
local isradio = false local isradio = nil
local isencrypted = false local isencrypted = false
local hasepg = nil
if line == "SERVICE" then if line == "SERVICE" then
while true do while true do
line = octoscan:read("*l") line = octoscan:read("*l")
@ -275,7 +276,10 @@ if tl.SourceList then
local channel = { Title=sname, local channel = { Title=sname,
Request = '?'..Request..cireq.."&pids="..all_pids, Request = '?'..Request..cireq.."&pids="..all_pids,
Tracks=tracks, Tracks=tracks,
ID=ID, Order=Order } ID=ID, Order=Order, Radio=isradio }
if not hasepg then
channel.NoEPG = true
end
if ((not isradio) or (include_radio > 0)) and ((not isencrypted) or (include_encrypted > 0)) then if ((not isradio) or (include_radio > 0)) and ((not isencrypted) or (include_encrypted > 0)) then
local group = GetGroup(ChannelList,gname) local group = GetGroup(ChannelList,gname)
if group then if group then
@ -289,6 +293,10 @@ if tl.SourceList then
local par,val = line:match("^ (%a+):(.*)") local par,val = line:match("^ (%a+):(.*)")
if par == "RADIO" then if par == "RADIO" then
isradio = true isradio = true
elseif par == "EIT" then
if val:sub(2,2) == "1" then
hasepg = true
end
elseif par == "PNAME" then elseif par == "PNAME" then
pname = val pname = val
elseif par == "SNAME" then elseif par == "SNAME" then

View File

@ -16,6 +16,8 @@ var hasCable = false;
var hasSat = false; var hasSat = false;
var hasTer = false; var hasTer = false;
var StartTime = null;
var xmlhttp = new XMLHttpRequest(); var xmlhttp = new XMLHttpRequest();
var url = "/channelscan.lua?select=keys"; var url = "/channelscan.lua?select=keys";
@ -156,8 +158,16 @@ function ScanStatus(response)
} }
else if( s.status == "done" ) else if( s.status == "done" )
{ {
var sec = "";
if( StartTime )
{
var t = new Date() - StartTime;
sec = ", time: " + Math.floor(t/1000) + " seconds";
StartTime = null;
}
document.getElementById("scancount").firstChild.nodeValue = s.count; document.getElementById("scancount").firstChild.nodeValue = s.count;
document.getElementById("scantext").firstChild.nodeValue = s.msg; document.getElementById("scantext").firstChild.nodeValue = s.msg + sec;
} }
else if( s.status == "deleted" ) else if( s.status == "deleted" )
{ {
@ -235,6 +245,7 @@ function InitiateScan()
ScanReq.send("select=scan" + param + "&sitables=1&sort=1&restartdms=1"); ScanReq.send("select=scan" + param + "&sitables=1&sort=1&restartdms=1");
document.getElementById("scancount").firstChild.nodeValue = "\u00A0"; document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
document.getElementById("scantext").firstChild.nodeValue = "Scanning..."; document.getElementById("scantext").firstChild.nodeValue = "Scanning...";
StartTime = new Date();
} }
else else
{ {
@ -246,11 +257,12 @@ function InitiateScan()
function InitiateEPGScan() function InitiateEPGScan()
{ {
DisableButtons(true); DisableButtons(true);
ScanReq.open("POST", "/channelscan.lua", true); ScanReq.open("POST", "/channelscan.lua", true);
ScanReq.setRequestHeader("Content-type","application/x-www-form-urlencoded"); ScanReq.setRequestHeader("Content-type","application/x-www-form-urlencoded");
ScanReq.send("select=epg"); ScanReq.send("select=epg");
document.getElementById("scancount").firstChild.nodeValue = "\u00A0"; document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
document.getElementById("scantext").firstChild.nodeValue = "Scanning..."; document.getElementById("scantext").firstChild.nodeValue = "Scanning...";
StartTime = new Date();
} }
function PollStatus() function PollStatus()

View File

@ -107,7 +107,8 @@ function LoadEPG()
function ChannelListResponse(response) function ChannelListResponse(response)
{ {
ChannelList = JSON.parse(response); ChannelList = JSON.parse(response);
if( ChannelList.GroupList[0].ChannelList[0].ID ) var Valid = false;
if( ChannelList.GroupList[0].ChannelList )
{ {
ChannelLookup = new Object(); ChannelLookup = new Object();
for(var i = 0; i < ChannelList.GroupList.length; i += 1) for(var i = 0; i < ChannelList.GroupList.length; i += 1)
@ -115,9 +116,16 @@ function ChannelListResponse(response)
var Group = ChannelList.GroupList[i]; var Group = ChannelList.GroupList[i];
for(var j = 0; j < Group.ChannelList.length; j += 1) for(var j = 0; j < Group.ChannelList.length; j += 1)
{ {
ChannelLookup[Group.ChannelList[j].ID] = Group.ChannelList[j]; if( Group.ChannelList[j].ID )
{
Valid = true;
ChannelLookup[Group.ChannelList[j].ID] = Group.ChannelList[j];
}
} }
} }
}
if( Valid )
{
LoadEPG(); LoadEPG();
} }
else else