def getVideos(self, videoUrl): HTTP_HEADER = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0', 'Accept': 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Encoding': 'gzip, deflate' } http_params = { 'header': HTTP_HEADER, 'with_metadata': True, 'cookiefile': self.COOKIE_FILE, 'use_cookie': True, 'load_cookie': True, 'save_cookie': True } printDBG(' -----------> URL = ' + videoUrl) urlTab = [] referer = self.MAIN_URL if '%%%' in videoUrl: videoUrl, referer, code = videoUrl.split('%%%', 2) if not videoUrl.startswith('http'): videoUrl = self.MAIN_URL + videoUrl if 'watch/?v' in videoUrl: #try: printDBG('try resolve url0: ' + videoUrl) urlTab = self.parserVIDSTREAM(videoUrl, 'egy') #except Exception as e: #printDBG('ERREUR:'+str(e)) else: addParams0 = dict(self.defaultParams) addParams0['header']['Referer'] = referer http_params['header']['Referer'] = referer sts, data = self.cm.getPage(self.MAIN_URL + '/' + atob(code), http_params) printDBG('data_meta0=' + str(data.meta)) GetIPTVSleep().Sleep(5) sts, data = self.cm.getPage(videoUrl, http_params) if sts: printDBG('data=' + str(data)) printDBG('data_meta1=' + str(data.meta)) if False: URL = data.meta['location'] VID_URL = urlparser.getDomain(URL, onlyDomain=False) if VID_URL.endswith('/'): VID_URL = VID_URL[:-1] self.VID_URL = VID_URL printDBG('HOST vstream = ' + self.VID_URL) try: printDBG('try resolve url1: ' + URL) urlTab = self.parserVIDSTREAM(URL) except Exception as e: printDBG('ERREUR:' + str(e)) return urlTab
def getLinksForVideo(self, cItem): try: urlTab = [] url = cItem['url'] baseUrl = strwithmeta(url) HTTP_HEADER = self.cm.getDefaultHeader(browser='chrome') referer = baseUrl.meta.get('Referer') if referer: HTTP_HEADER['Referer'] = referer urlParams = {'header':HTTP_HEADER} sts, data = self.cm.getPage(baseUrl, urlParams) if not sts: return [] if data == '': return [] cUrl = self.cm.meta['url'] f = ph.find(data, zlib.decompress(base64.b64decode('eJwryEmsTC2yBwALugLN')), '&', flags=0)[1] if not f: f = cUrl.split(zlib.decompress(base64.b64decode('eJwryEmsTC2yBwALugLN')), 1)[-1].rsplit('&', 1)[0] if not f: f = ph.find(data, zlib.decompress(base64.b64decode('eJwryEmsTC2yBwALugLN')), '&', flags=0)[1] if not f: return [] url = zlib.decompress(base64.b64decode('eJwVylsKgCAQBdDd+NljAdJSZMJrRqbDOEQh7r36PZzx2j2IEz0Qt0HdfaaBIy9t6qYqidrJINOaUDNxjeWH72soclqPemhhIwgQgdg29xc2Sx/I')).format(f, urllib.quote(baseUrl)) sts, data = self.cm.getPage(self.cm.getFullUrl(url, cUrl)) if not sts: return [] if data == '': return [] meta = {'Referer':cUrl, 'Origin':urlparser.getDomain(baseUrl, False)[:-1], 'User-Agent':HTTP_HEADER['User-Agent']} hlsMeta = MergeDicts(meta, {'iptv_proto':'m3u8'}) data = ph.find(data, ('<video_sources', '>'), '</video_sources>', flags=0)[1] if data == '': return [] data = ph.findall(data, ('<video_source', '>'), '</video_source>') if data == '': return [] for item in data: url = self.cm.getFullUrl(ph.clean_html(item), cUrl) if not url: continue if 'video/mp4' in item: width = ph.getattr(item, 'width') height = ph.getattr(item, 'height') name = ph.getattr(item, 'name') url = urlparser.decorateUrl(url, meta) urlTab.append({'name':'{0} - {1}x{2}'.format(name, width, height), 'url':url}) elif 'mpegurl' in item: url = urlparser.decorateUrl(url, hlsMeta) tmpTab = getDirectM3U8Playlist(url, checkExt=False, checkContent=True) urlTab.extend(tmpTab) urlTab.reverse() if cItem['category'] != 'list_third': self.susmrgts('2', '12', cItem['tps'], cItem['url'], cItem['title'], cItem['icon'], cItem['desc']) return urlTab except Exception: return []
def download_img(self, img_url, filename): # if at start there was NOT enough space on disk # new icon will not be downloaded if False == self.downloadNew: return False if len(self.currDownloadDir) < 4: printDBG('IconMenager.download_img: wrong path for IPTVCache') return False path = self.currDownloadDir + '/' # if at start there was enough space on disk # we will check if we still have free space if 0 >= self.checkSpace: printDBG('IconMenager.download_img: checking space on device') if not iptvtools_FreeSpace(path, 10): printDBG( 'IconMenager.download_img: not enough space for new icons, new icons will not be downloaded any more' ) self.downloadNew = False return False else: # for another 50 check again self.checkSpace = 50 else: self.checkSpace -= 1 file_path = "%s%s" % (path, filename) params = {} #{'maintype': 'image'} if config.plugins.iptvplayer.allowedcoverformats.value != 'all': subtypes = config.plugins.iptvplayer.allowedcoverformats.value.split( ',') #params['subtypes'] = subtypes params['check_first_bytes'] = [] if 'jpeg' in subtypes: params['check_first_bytes'].extend(['\xFF\xD8', '\xFF\xD9']) if 'png' in subtypes: params['check_first_bytes'].append('\x89\x50\x4E\x47') if 'gif' in subtypes: params['check_first_bytes'].extend(['GIF87a', 'GIF89a']) else: params['check_first_bytes'] = [ '\xFF\xD8', '\xFF\xD9', '\x89\x50\x4E\x47', 'GIF87a', 'GIF89a' ] if img_url.endswith('need_resolve.jpeg'): domain = urlparser.getDomain(img_url) if domain.startswith('www.'): domain = domain[4:] # link need resolve, at now we will have only one img resolver, # we should consider add img resolver to urlparser if more will be needed sts, data = self.cm.getPage(img_url) if not sts: return False if 'imdb.com' in domain: img_url = self.cm.ph.getDataBeetwenMarkers( data, 'class="poster"', '</div>')[1] img_url = self.cm.ph.getSearchGroups(img_url, 'src="([^"]+?)"')[0] if not self.cm.isValidUrl(img_url): img_url = self.cm.ph.getDataBeetwenMarkers( data, 'class="slate"', '</div>')[1] img_url = self.cm.ph.getSearchGroups( img_url, 'src="([^"]+?)"')[0] elif 'bs.to' in domain: baseUrl = img_url img_url = self.cm.ph.getSearchGroups( data, '(<img[^>]+?alt="Cover"[^>]+?>)')[0] img_url = self.cm.ph.getSearchGroups(img_url, 'src="([^"]+?)"')[0] if img_url.startswith('/'): img_url = urljoin(baseUrl, img_url) elif 'watchseriesmovie.' in domain or 'gowatchseries' in domain: baseUrl = img_url img_url = self.cm.ph.getDataBeetwenNodes( data, ('<div', '>', 'picture'), ('</div', '>'), False)[1] img_url = self.cm.ph.getSearchGroups( img_url, '<img[^>]+?src="([^"]+?)"')[0] if img_url.startswith('/'): img_url = urljoin(baseUrl, img_url) elif 'classiccinemaonline.com' in domain: baseUrl = img_url img_url = self.cm.ph.getDataBeetwenNodes( data, ('<center>', '</center>', '<img'), ('<', '>'))[1] img_url = self.cm.ph.getSearchGroups( img_url, '<img[^>]+?src="([^"]+?\.(:?jpe?g|png)(:?\?[^"]+?)?)"')[0] if img_url.startswith('/'): img_url = urljoin(baseUrl, img_url) elif 'nasze-kino.tv' in domain: baseUrl = img_url img_url = self.cm.ph.getDataBeetwenNodes( data, ('<div', '>', 'single-poster'), ('<img', '>'))[1] img_url = self.cm.ph.getSearchGroups( img_url, '<img[^>]+?src="([^"]+?\.(:?jpe?g|png)(:?\?[^"]+?)?)"')[0] if img_url.startswith('/'): img_url = urljoin(baseUrl, img_url) elif 'allbox.' in domain: baseUrl = img_url img_url = self.cm.ph.getDataBeetwenNodes( data, ('<img', '>', '"image"'), ('<', '>'))[1] if img_url != '': img_url = self.cm.ph.getSearchGroups( img_url, '<img[^>]+?src="([^"]+?\.(:?jpe?g|png)(:?\?[^"]+?)?)"' )[0] else: img_url = self.cm.ph.getSearchGroups( data, 'url\(([^"^\)]+?\.(:?jpe?g|png)(:?\?[^"^\)]+?)?)\);' )[0].strip() if img_url.startswith('/'): img_url = urljoin(baseUrl, img_url) elif 'efilmy.' in domain: baseUrl = img_url img_url = self.cm.ph.getDataBeetwenNodes( data, ('<img', '>', 'align="left"'), ('<', '>'))[1] img_url = self.cm.ph.getSearchGroups( img_url, '<img[^>]+?src="([^"]+?\.(:?jpe?g|png)(:?\?[^"]+?)?)"')[0] img_url = self.cm.getFullUrl(img_url, baseUrl) elif 'bajeczki.org' == domain: baseUrl = img_url img_url = self.cm.ph.getDataBeetwenNodes( data, ('<img', '>', 'wp-post-image'), ('<', '>'))[1] if img_url != '': img_url = self.cm.ph.getSearchGroups( img_url, '<img[^>]+?src="([^"]+?\.(:?jpe?g|png)(?:\?[^"]+?)?)"' )[0] if img_url.startswith('/'): img_url = urljoin(baseUrl, img_url) elif '7tv.de' == domain: data = ph.find(data, ('<meta', '>', 'thumbnail_image_url'))[1] img_url = ph.getattr(data, 'content') if not self.cm.isValidUrl(img_url): return False else: img_url = strwithmeta(img_url) if img_url.meta.get('icon_resolver', None) is not None: try: img_url = img_url.meta['icon_resolver'](self.cm, img_url) except Exception: printExc() return False if not self.cm.isValidUrl(img_url): return False return self.cm.saveWebFile(file_path, img_url, params)['sts']
return urlTab def getVideos(self, videoUrl): printDBG(' -----------> URL = ' + videoUrl) urlTab = [] if not videoUrl.startswith('http'): videoUrl = self.MAIN_URL + videoUrl if 'watch/?v' in videoUrl: try: urlTab = self.parserVIDSTREAM(videoUrl, 'egy') except Exception, e: printDBG('ERREUR:' + str(e)) else: sts, data = self.getPage(videoUrl) if sts: URL = data.meta['location'] VID_URL = urlparser.getDomain(URL, onlyDomain=False) if VID_URL.endswith('/'): VID_URL = VID_URL[:-1] self.VID_URL = VID_URL printDBG('HOST vstream = ' + self.VID_URL) try: urlTab = self.parserVIDSTREAM(URL) except Exception, e: printDBG('ERREUR:' + str(e)) return urlTab def getArticle(self, cItem): printDBG("EgyBest.getArticleContent [%s]" % cItem) desc = '' retTab = [] otherInfo = {}
def pro_listing(self, cItem): image = cItem['icon'] EPG_ = cItem.get('EPG', False) import_ = cItem.get('import_', '') nb_list = len(self.datas) if EPG_: desc_tmdb = get_desc(self.getArticle(cItem)) else: desc_tmdb = '' for elm in self.datas: sTitle = elm['sTitle'] sDescription = elm['sDescription'] sSiteName = elm['sSiteName'] sHosterIdentifier = elm['sHosterIdentifier'] sFunction = elm['sFunction'] sSiteUrl = elm['sSiteUrl'] sMediaUrl = elm['sMediaUrl'] sMeta = elm['sMeta'] argv = elm['argv'] #sIcon = elm['sIcon'] sThumbnail = elm['sThumbnail'] sFileName = elm['sFileName'] Year = elm['Year'] sMeta = str(sMeta).replace('1', 'movie').replace( '2', 'tvshow').replace('3', 'collection').replace( '4', 'anime').replace('7', 'person').replace('8', 'network') if sMeta in [ 'tvshow', 'movie', 'collection', 'anime', 'person', 'network' ]: EPG = True else: EPG = False if sFunction.lower() in self.fncs_search: EPG = False sThumbnail = sThumbnail.replace( 'special://home/addons/plugin.video.vstream/resources/', 'file:///usr/lib/enigma2/python/Plugins/Extensions/IPTVPlayer/tsiplayer/addons/resources/' ) image = sThumbnail sTitle = replaceColors(str(sTitle)) if desc_tmdb != '': sDescription = desc_tmdb else: sDescription = replaceColors(str(sDescription)).strip() sDescription = sDescription.replace('[I]', '').replace('[/I]', '') if str(Year).strip() != '': if sDescription == '': sDescription = tscolor( '\c00????00') + 'Year: ' + tscolor( '\c00??????') + str(Year) else: sDescription = sDescription + '\n' + tscolor( '\c00????00') + 'Year: ' + tscolor( '\c00??????') + str(Year) if ('Outils' != sTitle.strip()) and ( 'Mes comptes' != sTitle.strip()) and ('Marque-pages' != sTitle.strip()): if sFunction == 'DoNothing': if (nb_list == 1) and (sTitle.strip() == ''): sTitle = tscolor('\c00??8888') + 'No informations' self.addMarker({ 'title': sTitle, 'desc': '', 'icon': image }) elif (sFunction == 'play') or ((sSiteName == 'radio') and (sFunction == '')): if (sMediaUrl != ''): url = sMediaUrl else: url = sSiteUrl if (sHosterIdentifier == 'lien_direct'): host = 'direct' else: host = 'none' host = 'tshost' #if (sSiteName=='radio'): # url = sMediaUrl #host = 'direct' color = '' host_ = urlparser.getDomain(url).replace('www.', '') if sHosterIdentifier == 'lien_direct': color = tscolor('\c0060??60') elif ts_urlparser().checkHostSupportbyname(host_): color = tscolor('\c0090??20') elif ts_urlparser().checkHostNotSupportbyname(host_): color = tscolor('\c00??3030') elif ts_urlparser().checkHostSupportbyname_e2iplayer( host_): color = tscolor('\c00????60') sTitle = '| ' + sTitle + ' | ' + color + urlparser.getDomain( url).replace('www.', '').title() sDescription = tscolor('\c00????00') + 'Host: ' + tscolor( '\c00??????') + sHosterIdentifier.title( ) + '\n' + sDescription self.addVideo({ 'import': cItem['import'], 'good_for_fav': True, 'category': 'video', 'url': url, 'sHosterIdentifier': sHosterIdentifier, 'title': sTitle, 'desc': sDescription, 'icon': image, 'hst': host, 'gnr': 1 }) printDBG( str({ 'import': cItem['import'], 'good_for_fav': True, 'category': 'video', 'url': url, 'sHosterIdentifier': sHosterIdentifier, 'title': sTitle, 'desc': sDescription, 'icon': image, 'hst': host, 'gnr': 1 })) elif sTitle != 'None': dir = { 'good_for_fav': True, 'EPG': EPG, 'sMeta': sMeta, 'import': cItem['import'], 'sFileName': sFileName, 'Year': Year, 'category': 'host2', 'title': sTitle, 'sFunction': sFunction, 'sSiteUrl': sSiteUrl, 'desc': sDescription, 'sSiteName': sSiteName, 'argv': argv, 'icon': image, 'mode': '10', 'import_': import_, 'hst': 'tshost' } printDBG(dir) self.addDir(dir)
def download_img(self, img_url, filename): # if at start there was NOT enough space on disk # new icon will not be downloaded if False == self.downloadNew: return False if len(self.currDownloadDir) < 4: printDBG('IconMenager.download_img: wrong path for IPTVCache') return False path = self.currDownloadDir + '/' # if at start there was enough space on disk # we will check if we still have free space if 0 >= self.checkSpace: printDBG('IconMenager.download_img: checking space on device') if not iptvtools_FreeSpace(path, 10): printDBG( 'IconMenager.download_img: not enough space for new icons, new icons will not be downloaded any more' ) self.downloadNew = False return False else: # for another 50 check again self.checkSpace = 50 else: self.checkSpace -= 1 file_path = "%s%s" % (path, filename) params = {'maintype': 'image'} if config.plugins.iptvplayer.allowedcoverformats.value != 'all': params[ 'subtypes'] = config.plugins.iptvplayer.allowedcoverformats.value.split( ',') params['check_first_bytes'] = [] if 'jpeg' in params['subtypes']: params['check_first_bytes'].extend(['\xFF\xD8', '\xFF\xD9']) if 'png' in params['subtypes']: params['check_first_bytes'].append('\x89\x50\x4E\x47') if 'gif' in params['subtypes']: params['check_first_bytes'].extend(['GIF87a', 'GIF89a']) else: params['check_first_bytes'] = [ '\xFF\xD8', '\xFF\xD9', '\x89\x50\x4E\x47', 'GIF87a', 'GIF89a' ] if img_url.endswith('need_resolve.jpeg' ) and 'imdb.com' in urlparser.getDomain(img_url): # link need resolve, at now we will have only one img resolver, # we should consider add img resolver to urlparser if more will be needed sts, data = self.cm.getPage(img_url) if not sts: return False img_url = self.cm.ph.getDataBeetwenMarkers(data, 'class="poster"', '</div>')[1] img_url = self.cm.ph.getSearchGroups(img_url, 'src="([^"]+?)"')[0] if not self.cm.isValidUrl(img_url): img_url = self.cm.ph.getDataBeetwenMarkers( data, 'class="slate"', '</div>')[1] img_url = self.cm.ph.getSearchGroups(img_url, 'src="([^"]+?)"')[0] if not self.cm.isValidUrl(img_url): return False else: img_url = strwithmeta(img_url) if img_url.meta.get('icon_resolver', None) is not None: try: img_url = img_url.meta['icon_resolver'](self.cm, img_url) except Exception: printExc() return False if not self.cm.isValidUrl(img_url): return False return self.cm.saveWebFile(file_path, img_url, params)['sts']