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:
parent
562b4fd379
commit
cc6cb4709c
File diff suppressed because one or more lines are too long
@ -164,6 +164,8 @@ if tl.SourceList then
|
|||||||
print(line)
|
print(line)
|
||||||
local pname = "?"
|
local pname = "?"
|
||||||
local sname = "?"
|
local sname = "?"
|
||||||
|
local onid = 0
|
||||||
|
local tsid = 0
|
||||||
local sid = 0
|
local sid = 0
|
||||||
local pids = ""
|
local pids = ""
|
||||||
local tracks= { }
|
local tracks= { }
|
||||||
@ -187,12 +189,18 @@ if tl.SourceList then
|
|||||||
if #pids > 0 then
|
if #pids > 0 then
|
||||||
all_pids = all_pids..","..pids
|
all_pids = all_pids..","..pids
|
||||||
end
|
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
|
local gname = pname
|
||||||
if isradio then
|
if isradio then
|
||||||
gname = "Radio - "..gname
|
gname = "Radio - "..gname
|
||||||
end
|
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
|
||||||
table.insert(group.ChannelList,channel)
|
table.insert(group.ChannelList,channel)
|
||||||
@ -209,8 +217,12 @@ if tl.SourceList then
|
|||||||
pname = val
|
pname = val
|
||||||
elseif par == "SNAME" then
|
elseif par == "SNAME" then
|
||||||
sname = val
|
sname = val
|
||||||
|
elseif par == "ONID" then
|
||||||
|
onid = tonumber(val)
|
||||||
|
elseif par == "TSID" then
|
||||||
|
tsid = tonumber(val)
|
||||||
elseif par == "SID" then
|
elseif par == "SID" then
|
||||||
sid = tonumber(value)
|
sid = tonumber(val)
|
||||||
elseif par == "PIDS" then
|
elseif par == "PIDS" then
|
||||||
pids = val
|
pids = val
|
||||||
elseif par == "APIDS" then
|
elseif par == "APIDS" then
|
||||||
@ -219,6 +231,8 @@ if tl.SourceList then
|
|||||||
table.insert(tracks,tonumber(track))
|
table.insert(tracks,tonumber(track))
|
||||||
end
|
end
|
||||||
tracks[0] = #tracks
|
tracks[0] = #tracks
|
||||||
|
elseif par == "ENC" then
|
||||||
|
isencrypted = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif line:sub(1,5) == "TUNE:" then
|
elseif line:sub(1,5) == "TUNE:" then
|
||||||
@ -245,6 +259,9 @@ if tl.SourceList then
|
|||||||
local encode = newencoder()
|
local encode = newencoder()
|
||||||
cl = encode(ChannelList)
|
cl = encode(ChannelList)
|
||||||
|
|
||||||
|
if outfile == "/config/ChannelList.json" then
|
||||||
|
os.execute("mv /config/ChannelList.json /config/ChannelList.bak")
|
||||||
|
end
|
||||||
if cl then
|
if cl then
|
||||||
local f = io.open(outfile,"w+")
|
local f = io.open(outfile,"w+")
|
||||||
if f then
|
if f then
|
||||||
@ -255,6 +272,7 @@ if tl.SourceList then
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Report(ChannelCount,"Done")
|
||||||
os.execute("mv /tmp/doscan.lock/doscan.msg /tmp/doscan.msg")
|
os.execute("mv /tmp/doscan.lock/doscan.msg /tmp/doscan.msg")
|
||||||
|
|
||||||
if restart_dms then
|
if restart_dms then
|
||||||
|
@ -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();
|
var ScanReq = new XMLHttpRequest();
|
||||||
|
|
||||||
ScanReq.onreadystatechange=function()
|
ScanReq.onreadystatechange=function()
|
||||||
@ -110,6 +119,12 @@ ScanReq.onreadystatechange=function()
|
|||||||
{
|
{
|
||||||
if( ScanReq.status == 200 )
|
if( ScanReq.status == 200 )
|
||||||
ScanStatus(ScanReq.responseText);
|
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)
|
function ScanStatus(response)
|
||||||
{
|
{
|
||||||
var s = JSON.parse(response);
|
var s = JSON.parse(response);
|
||||||
if( s.status == "active" )
|
var done = false;
|
||||||
|
if( s.status )
|
||||||
{
|
{
|
||||||
document.getElementById("scancount").firstChild.nodeValue = s.count;
|
if( s.status == "active" )
|
||||||
document.getElementById("scantext").firstChild.nodeValue = s.msg;
|
{
|
||||||
window.setTimeout(GetStatus,500);
|
document.getElementById("scancount").firstChild.nodeValue = s.count;
|
||||||
|
document.getElementById("scantext").firstChild.nodeValue = s.msg;
|
||||||
|
}
|
||||||
|
else if( s.status == "busy" )
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( s.status == "busy" )
|
|
||||||
|
if( done )
|
||||||
{
|
{
|
||||||
document.getElementById("scancount").firstChild.nodeValue = "";
|
DisableButtons(false);
|
||||||
document.getElementById("scantext").firstChild.nodeValue = "BUSY";
|
|
||||||
}
|
|
||||||
else if( s.status == "done" )
|
|
||||||
{
|
|
||||||
document.getElementById("scancount").firstChild.nodeValue = s.count;
|
|
||||||
document.getElementById("scantext").firstChild.nodeValue = "Channels found";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
window.setTimeout(GetStatus,500);
|
window.setTimeout(GetStatus,500);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function InitiateScan()
|
function InitiateScan()
|
||||||
{
|
{
|
||||||
|
DisableButtons(true);
|
||||||
|
|
||||||
var param = "";
|
var param = "";
|
||||||
for(var i = 1; i < document.Cable.Select.options.length; i += 1)
|
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>
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
@ -257,7 +317,8 @@ function InitiateScan()
|
|||||||
<td> </td>
|
<td> </td>
|
||||||
<td style="text-align:right">
|
<td style="text-align:right">
|
||||||
<form action="">
|
<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>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -269,6 +330,15 @@ function InitiateScan()
|
|||||||
<div id="scantext" style="text-align:left"> </div>
|
<div id="scantext" style="text-align:left"> </div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> </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>
|
</table>
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
@ -56,22 +56,22 @@ local function LoadTransponderList()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if method == "GET" then
|
if method == "GET" then
|
||||||
local filename = nil
|
local filename = nil
|
||||||
local contenttype = "application/json; charset=utf-8"
|
local contenttype = "application/json; charset=utf-8"
|
||||||
local data = nil
|
local data = nil
|
||||||
|
|
||||||
local q,v
|
local q,v
|
||||||
local params = ""
|
local params = ""
|
||||||
local cmd = ""
|
local cmd = ""
|
||||||
for q,v in query:gmatch("(%a+)=([%w%.]+)") do
|
for q,v in query:gmatch("(%a+)=([%w%.]+)") do
|
||||||
if q == "select" then
|
if q == "select" then
|
||||||
cmd = v
|
cmd = v
|
||||||
else
|
else
|
||||||
params = params.." "..q.."="..v
|
params = params.." "..q.."="..v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if cmd == "keys" then
|
if cmd == "keys" then
|
||||||
local tl = LoadTransponderList()
|
local tl = LoadTransponderList()
|
||||||
if tl then
|
if tl then
|
||||||
local kl = { KeyList = { } }
|
local kl = { KeyList = { } }
|
||||||
@ -83,12 +83,17 @@ if method == "GET" then
|
|||||||
local encode = newencoder()
|
local encode = newencoder()
|
||||||
data = encode(kl)
|
data = encode(kl)
|
||||||
end
|
end
|
||||||
elseif cmd == "scan" then
|
elseif cmd == "scan" then
|
||||||
local rc = os.execute("mkdir /tmp/doscan.lock")
|
local rc = os.execute("mkdir /tmp/doscan.lock")
|
||||||
if rc ~= 0 then
|
if rc ~= 0 then
|
||||||
data = '{"status":"busy"}'
|
data = '{"status":"busy"}'
|
||||||
else
|
else
|
||||||
data = '{"status":"retry"}'
|
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 &")
|
os.execute("/var/channels/doscan.lua "..params.." >/tmp/doscan.log 2>&1 &")
|
||||||
end
|
end
|
||||||
elseif cmd == "status" then
|
elseif cmd == "status" then
|
||||||
@ -96,40 +101,75 @@ if method == "GET" then
|
|||||||
local f = io.open("/tmp/doscan.lock/doscan.msg")
|
local f = io.open("/tmp/doscan.lock/doscan.msg")
|
||||||
if f then
|
if f then
|
||||||
js.status = "active"
|
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 m = f:read("*l")
|
||||||
local count,msg = m:match("(%d+):(.*)")
|
local count,msg = m:match("(%d+):(.*)")
|
||||||
js.count = count
|
js.count = count
|
||||||
js.msg = msg
|
js.msg = msg
|
||||||
f:close()
|
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
|
end
|
||||||
local encode = newencoder()
|
local encode = newencoder()
|
||||||
data = encode(js)
|
data = encode(js)
|
||||||
end
|
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
|
if data then
|
||||||
http_print(proto.." 200" )
|
http_print(proto.." 200" )
|
||||||
http_print("Pragma: no-cache")
|
http_print("Pragma: no-cache")
|
||||||
http_print("Cache-Control: no-cache")
|
http_print("Cache-Control: no-cache")
|
||||||
http_print("Content-Type: "..contenttype)
|
http_print("Content-Type: "..contenttype)
|
||||||
if filename then
|
if filename then
|
||||||
http_print('Content-Disposition: filename="'..filename..'"')
|
http_print('Content-Disposition: filename="'..filename..'"')
|
||||||
end
|
end
|
||||||
http_print(string.format("Content-Length: %d",#data))
|
http_print(string.format("Content-Length: %d",#data))
|
||||||
http_print()
|
http_print()
|
||||||
http_print(data)
|
http_print(data)
|
||||||
else
|
else
|
||||||
SendError("404","not found")
|
SendError("404","not found")
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
SendError("500","What")
|
SendError("500","What")
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user