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

channelscan: doscan (WIP)

NIT scan added, adapted to revised octoscan cli interface

Manual usage:
	/var/channels/doscan.lua <key>
This commit is contained in:
mvoelkel 2016-01-09 19:57:54 +01:00
parent edffd6e172
commit 175f58aaa5

View File

@ -1,6 +1,6 @@
#!/usr/bin/lua #!/usr/bin/lua
-- --
local newdecoder = require("lunajson.decoder") local newdecoder = require("lunajson.decoder")
local newencoder = require("lunajson.encoder") local newencoder = require("lunajson.encoder")
@ -10,7 +10,7 @@ function GetIPAddr()
local ifconfig = io.popen("ifconfig eth0") local ifconfig = io.popen("ifconfig eth0")
if ifconfig then if ifconfig then
local eth0 = ifconfig:read("*a") local eth0 = ifconfig:read("*a")
ifconfig:close() ifconfig:close()
myip = string.match(eth0,"inet addr%:(%d+%.%d+%.%d+%.%d+)") myip = string.match(eth0,"inet addr%:(%d+%.%d+%.%d+%.%d+)")
end end
return myip return myip
@ -22,7 +22,7 @@ function LoadTransponderList()
if not f then if not f then
f = io.open("/var/channels/TransponderList.json","r") f = io.open("/var/channels/TransponderList.json","r")
end end
if f then if f then
local t = f:read("*a") local t = f:read("*a")
f:close() f:close()
@ -42,7 +42,7 @@ function GetGroup(ChannelList,Title)
end end
end end
if not Group then if not Group then
Group = { Title=Title, ChannelList = { [0] = 0 } } Group = { Title=Title, ChannelList = { [0] = 0 } }
table.insert(ChannelList.GroupList,Group) table.insert(ChannelList.GroupList,Group)
end end
return Group return Group
@ -63,23 +63,43 @@ if arg[2] then
Max = tonumber(arg[2]) Max = tonumber(arg[2])
end end
if tl.SourceList then if tl.SourceList then
for _,Source in ipairs(tl.SourceList) do for _,Source in ipairs(tl.SourceList) do
print(Source.Title) print(Source.Title)
if key == Source.Key then if key == Source.Key then
local req = "" local SourceOptions = ""
if Source.DVBType == "S" then if Source.UseNIT then
req = 'src=1&' SourceOptions = SourceOptions.."--use_nit "
end end
if Source.DVBType == "S" then
SourceOptions = '--src=1'
end
for _,Transponder in ipairs(Source.TransponderList) do for _,Transponder in ipairs(Source.TransponderList) do
Count = Count + 1 Count = Count + 1
if Count > Max then if Count > Max then
break break
end end
local Params = ""
local p,v
for p,v in Transponder.Request:gmatch("(%a+)=([%w%.]+)") do
if p == "freq" then
Params = Params .. " --freq="..v
elseif p == "pol" then
Params = Params .. " --pol="..v
elseif p == "msys" then
Params = Params .. " --msys="..v
elseif p == "sr" then
Params = Params .. " --sr="..v
elseif p == "mtype" then
Params = Params .. " --mtype="..v
end
end
print("--------------------------------------------------------------") print("--------------------------------------------------------------")
print(Transponder.Request) print('octoscan '..SourceOptions..Params..' '..ipAddr)
local octoscan = io.popen('octoscan '..ipAddr..' "'..req..Transponder.Request..'"',"r") local octoscan = io.popen('octoscan '..SourceOptions..' '..Params..' '..ipAddr,"r")
if octoscan then if octoscan then
while true do while true do
local line = octoscan:read("*l") local line = octoscan:read("*l")
@ -101,13 +121,13 @@ 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 = req..Transponder.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
end end
local category = GetGroup(ChannelList,cname) local category = GetGroup(ChannelList,cname)
if category then if category then
category.ChannelList[0] = category.ChannelList[0] + 1 category.ChannelList[0] = category.ChannelList[0] + 1
table.insert(category.ChannelList,channel) table.insert(category.ChannelList,channel)
end end
@ -132,6 +152,8 @@ if tl.SourceList then
end end
end end
end end
elseif line:sub(1,5) == "TUNE:" then
Request = line:sub(6)
end end
end end
octoscan:close() octoscan:close()