def save(self): print>>log, "[Manager] Saving..." old_bouquets = BouquetsReader().getBouquetsList(self.path) if "tv" not in old_bouquets: old_bouquets["tv"] = [] if "radio" not in old_bouquets: old_bouquets["radio"] = [] currentBouquets = {} currentBouquets["tv"] = [] currentBouquets["radio"] = [] for bouquet in old_bouquets["tv"]: currentBouquets["tv"].append(bouquet["filename"]) for bouquet in old_bouquets["radio"]: currentBouquets["radio"].append(bouquet["filename"]) if "tv" not in self.bouquetsToKeep: self.bouquetsToKeep["tv"] = [] if "radio" not in self.bouquetsToKeep: self.bouquetsToKeep["radio"] = [] print>>log, "[Manager] Bouquets to hide:", self.bouquetsToHide print>>log, "[Manager] TV bouquets to keep:", self.bouquetsToKeep["tv"] print>>log, "[Manager] Radio bouquets to keep:", self.bouquetsToKeep["radio"] #print>>log, "[Manager] Generate main bouquet:", str(self.makemain) #print>>log, "[Manager] Generate sections bouquets:", str(self.makesections) #print>>log, "[Manager] Generate HD bouquet:", str(self.makehd) #print>>log, "[Manager] Generate FTA bouquet:", str(self.makefta) print>>log, "[Manager] Add provider prefix to bouqets:", str(self.addprefix) writer = BouquetsWriter() writer.writeLamedb(self.path, self.transponders) providers = Providers().read() for provider_key in self.bouquetsOrder: if provider_key in providers: bouquetsToHide = [] if provider_key in self.bouquetsToHide: # expand section keys in channels numbers sections = sorted(providers[provider_key]["sections"].keys()) for bouquetToHide in self.bouquetsToHide[provider_key]: index = sections.index(bouquetToHide) if index == -1: continue if index < len(sections) - 1: bouquetsToHide += range(bouquetToHide, sections[index + 1]) else: bouquetsToHide += range(bouquetToHide, 65535) prefix = "" if self.addprefix: prefix = providers[provider_key]["name"] current_bouquet_key = self.providerConfigs[provider_key].getArea() if current_bouquet_key in providers[provider_key]["bouquets"] and providers[provider_key]["protocol"] in ("sky", "freesat"): current_bouquet = providers[provider_key]["bouquets"][current_bouquet_key]["bouquet"] current_region = providers[provider_key]["bouquets"][current_bouquet_key]["region"] else: current_bouquet = -1 current_region = -1 preferred_order = [] if self.providerConfigs[provider_key].isMakeNormalMain() and self.providerConfigs[provider_key].isSwapChannels(): for swapchannels_set in providers[provider_key]["swapchannels"]: if len(preferred_order) == 0 and len(swapchannels_set["filters"]) == 0: preferred_order = swapchannels_set["preferred_order"] continue if len(swapchannels_set["filters"]) > 0: for cfilter in swapchannels_set["filters"]: if cfilter[0] == current_bouquet and cfilter[1] == current_region: preferred_order = swapchannels_set["preferred_order"] break writer.buildBouquets(self.path, self.providerConfigs[provider_key], self.services[provider_key], providers[provider_key]["sections"], provider_key, preferred_order, providers[provider_key]["channelsontop"], bouquetsToHide, prefix) writer.buildBouquetsIndex(self.path, self.bouquetsOrder, providers, self.bouquetsToKeep, currentBouquets, self.bouquetsToHide, self.providerConfigs) print>>log, "[Manager] Done"
def save(self): print >> log, "[Manager] Saving..." old_bouquets = BouquetsReader().getBouquetsList(self.path) if "tv" not in old_bouquets: old_bouquets["tv"] = [] if "radio" not in old_bouquets: old_bouquets["radio"] = [] currentBouquets = {} currentBouquets["tv"] = [] currentBouquets["radio"] = [] for bouquet in old_bouquets["tv"]: currentBouquets["tv"].append(bouquet["filename"]) for bouquet in old_bouquets["radio"]: currentBouquets["radio"].append(bouquet["filename"]) if "tv" not in self.bouquetsToKeep: self.bouquetsToKeep["tv"] = [] if "radio" not in self.bouquetsToKeep: self.bouquetsToKeep["radio"] = [] print >> log, "[Manager] Bouquets to hide:", self.bouquetsToHide print >> log, "[Manager] TV bouquets to keep:", self.bouquetsToKeep[ "tv"] print >> log, "[Manager] Radio bouquets to keep:", self.bouquetsToKeep[ "radio"] #print>>log, "[Manager] Generate main bouquet:", str(self.makemain) #print>>log, "[Manager] Generate sections bouquets:", str(self.makesections) #print>>log, "[Manager] Generate HD bouquet:", str(self.makehd) #print>>log, "[Manager] Generate FTA bouquet:", str(self.makefta) print >> log, "[Manager] Add provider prefix to bouqets:", str( self.addprefix) writer = BouquetsWriter() writer.writeLamedb(self.path, self.transponders) providers = Providers().read() for provider_key in self.bouquetsOrder: if provider_key in providers: bouquetsToHide = [] if provider_key in self.bouquetsToHide: # expand section keys in channels numbers sections = sorted( providers[provider_key]["sections"].keys()) for bouquetToHide in self.bouquetsToHide[provider_key]: index = sections.index(bouquetToHide) if index == -1: continue if index < len(sections) - 1: bouquetsToHide += range(bouquetToHide, sections[index + 1]) else: bouquetsToHide += range(bouquetToHide, 65535) prefix = "" if self.addprefix: prefix = providers[provider_key]["name"] current_bouquet_key = self.providerConfigs[ provider_key].getArea() if current_bouquet_key in providers[provider_key]["bouquets"]: current_bouquet = providers[provider_key]["bouquets"][ current_bouquet_key]["bouquet"] current_region = providers[provider_key]["bouquets"][ current_bouquet_key]["region"] else: current_bouquet = -1 current_region = -1 preferred_order = [] if self.providerConfigs[provider_key].isMakeNormalMain( ) and self.providerConfigs[provider_key].isSwapChannels(): for swapchannels_set in providers[provider_key][ "swapchannels"]: if len(preferred_order) == 0 and len( swapchannels_set["filters"]) == 0: preferred_order = swapchannels_set[ "preferred_order"] continue if len(swapchannels_set["filters"]) > 0: for cfilter in swapchannels_set["filters"]: if cfilter[0] == current_bouquet and cfilter[ 1] == current_region: preferred_order = swapchannels_set[ "preferred_order"] break writer.buildBouquets(self.path, self.providerConfigs[provider_key], self.services[provider_key], providers[provider_key]["sections"], provider_key, preferred_order, providers[provider_key]["channelsontop"], bouquetsToHide, prefix) writer.buildBouquetsIndex(self.path, self.bouquetsOrder, providers, self.bouquetsToKeep, currentBouquets, self.bouquetsToHide, self.providerConfigs) print >> log, "[Manager] Done"
def favourites(self, path, services, providers, providerConfigs, bouquetsOrder): custom_dir = os.path.dirname(__file__) + "/../custom" provider_key = "favourites" customised = {"video": {}, "radio": {}} name = "" prefix = "" sections = {} bouquets = {"main": 1, "sections": 1} area_key = "" bouquets_to_hide = [] bouquetsToHide = [] swaprules = [] placement = 0 hacks = "" # Read favourites file dom = self.parseXML(custom_dir + "/favourites.xml") if dom is None: print >> log, "[ABM-Tools][favourites] No favorite.xml file" elif dom.documentElement.nodeType == dom.documentElement.ELEMENT_NODE and dom.documentElement.tagName == "favourites": print >> log, "[ABM-Tools][favourites] Reading favorite.xml file" for node in dom.documentElement.childNodes: if node.nodeType != node.ELEMENT_NODE: continue if node.tagName == "name": node.normalize() if len( node.childNodes ) == 1 and node.childNodes[0].nodeType == node.TEXT_NODE: name = node.childNodes[0].data.encode("utf-8") elif node.tagName == "sections": sections = {} for node2 in node.childNodes: if node2.nodeType == node2.ELEMENT_NODE and node2.tagName == "section": number = -1 for i in range(0, node2.attributes.length): if node2.attributes.item(i).name == "number": number = int( node2.attributes.item(i).value) if number == -1: continue node2.normalize() if len(node2.childNodes ) == 1 and node2.childNodes[ 0].nodeType == node2.TEXT_NODE: sections[number] = node2.childNodes[ 0].data.encode("utf-8") elif node.tagName == "inserts": for node2 in node.childNodes: if node2.nodeType == node2.ELEMENT_NODE and node2.tagName == "insert": provider = '' source = '' target = '' for i in range(0, node2.attributes.length): if node2.attributes.item(i).name == "provider": provider = node2.attributes.item( i).value.encode("utf-8") elif node2.attributes.item(i).name == "source": source = int( node2.attributes.item(i).value) elif node2.attributes.item(i).name == "target": target = int( node2.attributes.item(i).value) if provider and source and target and provider in services and source in services[ provider]["video"]: customised["video"][target] = services[ provider]["video"][source] elif node.tagName == "bouquets": for node2 in node.childNodes: if node2.nodeType == node2.ELEMENT_NODE and node2.tagName == "main": node2.normalize() if len(node2.childNodes) == 1 and node2.childNodes[ 0].nodeType == node2.TEXT_NODE and node2.childNodes[ 0].data.encode("utf-8") != "1": bouquets["main"] = 0 elif node2.nodeType == node2.ELEMENT_NODE and node2.tagName == "sections": node2.normalize() if len(node2.childNodes) == 1 and node2.childNodes[ 0].nodeType == node2.TEXT_NODE and node2.childNodes[ 0].data.encode("utf-8") != "1": bouquets["sections"] = 0 elif node.tagName == "placement": node.normalize() if len( node.childNodes ) == 1 and node.childNodes[0].nodeType == node.TEXT_NODE: placement = min( int(node.childNodes[0].data) - 1, len(bouquetsOrder)) if placement < 0: placement = 0 elif node.tagName == "hacks": node.normalize() for i in range(0, len(node.childNodes)): if node.childNodes[ i].nodeType == node.CDATA_SECTION_NODE: hacks = node.childNodes[i].data.encode( "utf-8").strip() if len(hacks) > 0: exec(hacks) if len(customised["video"]) > 0: providers[provider_key] = {} providers[provider_key]["name"] = name providers[provider_key]["bouquets"] = area_key providers[provider_key]["protocol"] = 'nolcn' providers[provider_key]["swapchannels"] = [] providers[provider_key]["sections"] = sections if config.autobouquetsmaker.addprefix.value: prefix = name services[provider_key] = customised bouquetsOrder.insert(placement, provider_key) from providerconfig import ProviderConfig providerConfigs[provider_key] = ProviderConfig("%s::0:" % provider_key) if bouquets["main"] == 1: providerConfigs[provider_key].setMakeNormalMain() if bouquets["sections"] == 1: providerConfigs[provider_key].setMakeSections() from bouquetswriter import BouquetsWriter BouquetsWriter().buildBouquets(path, providerConfigs[provider_key], services[provider_key], sections, provider_key, swaprules, bouquets_to_hide, prefix) else: print >> log, "[ABM-Tools][favourites] Favourites list is zero length."
def save(self): print>>log, "[Manager] Saving..." old_bouquets = BouquetsReader().getBouquetsList(self.path) if "tv" not in old_bouquets: old_bouquets["tv"] = [] if "radio" not in old_bouquets: old_bouquets["radio"] = [] currentBouquets = {} currentBouquets["tv"] = [] currentBouquets["radio"] = [] for bouquet in old_bouquets["tv"]: currentBouquets["tv"].append(bouquet["filename"]) for bouquet in old_bouquets["radio"]: currentBouquets["radio"].append(bouquet["filename"]) if "tv" not in self.bouquetsToKeep: self.bouquetsToKeep["tv"] = [] if "radio" not in self.bouquetsToKeep: self.bouquetsToKeep["radio"] = [] print>>log, "[Manager] Bouquets to hide:", self.bouquetsToHide print>>log, "[Manager] TV bouquets to keep:", self.bouquetsToKeep["tv"] print>>log, "[Manager] Radio bouquets to keep:", self.bouquetsToKeep["radio"] #print>>log, "[Manager] Generate main bouquet:", str(self.makemain) #print>>log, "[Manager] Generate sections bouquets:", str(self.makesections) #print>>log, "[Manager] Generate HD bouquet:", str(self.makehd) #print>>log, "[Manager] Generate FTA bouquet:", str(self.makefta) print>>log, "[Manager] Add provider prefix to bouqets:", str(self.addprefix) writer = BouquetsWriter() writer.writeLamedb(self.path, self.transponders) providers = Providers().read() bouquetsToHide = [] for provider_key in self.bouquetsOrder: if provider_key in providers: bouquetsToHide = [] if provider_key in self.bouquetsToHide: # expand section keys in channels numbers sections = sorted(providers[provider_key]["sections"].keys()) for bouquetToHide in self.bouquetsToHide[provider_key]: try: #get closest section, just in case section numbers in the provider file have been updated bouquetToHide = min(sections, key=lambda x:abs(x-bouquetToHide)) index = sections.index(bouquetToHide) except: continue if index < len(sections) - 1: bouquetsToHide += range(bouquetToHide, sections[index + 1]) else: bouquetsToHide += range(bouquetToHide, 65535) prefix = "" if self.addprefix: prefix = providers[provider_key]["name"] current_bouquet_key = self.providerConfigs[provider_key].getArea() if current_bouquet_key in providers[provider_key]["bouquets"] and providers[provider_key]["protocol"] in ("sky", "freesat"): current_bouquet = providers[provider_key]["bouquets"][current_bouquet_key]["bouquet"] current_region = providers[provider_key]["bouquets"][current_bouquet_key]["region"] else: current_bouquet = -1 current_region = -1 preferred_order = [] if (self.providerConfigs[provider_key].isMakeNormalMain() or self.providerConfigs[provider_key].isMakeSections()) and self.providerConfigs[provider_key].isSwapChannels(): for swapchannels_set in providers[provider_key]["swapchannels"]: if len(preferred_order) == 0 and len(swapchannels_set["filters"]) == 0: preferred_order = swapchannels_set["preferred_order"] continue if len(swapchannels_set["filters"]) > 0: for cfilter in swapchannels_set["filters"]: if cfilter[0] == current_bouquet and cfilter[1] == current_region: preferred_order = swapchannels_set["preferred_order"] break if current_bouquet_key.startswith('sd'): channelsontop = providers[provider_key]["sdchannelsontop"], else: channelsontop = providers[provider_key]["hdchannelsontop"], # swap services between providers services = Tools().customMix(self.services, provider_key) writer.buildBouquets(self.path, self.providerConfigs[provider_key], services, providers[provider_key]["sections"], provider_key, preferred_order, channelsontop, bouquetsToHide, prefix) # add a custom favourites list Tools().favourites(self.path, self.services, providers, self.providerConfigs, self.bouquetsOrder) writer.buildBouquetsIndex(self.path, self.bouquetsOrder, providers, self.bouquetsToKeep, currentBouquets, self.bouquetsToHide, self.providerConfigs) print>>log, "[Manager] Done"
def save(self, providers, dependent_providers={}): #merge dependent providers for provider_key in dependent_providers: if provider_key in self.services: for dependent_key in dependent_providers[provider_key]: if dependent_key in self.services: for type in ["video", "radio"]: for number in self.services[dependent_key][type]: self.services[provider_key][type][ number] = self.services[dependent_key][ type][number] print >> log, "[ABM-Manager][save] Saving..." old_bouquets = BouquetsReader().getBouquetsList(self.path) if "tv" not in old_bouquets: old_bouquets["tv"] = [] if "radio" not in old_bouquets: old_bouquets["radio"] = [] currentBouquets = {} currentBouquets["tv"] = [] currentBouquets["radio"] = [] for bouquet in old_bouquets["tv"]: currentBouquets["tv"].append(bouquet["filename"]) for bouquet in old_bouquets["radio"]: currentBouquets["radio"].append(bouquet["filename"]) if "tv" not in self.bouquetsToKeep: self.bouquetsToKeep["tv"] = [] if "radio" not in self.bouquetsToKeep: self.bouquetsToKeep["radio"] = [] print >> log, "[ABM-Manager][save] Bouquets to hide:", self.bouquetsToHide print >> log, "[ABM-Manager][save] TV bouquets to keep:", self.bouquetsToKeep[ "tv"] print >> log, "[ABM-Manager][save] Radio bouquets to keep:", self.bouquetsToKeep[ "radio"] #print>>log, "[ABM-Manager][save] Generate main bouquet:", str(self.makemain) #print>>log, "[ABM-Manager][save] Generate sections bouquets:", str(self.makesections) #print>>log, "[ABM-Manager][save] Generate HD bouquet:", str(self.makehd) #print>>log, "[ABM-Manager][save] Generate FTA bouquet:", str(self.makefta) print >> log, "[ABM-Manager][save] Add provider prefix to bouqets:", str( self.addprefix) writer = BouquetsWriter() writer.writeLamedb(self.path, self.transponders) #providers = Providers().read() bouquetsToHide = [] for provider_key in self.bouquetsOrder: if provider_key in providers: # FTA_only if config.autobouquetsmaker.level.value == "expert" and provider_key in config.autobouquetsmaker.FTA_only.value: video_services_tmp = {} for number in self.services[provider_key]["video"]: if self.services[provider_key]["video"][number][ "free_ca"] == 0: video_services_tmp[number] = self.services[ provider_key]["video"][number] self.services[provider_key]["video"] = video_services_tmp # CustomLCN self.services[provider_key] = Tools().customLCN( self.services[provider_key], provider_key, self.providerConfigs[provider_key].getArea()) for provider_key in self.bouquetsOrder: if provider_key in providers: bouquetsToHide = [] if provider_key in self.bouquetsToHide: # expand section keys in channels numbers sections = sorted( providers[provider_key]["sections"].keys()) for bouquetToHide in self.bouquetsToHide[provider_key]: try: #get closest section, just in case section numbers in the provider file have been updated bouquetToHide = min( sections, key=lambda x: abs(x - bouquetToHide)) index = sections.index(bouquetToHide) except: continue if index < len(sections) - 1: bouquetsToHide += range(bouquetToHide, sections[index + 1]) else: bouquetsToHide += range(bouquetToHide, 65535) prefix = "" if self.addprefix: prefix = providers[provider_key]["name"] current_bouquet_key = self.providerConfigs[ provider_key].getArea() if current_bouquet_key in providers[provider_key][ "bouquets"] and providers[provider_key][ "protocol"] in ("sky", "freesat"): current_bouquet = providers[provider_key]["bouquets"][ current_bouquet_key]["bouquet"] current_region = providers[provider_key]["bouquets"][ current_bouquet_key]["region"] else: current_bouquet = -1 current_region = -1 # swap services between providers services, providers[provider_key]["sections"] = Tools( ).customMix(self.services, provider_key, providers, self.providerConfigs[provider_key]) writer.buildBouquets( self.path, self.providerConfigs[provider_key], services, providers[provider_key]["sections"], provider_key, providers[provider_key]["swapchannels"], bouquetsToHide, prefix) # add a custom favourites list Tools().favourites(self.path, self.services, providers, self.providerConfigs, self.bouquetsOrder) writer.buildLastScannedBouquet(self.path, self.services) writer.buildBouquetsIndex(self.path, self.bouquetsOrder, providers, self.bouquetsToKeep, currentBouquets, self.bouquetsToHide, self.providerConfigs) print >> log, "[ABM-Manager][save] write bouquets, Done"
def save(self, providers, dependent_providers = {}): #merge dependent providers for provider_key in dependent_providers: if provider_key in self.services: for dependent_key in dependent_providers[provider_key]: if dependent_key in self.services: for type in ["video", "radio"]: for number in self.services[dependent_key][type]: self.services[provider_key][type][number] = self.services[dependent_key][type][number] print>>log, "[ABM-Manager][save] Saving..." old_bouquets = BouquetsReader().getBouquetsList(self.path) if "tv" not in old_bouquets: old_bouquets["tv"] = [] if "radio" not in old_bouquets: old_bouquets["radio"] = [] currentBouquets = {} currentBouquets["tv"] = [] currentBouquets["radio"] = [] for bouquet in old_bouquets["tv"]: currentBouquets["tv"].append(bouquet["filename"]) for bouquet in old_bouquets["radio"]: currentBouquets["radio"].append(bouquet["filename"]) if "tv" not in self.bouquetsToKeep: self.bouquetsToKeep["tv"] = [] if "radio" not in self.bouquetsToKeep: self.bouquetsToKeep["radio"] = [] print>>log, "[ABM-Manager][save] Bouquets to hide:", self.bouquetsToHide print>>log, "[ABM-Manager][save] TV bouquets to keep:", self.bouquetsToKeep["tv"] print>>log, "[ABM-Manager][save] Radio bouquets to keep:", self.bouquetsToKeep["radio"] #print>>log, "[ABM-Manager][save] Generate main bouquet:", str(self.makemain) #print>>log, "[ABM-Manager][save] Generate sections bouquets:", str(self.makesections) #print>>log, "[ABM-Manager][save] Generate HD bouquet:", str(self.makehd) #print>>log, "[ABM-Manager][save] Generate FTA bouquet:", str(self.makefta) print>>log, "[ABM-Manager][save] Add provider prefix to bouqets:", str(self.addprefix) writer = BouquetsWriter() writer.writeLamedb(self.path, self.transponders) #providers = Providers().read() bouquetsToHide = [] for provider_key in self.bouquetsOrder: if provider_key in providers: # FTA_only if config.autobouquetsmaker.level.value == "expert" and provider_key in config.autobouquetsmaker.FTA_only.value: video_services_tmp = {} for number in self.services[provider_key]["video"]: if self.services[provider_key]["video"][number]["free_ca"] == 0: video_services_tmp[number] = self.services[provider_key]["video"][number] self.services[provider_key]["video"] = video_services_tmp # CustomLCN self.services[provider_key] = Tools().customLCN(self.services[provider_key], provider_key, self.providerConfigs[provider_key].getArea()) for provider_key in self.bouquetsOrder: if provider_key in providers: bouquetsToHide = [] if provider_key in self.bouquetsToHide: # expand section keys in channels numbers sections = sorted(providers[provider_key]["sections"].keys()) for bouquetToHide in self.bouquetsToHide[provider_key]: try: #get closest section, just in case section numbers in the provider file have been updated bouquetToHide = min(sections, key=lambda x:abs(x-bouquetToHide)) index = sections.index(bouquetToHide) except: continue if index < len(sections) - 1: bouquetsToHide += range(bouquetToHide, sections[index + 1]) else: bouquetsToHide += range(bouquetToHide, 65535) prefix = "" if self.addprefix: prefix = providers[provider_key]["name"] current_bouquet_key = self.providerConfigs[provider_key].getArea() if current_bouquet_key in providers[provider_key]["bouquets"] and providers[provider_key]["protocol"] in ("sky", "freesat"): current_bouquet = providers[provider_key]["bouquets"][current_bouquet_key]["bouquet"] current_region = providers[provider_key]["bouquets"][current_bouquet_key]["region"] else: current_bouquet = -1 current_region = -1 # swap services between providers services, providers[provider_key]["sections"] = Tools().customMix(self.services, provider_key, providers, self.providerConfigs[provider_key]) writer.buildBouquets(self.path, self.providerConfigs[provider_key], services, providers[provider_key]["sections"], provider_key, providers[provider_key]["swapchannels"], bouquetsToHide, prefix) # add a custom favourites list Tools().favourites(self.path, self.services, providers, self.providerConfigs, self.bouquetsOrder) writer.buildLastScannedBouquet(self.path, self.services) writer.buildBouquetsIndex(self.path, self.bouquetsOrder, providers, self.bouquetsToKeep, currentBouquets, self.bouquetsToHide, self.providerConfigs) print>>log, "[ABM-Manager][save] write bouquets, Done"
def save(self): print >> log, "[Manager] Saving..." old_bouquets = BouquetsReader().getBouquetsList(self.path) if "tv" not in old_bouquets: old_bouquets["tv"] = [] if "radio" not in old_bouquets: old_bouquets["radio"] = [] currentBouquets = {} currentBouquets["tv"] = [] currentBouquets["radio"] = [] for bouquet in old_bouquets["tv"]: currentBouquets["tv"].append(bouquet["filename"]) for bouquet in old_bouquets["radio"]: currentBouquets["radio"].append(bouquet["filename"]) if "tv" not in self.bouquetsToKeep: self.bouquetsToKeep["tv"] = [] if "radio" not in self.bouquetsToKeep: self.bouquetsToKeep["radio"] = [] print >> log, "[Manager] Bouquets to hide:", self.bouquetsToHide print >> log, "[Manager] TV bouquets to keep:", self.bouquetsToKeep[ "tv"] print >> log, "[Manager] Radio bouquets to keep:", self.bouquetsToKeep[ "radio"] #print>>log, "[Manager] Generate main bouquet:", str(self.makemain) #print>>log, "[Manager] Generate sections bouquets:", str(self.makesections) #print>>log, "[Manager] Generate HD bouquet:", str(self.makehd) #print>>log, "[Manager] Generate FTA bouquet:", str(self.makefta) print >> log, "[Manager] Add provider prefix to bouqets:", str( self.addprefix) writer = BouquetsWriter() writer.writeLamedb(self.path, self.transponders) providers = Providers().read() bouquetsToHide = [] for provider_key in self.bouquetsOrder: if provider_key in providers: bouquetsToHide = [] if provider_key in self.bouquetsToHide: # expand section keys in channels numbers sections = sorted( providers[provider_key]["sections"].keys()) for bouquetToHide in self.bouquetsToHide[provider_key]: try: #get closest section, just in case section numbers in the provider file have been updated bouquetToHide = min( sections, key=lambda x: abs(x - bouquetToHide)) index = sections.index(bouquetToHide) except: continue if index < len(sections) - 1: bouquetsToHide += range(bouquetToHide, sections[index + 1]) else: bouquetsToHide += range(bouquetToHide, 65535) prefix = "" if self.addprefix: prefix = providers[provider_key]["name"] current_bouquet_key = self.providerConfigs[ provider_key].getArea() if current_bouquet_key in providers[provider_key][ "bouquets"] and providers[provider_key][ "protocol"] in ("sky", "freesat"): current_bouquet = providers[provider_key]["bouquets"][ current_bouquet_key]["bouquet"] current_region = providers[provider_key]["bouquets"][ current_bouquet_key]["region"] else: current_bouquet = -1 current_region = -1 preferred_order = [] if (self.providerConfigs[provider_key].isMakeNormalMain() or self.providerConfigs[provider_key].isMakeSections() ) and self.providerConfigs[provider_key].isSwapChannels(): for swapchannels_set in providers[provider_key][ "swapchannels"]: if len(preferred_order) == 0 and len( swapchannels_set["filters"]) == 0: preferred_order = swapchannels_set[ "preferred_order"] continue if len(swapchannels_set["filters"]) > 0: for cfilter in swapchannels_set["filters"]: if cfilter[0] == current_bouquet and cfilter[ 1] == current_region: preferred_order = swapchannels_set[ "preferred_order"] break if current_bouquet_key.startswith('sd'): channelsontop = providers[provider_key]["sdchannelsontop"], else: channelsontop = providers[provider_key]["hdchannelsontop"], # swap services between providers services = Tools().customMix(self.services, provider_key) writer.buildBouquets(self.path, self.providerConfigs[provider_key], services, providers[provider_key]["sections"], provider_key, preferred_order, channelsontop, bouquetsToHide, prefix) # add a custom favourites list Tools().favourites(self.path, self.services, providers, self.providerConfigs, self.bouquetsOrder) writer.buildBouquetsIndex(self.path, self.bouquetsOrder, providers, self.bouquetsToKeep, currentBouquets, self.bouquetsToHide, self.providerConfigs) print >> log, "[Manager] Done"