def get_idbyname(self, name, year='', mediaType='movie', page=1): # On enleve le contenu entre paranthese. try: name = name.split('(')[0] except: pass if year: term = QuotePlus(name) + '&year=' + year else: term = QuotePlus(name) meta = self._call('search/' + str(mediaType), 'query=' + term + '&page=' + str(page)) # si pas de résultat avec l'année, on teste sans l'année if 'total_results' in meta and meta['total_results'] == 0 and year: meta = self.search_movie_name(name, '') # cherche 1 seul resultat if 'total_results' in meta and meta['total_results'] != 0: tmdb_id = meta['results'][0]['id'] return tmdb_id else: return False return False
def search_tvshow_name(self, name, year='', page=1, genre=''): if year: term = QuotePlus(name) + '&year=' + year else: term = QuotePlus(name) meta = self._call('search/tv', 'query=' + term + '&page=' + str(page)) if 'errors' not in meta and 'status_code' not in meta: # si pas de résultat avec l'année, on teste sans l'année if 'total_results' in meta and meta['total_results'] == 0 and year: meta = self.search_tvshow_name(name, '') # cherche 1 seul resultat if 'total_results' in meta and meta['total_results'] != 0: movie = '' # s'il n'y en a qu'un, c'est le bon if meta['total_results'] == 1: movie = meta['results'][0] else: # premiere boucle, recherche la correspondance parfaite sur le nom for searchMovie in meta['results']: if genre == '' or genre in searchMovie['genre_ids']: movieName = searchMovie['name'] if self._clean_title( movieName) == self._clean_title(name): movie = searchMovie break # sinon, hors documentaire et année proche if not movie: for searchMovie in meta['results']: if genre and genre in searchMovie['genre_ids']: # controle supplémentaire sur l'année meme si déjà dans la requete if year: if 'release_date' in searchMovie and searchMovie[ 'release_date']: release_date = searchMovie[ 'release_date'] yy = release_date[:4] if int(year) - int(yy) > 1: continue # plus de deux ans d'écart, c'est pas bon movie = searchMovie break # Rien d'interessant, on prend le premier if not movie: movie = meta['results'][0] # recherche de toutes les infos tmdb_id = movie['id'] meta = self.search_tvshow_id(tmdb_id) else: meta = {} return meta
def get_idbyname(self, name, year='', mediaType='movie', page=1): #Pour les series il faut enlever le numero de l episode et la saison. if mediaType == "tv": m = re.search( '(?i)(?:^|[^a-z])((?:E|(?:\wpisode\s?))([0-9]+(?:[\-\.][0-9\?]+)*))', name) m1 = re.search('(?i)( s(?:aison +)*([0-9]+(?:\-[0-9\?]+)*))', name) name = name.replace(m.group(1), '').replace(m1.group(1), '').replace('+', ' ') #On enleve le contenu entre paranthese. try: name = name.split('(')[0] except: pass if year: term = QuotePlus(name) + '&year=' + year else: term = QuotePlus(name) meta = self._call('search/' + str(mediaType), 'query=' + term + '&page=' + str(page)) # si pas de résultat avec l'année, on teste sans l'année if 'total_results' in meta and meta['total_results'] == 0 and year: meta = self.search_movie_name(name, '') # cherche 1 seul resultat if 'total_results' in meta and meta['total_results'] != 0: if meta['total_results'] > 1: listitems = [] listitem = xbmcgui.ListItem() # boucle commit for i in meta['results']: icon = self.fanart + str(i['backdrop_path']) login = i["name"] desc = i["overview"] listitem = xbmcgui.ListItem(label=login, label2=desc) listitem.setArt({'icon': icon, 'thumb': icon}) listitem.setUniqueIDs({'tmdb': i['id']}, "tmdb") listitems.append(listitem) tmdb_id = self.Box(listitems) else: tmdb_id = meta['results'][0]['id'] return tmdb_id else: return False return False
def get_idbyname(self, name, year='', mediaType='movie', page=1): #Pour les series il faut enlever le numero de l episode et la saison. if mediaType == "tv": m = re.search( '(?i)(?:^|[^a-z])((?:E|(?:\wpisode\s?))([0-9]+(?:[\-\.][0-9\?]+)*))', name) m1 = re.search('(?i)( s(?:aison +)*([0-9]+(?:\-[0-9\?]+)*))', name) name = name.replace(m.group(1), '').replace(m1.group(1), '').replace('+', ' ') #On enleve le contenu entre paranthese. try: name = name.split('(')[0] except: pass if year: term = QuotePlus(name) + '&year=' + year else: term = QuotePlus(name) meta = self._call('search/' + str(mediaType), 'query=' + term + '&page=' + str(page)) # si pas de résultat avec l'année, on teste sans l'année if 'total_results' in meta and meta['total_results'] == 0 and year: meta = self.search_movie_name(name, '') # cherche 1 seul resultat if 'total_results' in meta and meta['total_results'] != 0: if meta['total_results'] > 1: qua = [] url = [] for aEntry in meta['results']: url.append(aEntry["id"]) qua.append(aEntry['name']) #Affichage du tableau tmdb_id = dialog().VSselectqual(qua, url) else: tmdb_id = meta['results'][0]['id'] return tmdb_id else: return False return False
def insert_resume(self, meta): title = self.str_conv(meta['title']) site = QuotePlus(meta['site']) point = meta['point'] total = meta['total'] ex = "DELETE FROM resume WHERE title = '%s'" % title try: self.dbcur.execute(ex) except Exception: VSlog('SQL ERROR - ' + ex) pass try: ex = 'INSERT INTO resume (title, hoster, point, total) VALUES (?, ?, ?, ?)' self.dbcur.execute(ex, (title, site, point, total)) self.db.commit() except Exception as e: if 'no such column' in str(e) or 'no column named' in str( e) or 'no such table' in str(e): self._create_tables('resume') VSlog('Table recreated : resume') # Deuxieme tentative self.dbcur.execute(ex, (title, site, point, total)) self.db.commit() else: VSlog('SQL ERROR INSERT : %s' % e)
def del_bookmark(self, sSiteUrl='', sMovieTitle='', sCat='', sAll=False): sql_delete = None # Tous supprimer if sAll: sql_delete = 'DELETE FROM favorite;' # Supprimer un bookmark selon son titre elif sMovieTitle: siteUrl = QuotePlus(sSiteUrl) title = self.str_conv(sMovieTitle) title = title.replace("'", r"''") sql_delete = "DELETE FROM favorite WHERE siteurl = '%s' AND title = '%s'" % ( siteUrl, title) # Supprimer un bookmark selon son url elif sSiteUrl: siteUrl = QuotePlus(sSiteUrl) sql_delete = "DELETE FROM favorite WHERE siteurl = '%s'" % siteUrl # Supprimer toute une catégorie elif sCat: catList = ('1', '7') # films, saga if sCat not in catList: catList = ('2', '3', '4', '8') if sCat not in catList: catList = ('0', sCat) sql_delete = "DELETE FROM favorite WHERE cat in %s" % str(catList) if sql_delete: from Plugins.Extensions.IPTVPlayer.tsiplayer.addons.resources.lib.gui.gui import cGui try: self.dbcur.execute(sql_delete) self.db.commit() update = self.db.total_changes if not update and sSiteUrl and sMovieTitle: # si pas trouvé, on essaie sans le titre, seulement l'URL return self.del_bookmark(sSiteUrl) dialog().VSinfo(addon().VSlang(30044)) cGui().updateDirectory() return True except Exception: VSlog('SQL ERROR %s' % sql_delete) return False
def insert_download(self, meta): title = self.str_conv(meta['title']) url = QuotePlus(meta['url']) sIcon = QuotePlus(meta['icon']) sPath = meta['path'] ex = 'INSERT INTO download (title, url, path, cat, icon, size, totalsize, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?)' try: self.dbcur.execute( ex, (title, url, sPath, meta['cat'], sIcon, '', '', 0)) self.db.commit() VSlog('SQL INSERT download Successfully') dialog().VSinfo(addon().VSlang(30042), meta['title']) except Exception: VSlog('SQL ERROR INSERT into download') pass
def __createItemUrl(self, oGuiElement, oOutputParameterHandler=''): if (oOutputParameterHandler == ''): oOutputParameterHandler = cOutputParameterHandler() sParams = oOutputParameterHandler.getParameterAsUri() sPluginPath = cPluginHandler().getPluginPath() if (len(oGuiElement.getFunction()) == 0): sItemUrl = '%s?site=%s&title=%s&%s' % ( sPluginPath, oGuiElement.getSiteName(), QuotePlus(oGuiElement.getCleanTitle()), sParams) else: sItemUrl = '%s?site=%s&function=%s&title=%s&%s' % ( sPluginPath, oGuiElement.getSiteName(), oGuiElement.getFunction(), QuotePlus(oGuiElement.getCleanTitle()), sParams) return sItemUrl
def search_collection_name(self, name): name = re.sub(" +", " ", name) # nettoyage du titre term = QuotePlus(name) meta = self._call('search/collection', 'query=' + term) if 'errors' not in meta and 'status_code' not in meta: # cherche 1 seul resultat if 'total_results' in meta and meta['total_results'] != 0: collection = '' # s'il n'y en a qu'un, c'est le bon if meta['total_results'] == 1: collection = meta['results'][0] else: # premiere boucle, recherche la correspondance parfaite sur le nom for searchCollec in meta['results']: cleanTitleTMDB = self._clean_title( searchCollec['name']) cleanTitleSearch = self._clean_title(name) if not cleanTitleSearch.endswith('saga'): cleanTitleSearch += 'saga' if cleanTitleTMDB == cleanTitleSearch: collection = searchCollec break elif (cleanTitleSearch + 'saga') == cleanTitleTMDB: collection = searchCollec break # sinon, le premier qui n'est pas du genre animation if not collection: for searchCollec in meta['results']: if 'animation' not in searchCollec['name']: collection = searchCollec break # Rien d'interessant, on prend le premier if not collection: collection = meta['results'][0] meta = collection tmdb_id = collection['id'] meta['tmdb_id'] = tmdb_id # recherche de toutes les infos meta = self.search_collection_id(tmdb_id) else: meta = {} return meta
def reset_download(self, meta): url = QuotePlus(meta['url']) sql_select = "UPDATE download SET status = '0' WHERE status = '2' AND url = '%s'" % url try: self.dbcur.execute(sql_select) self.db.commit() return False, False except Exception: VSlog('SQL ERROR %s' % sql_select) return False, False
def del_resume(self, meta): title = QuotePlus(meta['title']) sql_select = "DELETE FROM resume WHERE title = '%s'" % title try: self.dbcur.execute(sql_select) self.db.commit() return False, False except Exception: VSlog('SQL ERROR %s' % sql_select) return False, False
def get_resume(self, meta): # title = self.str_conv(meta['title']) site = QuotePlus(meta['site']) sql_select = "SELECT * FROM resume WHERE hoster = '%s'" % site try: self.dbcur.execute(sql_select) # matchedrow = self.dbcur.fetchone() matchedrow = self.dbcur.fetchall() return matchedrow except Exception: VSlog('SQL ERROR %s' % sql_select) return None
def insert_watched(self, meta): title = meta['title'] if not title: return site = QuotePlus(meta['site']) ex = 'INSERT INTO watched (title, site) VALUES (?, ?)' try: self.dbcur.execute(ex, (title, site)) self.db.commit() VSlog('SQL INSERT watched Successfully') except Exception: VSlog('SQL ERROR INSERT watched : title = %s, site = %s' % (title, site)) pass
def get_download(self, meta=''): if meta == '': sql_select = 'SELECT * FROM download' else: url = QuotePlus(meta['url']) sql_select = "SELECT * FROM download WHERE url = '%s' AND status = '0'" % url try: self.dbcur.execute(sql_select) matchedrow = self.dbcur.fetchall() return matchedrow except Exception: VSlog('SQL ERROR %s' % sql_select) return None
def del_download(self, meta): if len(meta['url']) > 1: url = QuotePlus(meta['url']) sql_select = "DELETE FROM download WHERE url = '%s'" % url elif len(meta['path']) > 1: path = meta['path'] sql_select = "DELETE FROM download WHERE path = '%s'" % path else: return try: self.dbcur.execute(sql_select) self.db.commit() return False, False except Exception: VSlog('SQL ERROR %s' % sql_select) return False, False
def insert_viewing(self, meta): if not 'title' in meta: return if not 'siteurl' in meta: return title = self.str_conv(meta['title']) titleWatched = self.str_conv(meta['titleWatched']) siteurl = QuotePlus(meta['siteurl']) cat = meta['cat'] saison = meta['season'] if 'season' in meta else '' sTmdbId = meta['sTmdbId'] if 'sTmdbId' in meta else '' ex = "DELETE FROM viewing WHERE title_id = '%s' and cat = '%s'" % ( titleWatched, cat) try: self.dbcur.execute(ex) except Exception: VSlog('SQL ERROR - ' + ex) pass try: ex = 'INSERT INTO viewing (tmdb_id, title_id, title, siteurl, site, fav, cat, season) VALUES (?, ?, ?, ?, ?, ?, ?, ?)' self.dbcur.execute(ex, (sTmdbId, titleWatched, title, siteurl, meta['site'], meta['fav'], cat, saison)) self.db.commit() VSlog('SQL INSERT viewing Successfully') except Exception as e: if 'no such column' in str(e) or 'no column named' in str( e) or 'no such table' in str(e): self._create_tables('viewing') VSlog('Table recreated : viewing') # Deuxieme tentative self.dbcur.execute( ex, (meta['sTmdbId'], titleWatched, title, siteurl, meta['site'], meta['fav'], meta['cat'], saison, episode)) self.db.commit() else: VSlog('SQL ERROR INSERT : %s' % e) pass
def insert_resume(self, meta): title = self.str_conv(meta['title']) site = QuotePlus(meta['site']) # hoster = meta['hoster'] point = meta['point'] ex = "DELETE FROM resume WHERE title = '%s'" % title try: self.dbcur.execute(ex) except Exception: VSlog('SQL ERROR - ' + ex) pass try: ex = 'INSERT INTO resume (title, hoster, point) VALUES (?, ?, ?)' self.dbcur.execute(ex, (title, site, point)) self.db.commit() except Exception: VSlog('SQL ERROR INSERT resume, title = %s' % title) pass
def search_person_name(self, name): name = re.sub(" +", " ", name) # nettoyage du titre term = QuotePlus(name) meta = self._call('search/person', 'query=' + term) # si pas d'erreur if 'errors' not in meta and 'status_code' not in meta: # on prend le premier resultat if 'total_results' in meta and meta['total_results'] != 0: meta = meta['results'][0] # recherche de toutes les infos person_id = meta['id'] meta = self.search_person_id(person_id) else: meta = {} return meta
def TsiplayerWrite(self, oGuiElement, oOutputParameterHandler): sPluginPath = 'Tsiplayer' sParams = oOutputParameterHandler.getParameterAsUri() sId = oGuiElement.getSiteName() sLabel = oGuiElement.getTitle() sFunction = oGuiElement.getFunction() sIcon = oGuiElement.getIcon() sThumbnail = oGuiElement.getThumbnail() sMeta = oGuiElement.getMeta() sItemUrl = '%s?site=%s&function=%s&title=%s&meta=%s&%s' % ( sPluginPath, sId, sFunction, QuotePlus( str(sLabel)), sMeta, sParams) if sIcon == 'special://home/addons/plugin.video.vstream/resources/art/': sIcon = sThumbnail #PIK = self.MyPath() + "VStream_listing.dat" PIK = self.MyPath() + ("tmdb/VStream_listing_%s.dat" % sId) time_now = round(time.time() * 1000) data = [oGuiElement, oOutputParameterHandler, time_now] with open(PIK, "a+b") as f: pickle.dump(data, f) return ''
def insert_bookmark(self, meta): title = self.str_conv(meta['title']) siteurl = QuotePlus(meta['siteurl']) try: sIcon = meta['icon'].decode('UTF-8') except: sIcon = meta['icon'] try: ex = 'INSERT INTO favorite (title, siteurl, site, fav, cat, icon, fanart) VALUES (?, ?, ?, ?, ?, ?, ?)' self.dbcur.execute(ex, (title, siteurl, meta['site'], meta['fav'], meta['cat'], sIcon, meta['fanart'])) self.db.commit() dialog().VSinfo(addon().VSlang(30042), meta['title']) VSlog('SQL INSERT favorite Successfully') except Exception as e: if 'UNIQUE constraint failed' in e.message: dialog().VSinfo(addon().VSlang(30043), meta['title']) VSlog('SQL ERROR INSERT : %s' % e) pass
def showWeb(infile=None): # Code qui s'occupe de liens TV du Web oGui = cGui() oInputParameterHandler = cInputParameterHandler() if infile is None: sUrl = oInputParameterHandler.getValue('siteUrl') playlist = parseM3U(sUrl=sUrl) else: playlist = parseM3U(infile=infile) if oInputParameterHandler.exist('AZ'): sAZ = oInputParameterHandler.getValue('AZ') string = filter(lambda t: t.title.strip().capitalize().startswith(sAZ), playlist) playlist = sorted(string, key=lambda t: t.title.strip().capitalize()) else: playlist = sorted(playlist, key=lambda t: t.title.strip().capitalize()) if not playlist: oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('siteUrl', 'http://') oGui.addText( SITE_IDENTIFIER, '[COLOR red]Problème de lecture avec la playlist[/COLOR]') else: total = len(playlist) progress_ = progress().VScreate(SITE_NAME) for track in playlist: progress_.VSupdate(progress_, total) if progress_.iscanceled(): break sThumb = track.icon if not sThumb: sThumb = 'tv.png' # les + ne peuvent pas passer url2 = track.path.replace('+', 'P_L_U_S') if not xbmc.getInfoLabel('system.buildversion')[0:2] >= '19': if '[' not in url2 and ']' not in url2 and '.m3u8' not in url2 and 'dailymotion' not in url2: url2 = 'plugin://plugin.video.f4mTester/?url=' + QuotePlus( url2) url2 += '&streamtype=TSDOWNLOADER&name=' + Quote( track.title) thumb = '/'.join([sRootArt, sThumb]) oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('siteUrl', url2) oOutputParameterHandler.addParameter('sMovieTitle', track.title) oOutputParameterHandler.addParameter('sThumbnail', thumb) oGuiElement = cGuiElement() oGuiElement.setSiteName(SITE_IDENTIFIER) oGuiElement.setFunction('play__') oGuiElement.setTitle(track.title) oGuiElement.setFileName(track.title) oGuiElement.setIcon('tv.png') oGuiElement.setMeta(0) oGuiElement.setThumbnail(thumb) oGuiElement.setDirectTvFanart() oGuiElement.setCat(6) oGui.CreateSimpleMenu(oGuiElement, oOutputParameterHandler, SITE_IDENTIFIER, SITE_IDENTIFIER, 'direct_epg', 'Guide tv Direct') oGui.CreateSimpleMenu(oGuiElement, oOutputParameterHandler, SITE_IDENTIFIER, SITE_IDENTIFIER, 'soir_epg', 'Guide tv Soir') oGui.CreateSimpleMenu(oGuiElement, oOutputParameterHandler, SITE_IDENTIFIER, SITE_IDENTIFIER, 'enregistrement', 'Enregistrement') oGui.createContexMenuBookmark(oGuiElement, oOutputParameterHandler) oGui.addFolder(oGuiElement, oOutputParameterHandler) progress_.VSclose(progress_) oGui.setEndOfDirectory()
def __getMediaLinkForGuest(self): if 'yggseries.com' in self.__sUrl: baseUrl = 'https://yggseries.com/api/source/' elif 'french-vid' in self.__sUrl: baseUrl = 'https://www.fembed.com/api/source/' elif 'fembed' in self.__sUrl: baseUrl = 'https://www.fembed.com/api/source/' elif 'feurl' in self.__sUrl: baseUrl = 'https://feurl.com/api/source/' elif 'vfsplayer' in self.__sUrl: baseUrl = 'https://vfsplayer.xyz/api/source/' elif 'fsimg' in self.__sUrl: baseUrl = 'https://www.fsimg.info/api/source/' elif 'fem.tohds' in self.__sUrl: baseUrl = 'https://feurl.com/api/source/' elif 'core1player' in self.__sUrl: baseUrl = 'https://www.core1player.com/api/source/' elif 'gotochus' in self.__sUrl: baseUrl = 'https://www.gotochus.com/api/source/' if 'fem.tohds' in self.__sUrl: oRequestHandler = cRequestHandler(self.__sUrl) sHtmlContent = oRequestHandler.request() sPattern = '<iframe src="([^"]+)"' oParser = cParser() aResult = oParser.parse(sHtmlContent, sPattern) url = baseUrl + aResult[1][0].rsplit('/', 1)[1] postdata = 'r=' + QuotePlus(self.__sUrl) + '&d=' + baseUrl.replace( 'https://', '').replace('/api/source/', '') else: url = baseUrl + self.__sUrl.rsplit('/', 1)[1] postdata = 'r=' + QuotePlus(self.__sUrl) + '&d=' + baseUrl.replace( 'https://', '').replace('/api/source/', '') VSlog(url) oRequest = cRequestHandler(url) oRequest.setRequestType(1) oRequest.addHeaderEntry('User-Agent', UA) # oRequest.addHeaderEntry('Accept', '*/*') # oRequest.addHeaderEntry('Accept-Encoding','gzip, deflate, br') # oRequest.addHeaderEntry('Accept-Language','fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3') # oRequest.addHeaderEntry('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8') oRequest.addHeaderEntry('Referer', self.__sUrl) oRequest.addParametersLine(postdata) sHtmlContent = oRequest.request() VSlog(sHtmlContent) page = json.loads(sHtmlContent) if page: url = [] qua = [] for x in page['data']: url.append(x['file']) qua.append(x['label']) if (url): api_call = dialog().VSselectqual(qua, url) if (api_call): return True, api_call return False, False
def __getMediaLinkForGuest(self): if 'yggseries.com' in self.__sUrl: baseUrl = 'https://yggseries.com/api/source/' elif 'french-vid' in self.__sUrl: baseUrl = 'https://www.fembed.com/api/source/' elif 'fembed' in self.__sUrl: baseUrl = 'https://www.fembed.com/api/source/' elif 'feurl' in self.__sUrl: baseUrl = 'https://feurl.com/api/source/' elif 'vfsplayer' in self.__sUrl: baseUrl = 'https://vfsplayer.xyz/api/source/' elif 'fsimg' in self.__sUrl: baseUrl = 'https://www.fsimg.info/api/source/' elif 'fem.tohds' in self.__sUrl: baseUrl = 'https://feurl.com/api/source/' elif 'core1player' in self.__sUrl: baseUrl = 'https://www.core1player.com/api/source/' elif 'gotochus' in self.__sUrl: baseUrl = 'https://www.gotochus.com/api/source/' if 'fem.tohds' in self.__sUrl: oRequestHandler = cRequestHandler(self.__sUrl) sHtmlContent = oRequestHandler.request() sPattern = '<iframe src="([^"]+)"' oParser = cParser() aResult = oParser.parse(sHtmlContent, sPattern) url = baseUrl + aResult[1][0].rsplit('/', 1)[1] postdata = 'r=' + QuotePlus(self.__sUrl) + '&d=' + baseUrl.replace( 'https://', '').replace('/api/source/', '') else: url = baseUrl + self.__sUrl.rsplit('/', 1)[1] postdata = 'r=' + QuotePlus(self.__sUrl) + '&d=' + baseUrl.replace( 'https://', '').replace('/api/source/', '') oRequest = cRequestHandler(url) oRequest.setRequestType(1) oRequest.addHeaderEntry('User-Agent', UA) oRequest.addHeaderEntry('Referer', self.__sUrl) oRequest.addParametersLine(postdata) sHtmlContent = oRequest.request() page = json.loads(sHtmlContent) if page: url = [] qua = [] for x in page['data']: url.append(x['file']) qua.append(x['label']) if (url): api_call = dialog().VSselectqual(qua, url) if (api_call): oRequest = cRequestHandler(api_call) oRequest.addHeaderEntry('Host', 'fvs.io') oRequest.addHeaderEntry('User-Agent', UA) sHtmlContent = oRequest.request() api_call = oRequest.getRealUrl() if '::/' in api_call: dialog().VSinfo('Desactiver l\'IPV6 sur votre appareil', 'Lecture impossible', 4) return True, api_call + '|User-Agent=' + UA return False, False
def __getMediaLinkForGuest(self): stream_url = False oParser = cParser() sID = self.__getIdFromUrl(self.__sUrl) sRestUrl = self.__getRestFromUrl(self.__sUrl) api = 'http://rutube.ru/api/play/options/' + sID + '/?format=json&no_404=true&referer=' + QuotePlus( self.__sUrl) api = api + '&' + sRestUrl oRequest = cRequestHandler(api) sHtmlContent = oRequest.request() sPattern = '"m3u8": *"([^"]+)"' aResult = oParser.parse(sHtmlContent, sPattern) if not (aResult): sPattern = '"default": *"([^"]+)"' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): url2 = aResult[1][0] else: return False, False oRequest = cRequestHandler(url2) sHtmlContent = oRequest.request() sPattern = '(http.+?\?i=)([0-9x_]+)' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): url = [] qua = [] for aEntry in aResult[1]: url.append(aEntry[0] + aEntry[1]) qua.append(aEntry[1]) #tableau stream_url = dialog().VSselectqual(qua, url) if (stream_url): return True, stream_url else: return False, False return False, False
def showMovies(sSearch=''): oGui = cGui() oParser = cParser() if sSearch: typeSearch, sSearch = sSearch.split('=') sSearch = Unquote(sSearch) sSearch = cUtil().CleanName(sSearch) sSearch = QuotePlus(sSearch).upper() # remplace espace par + et passe en majuscule sUrl = URL_SEARCH[0] + sSearch + '.html' oRequestHandler = cRequestHandler(sUrl) oRequestHandler.addHeaderEntry('User-Agent', UA) oRequestHandler.addHeaderEntry('Referer', URL_MAIN) sHtmlContent = oRequestHandler.request() sHtmlContent = cutSearch(sHtmlContent, typeSearch) else: oInputParameterHandler = cInputParameterHandler() sUrl = oInputParameterHandler.getValue('siteUrl') oRequestHandler = cRequestHandler(sUrl) oRequestHandler.addHeaderEntry('User-Agent', UA) oRequestHandler.addHeaderEntry('Referer', RandomReferer()) sHtmlContent = oRequestHandler.request() # sHtmlContent = DecryptMangacity(sHtmlContent) if 'HTML/JavaScript Encoder' in sHtmlContent: sHtmlContent = ICDecode(sHtmlContent) if sHtmlContent.startswith('<script type="text/javascript">'): sHtmlContent = FullUnescape(sHtmlContent) if sSearch or 'categorie.php' in sUrl or 'categorie_' in sUrl or 'listing3.php?' in sUrl or 'drama.php' in sUrl: sPattern = '<center><div style="background: url\(\'([^\'].+?)\'\); background-size.+?alt="(.+?)" title.+?<a href=["\']*(.+?)[\'"]* class=.button' else: sPattern = '<center><div style="background: url\(\'([^\'].+?)\'\); background-size.+?<a href="([^"]+)".+?alt="(.+?)"' sHtmlContent = re.sub('<a\s*href=\"categorie.php\?watch=\"\s*class="genre\s*\"', '', sHtmlContent, re.DOTALL) aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == False): oGui.addText(SITE_IDENTIFIER) if (aResult[0] == True): total = len(aResult[1]) progress_ = progress().VScreate(SITE_NAME) isPython3 = isMatrix() oOutputParameterHandler = cOutputParameterHandler() for aEntry in aResult[1]: progress_.VSupdate(progress_, total) if progress_.iscanceled(): break sThumb = aEntry[0] if not sThumb.startswith('http'): sThumb = URL_MAIN + sThumb if sSearch or 'categorie.php' in sUrl or 'categorie_' in sUrl or 'listing3.php?' in sUrl or 'drama.php' in sUrl: sTitle = aEntry[1] sUrl2 = aEntry[2] else: sTitle = str(aEntry[2]) sUrl2 = aEntry[1] if not sUrl2.startswith('http'): sUrl2 = URL_MAIN + sUrl2 # affichage de la langue sLang = '' if 'VF' in sTitle: sLang = 'VF' elif 'VOSTFR' in sTitle: sLang = 'VOSTFR' # affichage de la qualité -> NON, qualité fausse # sQual = '' # if 'DVDRIP' in sTitle: # sQual = 'DVDRIP' # Nettoyer le titre sTitle = sTitle.replace(' DVDRIP', '').replace('Visionnez ', '') sTitle = sTitle.replace('[Streaming] - ', '').replace('gratuitement maintenant', '') if ' - Episode' in sTitle: sTitle = sTitle.replace(' -', '') if not isPython3: sTitle = cUtil().CleanName(sTitle).capitalize() else: sTitle.capitalize() sDisplayTitle = ('%s (%s)') % (sTitle, sLang) oOutputParameterHandler.addParameter('siteUrl', sUrl2) oOutputParameterHandler.addParameter('sMovieTitle', sTitle) oOutputParameterHandler.addParameter('sThumb', sThumb) if 'drama.php' in sUrl: oGui.addTV(SITE_IDENTIFIER, 'showEpisode', sDisplayTitle, 'animes.png', sThumb, '', oOutputParameterHandler) elif '?manga=' in sUrl2: oGui.addAnime(SITE_IDENTIFIER, 'showEpisode', sDisplayTitle, 'animes.png', sThumb, '', oOutputParameterHandler) elif '?serie=' in sUrl2: oGui.addTV(SITE_IDENTIFIER, 'showEpisode', sDisplayTitle, 'series.png', sThumb, '', oOutputParameterHandler) elif '?film=' in sUrl2: oGui.addMovie(SITE_IDENTIFIER, 'showMovies', sDisplayTitle, 'films.png', sThumb, '', oOutputParameterHandler) else: oGui.addMovie(SITE_IDENTIFIER, 'showHosters', sDisplayTitle, 'films.png', sThumb, '', oOutputParameterHandler) progress_.VSclose(progress_) if not sSearch: # une seule page par recherche sNextPage = __checkForNextPage(sHtmlContent) if (sNextPage != False): oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('siteUrl', sNextPage) oGui.addNext(SITE_IDENTIFIER, 'showMovies', 'Suivant', oOutputParameterHandler) oGui.setEndOfDirectory()