mirror of
https://github.com/DigitalDevices/octonet.git
synced 2023-10-10 13:36:52 +02:00
doscan parameters added
This commit is contained in:
parent
7b8627b7a8
commit
90e8bcc7f8
@ -5,7 +5,7 @@ local newdecoder = require("lunajson.decoder")
|
||||
local newencoder = require("lunajson.encoder")
|
||||
|
||||
|
||||
function GetIPAddr()
|
||||
local function GetIPAddr()
|
||||
local myip = nil
|
||||
local ifconfig = io.popen("ifconfig eth0")
|
||||
if ifconfig then
|
||||
@ -16,25 +16,28 @@ function GetIPAddr()
|
||||
return myip
|
||||
end
|
||||
|
||||
function LoadTransponderList()
|
||||
local function LoadTransponderList(infile)
|
||||
local tl = nil
|
||||
local f = io.open("/config/TransponderList.json","r")
|
||||
if not f then
|
||||
f = io.open("/var/channels/TransponderList.json","r")
|
||||
local f = nil
|
||||
if infile then
|
||||
f = io.open(infile,"r")
|
||||
else
|
||||
f = io.open("/config/TransponderList.json","r")
|
||||
if not f then
|
||||
f = io.open("/var/channels/TransponderList.json","r")
|
||||
end
|
||||
end
|
||||
|
||||
if f then
|
||||
local t = f:read("*a")
|
||||
f:close()
|
||||
print(#t)
|
||||
|
||||
local decode = newdecoder()
|
||||
tl = decode(t)
|
||||
end
|
||||
return tl
|
||||
end
|
||||
|
||||
function GetGroup(ChannelList,Title)
|
||||
local function GetGroup(ChannelList,Title)
|
||||
local Group
|
||||
for _,c in ipairs(ChannelList.GroupList) do
|
||||
if c.Title == Title then
|
||||
@ -42,16 +45,57 @@ function GetGroup(ChannelList,Title)
|
||||
end
|
||||
end
|
||||
if not Group then
|
||||
Group = { Title=Title, ChannelList = { [0] = 0 } }
|
||||
Group = { Title=Title, ChannelList = { } }
|
||||
table.insert(ChannelList.GroupList,Group)
|
||||
end
|
||||
return Group
|
||||
end
|
||||
|
||||
local key = arg[1]
|
||||
local function cmp_title(a,b)
|
||||
return a.Title < b.Title
|
||||
end
|
||||
|
||||
local ipAddr = GetIPAddr()
|
||||
local tl = LoadTransponderList()
|
||||
local keys = {}
|
||||
local include_radio = 1
|
||||
local include_encrypted = 0
|
||||
local infile = nil
|
||||
local outfile = "/config/ChannelList.json"
|
||||
local ipAddr = nil
|
||||
local sort = nil
|
||||
local include_sitables = nil
|
||||
|
||||
local a
|
||||
|
||||
for _,a in ipairs(arg) do
|
||||
local par,val = a:match("(%a+)=(.+)")
|
||||
if par == "key" then
|
||||
local key,src = val:match("(%a+),(d+)")
|
||||
if key then
|
||||
keys[key] = tonumber(src)
|
||||
else
|
||||
keys[val] = 1
|
||||
end
|
||||
elseif par == "radio" then
|
||||
include_radio = tonumber(val)
|
||||
elseif par == "enc" then
|
||||
include_encrypted = tonumber(val)
|
||||
elseif par == "sort" then
|
||||
sort = val
|
||||
elseif par == "sitables" then
|
||||
include_sitables = val
|
||||
elseif par == "in" then
|
||||
infile = val
|
||||
elseif par == "out" then
|
||||
outfile = val
|
||||
elseif par == "ip" then
|
||||
ipAddr = val
|
||||
end
|
||||
end
|
||||
|
||||
if not ipAddr then
|
||||
ipAddr = GetIPAddr()
|
||||
end
|
||||
local tl = LoadTransponderList(infile)
|
||||
|
||||
local ChannelList = {}
|
||||
ChannelList.GroupList = {}
|
||||
@ -59,20 +103,16 @@ ChannelList.GroupList = {}
|
||||
local Max = 999999
|
||||
local Count = 0
|
||||
|
||||
if arg[2] then
|
||||
Max = tonumber(arg[2])
|
||||
end
|
||||
|
||||
if tl.SourceList then
|
||||
for _,Source in ipairs(tl.SourceList) do
|
||||
print(Source.Title)
|
||||
if key == Source.Key then
|
||||
if keys[Source.Key] then
|
||||
print("Scanning: "..Source.Title)
|
||||
local SourceOptions = ""
|
||||
if Source.UseNIT then
|
||||
SourceOptions = SourceOptions.."--use_nit "
|
||||
end
|
||||
if Source.DVBType == "S" then
|
||||
SourceOptions = '--src=1'
|
||||
SourceOptions = '--src='..keys[Source.Key]
|
||||
end
|
||||
|
||||
for _,Transponder in ipairs(Source.TransponderList) do
|
||||
@ -111,8 +151,9 @@ if tl.SourceList then
|
||||
local sname = "?"
|
||||
local sid = 0
|
||||
local pids = ""
|
||||
local tracks= { [0] = 0 }
|
||||
local tracks= { }
|
||||
local isradio = false
|
||||
local isencrypted = false
|
||||
if line == "BEGIN" then
|
||||
while true do
|
||||
line = octoscan:read("*l")
|
||||
@ -121,15 +162,26 @@ if tl.SourceList then
|
||||
end
|
||||
print(line)
|
||||
if line == "END" then
|
||||
local channel = { Title=sname, Service=sid, Request = '?'..Request.."&pids=0,"..pids, Tracks=tracks }
|
||||
local cname = pname
|
||||
if isradio then
|
||||
cname = "Radio - "..pname
|
||||
local all_pids = ",0"
|
||||
if include_sitables then
|
||||
if isencrypted then
|
||||
all_pids = all_pids..",1"
|
||||
end
|
||||
all_pids = all_pids..",16,17,18,20"
|
||||
end
|
||||
local category = GetGroup(ChannelList,cname)
|
||||
if category then
|
||||
category.ChannelList[0] = category.ChannelList[0] + 1
|
||||
table.insert(category.ChannelList,channel)
|
||||
if #pids > 0 then
|
||||
all_pids = all_pids .. ",pids"
|
||||
end
|
||||
local channel = { Title=sname, Service=sid, Request = '?'..Request.."&pids="..pids, Tracks=tracks }
|
||||
local gname = pname
|
||||
if isradio then
|
||||
gname = "Radio - "..gname
|
||||
end
|
||||
if not isradio or (include_radio > 0) then
|
||||
local group = GetGroup(ChannelList,gname)
|
||||
if group then
|
||||
table.insert(group.ChannelList,channel)
|
||||
end
|
||||
end
|
||||
break
|
||||
end
|
||||
@ -147,9 +199,9 @@ if tl.SourceList then
|
||||
elseif par == "APIDS" then
|
||||
local track
|
||||
for track in val:gmatch("%d+") do
|
||||
tracks[0] = tracks[0] + 1
|
||||
table.insert(tracks,tonumber(track))
|
||||
end
|
||||
tracks[0] = #tracks
|
||||
end
|
||||
end
|
||||
elseif line:sub(1,5) == "TUNE:" then
|
||||
@ -161,15 +213,28 @@ if tl.SourceList then
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local encode = newencoder()
|
||||
cl = encode(ChannelList)
|
||||
|
||||
if cl then
|
||||
local f = io.open("/config/ChannelList.json","w+")
|
||||
if f then
|
||||
f:write(cl)
|
||||
f:close()
|
||||
for _,group in ipairs(ChannelList.GroupList) do
|
||||
if sort then
|
||||
table.sort(group.ChannelList,cmp_title)
|
||||
end
|
||||
group.ChannelList[0] = #group.ChannelList
|
||||
end
|
||||
if sort then
|
||||
table.sort(ChannelList.GroupList,cmp_title)
|
||||
end
|
||||
ChannelList.GroupList[0] = #ChannelList.GroupList
|
||||
|
||||
local encode = newencoder()
|
||||
cl = encode(ChannelList)
|
||||
|
||||
if cl then
|
||||
local f = io.open(outfile,"w+")
|
||||
if f then
|
||||
f:write(cl)
|
||||
f:close()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user