def GetIptvChannels(): allCategories = common.GetChannels('categories') categories = GetCategories() channelsList = [] for category in categories: if category.get('type', '') == "ignore": continue channels = common.GetChannels(category["id"]) if category["id"] != "Favourites" else common.ReadList(FAV) ind = -1 for channel in channels: ind += 1 if channel["type"] == 'video' or channel["type"] == 'audio': try: channelName = common.GetUnColor(channel['name'].encode("utf-8")) tvg_id = common.GetUnColor(channel.get("tvg", channel["name"]).encode("utf-8")) if category["id"] == "Favourites": gp = [x["name"] for x in allCategories if x["id"] == channel.get("group", "")] groupName = gp[0] if len(gp) > 0 else 'Favourites' channelID = ind else: groupName = category['name'] channelID = channel['id'] data = {'name': channelName, 'tvg': tvg_id, 'url': channel['url'], 'image': channel['image'], 'type': channel['type'], 'group': groupName.encode("utf-8"), 'id': channelID, 'catid': category["id"]} channelsList.append(data) except Exception, e: pass
def GetCategories(): iptvList = int(Addon.getSetting("iptvList")) if iptvList == 0: categories = [{"id": "Favourites"}] elif iptvList == 1: categories = common.GetChannels('categories') elif iptvList == 2: categories = common.GetChannels('selectedCategories') return categories
def AddCategoryToFavorites(categoryID): allCatList = common.ReadList(categoriesFile) category = [ u"[COLOR {0}][B][{1}][/B][/COLOR]".format(Addon.getSetting("catColor"), item["name"]) for item in allCatList if item['id'] == categoryID ] channels = common.GetChannels(categoryID) if not common.YesNoDialog(localizedString(30210).encode('utf-8'), localizedString(30221).encode('utf-8'), localizedString(30222).encode('utf-8').format( category[0].encode('utf-8'), len(channels)), localizedString(30223).encode('utf-8'), nolabel=localizedString(30002).encode('utf-8'), yeslabel=localizedString(30001).encode('utf-8')): return xbmc.executebuiltin( 'Notification({0}, Start adding channels to favourites, {1}, {2})'. format(AddonName, 5000, icon)) addFavorites([channel["id"] for channel in channels], categoryID, showNotification=False) common.MakeFavouritesGuide(fullGuideFile) xbmc.executebuiltin( 'Notification({0}, Channels added to favourites, {1}, {2})'.format( AddonName, 5000, __icon__))
def addFavorites(channelsIDs, categoryID, showNotification=True): channels = common.GetChannels(categoryID) favsList = common.ReadList(FAV) for channelID in channelsIDs: channel = [x for x in channels if x["id"] == channelID] if len(channel) < 1: if showNotification: xbmc.executebuiltin( 'Notification({0}, [COLOR {1}][B]{2}[/B][/COLOR] Cannot add to favourites, {3}, {4})' .format(AddonName, Addon.getSetting("chColor"), channel["name"].encode("utf-8"), 5000, __icon2__)) continue channel = channel[0] if any(f.get('id', '') == channel["id"] for f in favsList): if showNotification: xbmc.executebuiltin( 'Notification({0}, [COLOR {1}][B]{2}[/B][/COLOR] Already in favourites, {3}, {4})' .format(AddonName, Addon.getSetting("chColor"), channel["name"].encode("utf-8"), 5000, __icon2__)) continue favsList.append(channel) if showNotification: xbmc.executebuiltin( 'Notification({0}, [COLOR {1}][B]{2}[/B][/COLOR] added to favourites, {3}, {4})' .format(AddonName, Addon.getSetting("chColor"), channel["name"].encode("utf-8"), 5000, __icon__)) common.WriteList(FAV, favsList) common.MakeFavouritesGuide(fullGuideFile)
def AddCategoryToFavorites(categoryID): channels = common.GetChannels(categoryID) xbmc.executebuiltin( 'Notification({0}, Start adding channels to favourites, {1}, {2})'. format(AddonName, 5000, icon)) addFavorites([channel["id"] for channel in channels], categoryID, showNotification=False) common.MakeCatGuide(fullGuideFile, "Favourites") xbmc.executebuiltin( 'Notification({0}, Channels added to 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 ListLive(categoryID, iconimage=None): channels = common.GetChannels(categoryID) for channel in channels: url = channel['url'] image = channel['image'] description = "" channelName = channel['name'].encode("utf-8") background = None isTvGuide = False if channel["type"] == 'video' or channel["type"] == 'audio': if url.find(AddonID) > 0: itemMode = re.compile('url=([0-9]*).*?mode=([0-9]*).*?$', re.I + re.M + re.U + re.S).findall(url) if len(itemMode) > 0 and itemMode[0] != '': mode = int(itemMode[0][1]) if mode == 1: mode = 3 elif url.find('?mode=3') > 0 and not useIPTV: continue else: mode = 10 displayName, description, background, isTvGuide = GetProgrammeDetails( channelName, categoryID) elif not useCategories and channel["type"] == 'playlist': mode = 2 displayName = "[COLOR {0}][B][{1}][/B][/COLOR]".format( Addon.getSetting("catColor"), channelName) background = image channelName = channel["id"] else: continue if background is None or background == "": background = iconimage addDir(displayName, url, mode, image, description, channelName=channelName, background=background, isTvGuide=isTvGuide, channelID=channel["id"], categoryID=categoryID) SetViewMode()
def GetIptvChannels(): allCategories = common.GetChannels('categories') categories = GetCategories() channelsList = [] for category in categories: if category.has_key("type") and category["type"] == "ignore": continue channels = common.GetChannels(category["id"]) if category["id"] != "Favourites" else common.ReadList(os.path.join(user_dataDir, 'favorites.txt')) for channel in channels: if channel["type"] == 'video' or channel["type"] == 'audio': try: channelName = channel['name'].encode("utf-8").replace("[COLOR yellow][B]", "").replace("[/B][/COLOR]", "") if category["id"] == "Favourites": gp = [x["name"] for x in allCategories if x["id"] == channel.get("group", "")] groupName = gp[0] if len(gp) > 0 else 'Favourites' else: groupName = category['name'] data = {'name': channelName, 'url': channel['url'], 'image': channel['image'], 'type': channel['type'], 'group': groupName.encode("utf-8")} channelsList.append(data) except Exception, e: pass
def ListLive(categoryID, iconimage=None): channels = common.GetChannels(categoryID) for channel in channels: url = channel['url'] image = channel['image'] description = "" channelName = channel['name'].encode("utf-8") background = None isTvGuide = False isFolder = True if channel["type"] == 'video' or channel["type"] == 'audio': if url.find('?mode=3') > 0 and not useIPTV: continue else: mode = 10 isFolder = False displayName, description, background, isTvGuide = GetProgrammeDetails( channelName, categoryID) elif not useCategories and channel["type"] == 'playlist': mode = 2 displayName = "[COLOR {0}][B][{1}][/B][/COLOR]".format( Addon.getSetting("catColor"), channelName) background = image channelName = channel["id"] else: continue if background is None or background == "": background = iconimage addDir(displayName, url, mode, image, description, isFolder=isFolder, channelName=channelName, background=background, isTvGuide=isTvGuide, channelID=channel["id"], categoryID=categoryID) SetViewMode()
def ListLive(categoryID=None, iconimage=None, chID=None, catChannels=None, showSearch=False, makeGroup=True, catName=False): if catChannels is None: catChannels = common.GetChannels(categoryID) groupChannels = [] for channel in catChannels: if channel["type"] == 'ignore': continue matches = [groupChannels.index(x) for x in groupChannels if len(x) > 0 and x[0]["name"] == channel["name"]] if len(matches) == 1 and makeGroup: groupChannels[matches[0]].append(channel) else: if chID is None or chID == channel['id']: groupChannels.append([channel]) if showSearch and len(groupChannels) > 0: addDir("[COLOR white][B]<{0}>[/B][/COLOR]".format(localizedString(30027).encode('utf-8')), 60, categoryID=categoryID) for channels in groupChannels: isGroupChannel = len(channels) > 1 and chID is None chs = [channels[0]] if isGroupChannel else channels for channel in chs: image = channel['image'] description = "" channelName = channel['name'].encode("utf-8") background = None isTvGuide = False isFolder=True displayName, description, background, isTvGuide = GetProgrammeDetails(channelName, channel['group'], catName= catName and categoryID != channel['group'], progName=showProgNames) if isGroupChannel: mode = 3 displayName = displayName.replace('[COLOR {0}][B]'.format(Addon.getSetting("chColor")), '[COLOR {0}][B]['.format(Addon.getSetting("catColor")), 1).replace('[/B]', '][/B]', 1) elif channel["type"] == 'video' or channel["type"] == 'audio': mode = 10 isFolder=False elif not useCategories and channel["type"] == 'playlist': mode = 2 displayName = displayName.replace('[COLOR {0}][B]'.format(Addon.getSetting("chColor")), '[COLOR {0}][B]['.format(Addon.getSetting("catColor")), 1).replace('[/B]', '][/B]', 1) background = image else: continue if background is None or background == "": background = iconimage addDir(displayName, mode, image, description, isFolder=isFolder, background=background, isTvGuide=isTvGuide, channelID=channel["id"], categoryID=channel['group']) SetViewMode()
elif mode == '3': ListLive(categoryID=categoryID, iconimage=iconimage, chID=channelID) updateList = True elif mode == '4': SearchResults(channelID, categoryID) updateList = True elif mode == '5': ChannelGuide(channelID, categoryID) updateList = True elif mode == '11': updateList = PlayChannelByID(chID=channelID, fromFav=True) elif mode == '16': listFavorites() updateList = True elif mode == '17': channels = common.GetChannels(categoryID) channel = [x for x in channels if x["id"] == channelID] if len(channel) < 1: xbmc.executebuiltin( 'Notification({0}, Cannot add this channel to favourites, {2}, {3})' .format(AddonName, Addon.getSetting("chColor"), 5000, __icon2__)) else: addFavorites(channel) updateList = True elif mode == '18': removeFavorties([int(channelID)]) xbmc.executebuiltin("XBMC.Container.Refresh()") elif mode == '22': # Update Channels Lists now UpdateChannelsLists() elif mode == '23': # Clean addon profile folder and refresh lists RefreshUserdataFolder()
def VideoListChannels(uid=None, offset=0): return Common.GetChannels(VideoAlbums, VideoListChannels, uid, offset)