def SaveChannelsLogos(logosDir): if not os.path.exists(logosDir): os.makedirs(logosDir) newFilesList = [] channelsList = GetIptvChannels() for channel in channelsList: try: logoFile = common.GetLogoFileName(channel) if logoFile != "": newFilesList.append(logoFile) logoFile = os.path.join(logosDir, logoFile) if not os.path.isfile(logoFile): logo = channel['image'] if logo.startswith('http'): urllib.urlretrieve(logo, logoFile) else: shutil.copyfile(logo, 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 SaveChannelsLogos(logosDir): if not os.path.exists(logosDir): os.makedirs(logosDir) forcePng = GetIptvType() == 0 ua = UA.GetUA() newFilesList = [] channelsList = GetIptvChannels() for channel in channelsList: try: logoFile = common.GetLogoFileName(channel) if logoFile != "": if forcePng: logoFile = '{0}.png'.format(logoFile[:logoFile.rfind('.')]) newFilesList.append(logoFile) logoFile = os.path.join(logosDir, logoFile) if not os.path.isfile(logoFile): logo = channel['image'] if logo.startswith('http'): threading.Thread(target=SaveChannelBackground, args=(logo, logoFile, ua, )).start() else: shutil.copyfile(logo, logoFile) except Exception as ex: xbmc.log("{0}".format(ex), 3) 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 ex: xbmc.log("{0}".format(ex), 3)
def makeIPTVlist(iptvFile): first21 = True iptvList = '#EXTM3U\n' channelsList = GetIptvChannels() portNum = common.GetLivestreamerPort() for item in channelsList: try: url = item['url'] tvg_id = item['name'] view_name = item['name'] if url.find('plugin.video.f4mTester') > 0: url = "http://localhost:{0}/{1}".format( portNum, url[url.find('?'):]) elif url.find('www.youtube.com') > 0 or url == "BB": url = "http://localhost:{0}/?url={1}".format(portNum, url) else: matches = re.compile('^(.*?)[\?|&]mode=(\-?[0-9]+)(.*?)$', re.I + re.M + re.U + re.S).findall(url) if len(matches) > 0: url = matches[0][0] mode = matches[0][1] if len(matches[0]) > 2: url += matches[0][2] if mode == '1': url = "http://localhost:{0}/{1}&mode={2}".format( portNum, url[url.find('?'):], mode) elif mode == '3': url = "http://localhost:{0}/?url={1}".format( portNum, url) elif mode == '-3' or mode == '0' or mode == '7' or mode == '16' or mode == '20' or mode == '21' or mode == '22' or mode == '23' or mode == '24' or mode == '25': if mode == '21': if first21: first21 = False else: url += ";s" url = myResolver.Resolve(url, mode) if url is None or url == "down": continue elif mode == '10' or mode == '13': continue else: url = "http://localhost:{0}/?url={1}&mode={2}".format( portNum, url.replace('?', '&'), mode) tvg_name = item['name'].replace(' ', '_') tvg_logo = common.GetLogoFileName(item) radio = ' radio="true"' if item['type'].lower() == "audio" else '' group = ' group-title="{0}"'.format( item['group']) if item.has_key('group') else '' iptvList += '\n#EXTINF:-1 tvg-id="{0}" tvg-name="{1}"{2} tvg-logo="{3}"{4},{5}\n{6}\n'.format( tvg_id, tvg_name, group, tvg_logo, radio, view_name, url) except Exception as e: print e f = open(iptvFile, 'w') f.write(iptvList) f.close()
def makeIPTVlist(iptvFile): iptvType = GetIptvType() iptvList = '#EXTM3U\n' channelsList = GetIptvChannels() portNum = common.GetLivestreamerPort() hostName = '127.0.0.1' for item in channelsList: try: tvg_id = item['name'] view_name = item['name'] tvg_name = item['name'].replace(' ', '_') tvg_logo = item[ 'image'] if iptvType > 1 else common.GetLogoFileName(item) if iptvType == 0: tvg_logo = tvg_logo[:tvg_logo.rfind('.')] radio = ' radio="true"' if item['type'].lower() == "audio" else '' group = ' group-title="{0}"'.format( item['group']) if item.has_key('group') else '' url = item['url'] if "mode=" in url: if KodiPlayer: url = "http://{0}:{1}/?url=plugin://plugin.video.israelive/&channelid={2}".format( hostName, portNum, item['id']) if item.get('catid') == 'Favourites': url += '&mode=11' else: url += '&mode=10' else: regex = re.compile('[\?|&]mode=(\-?[0-9]+)', re.I + re.M + re.U + re.S) matches = regex.findall(url) if len(matches) > 0: url = regex.sub('', url).strip() mode = matches[0] if myResolver is not None and (mode == '-3' or mode == '0' or mode == '16' or mode == '34'): url = myResolver.Resolve(url, mode) if url is None: continue elif mode == '13': continue else: url = "http://{0}:{1}/?url={2}&mode={3}".format( hostName, portNum, urllib.quote(url.replace('?', '&')), mode) iptvList += '\n#EXTINF:-1 tvg-id="{0}" tvg-name="{1}"{2} tvg-logo="{3}"{4},{5}\n{6}\n'.format( tvg_id, tvg_name, group, tvg_logo, radio, view_name, url) except Exception as ex: xbmc.log("{0}".format(ex), 3) with open(iptvFile, 'w') as f: f.write(iptvList)
def makeIPTVlist(iptvFile): iptvType = GetIptvType() iptvList = '#EXTM3U\n' channelsList = GetIptvChannels() portNum = common.GetLivestreamerPort() for item in channelsList: try: url = item['url'] tvg_id = item['name'] view_name = item['name'] matches = re.compile('^(.*?)[\?|&]mode=(\-?[0-9]+)(.*?)$', re.I + re.M + re.U + re.S).findall(url) if len(matches) > 0: url = matches[0][0] mode = matches[0][1] if len(matches[0]) > 2: url += matches[0][2] if mode == '-3' or mode == '0' or mode == '16' or mode == '34': url = myResolver.Resolve(url, mode) if url is None or url == "down": continue elif mode == '13': continue else: url = "http://localhost:{0}/?url={1}&mode={2}".format( portNum, urllib.quote(url.replace('?', '&')), mode) tvg_name = item['name'].replace(' ', '_') tvg_logo = item[ 'image'] if iptvType > 1 else common.GetLogoFileName(item) if iptvType == 0: tvg_logo = tvg_logo[:tvg_logo.rfind('.')] radio = ' radio="true"' if item['type'].lower() == "audio" else '' group = ' group-title="{0}"'.format( item['group']) if item.has_key('group') else '' iptvList += '\n#EXTINF:-1 tvg-id="{0}" tvg-name="{1}"{2} tvg-logo="{3}"{4},{5}\n{6}\n'.format( tvg_id, tvg_name, group, tvg_logo, radio, view_name, url) except Exception as ex: xbmc.log("{0}".format(ex), 3) with open(iptvFile, 'w') as f: f.write(iptvList)