def SaveChannelsLogos(logosDir): if not os.path.exists(logosDir): os.makedirs(logosDir) newFilesList = [] list = common.GetListFromPlx(includeCatNames=False, fullScan=True) for item in list: try: logoFile = GetLogoFileName(item) if logoFile != "": newFilesList.append(logoFile) logoFile = format(os.path.join(logosDir, logoFile)) if not os.path.isfile(logoFile): #print "---------\n{0}\n{1}".format(item['name'], item['image']) urllib.urlretrieve(item['image'], logoFile) except Exception as e: print e for the_file in os.listdir(logosDir): file_path = os.path.join(logosDir, the_file) try: if os.path.isfile(file_path) and the_file not in newFilesList: os.unlink(file_path) except Exception as e: print e
def ListLive(name, iconimage=None): list = [] list1 = common.GetListFromPlx(filterCat=name) listIndex = 0 for item_data in list1: url = item_data['url'] image = item_data['image'] description = "" channelName = common.GetEncodeString(item_data['name']) background = None isTvGuide = False if item_data["type"] == 'video' or item_data["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) elif item_data["type"] == 'playlist': mode = 2 displayName = "[COLOR {0}][B][{1}][/B][/COLOR]".format( Addon.getSetting("catColor"), channelName) background = image else: continue if background is None or background == "": background = iconimage addDir(displayName, url, mode, image, description, channelName=channelName, background=background, isTvGuide=isTvGuide, listIndex=listIndex) list.append({ "url": url, "image": image, "name": channelName.decode("utf-8"), "type": item_data["type"] }) listIndex += 1 common.WriteList(tmpList, list) SetViewMode()
def GetFilmonChannelsList(url): list = [] try: list1 = common.GetListFromPlx(includeCatNames=False, fullScan=True) for item in list1: if item["type"] == 'video': url = item['url'] if url.find(AddonID) > 0: channel = re.compile('url=([0-9]*).*?mode=1(.*?)$',re.I+re.M+re.U+re.S).findall(url) if len(channel) > 0 and channel[0][0] != "" and channel[0][1] != "&ignorefilmonguide=1": list.append(int(channel[0][0])) except: pass return list
def SaveChannelsLogos(listsDir, mainPlxFile, groupName, logosDir): if not os.path.exists(logosDir): os.makedirs(logosDir) list = common.GetListFromPlx(includeCatNames=False, fullScan=True) for item in list: try: if item.has_key('image') and item[ 'image'] is not None and item['image'] != "": tvg_logo = hashlib.md5(item['name']).hexdigest() logoFile = "{0}.png".format(os.path.join(logosDir, tvg_logo)) if not os.path.isfile(logoFile): urllib.urlretrieve(item['image'], logoFile) except Exception as e: print e pass
def makeIPTVlist(iptvFile, portNum): list = common.GetListFromPlx(includeCatNames=False, fullScan=True) iptvList = '#EXTM3U\n' for item in list: url = item['url'] tvg_id = item['name'] view_name = item['name'] if url.find('plugin.video.pallive') > 0: urlParams = url[url.find('?'):] url = "http://localhost:{0}/{1}".format(portNum, urlParams) elif url.find('plugin.video.f4mTester') > 0: url = "http://localhost:{0}/{1}".format(portNum, url[url.find('?'):]) elif url.find('www.youtube.com') > 0: url = "http://localhost:{0}/?url={1}".format(portNum, url) elif url.find('?mode=2') > 0: url = "http://localhost:{0}/?url={1}".format( portNum, url.replace('?', '&')) elif url.find('?mode=3') > 0: url = "http://localhost:{0}/?url={1}".format( portNum, url[:url.find('?mode')]) elif url.find('?mode=4') > 0: url = myResolver.GetLivestreamTvFullLink(url[:url.find('?mode')]) if url == "down": view_name += " (down)" tvg_name = item['name'].replace(' ', '_') tvg_logo = GetLogoFileName(item) radio = ' radio="true"' if item['type'].lower() == "audio" else '' iptvList += '\n#EXTINF:-1 tvg-id="{0}" tvg-name="{1}" group-title="{2}" tvg-logo="{3}"{4},{5}\n{6}\n'.format( tvg_id, tvg_name, item['group'], tvg_logo, radio, view_name, url) f = open(iptvFile, 'w') f.write(iptvList) f.close()
def makeIPTVlist(listsDir, mainPlxFile, groupName, iptvFile, portNum): list = common.GetListFromPlx(includeCatNames=False, fullScan=True) changeLog = "" #M3Ulist = '#EXTM3U\n' iptvList = '#EXTM3U\n' for item in list: url = item['url'] tvg_id = item['name'] if url.find('plugin.video.israelive') > 0: urlParams = url[url.find('?'):] url = "http://localhost:{0}/{1}".format(portNum, urlParams) tvg_id = "fil-{0}".format(urlParams[5:urlParams.find('&')]) elif url.find('plugin.video.f4mTester') > 0: url = "http://localhost:{0}/{1}".format(portNum, url[url.find('?'):]) elif url.find('plugin.video.youtube') > 0: url = "http://localhost:{0}/?url=http://youtu.be/{1}".format( portNum, url[url.rfind('=') + 1:]) elif url.find('?mode=2') > 0: url = "http://localhost:{0}/?url={1}".format( portNum, url.replace('?', '&')) tvg_name = item['name'].replace(' ', '_') view_name = item['name'] tvg_logo = hashlib.md5(item['name']).hexdigest() radio = ' radio="true"' if item['type'].lower() == "audio" else '' #M3Ulist += '\n#EXTINF:-1 tvg-id="{0}" tvg-name="{1}" group-title="{2}" tvg-logo="{3}"{4},{5}\n{6}\n'.format(tvg_id, tvg_name, item['group'], tvg_logo, radio, view_name, url) iptvList += '\n#EXTINF:-1 tvg-id="{0}" tvg-name="{1}" group-title="{2}" tvg-logo="{3}.png"{4},{5}\n{6}\n'.format( tvg_id, tvg_name, item['group'], tvg_logo, radio, view_name, url) f = open(iptvFile, 'w') f.write("{0}\n".format(iptvList)) f.close()
def ListLive(name, iconimage=None): list = [] list1 = common.GetListFromPlx(filterCat=name) for item_data in list1: url = item_data['url'] image = item_data['image'] description = "" channelName = common.GetEncodeString(item_data['name']) background = None isTvGuide = False if item_data["type"] == 'video' or item_data["type"] == 'audio': channelName = "[COLOR yellow][B]{0}[/B][/COLOR]".format( channelName) displayName = channelName chNum = None filmon = False if url.find('plugin.video.israelive') > 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 chNum = itemMode[0][0] if itemMode[0][2] != "&ignorefilmonguide=1": filmon = True elif url.find('plugin.video.f4mTester') > 0: mode = 12 elif url.find('?mode=2') > 0: mode = 14 #url = url[:url.find('?mode')] else: mode = 10 displayName, description, background, isTvGuide = GetProgrammeDetails( channelName, chNum, filmon=filmon) elif item_data["type"] == 'playlist': mode = 2 displayName = "[COLOR blue][B][{0}][/B][/COLOR]".format( channelName) background = image else: continue if background is None or background == "": background = iconimage addDir(displayName, url, mode, image, description, channelName=channelName, background=background, isTvGuide=isTvGuide) list.append({ "url": url, "image": image, "name": channelName.decode("utf-8"), "type": item_data["type"] }) common.WriteList(tmpList, list) SetViewMode()