def RemoveSelectedFavorties(): allCategories = common.ReadList(categoriesFile) channels = common.ReadList(FAV) channelsNames = [] for channel in channels: gp = [ x["name"] for x in allCategories if x["id"] == channel.get("group", "") ] groupName = gp[0] if len(gp) > 0 else 'Favourites' channelsNames.append( u"[COLOR {0}][B]{1}[/B][/COLOR] [COLOR {2}][B][{3}][/B][/COLOR]". format(Addon.getSetting("chColor"), channel["name"], Addon.getSetting("catColor"), groupName)) selected = common.GetMultiChoiceSelected( localizedString(30209).encode('utf-8'), channelsNames) if len(selected) < 1: return xbmc.executebuiltin( 'Notification({0}, Start removing channels from favourites, {1}, {2})'. format(AddonName, 5000, icon)) removeFavorties(selected) common.MakeFavouritesGuide(fullGuideFile) xbmc.executebuiltin( 'Notification({0}, Channels removed trom favourites, {1}, {2})'.format( AddonName, 5000, __icon__))
def AddFavoritesFromCategory(categoryID): channels = common.GetChannels(categoryID) channels = [channel for channel in channels if channel["type"] == "video" or channel["type"] == "audio"] channelsNames = [u"[COLOR {0}][B]{1}[/B][/COLOR]".format(Addon.getSetting("chColor"), channel["name"]) for channel in channels] selected = common.GetMultiChoiceSelected(localizedString(30208).encode('utf-8'), channelsNames) if len(selected) < 1: return selectedList = [channels[index] for index in selected] xbmc.executebuiltin('Notification({0}, Start adding channels to favourites, {1}, {2})'.format(AddonName, 5000, icon)) addFavorites(selectedList, showNotification=False) common.MakeFavouritesGuide(fullGuideFile) xbmc.executebuiltin('Notification({0}, Channels added to favourites, {1}, {2})'.format(AddonName, 5000, __icon__))
def AddCategories(): if not os.path.isfile(categoriesFile): common.UpdateChList() allCatList = common.ReadList(categoriesFile) selectedCatList = common.ReadList(selectedCategoriesFile) categories = common.GetUnSelectedList(allCatList, selectedCatList) categoriesNames = [u"[COLOR {0}][B][{1}][/B][/COLOR]".format(Addon.getSetting("catColor"), item["name"]) for item in categories] selected = common.GetMultiChoiceSelected(localizedString(30503).encode('utf-8'), categoriesNames) if len(selected) < 1: return selectedList = [categories[item] for item in selected] common.WriteList(selectedCategoriesFile, selectedCatList + selectedList)
def RemoveCategories(): if not os.path.isfile(categoriesFile): common.UpdateChList() selectedCatList = common.ReadList(selectedCategoriesFile) categories = [u"[COLOR {0}][B][{1}][/B][/COLOR]".format(Addon.getSetting("catColor"), item["name"]) for item in selectedCatList] selected = common.GetMultiChoiceSelected(localizedString(30503).encode('utf-8'), categories) if len(selected) < 1: return for ind in range(len(selected)-1, -1, -1): selectedCatList.remove(selectedCatList[selected[ind]]) common.WriteList(selectedCategoriesFile, selectedCatList)
def AddCategories(): if not os.path.isfile(categoriesFile): common.UpdatePlx(plxFile, "plx", forceUpdate=True) allCatList = common.ReadList(categoriesFile) selectedCatList = common.ReadList(selectedCategoriesFile) showCat = [] for index, cat in enumerate(allCatList): if not any(f["id"] == cat.get("id", "") for f in selectedCatList): showCat.append(cat) categories = [ u"[COLOR {0}][B][{1}][/B][/COLOR]".format(Addon.getSetting("catColor"), item["name"]) for item in showCat ] selected = common.GetMultiChoiceSelected( localizedString(30503).encode('utf-8'), categories) if len(selected) < 1: return selectedList = [showCat[item] for item in selected] common.WriteList(selectedCategoriesFile, selectedCatList + selectedList)