def getSatellites(stype): ret = [] s_type = service_types_tv if stype == "radio": s_type = service_types_radio refstr = '%s FROM SATELLITES ORDER BY satellitePosition' % (s_type) ref = eServiceReference(refstr) serviceHandler = eServiceCenter.getInstance() servicelist = serviceHandler.list(ref) if servicelist is not None: while True: service = servicelist.getNext() if not service.valid(): break unsigned_orbpos = service.getUnsignedData(4) >> 16 orbpos = service.getData(4) >> 16 if orbpos < 0: orbpos += 3600 if service.getPath().find("FROM PROVIDER") != -1: # service_type = _("Providers") continue elif service.getPath().find("flags == %d" % (FLAG_SERVICE_NEW_FOUND)) != -1: service_type = _("New") else: service_type = _("Services") try: service_name = str(nimmanager.getSatDescription(orbpos)) except: # noqa: E722 if unsigned_orbpos == 0xFFFF: # Cable service_name = _("Cable") elif unsigned_orbpos == 0xEEEE: # Terrestrial service_name = _("Terrestrial") else: service_name = getOrb(orbpos) service.setName("%s - %s" % (service_name, service_type)) ret.append({ "service": service.toString(), "name": service.getName() }) ret = sortSatellites(ret) return {"satellites": ret}
def getSearchEpg(sstr, endtime=None, fulldesc=False, bouquetsonly=False, encode=False): ret = [] ev = {} if config.OpenWebif.epg_encoding.value != 'utf-8': try: sstr = sstr.encode(config.OpenWebif.epg_encoding.value) except UnicodeEncodeError: pass epgcache = eEPGCache.getInstance() search_type = eEPGCache.PARTIAL_TITLE_SEARCH if fulldesc: if hasattr(eEPGCache, 'FULL_DESCRIPTION_SEARCH'): search_type = eEPGCache.FULL_DESCRIPTION_SEARCH events = epgcache.search(('IBDTSENRW', 128, search_type, sstr, 1)) if events is not None: # TODO : discuss #677 # events.sort(key = lambda x: (x[1],x[6])) # sort by date,sname # events.sort(key = lambda x: x[1]) # sort by date if bouquetsonly: # collect service references from TV bouquets bsref = {} for service in getAllServices('tv')['services']: for service2 in service['subservices']: bsref[service2['servicereference']] = True else: bsref[service['servicereference']] = True for event in events: if bouquetsonly and not event[7] in bsref: continue ev = {} ev['id'] = event[0] ev['date'] = "%s %s" % (tstrings[ ("day_" + strftime("%w", (localtime(event[1]))))], strftime("%d.%m.%Y", (localtime(event[1])))) ev['begin_timestamp'] = event[1] ev['begin'] = strftime("%H:%M", (localtime(event[1]))) ev['duration_sec'] = event[2] ev['duration'] = int(event[2] / 60) ev['end'] = strftime("%H:%M", (localtime(event[1] + event[2]))) ev['title'] = filterName(event[3], encode) ev['shortdesc'] = convertDesc(event[4], encode) ev['longdesc'] = convertDesc(event[5], encode) ev['sref'] = event[7] ev['sname'] = filterName(event[6], encode) ev['picon'] = getPicon(event[7]) ev['now_timestamp'] = None ev['genre'], ev['genreid'] = convertGenre(event[8]) if endtime: # don't show events if begin after endtime if event[1] <= endtime: ret.append(ev) else: ret.append(ev) psref = parse_servicereference(event[7]) ev['service_type'] = SERVICE_TYPE_LOOKUP.get( psref.get('service_type'), "UNKNOWN") nsi = psref.get('ns') ns = NS_LOOKUP.get(nsi, "DVB-S") if ns == "DVB-S": ev['ns'] = getOrb(nsi >> 16 & 0xFFF) else: ev['ns'] = ns return {"events": ret, "result": True}
def getChannels(idbouquet, stype): ret = [] idp = 0 s_type = service_types_tv if stype == "radio": s_type = service_types_radio if idbouquet == "ALL": idbouquet = '%s ORDER BY name' % (s_type) epgcache = eEPGCache.getInstance() serviceHandler = eServiceCenter.getInstance() services = serviceHandler.list(eServiceReference(idbouquet)) channels = services and services.getContent("SN", True) for channel in channels: chan = {} chan['ref'] = quote(channel[0], safe=' ~@%#$&()*!+=:;,.?/\'') if chan['ref'].split(":")[1] == '320': # Hide hidden number markers continue chan['name'] = filterName(channel[1]) if chan['ref'].split(":")[ 0] == '5002': # BAD fix !!! this needs to fix in enigma2 !!! chan['name'] = chan['ref'].split(":")[-1] if not int(channel[0].split(":")[1]) & 64: psref = parse_servicereference(channel[0]) chan['service_type'] = SERVICE_TYPE_LOOKUP.get( psref.get('service_type'), "UNKNOWN") nsi = psref.get('ns') ns = NS_LOOKUP.get(nsi, "DVB-S") if ns == "DVB-S": chan['ns'] = getOrb(nsi >> 16 & 0xFFF) else: chan['ns'] = ns chan['picon'] = getPicon(chan['ref']) if config.OpenWebif.parentalenabled.value and config.ParentalControl.configured.value and config.ParentalControl.servicepinactive.value: chan['protection'] = getProtection(channel[0]) else: chan['protection'] = "0" nowevent = epgcache.lookupEvent(['TBDCIX', (channel[0], 0, -1)]) if len(nowevent) > 0 and nowevent[0][0] is not None: chan['now_title'] = filterName(nowevent[0][0]) chan['now_begin'] = strftime("%H:%M", (localtime(nowevent[0][1]))) chan['now_end'] = strftime( "%H:%M", (localtime(nowevent[0][1] + nowevent[0][2]))) chan['now_left'] = int( ((nowevent[0][1] + nowevent[0][2]) - nowevent[0][3]) / 60) chan['progress'] = int( ((nowevent[0][3] - nowevent[0][1]) * 100 / nowevent[0][2])) chan['now_ev_id'] = nowevent[0][4] chan['now_idp'] = "nowd" + str(idp) nextevent = epgcache.lookupEvent( ['TBDIX', (channel[0], +1, -1)]) # Some fields have been seen to be missing from the next event... if len(nextevent) > 0 and nextevent[0][0] is not None: if nextevent[0][1] is None: nextevent[0][1] = time() if nextevent[0][2] is None: nextevent[0][2] = 0 chan['next_title'] = filterName(nextevent[0][0]) chan['next_begin'] = strftime("%H:%M", (localtime(nextevent[0][1]))) chan['next_end'] = strftime( "%H:%M", (localtime(nextevent[0][1] + nextevent[0][2]))) chan['next_duration'] = int(nextevent[0][2] / 60) chan['next_ev_id'] = nextevent[0][3] chan['next_idp'] = "nextd" + str(idp) else: # Have to fudge one in, as rest of OWI code expects it... chan['next_title'] = filterName("<<absent>>") chan['next_begin'] = chan['now_end'] chan['next_end'] = chan['now_end'] chan['next_duration'] = 0 chan['next_ev_id'] = chan['now_ev_id'] chan['next_idp'] = chan['now_idp'] idp += 1 if int(channel[0].split(":")[1]) != 832: ret.append(chan) return {"channels": ret}