support: add basic IPTV migration to conf_migrate script
This commit is contained in:
parent
6f62adc287
commit
dae84cec66
1 changed files with 67 additions and 0 deletions
|
@ -197,6 +197,44 @@ def load_channels ( path, nets ):
|
||||||
# Done
|
# Done
|
||||||
return chns
|
return chns
|
||||||
|
|
||||||
|
#
|
||||||
|
# IPTV
|
||||||
|
#
|
||||||
|
|
||||||
|
def iptv_network ( nets, opts ):
|
||||||
|
muxes = {}
|
||||||
|
for f in glob.glob(os.path.join(path, 'iptvservices', '*')):
|
||||||
|
s = open(f).read()
|
||||||
|
d = json.loads(s)
|
||||||
|
url = '%s://%s:%d' % (opts.iptv, d['group'], d['port'])
|
||||||
|
if url not in muxes:
|
||||||
|
e = 'disabled' not in d or not d['disabled']
|
||||||
|
i = ''
|
||||||
|
if 'interface' in d: i = d['interface']
|
||||||
|
muxes[url] = m = { 'iptv_url' : url, 'enabled' : e, 'svcs' : {},
|
||||||
|
'iptv_interface': i }
|
||||||
|
else:
|
||||||
|
m = muxes[url]
|
||||||
|
|
||||||
|
# Create service entry
|
||||||
|
d['svcname'] = d['channelname']
|
||||||
|
d['dvb_servicetype'] = d['stype']
|
||||||
|
d['sid'] = 1 # Let's hope!
|
||||||
|
m['svcs'] = { '1' : d }
|
||||||
|
|
||||||
|
# Remove
|
||||||
|
for f in [ 'stream', 'group', 'stype', 'interface' ]:
|
||||||
|
if f in d:
|
||||||
|
del d[f]
|
||||||
|
|
||||||
|
|
||||||
|
nets.append({ 'type' : 'iptv',
|
||||||
|
'muxs' : muxes,\
|
||||||
|
'skipinitscan' : True,\
|
||||||
|
'autodiscovery' : False })
|
||||||
|
|
||||||
|
return nets
|
||||||
|
|
||||||
#
|
#
|
||||||
# Output
|
# Output
|
||||||
#
|
#
|
||||||
|
@ -342,6 +380,31 @@ def output_networks ( path, nets, opts ):
|
||||||
|
|
||||||
# Muxes
|
# Muxes
|
||||||
output_muxes(os.path.join(npath, 'muxes'), n['muxs'], opts)
|
output_muxes(os.path.join(npath, 'muxes'), n['muxs'], opts)
|
||||||
|
|
||||||
|
# Output IPTV
|
||||||
|
def output_iptv ( path, nets, opts ):
|
||||||
|
d = None
|
||||||
|
|
||||||
|
# Find
|
||||||
|
for n in nets:
|
||||||
|
if n['type'] == 'iptv':
|
||||||
|
d = n
|
||||||
|
if not d: return
|
||||||
|
|
||||||
|
# Ensure dir exists
|
||||||
|
path = os.path.join(path, 'input', 'iptv')
|
||||||
|
if not os.path.exists(path):
|
||||||
|
os.makedirs(path)
|
||||||
|
|
||||||
|
# Write
|
||||||
|
u = uuid()
|
||||||
|
n = { 'uuid' : u,
|
||||||
|
'skipinitscan' : True,
|
||||||
|
'autodiscovery' : False }
|
||||||
|
open(os.path.join(path, 'config'), 'w').write(json.dumps(n, indent=2))
|
||||||
|
|
||||||
|
# Muxes
|
||||||
|
output_muxes(os.path.join(path, 'muxes'), d['muxs'], opts)
|
||||||
|
|
||||||
# Channels
|
# Channels
|
||||||
def output_channels ( path, chns, opts ):
|
def output_channels ( path, chns, opts ):
|
||||||
|
@ -451,6 +514,8 @@ def update_epg ( path, chns ):
|
||||||
optp = OptionParser()
|
optp = OptionParser()
|
||||||
optp.add_option('-o', '--overlap', type='float', default=0.5,
|
optp.add_option('-o', '--overlap', type='float', default=0.5,
|
||||||
help='Percentage overlap at which networks considered same')
|
help='Percentage overlap at which networks considered same')
|
||||||
|
optp.add_option('-i', '--iptv', type='string', default='udp',
|
||||||
|
help='IPTV input type, rtp/udp')
|
||||||
(opts,args) = optp.parse_args()
|
(opts,args) = optp.parse_args()
|
||||||
path = args[0]
|
path = args[0]
|
||||||
adps = load_adapters(path)
|
adps = load_adapters(path)
|
||||||
|
@ -458,6 +523,8 @@ muxs = load_muxes(path, adps)
|
||||||
svcs = load_services(path, muxs)
|
svcs = load_services(path, muxs)
|
||||||
nets = build_networks(adps, opts)
|
nets = build_networks(adps, opts)
|
||||||
output_networks(path, nets, opts)
|
output_networks(path, nets, opts)
|
||||||
|
nets = iptv_network(nets, opts)
|
||||||
|
output_iptv(path, nets, opts)
|
||||||
chns = load_channels(path, nets)
|
chns = load_channels(path, nets)
|
||||||
output_channels(path, chns, opts)
|
output_channels(path, chns, opts)
|
||||||
update_dvr(path, chns)
|
update_dvr(path, chns)
|
||||||
|
|
Loading…
Add table
Reference in a new issue