def Getheader(url, c): opener = Noredirection() opener.addheaders = [('User-Agent', UA)] opener.addheaders = [('Cookie', c)] response = opener.open(url) return response.headers['Location']
def showHosters(): oGui = cGui() oInputParameterHandler = cInputParameterHandler() sUrl = oInputParameterHandler.getValue('siteUrl') sMovieTitle = oInputParameterHandler.getValue('sMovieTitle') sThumb = oInputParameterHandler.getValue('sThumb') host = sUrl.split('/')[0:3] host = host[0] + '//' + host[2] + '/' # VSlog('org > ' + sUrl) # Attention ne marche pas dans tout les cas, certain site retourne aussi un 302 et la lib n'en gere qu'un if (False): # On recupere la redirection oRequestHandler = cRequestHandler(sUrl) oRequestHandler.addHeaderEntry('User-Agent', UA) oRequestHandler.addHeaderEntry('Referer', host) sHtmlContent = oRequestHandler.request() redirection_target = oRequestHandler.getRealUrl() else: opener = Noredirection() opener.addheaders = [('User-Agent', UA)] opener.addheaders = [('Referer', host)] response = opener.open(sUrl) sHtmlContent = response.read() redirection_target = sUrl if response.code == 302: redirection_target = response.headers['Location'] response.close() # attention fake redirection sUrl = redirection_target try: m = re.search(r'url=([^"]+)', sHtmlContent) except: m = re.search(r'url=([^"]+)', str(sHtmlContent)) if m: sUrl = m.group(1) # Modifications sUrl = sUrl.replace('1wskdbkp.xyz', 'youwatch.org') if '1fichier' in sUrl: sUrl = re.sub('(http.+?\?link=)', 'https://1fichier.com/?', sUrl) sHosterUrl = sUrl oHoster = cHosterGui().checkHoster(sHosterUrl) if (oHoster != False): oHoster.setDisplayName(sMovieTitle) oHoster.setFileName(sMovieTitle) cHosterGui().showHoster(oGui, oHoster, sHosterUrl, sThumb) oGui.setEndOfDirectory()
def GetTinyUrl(url): if not 'tinyurl' in url: return url #Lien deja connu ? if '://tinyurl.com/h7c9sr7' in url: url = url.replace('://tinyurl.com/h7c9sr7/', '://vidwatch.me/') elif '://tinyurl.com/jxblgl5' in url: url = url.replace('://tinyurl.com/jxblgl5/', '://streamin.to/') elif '://tinyurl.com/q44uiep' in url: url = url.replace('://tinyurl.com/q44uiep/', '://openload.co/') elif '://tinyurl.com/jp3fg5x' in url: url = url.replace('://tinyurl.com/jp3fg5x/', '://allmyvideos.net/') elif '://tinyurl.com/kqhtvlv' in url: url = url.replace('://tinyurl.com/kqhtvlv/', '://openload.co/embed/') elif '://tinyurl.com/lr6ytvj' in url: url = url.replace('://tinyurl.com/lr6ytvj/', '://netu.tv/') elif '://tinyurl.com/kojastd' in url: url = url.replace('://tinyurl.com/kojastd/', '://www.rapidvideo.com/embed/') elif '://tinyurl.com/l3tjslm' in url: url = url.replace('://tinyurl.com/l3tjslm/', '://hqq.tv/player/') elif '://tinyurl.com/n34gtt7' in url: url = url.replace('://tinyurl.com/n34gtt7/', '://vidlox.tv/') elif '://tinyurl.com/kdo4xuk' in url: url = url.replace('://tinyurl.com/kdo4xuk/', '://watchers.to/') elif '://tinyurl.com/kjvlplm' in url: url = url.replace('://tinyurl.com/kjvlplm/', '://streamango.com/') elif '://tinyurl.com/kt3owzh' in url: url = url.replace('://tinyurl.com/kt3owzh/', '://estream.to/') #On va chercher le vrai lien else: #VSlog('Decodage lien tinyurl : ' + str(url)) headers9 = [( 'User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0' ), ('Referer', URL_MAIN)] opener = Noredirection() opener.addheaders = headers9 reponse = opener.open(url, None, 5) UrlRedirect = reponse.geturl() if not (UrlRedirect == url): url = UrlRedirect elif 'Location' in reponse.headers: url = reponse.headers['Location'] reponse.close() return url
def showMovies(sSearch=''): oGui = cGui() oParser = cParser() if sSearch: sUrl = sSearch.replace(' ', '+') else: oInputParameterHandler = cInputParameterHandler() sUrl = oInputParameterHandler.getValue('siteUrl') Cookie = GestionCookie().Readcookie('time2watch') oRequestHandler = cRequestHandler(sUrl) if Cookie: oRequestHandler.addHeaderEntry('Cookie', Cookie) sHtmlContent = oRequestHandler.request() # Connection pour passer la limite if not 'Déconnexion' in sHtmlContent and ADDON.getSetting( 'hoster_time2watch_premium') == "true": VSlog("Connection") data = { 'username': ADDON.getSetting('hoster_time2watch_username'), 'pwd': ADDON.getSetting('hoster_time2watch_password') } data = urlEncode(data) opener = Noredirection() opener.addheaders = [('User-Agent', UA)] opener.addheaders.append( ('Content-Type', 'application/x-www-form-urlencoded')) opener.addheaders.append(('Accept-Encoding', 'gzip, deflate')) opener.addheaders.append(('Content-Length', str(len(data)))) response = opener.open("https://time2watch.io/login/", data) head = response.info() # get cookie Cookie = '' if 'Set-Cookie' in head: oParser = cParser() sPattern = '(?:^|,) *([^;,]+?)=([^;,\/]+?);' aResult = oParser.parse(str(head['Set-Cookie']), sPattern) # print(aResult) if (aResult[0] == True): for cook in aResult[1]: if 'deleted' in cook[1]: continue Cookie = Cookie + cook[0] + '=' + cook[1] + ';' GestionCookie().SaveCookie('time2watch', Cookie) oRequestHandler = cRequestHandler(sUrl) oRequestHandler.addHeaderEntry('Cookie', Cookie) sHtmlContent = oRequestHandler.request() sPattern = '<div class="col-lg-4.+?<a href="([^"]+)">.+?affiche_liste" src="([^"]+)".+?alt="([^"]+)".+?<i class="fa fa-tv"></i>([^<]+)<.+?div class="synopsis_hover".+?>([^<]+)<' 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) for aEntry in aResult[1]: progress_.VSupdate(progress_, total) if progress_.iscanceled(): break sUrl2 = URL_MAIN + aEntry[0] sThumb = URL_MAIN + aEntry[1] sTitle = aEntry[2] sQual = aEntry[3].replace(' ', '') sDesc = aEntry[4] sTitle = sTitle.replace('En streaming', '') sDisplayTitle = ('%s [%s]') % (sTitle, sQual) oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('siteUrl', sUrl2) oOutputParameterHandler.addParameter('sMovieTitle', sTitle) oOutputParameterHandler.addParameter('sThumb', sThumb) oOutputParameterHandler.addParameter('sDesc', sDesc) oOutputParameterHandler.addParameter('sCookie', Cookie) if '/serie/' in sUrl2 or '/anime/' in sUrl2: oGui.addTV(SITE_IDENTIFIER, 'showSaisonEpisodes', sDisplayTitle, '', sThumb, sDesc, oOutputParameterHandler) else: oGui.addMovie(SITE_IDENTIFIER, 'showMoviesLink', sDisplayTitle, '', sThumb, sDesc, oOutputParameterHandler) progress_.VSclose(progress_) if not sSearch: sNextPage = __checkForNextPage(sHtmlContent) if (sNextPage != False): oOutputParameterHandler = cOutputParameterHandler() oOutputParameterHandler.addParameter('siteUrl', sNextPage) number = re.search('/([0-9]+)', sNextPage).group(1) oGui.addNext(SITE_IDENTIFIER, 'showMovies', '[COLOR teal]Page ' + number + ' >>>[/COLOR]', oOutputParameterHandler) oGui.setEndOfDirectory()
def showHosters(): oGui = cGui() oInputParameterHandler = cInputParameterHandler() sUrl = oInputParameterHandler.getValue('siteUrl') sMovieTitle = oInputParameterHandler.getValue('sMovieTitle') sThumb = oInputParameterHandler.getValue('sThumb') referer = oInputParameterHandler.getValue('referer') pdata = oInputParameterHandler.getValue('pdata') oRequest = cRequestHandler(sUrl) oRequest.setRequestType(1) oRequest.addHeaderEntry('User-Agent', UA) oRequest.addHeaderEntry('Referer', referer) oRequest.addHeaderEntry('Accept', '*/*') 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') oRequest.addParametersLine(pdata) sHtmlContent = oRequest.request() # oParser = cParser() # 1 sPattern = '(?:<iframe|<IFRAME).+?(?:src|SRC)=[\'|"]([^\'"|]+)' aResult1 = re.findall(sPattern, sHtmlContent) # 2 sPattern = '<a href="([^"]+)">' aResult2 = re.findall(sPattern, sHtmlContent) # fusion aResult = aResult1 + aResult2 if aResult: for aEntry in aResult: sHosterUrl = aEntry if 'zustreamv2/viplayer' in sHosterUrl: return if 're.zu-lien.com' in sHosterUrl: oRequestHandler = cRequestHandler(sHosterUrl) oRequestHandler.addHeaderEntry('User-Agent', UA) oRequestHandler.addHeaderEntry('Referer', 'https://re.zu-lien.com') oRequestHandler.request() sUrl1 = oRequestHandler.getRealUrl() if not sUrl1 or sUrl1 == sHosterUrl: opener = Noredirection() opener.addheaders = [('User-Agent', UA)] opener.addheaders = [('Referer', 'https://re.zu-lien.com')] response = opener.open(sHosterUrl) response.read() getreal = sHosterUrl if response.code == 302: getreal = response.headers['Location'] response.close() sHosterUrl = getreal else: sHosterUrl = sUrl1 oHoster = cHosterGui().checkHoster(sHosterUrl) if (oHoster != False): oHoster.setDisplayName(sMovieTitle) oHoster.setFileName(sMovieTitle) cHosterGui().showHoster(oGui, oHoster, sHosterUrl, sThumb) oGui.setEndOfDirectory()
def showHosters(): # UA = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0' oGui = cGui() oParser = cParser() oInputParameterHandler = cInputParameterHandler() sUrl = oInputParameterHandler.getValue('siteUrl') sMovieTitle = oInputParameterHandler.getValue('sMovieTitle') sThumb = oInputParameterHandler.getValue('sThumb') oRequestHandler = cRequestHandler(sUrl) sHtmlContent = oRequestHandler.request() # Recuperer variable pour url de base sPattern = 'trembed=(\d+).+?trid=(\d+).+?trtype=(\d+)' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == False): oGui.addText(SITE_IDENTIFIER) if (aResult[0] == True): list_site_film = [] for aEntry in aResult[1]: site = URL_MAIN + "?trembed=" + aEntry[0] + "&trid=" + aEntry[1] + "&trtype=" + aEntry[2] # Marche plus ?........constaté : ne marche pas toujours avec les series...affaire à suivre if aEntry[2] == '1': site = site.replace("trembed=1", "trembed=0") if site not in list_site_film: list_site_film.append(site) else: continue # inutile de faire des requetes identiques pour les films oRequestHandler = cRequestHandler(site) sHtmlContent = oRequestHandler.request() # Recuperation de l'url suivante sPattern1 = '<div class="Video"><iframe.+?src="([^"]+)"' aResult = oParser.parse(sHtmlContent, sPattern1) Url = aResult[1][0][:-1] oRequestHandler = cRequestHandler(Url) sHtmlContent = oRequestHandler.request() # Recuperation de l'id sPattern1 = "var id.+?'([^']+)'" aResult = oParser.parse(sHtmlContent, sPattern1) # sPost = decode(aResult[1][0]) # t[::-1] renvoie la chaine t dans l'ordre inverse, identique à decode(t) sPost = aResult[1][0][::-1] if sPost: sUrl1 = URL_MAIN + '?trhidee=1&trfex=' + sPost oRequestHandler = cRequestHandler(sUrl1) oRequestHandler.addHeaderEntry('Referer', Url) oRequestHandler.addHeaderEntry('User-Agent', UA) oRequestHandler.request() sHosterUrl = oRequestHandler.getRealUrl() if sHosterUrl == sUrl1: opener = Noredirection() opener.addheaders = [('User-Agent', UA)] opener.addheaders = [('Referer', Url)] response = opener.open(sUrl1) sHtmlContent = response.read() getreal = sUrl1 if response.code == 302: getreal = response.headers['Location'] response.close() sHosterUrl = getreal # https://lb.hdsto.me/hls/xxx.playlist.m3u8 # https://lb.hdsto.me/public/dist/index.html?id=xxx if 'public/dist' in sHosterUrl: sHosterUrl = 'https://' + sHosterUrl.split('/')[2] + '/hls/' + sHosterUrl.split('id=')[1] + '/' + sHosterUrl.split('id=')[1] + '.m3u8' oRequestHandler = cRequestHandler(sHosterUrl) oRequestHandler.addHeaderEntry('Referer', Url) sHtmlContent = oRequestHandler.request() sHosterUrl = oRequestHandler.getRealUrl() oHoster = cHosterGui().checkHoster(sHosterUrl) if (oHoster != False): oHoster.setDisplayName(sMovieTitle) oHoster.setFileName(sMovieTitle) cHosterGui().showHoster(oGui, oHoster, sHosterUrl, sThumb) oGui.setEndOfDirectory()