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

Channelscan

Added backup and restore previous list
Added delete list to allow to revert to legacy mode
Added ID created from key,onid,tsid,sid
Userinterface improvment.
(Note requires updated octoscan from, dddvb)
This commit is contained in:
mvoelkel 2016-01-20 14:28:34 +01:00
parent 562b4fd379
commit cc6cb4709c
4 changed files with 182 additions and 54 deletions

File diff suppressed because one or more lines are too long

View File

@ -164,6 +164,8 @@ if tl.SourceList then
print(line)
local pname = "?"
local sname = "?"
local onid = 0
local tsid = 0
local sid = 0
local pids = ""
local tracks= { }
@ -187,12 +189,18 @@ if tl.SourceList then
if #pids > 0 then
all_pids = all_pids..","..pids
end
local channel = { Title=sname, Service=sid, Request = '?'..Request.."&pids="..all_pids, Tracks=tracks }
local channel = { Title=sname,
Request = '?'..Request.."&pids="..all_pids,
Tracks=tracks,
ID = string.format("%s:%d:%d:%d",Source.Key,onid,tsid,sid) }
if pname == "" then
pname = Source.Title
end
local gname = pname
if isradio then
gname = "Radio - "..gname
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)
if group then
table.insert(group.ChannelList,channel)
@ -209,8 +217,12 @@ if tl.SourceList then
pname = val
elseif par == "SNAME" then
sname = val
elseif par == "ONID" then
onid = tonumber(val)
elseif par == "TSID" then
tsid = tonumber(val)
elseif par == "SID" then
sid = tonumber(value)
sid = tonumber(val)
elseif par == "PIDS" then
pids = val
elseif par == "APIDS" then
@ -219,6 +231,8 @@ if tl.SourceList then
table.insert(tracks,tonumber(track))
end
tracks[0] = #tracks
elseif par == "ENC" then
isencrypted = true
end
end
elseif line:sub(1,5) == "TUNE:" then
@ -245,6 +259,9 @@ if tl.SourceList then
local encode = newencoder()
cl = encode(ChannelList)
if outfile == "/config/ChannelList.json" then
os.execute("mv /config/ChannelList.json /config/ChannelList.bak")
end
if cl then
local f = io.open(outfile,"w+")
if f then
@ -255,6 +272,7 @@ if tl.SourceList then
end
Report(ChannelCount,"Done")
os.execute("mv /tmp/doscan.lock/doscan.msg /tmp/doscan.msg")
if restart_dms then

View File

