Skip to content

Instantly share code, notes, and snippets.

@ckarrie
Created November 7, 2016 19:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ckarrie/ca74d8fd27c0998446d66cd764322cd8 to your computer and use it in GitHub Desktop.
from htsp import HTSPClient
"""
"""
htsp = HTSPClient(('HOSTNAME', 9982))
msg = htsp.hello()
htsp.authenticate('USER', 'PASS')
cap = []
if 'servercapability' in msg:
cap = msg['servercapability']
def search_channelnames(lookup):
htsp.send('api', {'path': 'channel/list'})
msg = htsp.recv()
found = []
for re in msg['response']['entries']:
if lookup in re['val']:
found.append(re)
return found
def get_serviceuuids_from_channeluuid(uuid):
htsp.send('api', {'path': 'idnode/load', 'args': {'uuid': uuid, 'meta': 1}})
msg = htsp.recv()
found_services = []
for re in msg['response']['entries']:
params = re['params']
for paramdict in params:
if 'services' in paramdict.values():
found_services.extend(paramdict['value'])
return found_services
def create_channel(name, services=[], tags=[], epg_parent="", enabled=True, number=0):
htsp.send('api', {
'path': 'channel/create',
'args': {
'conf': {
'name': name,
'enabled': 'true',
'number': number,
'services': services,
'tags': tags,
#'bouquet': '',
}
}
})
msg = htsp.recv()
print msg
found_zdf = search_channelnames("ZDF")
for c in found_zdf:
print "- ", c
merge_channels_to_one = [
'70059a8382a01c0acbc20d2a1cd8cf9c',
'b739e0124869926b6216505511b51481',
'960ad9996121eb2730b7bf3a8dd89d78',
'6405e43979ae2ea0e0854ace03141263',
'39246d48e8af74a5a7dd1e02f3d421a8',
'775b10d89d790d64ec0c6f465cdd5d22',
'ca598fd82ceea14b49050d5786701113',
'8db1e065d221f499b2b4071bf89b1fb0',
'e1c5e27795ce47969dabce68c8187028',
]
found_services = []
for chan in merge_channels_to_one:
services = get_serviceuuids_from_channeluuid(chan)
found_services.extend(services)
found_services = list(set(found_services))
#zdf_services = get_serviceuuids_from_channeluuid('775b10d89d790d64ec0c6f465cdd5d22')
#print "zdf_services", zdf_services
print "found_services", found_services
create_channel("Merged ZDF", services=found_services, number=100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment