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
1 changed files with 35 additions and 13 deletions

View File

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