@ -102,6 +102,15 @@ function OnLoad()
}
function DisableButtons(disabled)
{
document.getElementById("ScanButton").disabled = disabled;
document.getElementById("StatusButton").disabled = disabled;
document.getElementById("DeleteButton").disabled = disabled;
document.getElementById("RestoreButton").disabled = disabled;
}
var ScanReq = new XMLHttpRequest();
ScanReq.onreadystatechange=function()
@ -110,6 +119,12 @@ ScanReq.onreadystatechange=function()
{
if( ScanReq.status == 200 )
ScanStatus(ScanReq.responseText);
else
{
document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
document.getElementById("scantext").firstChild.nodeValue = "Error " + ScanReq.status;
DisableButtons(false);
}
}
}
@ -122,31 +137,56 @@ function GetStatus()
function ScanStatus(response)
{
var s = JSON.parse(response);
var done = false;
if( s.status )
{
if( s.status == "active" )
{
document.getElementById("scancount").firstChild.nodeValue = s.count;
document.getElementById("scantext").firstChild.nodeValue = s.msg;
window.setTimeout(GetStatus,500);
}
else if( s.status == "busy" )
{
document.getElementById("scancount").firstChild.nodeValue = "";
document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
document.getElementById("scantext").firstChild.nodeValue = "BUSY";
done = true;
}
else if( s.status == "done" )
{
document.getElementById("scancount").firstChild.nodeValue = s.count;
document.getElementById("scantext").firstChild.nodeValue = "Channels found";
done = true;
}
else if( s.status == "deleted" )
{
document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
document.getElementById("scantext").firstChild.nodeValue = "Channel list deleted";
done = true;
}
else if( s.status == "restored" )
{
document.getElementById("scancount").firstChild.nodeValue = "\u00A0";
if( s.count == 0 )
document.getElementById("scantext").firstChild.nodeValue = "Nothing restored";
else
document.getElementById("scantext").firstChild.nodeValue = "Previous channel list restored";
done = true;
}
}
if( done )
{
DisableButtons(false);
}
else
{
window.setTimeout(GetStatus,500);
}
}
function InitiateScan()
{
DisableButtons(true);
var param = "";
for(var i = 1; i < document.Cable.Select.options.length; i += 1)
{
@ -188,6 +228,26 @@ function InitiateScan()
}
}
function PollStatus()
{
DisableButtons(true);
GetStatus();
}
function DeleteScan()
{
DisableButtons(true);
ScanReq.open("GET", "/channelscan.lua?select=delete", true);
ScanReq.send();
}
function RestoreScan()
{
DisableButtons(true);
ScanReq.open("GET", "/channelscan.lua?select=restore", true);
ScanReq.send();
}
</script>
</head>
@ -257,7 +317,8 @@ function InitiateScan()
<td>&nbsp;</td>
<td style="text-align:right">
<form action="">
<input type="Button" value="Start Scan" onclick="InitiateScan()" >
<input id="ScanButton" type="Button" value="Start Scan" onclick="InitiateScan()" >
<input id="StatusButton" type="Button" value="Get Status" onclick="PollStatus()" >
</form>
</td>
</tr>
@ -269,6 +330,15 @@ function InitiateScan()
<div id="scantext" style="text-align:left">&nbsp;</div>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td style="text-align:right">
<form action="">
<input id="DeleteButton" type="Button" value="Delete Scan" onclick="DeleteScan()" >
<input id="RestoreButton" type="Button" value="Restore Previous Scan" onclick="RestoreScan()" >
</form>
</td>
</tr>
</table>
<hr/>

View File

@ -89,6 +89,11 @@ if method == "GET" then
data = '{"status":"busy"}'
else
data = '{"status":"retry"}'
local f = io.open("/tmp/doscan.msg","w+")
if f then
f:write("Scanning")
f:close()
end
os.execute("/var/channels/doscan.lua "..params.." >/tmp/doscan.log 2>&1 &")
end
elseif cmd == "status" then
@ -96,23 +101,58 @@ if method == "GET" then
local f = io.open("/tmp/doscan.lock/doscan.msg")
if f then
js.status = "active"
else
f = io.open("/tmp/doscan.msg")
if f then
js.status = "done"
else
js.status = "retry"
end
end
if f then
local m = f:read("*l")
local count,msg = m:match("(%d+):(.*)")
js.count = count
js.msg = msg
f:close()
else
f = io.open("/tmp/doscan.msg")
if f then
local m = f:read("*l")
local count,msg = m:match("(%d+):(.*)")
if count and msg then
js.count = count
js.msg = msg
js.status = "done"
else
if m == "Scanning" then
js.status = "retry"
else
js.status = nil
end
end
f:close()
else
js.status = ""
end
end
local encode = newencoder()
data = encode(js)
elseif cmd == "delete" then
local rc = os.execute("mkdir /tmp/doscan.lock")
if rc ~= 0 then
data = '{"status":"busy"}'
else
data = '{"status":"deleted"}'
os.execute("rm /config/ChannelList.json");
os.execute("rm /tmp/doscan.msg");
os.execute("rm -rf /tmp/doscan.lock");
end
elseif cmd == "restore" then
local rc = os.execute("mkdir /tmp/doscan.lock")
if rc ~= 0 then
data = '{"status":"busy"}'
else
local rc = os.execute("mv /config/ChannelList.bak /config/ChannelList.json");
if rc == 0 then
data = '{"status":"restored", "count":1}'
else
data = '{"status":"restored", "count":0}'
end
os.execute("rm /tmp/doscan.msg");
os.execute("rm -rf /tmp/doscan.lock");
end
end
if data then