def PlxCategory(url, cache): tmpList = [] chList = common.plx2list(url, cache) background = chList[0]["background"] for channel in chList[1:]: iconimage = "" if "thumb" not in channel else common.GetEncodeString( channel["thumb"]) name = common.GetEncodeString(channel["name"]) if channel["type"] == 'playlist': AddDir("[{0}]".format(name), channel["url"], 1, iconimage, background=background) else: AddDir(name, channel["url"], 3, iconimage, isFolder=False, IsPlayable=True, background=background) tmpList.append({ "url": channel["url"], "image": iconimage, "name": name }) common.SaveList(tmpListFile, tmpList)
def AddListItems(chList, addToVdir=True): cacheList = [] i = 0 for item in chList: mode = 1 if '.plx' in item["url"] else 2 name = common.GetEncodeString(item["name"]) image = item.get('image', '') uuid4 = item["uuid"] if image == "" or image is None: image = os.path.join(iconsDir, "default-list-image.png") logos = item.get('logos', '') cacheMin = item.get('cache', '0') if item["url"].startswith('http'): cacheList.append(hashlib.md5(item["url"].encode()).hexdigest()) AddDir("[{0}]".format(name), item["url"], mode, image, logos, index=i, uuid=uuid4, cacheMin=cacheMin, addToVdir=addToVdir) i += 1 for the_file in os.listdir(cacheDir): file_path = os.path.join(cacheDir, the_file) try: if os.path.isfile(file_path) and the_file not in cacheList: os.unlink(file_path) except Exception as ex: xbmc.log("{0}".format(ex), 3)
def m3uCategory(url, logos, cache, gListIndex=-1): meta = None tmpList = [] chList = common.m3u2list(url, cache) groupChannels = [] for channel in chList: if makeGroups: matches = [groupChannels.index(x) for x in groupChannels if len(x) > 0 and x[0].get("group_title", x[0]["display_name"]) == channel.get("group_title", channel["display_name"])] if makeGroups and len(matches) == 1: groupChannels[matches[0]].append(channel) else: groupChannels.append([channel]) for channels in groupChannels: idx = groupChannels.index(channels) if gListIndex > -1 and gListIndex != idx: continue isGroupChannel = gListIndex < 0 and len(channels) > 1 chs = [channels[0]] if isGroupChannel else channels for channel in chs: name = common.GetEncodeString(channel["display_name"]) if not isGroupChannel else common.GetEncodeString(channel.get("group_title", channel["display_name"])) plot = "" if meta is None else meta[channel["group_title"]]["overview"] if channel["group_title"] in meta else "" fanart = "" if meta is None else meta[channel["group_title"]]["fanarts"][0] if (channel["group_title"] in meta and len(meta[channel["group_title"]]["fanarts"]) > 0) else "" if isGroupChannel: name = '{0}'.format(name) chUrl = url try: image = channel['tvg_logo'] if meta is None else meta[channel["group_title"]]["poster"] if channel["group_title"] in meta else channel['tvg_logo'] except KeyError: image = "DefaultTVShows.png" AddDir(name, url, 10, index=idx, iconimage=image, plot=plot, fanart=fanart) else: chUrl = common.GetEncodeString(channel["url"]) image = channel.get("tvg_logo", channel.get("logo", "")) if logos is not None and logos != '' and image != "" and not image.startswith('http'): image = logos + image AddDir(name, chUrl, 3, image, index=-1, isFolder=False, IsPlayable=True, plot=plot, fanart=fanart) tmpList.append({"url": chUrl, "image": image, "name": name}) common.SaveList(tmpListFile, tmpList)
def m3uCategory(url, logos, epg, cache, mode, gListIndex=-1): meta = None tmpList = [] chList = common.m3u2list(url, cache) if (mode == 2 or mode == 10) and epg != None and epg != '': epgDict = common.epg2dict(epg, cache=720) dnow = datetime.now(tz.UTC) to_zone = tz.tzlocal() use_percent = 'true' use_time = 'true' else: epgDict = {} #xbmc.log('EPGDICT') #xbmc.log(str(epgDict)) groupChannels = [] for channel in chList: if makeGroups: matches = [groupChannels.index(x) for x in groupChannels if len(x) > 0 and x[0].get("group_title", x[0]["display_name"]) == channel.get("group_title", channel["display_name"])] if makeGroups and len(matches) == 1: groupChannels[matches[0]].append(channel) else: groupChannels.append([channel]) for channels in groupChannels: idx = groupChannels.index(channels) if gListIndex > -1 and gListIndex != idx: continue isGroupChannel = gListIndex < 0 and len(channels) > 1 chs = [channels[0]] if isGroupChannel else channels for channel in chs: name = common.GetEncodeString(channel["display_name"]) if not isGroupChannel else common.GetEncodeString(channel.get("group_title", channel["display_name"])) plot = "" if meta is None else meta[channel["group_title"]]["overview"] if channel["group_title"] in meta else "" fanart = "" if meta is None else meta[channel["group_title"]]["fanarts"][0] if (channel["group_title"] in meta and len(meta[channel["group_title"]]["fanarts"]) > 0) else "" if isGroupChannel: name = '{0}'.format(name) chUrl = url try: image = channel['tvg_logo'] if meta is None else meta[channel["group_title"]]["poster"] if channel["group_title"] in meta else channel['tvg_logo'] except KeyError: image = "DefaultTVShows.png" AddDir(name ,url, 10, epg=epg, index=idx, iconimage=image, cacheMin=cache, plot=plot, fanart=fanart) else: chUrl = common.GetEncodeString(channel["url"]) image = channel.get("tvg_logo", channel.get("logo", "")) if epgDict: idx = None id = None if epgDict.get(u'name'): if name in epgDict.get(u'name'): idx = epgDict[u'name'].index(name) if image == "" and idx is not None: image = epgDict[u'data'][idx][1] t2len = 0 title2nd = '' edescr = '' next = False if idx is not None: #xbmc.log(str( epgDict.get('prg').get(epgDict[u'data'][idx][0]))) if epgDict.get('prg').get(epgDict[u'data'][idx][0]): for start,stop,title in epgDict.get('prg').get(epgDict[u'data'][idx][0]): stime = parser.parse(start) etime = parser.parse(stop) if stime <= dnow <= etime or next: ebgn = stime.astimezone(to_zone).strftime('%H:%M') eend = etime.astimezone(to_zone).strftime('%H:%M') if use_time == 'true': stmp = '%s-%s' % (ebgn, eend) t2len += (len(stmp) + 1) if not next: title2nd += ' [COLOR FF00BB66]%s[/COLOR]' % stmp else: title2nd += ' %s' % stmp title2nd += ' %s' % title t2len += (len(title) + 1) title2nd = title2nd.replace('"','`').replace('&',' & ') if not t2len: t2len = len(name) if not next: plot += '[B][COLOR FF0084FF]%s-%s[/COLOR]\n[COLOR FFFFFFFF]%s[/COLOR][/B]' % (ebgn, eend, title) name = '[B]%s[/B]\n%s' % (name.ljust(int(t2len * 1.65)), title2nd) next = True else: plot += '\n\n[B][COLOR FF0084FF]%s-%s[/COLOR]\n%s[/B]' % (ebgn, eend, title) next = False break elif dnow < stime and not next: break if logos is not None and logos != '' and image != "" and not image.startswith('http'): image = logos + image AddDir(name, chUrl, 3, image, epg=epg, index=-1, isFolder=False, IsPlayable=True, plot=plot, fanart=fanart) tmpList.append({"url": chUrl, "image": image, "name": name}) common.SaveList(tmpListFile, tmpList)