def TextBoxes(self, heading, anounce): # activate the text viewer window xbmc.executebuiltin( "ActivateWindow(%d)" % ( 10147, ) ) # get window win = window(10147) #win.show() # give window time to initialize xbmc.sleep(100) # set heading win.getControl(1).setLabel(heading) win.getControl(5).setText(anounce) return
def ProtectstreamBypass(url): #lien commencant par VID_ Codedurl = url oRequestHandler = cRequestHandler(Codedurl) sHtmlContent = oRequestHandler.request() oParser = cParser() sPattern = 'var k=\"([^<>\"]*?)\";' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): postdata = 'k=' + aResult[1][0] dialog().VSinfo('Décodage en cours', "Patientez", 5) xbmc.sleep(5000) UA = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0' oRequest = cRequestHandler(URL_MAIN + 'secur22.php') oRequest.setRequestType(1) oRequest.addHeaderEntry('User-Agent', UA) #oRequest.addHeaderEntry('Host', 'www.protect-stream.com') oRequest.addHeaderEntry('Referer', Codedurl) oRequest.addHeaderEntry('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8') oRequest.addHeaderEntry('Content-Type', 'application/x-www-form-urlencoded') oRequest.addParametersLine(postdata) sHtmlContent = oRequest.request() #Test de fonctionnement aResult = oParser.parse(sHtmlContent, sPattern) if aResult[0]: dialog().VSinfo('Lien encore protégé', "Erreur", 5) return '' #recherche du lien embed sPattern = '<iframe src=["\']([^<>"\']+?)["\']' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): return aResult[1][0] #recherche d'un lien redirigee sPattern = '<a class=.button. href=["\']([^<>"\']+?)["\'] target=._blank.>' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): return aResult[1][0] return ''
def TextBoxes(self, anounce): # activate the text viewer window xbmc.executebuiltin( "ActivateWindow(%d)" % ( 10147, ) ) # get window win = window(10147) #win.show() # give window time to initialize xbmc.sleep(100) # set heading win.getControl(1).setLabel("vStream mise à jour") win.getControl(5).setText(anounce) while xbmc.getCondVisibility("Window.IsActive(10147)"): xbmc.sleep(100) ret = dialog().VSok('Mise à jour terminée') if ret: xbmc.executebuiltin("Container.Refresh") return
def TextBoxes(self, anounce): # activate the text viewer window xbmc.executebuiltin("ActivateWindow(%d)" % (10147, )) # get window win = window(10147) #win.show() # give window time to initialize xbmc.sleep(100) # set heading win.getControl(1).setLabel("vStream mise à jour") win.getControl(5).setText(anounce) while xbmc.getCondVisibility("Window.IsActive(10147)"): xbmc.sleep(100) ret = dialog().VSok('Mise à jour terminée') if ret: xbmc.executebuiltin("Container.Refresh") return
def showHosters(): oGui = cGui() oInputParameterHandler = cInputParameterHandler() sUrl = oInputParameterHandler.getValue('siteUrl') sMovieTitle = oInputParameterHandler.getValue('sMovieTitle') sThumb = oInputParameterHandler.getValue('sThumb') if 'forum-tv' in sUrl: dialog().VSinfo('Décodage en cours', "Patientez", 5) s = requests.Session() response = s.get(sUrl, headers={'User-Agent': UA}) sHtmlContent = str(response.content) cookie_string = "; ".join( [str(x) + "=" + str(y) for x, y in s.cookies.items()]) oParser = cParser() sPattern = '<input type="hidden".+?value="([^"]+)"' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): data = "_method=" + aResult[1][0] + "&_csrfToken=" + aResult[1][ 1] + "&ad_form_data=" + Quote( aResult[1][2]) + "&_Token%5Bfields%5D=" + Quote( aResult[1][3]) + "&_Token%5Bunlocked%5D=" + Quote( aResult[1][4]) #Obligatoire pour validé les cookies. xbmc.sleep(6000) oRequestHandler = cRequestHandler( "https://forum-tv.org/adslinkme/links/go") oRequestHandler.setRequestType(1) oRequestHandler.addHeaderEntry('Referer', sUrl) oRequestHandler.addHeaderEntry( 'Accept', 'application/json, text/javascript, */*; q=0.01') oRequestHandler.addHeaderEntry('User-Agent', UA) oRequestHandler.addHeaderEntry('Content-Length', len(data)) oRequestHandler.addHeaderEntry( 'Content-Type', "application/x-www-form-urlencoded; charset=UTF-8") oRequestHandler.addHeaderEntry('X-Requested-With', 'XMLHttpRequest') oRequestHandler.addHeaderEntry('Cookie', cookie_string) oRequestHandler.addParametersLine(data) sHtmlContent = oRequestHandler.request() sPattern = 'url":"([^"]+)"' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): sHosterUrl = aResult[1][0] oHoster = cHosterGui().checkHoster(sHosterUrl) if (oHoster != False): oHoster.setDisplayName(sMovieTitle) oHoster.setFileName(sMovieTitle) cHosterGui().showHoster(oGui, oHoster, sHosterUrl, sThumb) else: sHosterUrl = sUrl oHoster = cHosterGui().checkHoster(sHosterUrl) if (oHoster != False): oHoster.setDisplayName(sMovieTitle) oHoster.setFileName(sMovieTitle) cHosterGui().showHoster(oGui, oHoster, sHosterUrl, sThumb) oGui.setEndOfDirectory()
def run(self, oGuiElement, sTitle, sUrl): # Lancement d'une vidéo sans avoir arreté la précedente self.tvShowTitle = oGuiElement.getItemValue('tvshowtitle') if self.isPlaying(): self.multi = True self._setWatched() # la vidéo en cours doit être marquée comme VUE self.totalTime = 0 self.currentTime = 0 sPluginHandle = cPluginHandler().getPluginHandle() oGui = cGui() item = oGui.createListItem(oGuiElement) item.setPath(oGuiElement.getMediaUrl()) #Sous titres if (self.Subtitles_file): try: item.setSubtitles(self.Subtitles_file) VSlog('Load SubTitle :' + str(self.Subtitles_file)) self.SubtitleActive = True except: VSlog("Can't load subtitle:" + str(self.Subtitles_file)) player_conf = self.ADDON.getSetting('playerPlay') #Si lien dash, methode prioritaire if splitext(urlparse(sUrl).path)[-1] in [".mpd",".m3u8"]: if isKrypton() == True: addonManager().enableAddon('inputstream.adaptive') item.setProperty('inputstream','inputstream.adaptive') if '.m3u8' in sUrl: item.setProperty('inputstream.adaptive.manifest_type', 'hls') else: item.setProperty('inputstream.adaptive.manifest_type', 'mpd') xbmcplugin.setResolvedUrl(sPluginHandle, True, listitem=item) VSlog('Player use inputstream addon') else: dialog().VSerror('Nécessite kodi 17 minimum') return #1 er mode de lecture elif (player_conf == '0'): self.play(sUrl,item) VSlog('Player use Play() method') #2 eme mode non utilise elif (player_conf == 'neverused'): xbmc.executebuiltin('PlayMedia(' + sUrl + ')') VSlog('Player use PlayMedia() method') #3 eme mode (defaut) else: xbmcplugin.setResolvedUrl(sPluginHandle, True, item) VSlog('Player use setResolvedUrl() method') #Attend que le lecteur demarre, avec un max de 20s for _ in range(20): if self.playBackEventReceived: break xbmc.sleep(1000) #active/desactive les sous titres suivant l'option choisie dans la config if self.getAvailableSubtitleStreams(): if (self.ADDON.getSetting('srt-view') == 'true'): self.showSubtitles(True) else: self.showSubtitles(False) dialog().VSinfo('Des sous-titres sont disponibles', 'Sous-Titres', 4) waitingNext = 0 while self.isPlaying() and not self.forcestop: try: self.currentTime = self.getTime() waitingNext += 1 if waitingNext == 8: # attendre un peu avant de chercher le prochain épisode d'une série self.totalTime = self.getTotalTime() self.infotag = self.getVideoInfoTag() UpNext().nextEpisode(oGuiElement) except Exception as err: VSlog("Exception run: {0}".format(err)) xbmc.sleep(1000) if not self.playBackStoppedEventReceived: self.onPlayBackStopped() #Uniquement avec la lecture avec play() if (player_conf == '0'): r = xbmcplugin.addDirectoryItem(handle=sPluginHandle, url=sUrl, listitem=item, isFolder=False) return r VSlog('Closing player') return True
def run(self, oGuiElement, sTitle, sUrl): self.totalTime = 0 self.currentTime = 0 sPluginHandle = cPluginHandler().getPluginHandle() oGui = cGui() item = oGui.createListItem(oGuiElement) item.setPath(oGuiElement.getMediaUrl()) #meta = {'label': oGuiElement.getTitle(), 'title': oGuiElement.getTitle()} #item = xbmcgui.ListItem(path=sUrl, iconImage="DefaultVideo.png", thumbnailImage=self.sThumbnail) #item.setInfo( type="Video", infoLabels= meta ) #Sous titres if (self.Subtitles_file): try: item.setSubtitles(self.Subtitles_file) VSlog("Load SubTitle :" + str(self.Subtitles_file)) self.SubtitleActive = True except: VSlog("Can't load subtitle :" + str(self.Subtitles_file)) player_conf = self.ADDON.getSetting("playerPlay") #Si lien dash, methode prioritaire if sUrl.endswith('.mpd'): if isKrypton() == True: self.enable_addon("inputstream.adaptive") item.setProperty('inputstreamaddon','inputstream.adaptive') item.setProperty('inputstream.adaptive.manifest_type', 'mpd') xbmcplugin.setResolvedUrl(sPluginHandle, True, listitem=item) VSlog('Player use inputstream addon') else: dialog().VSerror('Nécessite kodi 17 minimum') return #1 er mode de lecture elif (player_conf == '0'): self.play(sUrl,item) VSlog('Player use Play() method') #2 eme mode non utilise elif (player_conf == 'neverused'): xbmc.executebuiltin( "PlayMedia("+sUrl+")" ) VSlog('Player use PlayMedia() method') #3 eme mode (defaut) else: xbmcplugin.setResolvedUrl(sPluginHandle, True, item) VSlog('Player use setResolvedUrl() method') #Attend que le lecteur demarre, avec un max de 20s for _ in xrange(20): if self.playBackEventReceived: break xbmc.sleep(1000) #active/desactive les sous titres suivant l'option choisie dans la config if (self.SubtitleActive): if (self.ADDON.getSetting("srt-view") == 'true'): self.showSubtitles(True) self.DIALOG.VSinfo("Sous titre charges", "Sous-Titres", 5) else: self.showSubtitles(False) self.DIALOG.VSinfo("Sous titre charges, Vous pouvez les activer", "Sous-Titres", 15) while self.isPlaying() and not self.forcestop: #while not xbmc.abortRequested: try: self.currentTime = self.getTime() self.totalTime = self.getTotalTime() #xbmc.log(str(self.currentTime)) except: pass #break xbmc.sleep(1000) if not self.playBackStoppedEventReceived: self.onPlayBackStopped() #Uniquement avec la lecture avec play() if (player_conf == '0'): r = xbmcplugin.addDirectoryItem(handle=sPluginHandle,url=sUrl,listitem=item,isFolder=False) #xbmcplugin.endOfDirectory(sPluginHandle, True, False, False) return r VSlog('Closing player')
def __getMediaLinkForGuest(self): api_call = False oRequest = cRequestHandler(self.__sUrl) sHtmlContent = oRequest.request() oParser = cParser() #methode1 #lien indirect if 'You have requested the file:' in sHtmlContent: POST_Url = re.findall('form method="POST" action=\'([^<>"]*)\'',sHtmlContent)[0] POST_Selected = re.findall('form method="POST" action=(.*)</Form>',sHtmlContent,re.DOTALL)[0] POST_Data = {} POST_Data['op'] = re.findall('input type="hidden" name="op" value="([^<>"]*)"',POST_Selected)[0] #POST_Data['usr_login'] = re.findall('input type="hidden" name="usr_login" value="([^<>"]*)"',POST_Selected)[0] POST_Data['id'] = re.findall('input type="hidden" name="id" value="([^<>"]*)"',POST_Selected)[0] POST_Data['fname'] = re.findall('input type="hidden" name="fname" value="([^<>"]*)"',POST_Selected)[0] #POST_Data['referer'] = re.findall('input type="hidden" name="referer" value="([^<>"]*)"',POST_Selected)[0] POST_Data['hash'] = re.findall('input type="hidden" name="hash" value="([^<>"]*)"',POST_Selected)[0] POST_Data['imhuman'] = 'Proceed to video' UA = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0' headers = {'User-Agent': UA , 'Host' : 'www.exashare.com', 'Referer' : self.__sUrl , 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Content-Type': 'application/x-www-form-urlencoded'} postdata = urllib.urlencode(POST_Data) req = urllib2.Request(POST_Url,postdata,headers) xbmc.sleep(10*1000) response = urllib2.urlopen(req) sHtmlContent = response.read() response.close() #fh = open('c:\\test.txt', "w") #fh.write(sHtmlContent) #fh.close() sPattern = 'file: "([^"]+)"' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): api_call = aResult[1][0] #methode2 sPattern = '<iframe[^<>]+?src="(.+?)"[^<>]+?><\/iframe>' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): url = aResult[1][0] oRequest = cRequestHandler(url) oRequest.addHeaderEntry('Referer',url) #oRequest.addHeaderEntry('Host','dowed.info') sHtmlContent = oRequest.request() sPattern = 'file: *"([^"]+)"' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): api_call = aResult[1][0] #methode2-3 sPattern = '<iframe.+?src="([^"]+)".+?<\/iframe>' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): vurl = aResult[1][0] oRequest = cRequestHandler(vurl) sHtmlContent = oRequest.request() sPattern = 'file: *"([^"]+)"' aResult = oParser.parse(sHtmlContent, sPattern) api_call = aResult[1][0] if (api_call): return True, api_call return False, False
def UptomyAccount(): addons = addon() if (addons.getSetting('hoster_uptobox_username') == '') and (addons.getSetting('hoster_uptobox_password') == ''): return oInputParameterHandler = cInputParameterHandler() sMediaUrl = oInputParameterHandler.getValue('sMediaUrl') oPremiumHandler = cPremiumHandler('uptobox') sHtmlContent = oPremiumHandler.GetHtml(URL_MAIN) cookies = GestionCookie().Readcookie('uptobox') aResult = re.search('<form id="fileupload" action="([^"]+)"', sHtmlContent, re.DOTALL) if (aResult): UPurl = aResult.group(1).replace('upload?','remote?') if UPurl.startswith('//'): UPurl = 'https:' + UPurl fields = {'urls':'["' + sMediaUrl + '"]'} mpartdata = MPencode(fields) req = urllib2.Request(UPurl, mpartdata[1], headers) req.add_header('Content-Type', mpartdata[0].replace(',', ';')) req.add_header('Cookie', cookies) req.add_header('Content-Length', len(mpartdata[1])) #penible ce dialog auth xbmc.executebuiltin("Dialog.Close(all,true)") xbmcgui.Dialog().notification('Requete envoyé', 'vous pouvez faire autre chose', xbmcgui.NOTIFICATION_INFO, 4000, False) try: rep = urllib2.urlopen(req) except urllib2.URLError, e: return '' sHtmlContent = rep.read() rep.close() sPattern = '{"id":.+?,(?:"size":|"progress":)([0-9]+)' oParser = cParser() aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): total = aResult[1][0] del aResult[1][0] dialog = xbmcgui.DialogProgressBG() dialog.create(SITE_NAME, 'Transfert de fichiers sur votre compte Uptobox') for aEntry in aResult[1]: dialog.update(int(aEntry) * 100 / int(total),'Upload en cours...') xbmc.sleep(500) dialog.close() else: #penible ce dialog auth xbmc.executebuiltin("Dialog.Close(all,true)") xbmcgui.Dialog().notification('Info upload', 'Fichier introuvable', xbmcgui.NOTIFICATION_INFO, 2000, False)
def _StartDownload(self): #print 'Thread actuel' #print threading.current_thread().getName() diag = self.createProcessDialog() #diag.isFinished() xbmcgui.Window(10101).setProperty('arret', '0') #self.Memorise.set('VstreamDownloaderWorking', '1') headers = self.oUrlHandler.info() #print headers iTotalSize = -1 if 'content-length' in headers: iTotalSize = int(headers['Content-Length']) chunk = 16 * 1024 TotDown = 0 #mise a jour pour info taille self.__updatedb(TotDown, iTotalSize) self.DIALOG.VSinfo('Téléchargement Démarré') while not (self.processIsCanceled or diag.isFinished()): data = self.oUrlHandler.read(chunk) if not data: print 'DL err' break self.file.write(data) TotDown = TotDown + data.__len__() self.__updatedb(TotDown, iTotalSize) self.__stateCallBackFunction(TotDown, iTotalSize) #if self.Memorise.get('VstreamDownloaderWorking') == '0': # self.processIsCanceled = True if xbmcgui.Window(10101).getProperty('arret') == '1': self.processIsCanceled = True #petite pause, ca ralentit le download mais evite de bouffer 100/100 ressources if not (self.__bFastMode): xbmc.sleep(300) self.oUrlHandler.close() self.file.close() self.__oDialog.close() #On autorise le prochain DL #???????????????? #Memorise.unlock('VstreamDownloaderLock') #fait une pause pour fermer le Dialog xbmc.sleep(900) #if download finish meta = {} meta['path'] = self.__fPath meta['size'] = TotDown meta['totalsize'] = iTotalSize if (TotDown == iTotalSize) and (iTotalSize > 10000): meta['status'] = 2 try: cDb().update_download(meta) self.DIALOG.VSinfo('Téléchargements Terminé', self.__sTitle) #print 'Téléchargements Terminé: %s' % self.__sTitle self.RefreshDownloadList() except: pass else: meta['status'] = 0 try: cDb().update_download(meta) self.DIALOG.VSinfo('Téléchargements Arrêté', self.__sTitle) #print 'Téléchargements Arrêté: %s' % self.__sTitle self.RefreshDownloadList() except: pass return #ok tout est bon on continu ou pas? #if Memorise.get('SimpleDownloaderQueue') == '1': if xbmcgui.Window(10101).getProperty('SimpleDownloaderQueue') == '1': print 'Download suivant' tmp = cDownload() data = tmp.GetNextFile() tmp.StartDownload(data)
def __getMediaLinkForGuest(self): oParser = cParser() #recuperation de la page #xbmc.log('url teste : ' + self.__sUrl) oRequest = cRequestHandler(self.__sUrl) oRequest.addHeaderEntry('referer', self.__sUrl) oRequest.addHeaderEntry('User-Agent', UA) sHtmlContent1 = oRequest.request() #fh = open('c:\\test.txt', "w") #fh.write(sHtmlContent1) #fh.close() #Recuperation url cachee TabUrl = [] #sPattern = '<span style="".+?id="([^"]+)">([^<]+)<\/span>' sPattern = '<p id="([^"]+)" *style=\"\">([^<]+)<\/p>' aResult = re.findall(sPattern, sHtmlContent1) if not aResult: sPattern = '<p style="" *id="([^"]+)" *>([^<]+)<\/p>' aResult = re.findall(sPattern, sHtmlContent1) if (aResult): TabUrl = aResult else: VSlog('OPL er 1') return False, False #xbmc.log("Nbre d'url : " + str(len(TabUrl))) #on essait de situer le code sPattern = '<script src="\/assets\/js\/video-js\/video\.js.+?.js"(.+)*' aResult = re.findall(sPattern, sHtmlContent1, re.DOTALL) if (aResult): sHtmlContent3 = aResult[0] else: VSlog('OPL er 2') return False, False #Deobfuscation, a optimiser pour accelerer le traitement code = '' maxboucle = 4 while (maxboucle > 0): sHtmlContent3 = CheckCpacker(sHtmlContent3) sHtmlContent3 = CheckJJDecoder(sHtmlContent3) sHtmlContent3 = CheckAADecoder(sHtmlContent3) maxboucle = maxboucle - 1 code = sHtmlContent3 #fh = open('c:\\html.txt', "w") #fh.write(code) #fh.close() id_final = "" sPattern = 'var srclink.*?\/stream\/.*?(#[^\'"]+).*?mime=true' aResult = re.findall(sPattern, code) if (aResult): id_final = aResult[0] else: VSlog('OPL er 9') return False, False if not (code): VSlog('OPL er 3') return False, False #Search the coded url Coded_url = '' for i in TabUrl: if len(i[1]) > 30: Coded_url = i[1] Item_url = '#' + i[0] VSlog( Item_url + ' : ' + Coded_url ) if not(Coded_url): VSlog('Url codée non trouvée') return False, False #Nettoyage du code pr traitement code = CleanCode(code, Coded_url) #fh = open('c:\\JS.txt', "w") #fh.write(code) #fh.close() VSlog('Code JS extrait') dialog().VSinfo('Décodage: Peut durer plus d\'une minute.', self.__sDisplayName, 15) #interpreteur JS JP = JsParser() Liste_var = [] JP.AddHackVar(Item_url, Coded_url) JP.ProcessJS(code, Liste_var) url = None #for name in [ '#streamurl', '#streamuri', '#streamurj']: # if JP.IsVar( JP.HackVars, name ): # url = JP.GetVarHack( name ) # VSlog( 'Decoded url ' + name + ' : ' + url ) # break url = JP.GetVarHack(id_final) if not(url): VSlog('Rate, debug: ' + str(Liste_var)) return False, False dialog().VSinfo('Ok, lien décodé.', self.__sDisplayName, 15) api_call = self.__getHost() + "/stream/" + url + "?mime=true" if '::' in api_call: dialog().VSinfo('Possible problème d\'ip V6', self.__sDisplayName, 5) xbmc.sleep(5*1000) VSlog(api_call) if (api_call): return True, api_call return False, False
def __init__(self, *args, **kwargs): self.cptloc = kwargs.get('captcha') # self.img = xbmcgui.ControlImage(250, 110, 780, 499, '') # xbmc.sleep(500) self.img = xbmcgui.ControlImage(250, 110, 780, 499, self.cptloc) xbmc.sleep(500) bg_image = os.path.join( __addon__.getAddonInfo('path'), 'resources/art/' ) + 'background.png' check_image = os.path.join( __addon__.getAddonInfo('path'), 'resources/art/' ) + 'trans_checked.png' self.ctrlBackgound = xbmcgui.ControlImage(0, 0, 1280, 720, bg_image) self.cancelled = False self.addControl (self.ctrlBackgound) self.strActionInfo = xbmcgui.ControlLabel(250, 20, 724, 400, 'Veuillez sélectionnez les images correspondants au thème.\nIl devrait y en avoir 3 ou 4 à sélectionner.', 'font40', '0xFFFF00FF') self.addControl(self.strActionInfo) self.msg = kwargs.get('msg') self.roundnum = kwargs.get('roundnum') self.strActionInfo = xbmcgui.ControlLabel(250, 70, 700, 300, 'Le thème est: ' + self.msg, 'font13', '0xFFFF00FF') self.addControl(self.strActionInfo) self.addControl(self.img) self.chk = [0]*9 self.chkbutton = [0]*9 self.chkstate = [False]*9 if 1 == 2: self.chk[0]= xbmcgui.ControlCheckMark(250, 110, 260, 166, '1', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166) self.chk[1]= xbmcgui.ControlCheckMark(250 + 260, 110, 260, 166, '2', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166) self.chk[2]= xbmcgui.ControlCheckMark(250 + 520, 110, 260, 166, '3', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166) self.chk[3]= xbmcgui.ControlCheckMark(250, 110 + 166, 260, 166, '4', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166) self.chk[4]= xbmcgui.ControlCheckMark(250 + 260, 110 + 166, 260, 166, '5', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166) self.chk[5]= xbmcgui.ControlCheckMark(250 + 520, 110 + 166, 260, 166, '6', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166) self.chk[6]= xbmcgui.ControlCheckMark(250, 110 + 332, 260, 166, '7', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166) self.chk[7]= xbmcgui.ControlCheckMark(250 + 260, 110 + 332, 260, 166, '8', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166) self.chk[8]= xbmcgui.ControlCheckMark(250 + 520, 110 + 332, 260, 166, '9', font = 'font14', focusTexture = check_image, checkWidth = 260, checkHeight = 166) else: self.chk[0]= xbmcgui.ControlImage(250, 110, 260, 166, check_image) self.chk[1]= xbmcgui.ControlImage(250 + 260, 110, 260, 166, check_image) self.chk[2]= xbmcgui.ControlImage(250 + 520, 110, 260, 166, check_image) self.chk[3]= xbmcgui.ControlImage(250, 110 + 166, 260, 166, check_image) self.chk[4]= xbmcgui.ControlImage(250 + 260, 110 + 166, 260, 166, check_image) self.chk[5]= xbmcgui.ControlImage(250 + 520, 110 + 166, 260, 166, check_image) self.chk[6]= xbmcgui.ControlImage(250, 110 + 332, 260, 166, check_image) self.chk[7]= xbmcgui.ControlImage(250 + 260, 110 + 332, 260, 166, check_image) self.chk[8]= xbmcgui.ControlImage(250 + 520, 110 + 332, 260, 166, check_image) self.chkbutton[0]= xbmcgui.ControlButton(250, 110, 260, 166, '1', font = 'font1'); self.chkbutton[1]= xbmcgui.ControlButton(250 + 260, 110, 260, 166, '2', font = 'font1'); self.chkbutton[2]= xbmcgui.ControlButton(250 + 520, 110, 260, 166, '3', font = 'font1'); self.chkbutton[3]= xbmcgui.ControlButton(250, 110 + 166, 260, 166, '4', font = 'font1'); self.chkbutton[4]= xbmcgui.ControlButton(250 + 260, 110 + 166, 260, 166, '5', font = 'font1'); self.chkbutton[5]= xbmcgui.ControlButton(250 + 520, 110 + 166, 260, 166, '6', font = 'font1'); self.chkbutton[6]= xbmcgui.ControlButton(250, 110 + 332, 260, 166, '7', font = 'font1'); self.chkbutton[7]= xbmcgui.ControlButton(250 + 260, 110 + 332, 260, 166, '8', font = 'font1'); self.chkbutton[8]= xbmcgui.ControlButton(250 + 520, 110 + 332, 260, 166, '9', font = 'font1'); for obj in self.chk: self.addControl(obj) obj.setVisible(False) for obj in self.chkbutton: self.addControl(obj) self.cancelbutton = xbmcgui.ControlButton(250 + 260 - 70, 620, 140, 50, 'Cancel', alignment = 2) self.okbutton = xbmcgui.ControlButton(250 + 520 - 50, 620, 100, 50, 'OK', alignment = 2) self.addControl(self.okbutton) self.addControl(self.cancelbutton) self.chkbutton[6].controlDown(self.cancelbutton); self.chkbutton[6].controlUp(self.chkbutton[3]) self.chkbutton[7].controlDown(self.cancelbutton); self.chkbutton[7].controlUp(self.chkbutton[4]) self.chkbutton[8].controlDown(self.okbutton); self.chkbutton[8].controlUp(self.chkbutton[5]) self.chkbutton[6].controlLeft(self.chkbutton[8]); self.chkbutton[6].controlRight(self.chkbutton[7]); self.chkbutton[7].controlLeft(self.chkbutton[6]); self.chkbutton[7].controlRight(self.chkbutton[8]); self.chkbutton[8].controlLeft(self.chkbutton[7]); self.chkbutton[8].controlRight(self.chkbutton[6]); self.chkbutton[3].controlDown(self.chkbutton[6]); self.chkbutton[3].controlUp(self.chkbutton[0]) self.chkbutton[4].controlDown(self.chkbutton[7]); self.chkbutton[4].controlUp(self.chkbutton[1]) self.chkbutton[5].controlDown(self.chkbutton[8]); self.chkbutton[5].controlUp(self.chkbutton[2]) self.chkbutton[3].controlLeft(self.chkbutton[5]); self.chkbutton[3].controlRight(self.chkbutton[4]); self.chkbutton[4].controlLeft(self.chkbutton[3]); self.chkbutton[4].controlRight(self.chkbutton[5]); self.chkbutton[5].controlLeft(self.chkbutton[4]); self.chkbutton[5].controlRight(self.chkbutton[3]); self.chkbutton[0].controlDown(self.chkbutton[3]); self.chkbutton[0].controlUp(self.cancelbutton) self.chkbutton[1].controlDown(self.chkbutton[4]); self.chkbutton[1].controlUp(self.cancelbutton) self.chkbutton[2].controlDown(self.chkbutton[5]); self.chkbutton[2].controlUp(self.okbutton) self.chkbutton[0].controlLeft(self.chkbutton[2]); self.chkbutton[0].controlRight(self.chkbutton[1]); self.chkbutton[1].controlLeft(self.chkbutton[0]); self.chkbutton[1].controlRight(self.chkbutton[2]); self.chkbutton[2].controlLeft(self.chkbutton[1]); self.chkbutton[2].controlRight(self.chkbutton[0]); self.cancelled = False self.setFocus(self.okbutton) self.okbutton.controlLeft(self.cancelbutton); self.okbutton.controlRight(self.cancelbutton); self.cancelbutton.controlLeft(self.okbutton); self.cancelbutton.controlRight(self.okbutton); self.okbutton.controlDown(self.chkbutton[2]); self.okbutton.controlUp(self.chkbutton[8]); self.cancelbutton.controlDown(self.chkbutton[0]); self.cancelbutton.controlUp(self.chkbutton[6]);
def UptomyAccount(): addons = addon() if (addons.getSetting('hoster_uptobox_username') == '') and (addons.getSetting('hoster_uptobox_password') == ''): return oInputParameterHandler = cInputParameterHandler() sMediaUrl = oInputParameterHandler.getValue('sMediaUrl') oPremiumHandler = cPremiumHandler('uptobox') sHtmlContent = oPremiumHandler.GetHtml(URL_MAIN) cookies = GestionCookie().Readcookie('uptobox') aResult = re.search('<form id="fileupload" action="([^"]+)"', sHtmlContent, re.DOTALL) if (aResult): UPurl = aResult.group(1).replace('upload?', 'remote?') if UPurl.startswith('//'): UPurl = 'https:' + UPurl fields = {'urls': '["' + sMediaUrl + '"]'} mpartdata = MPencode(fields) req = urllib2.Request(UPurl, mpartdata[1], headers) req.add_header('Content-Type', mpartdata[0].replace(',', ';')) req.add_header('Cookie', cookies) req.add_header('Content-Length', len(mpartdata[1])) #penible ce dialog auth xbmc.executebuiltin("Dialog.Close(all,true)") xbmcgui.Dialog().notification('Requete envoyé', 'vous pouvez faire autre chose', xbmcgui.NOTIFICATION_INFO, 4000, False) try: rep = urllib2.urlopen(req) except urllib2.URLError, e: return '' sHtmlContent = rep.read() rep.close() sPattern = '{"id":.+?,(?:"size":|"progress":)([0-9]+)' oParser = cParser() aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): total = aResult[1][0] del aResult[1][0] dialog = xbmcgui.DialogProgressBG() dialog.create(SITE_NAME, 'Transfert de fichiers sur votre compte Uptobox') for aEntry in aResult[1]: dialog.update( int(aEntry) * 100 / int(total), 'Upload en cours...') xbmc.sleep(500) dialog.close() else: #penible ce dialog auth xbmc.executebuiltin("Dialog.Close(all,true)") xbmcgui.Dialog().notification('Info upload', 'Fichier introuvable', xbmcgui.NOTIFICATION_INFO, 2000, False)
def __getMediaLinkForGuest(self): #http:///dl/12345XXYEEEEREERERE UA = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0' headers = {'User-Agent': UA , 'Host': 'uplea.com', #'Referer': self.__sUrl , 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3' #'Content-Type': 'application/x-www-form-urlencoded' } req = urllib2.Request(self.__sUrl, None, headers) response = urllib2.urlopen(req) sHtmlContent = response.read() head = response.headers response.close() oParser = cParser() #get step urlstep = '' sPattern = '<a href="(\/step\/[^<>"]+)">' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): urlstep = aResult[1][0] #get cookie cookies = '' if 'Set-Cookie' in head: cookies = head['Set-Cookie'] sPattern = '(__cfduid=[0-9a-z]+;).+?(PHPSESSID=[0-9a-z]+)' aResult = oParser.parse(str(cookies), sPattern) if (aResult[0] == True): cookies = str(aResult[1][0][0]) + str(aResult[1][0][1]) url = 'http://uplea.com' + urlstep headers['Cookie'] = cookies headers['Referer'] = self.__sUrl req = urllib2.Request(url, None, headers) response = urllib2.urlopen(req) sHtmlContent = response.read() head = response.headers response.close() #fh = open('c:\\test.txt', "w") #fh.write(sHtmlContent) #fh.close() #waiting time waitingtime = 20 sPattern = "ulCounter\({'timer':([0-9]+)}\);" aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): waitingtime = int(aResult[1][0]) + 2 sPattern = '<a class="button-download" href="([^<>"]+?)">' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): dialog.VSinfo('Waiting time', self.__sDisplayName, waitingtime) xbmc.sleep(waitingtime*1000) #print aResult[1][0] return True, aResult[1][0] + '|User-Agent=' + UA# + '&Referer=' + self.__sUrl return False, False
def GetHtml(self, url, htmlcontent='', cookies='', postdata=None, Gived_headers=''): #Memorise headers self.Memorised_Headers = Gived_headers #Memorise postdata self.Memorised_PostData = postdata #Memorise cookie self.Memorised_Cookies = cookies #VSlog(cookies) #cookies in headers ? if Gived_headers != '': if Gived_headers.get('Cookie', None): if cookies: self.Memorised_Cookies = cookies + '; ' + Gived_headers.get( 'Cookie') else: self.Memorised_Cookies = Gived_headers['Cookie'] #For debug if (Mode_Debug): VSlog('Headers present ' + str(Gived_headers)) VSlog('url ' + url) VSlog('Content : ' + str(htmlcontent)) if (htmlcontent): VSlog('code html ok') VSlog('cookies passes' + self.Memorised_Cookies) VSlog('post data :' + str(postdata)) self.hostComplet = re.sub(r'(https*:\/\/[^/]+)(\/*.*)', '\\1', url) self.host = re.sub(r'https*:\/\/', '', self.hostComplet) self.url = url cookieMem = GestionCookie().Readcookie(self.host.replace('.', '_')) if not (cookieMem == ''): #VSlog('cookies present sur disque :' + cookieMem ) if not (self.Memorised_Cookies): cookies = cookieMem else: cookies = self.Memorised_Cookies + '; ' + cookieMem #Max 3 loop loop = 3 while (loop > 0): loop -= 1 #To check self.check = False #Redirection possible ? if (True): opener = urllib2.build_opener(NoRedirection) else: opener = urllib2.build_opener() opener.addheaders = self.SetHeader() if ('cf_clearance' not in cookies) and htmlcontent and ('__cfduid=' in cookies): self.check = True VSlog("##### Decodage #####") #fh = open('c:\\test.txt', "w") #fh.write(htmlcontent.decode("utf-8") ) #fh.close() #recuperation parametres hash = re.findall( '<input type="hidden" name="jschl_vc" value="(.+?)"\/>', str(htmlcontent))[0] passe = re.findall( '<input type="hidden" name="pass" value="(.+?)"\/>', str(htmlcontent))[0] s = re.findall('<input type="hidden" name="s" value="([^"]+)"', str(htmlcontent), re.DOTALL)[0] #encoding s = urllib.quote_plus(s) passe = urllib.quote_plus(passe) #calcul de la reponse rep = self.GetResponse(htmlcontent) #Temporisation #showInfo("Information", 'Decodage protection CloudFlare' , 5) xbmc.sleep(8000) #Take care at order url = self.hostComplet + '/cdn-cgi/l/chk_jschl?s=' + s + '&jschl_vc=' + hash + '&pass='******'&jschl_answer=' + rep #No post data here postdata = None #To avoid captcha if not "'Accept'" in str(opener.addheaders): opener.addheaders.append(( 'Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' )) if not 'Host' in str(opener.addheaders): opener.addheaders.append(('Host', self.host)) #opener.addheaders.append(('Connection', 'keep-alive')) #opener.addheaders.append(('Accept-Encoding', 'gzip, deflate, br')) #opener.addheaders.append(('Upgrade-Insecure-Requests', '1')) #opener.addheaders.append(('DNT', '1')) #opener.addheaders.append(('Cache-Control', 'max-age=0')) #Add cookies if cookies: opener.addheaders.append(('Cookie', cookies)) if not 'Referer' in str(opener.addheaders): opener.addheaders.append(('Referer', self.url)) #if not 'Accept' in str(opener.addheaders): # opener.addheaders.append(('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')) #VSlog("Url demandee " + str(url) ) #VSlog(str(opener.addheaders)) if not url.startswith('http'): url = self.hostComplet + url try: if postdata: self.HttpReponse = opener.open(url, postdata) else: self.HttpReponse = opener.open(url) htmlcontent = self.HttpReponse.read() self.Header = self.HttpReponse.headers self.RedirectionUrl = self.HttpReponse.geturl() self.HttpReponse.close() except urllib2.HTTPError as e: #VSlog("Error " + str(e.code)) htmlcontent = e.read() self.Header = e.headers self.RedirectionUrl = e.geturl() url = self.RedirectionUrl postdata = self.Memorised_PostData #compressed page ? if self.Header.get('Content-Encoding') == 'gzip': import zlib htmlcontent = zlib.decompress(htmlcontent, zlib.MAX_WBITS | 16) #For debug if (Mode_Debug): VSlog("Url obtenue : " + str(self.RedirectionUrl)) VSlog("Headers send : " + str(opener.addheaders)) VSlog("cookie send : " + str(cookies)) VSlog("header recu : " + str(self.Header)) if 'Please complete the security check' in str(htmlcontent): #fh = open('d:\\test.txt', "w") #fh.write(htmlcontent) #fh.close() VSlog("Probleme protection Cloudflare : Protection captcha") #showInfo("Erreur", 'Probleme CloudFlare, pls Retry' , 5) return '' if not CheckIfActive(htmlcontent): VSlog('Page decodee') #First check if we have solved the challenge if self.check and 'cf_clearance' not in self.Header.get( 'Set-Cookie', ''): VSlog("###### Challenge rate ######") #To reset, enabled later to prevent loop htmlcontent = '' #need to save cookies ? if not cookieMem: GestionCookie().SaveCookie(self.host.replace('.', '_'), cookies) url2 = self.Header.get('Location', '') if url2: url = url2 else: #All finished, return code return htmlcontent else: #Arf, problem, cookies not working, delete them if cookieMem: VSlog('Cookies Out of date') GestionCookie().DeleteCookie(self.host.replace('.', '_')) cookieMem = '' #one more loop, and reset all cookies, event only cf_clearance is needed loop += 1 cookies = self.Memorised_Cookies #Get new cookies if 'Set-Cookie' in self.Header: cookies2 = str(self.Header.get('Set-Cookie')) listcookie = self.ParseCookies(cookies2) listcookie2 = self.ParseCookies(cookies) cookies = "" #New cookies for a, b in listcookie: if len(cookies) > 0: cookies = cookies + '; ' cookies = cookies + str(a) + '=' + str(b) #old cookies only is needed for a, b in listcookie2: if not str(a) in cookies: if len(cookies) > 0: cookies = cookies + '; ' cookies = cookies + str(a) + '=' + str(b) VSlog("Probleme protection Cloudflare : Cookies manquants") return ''
def _StartDownload(self): #print 'Thread actuel' #print threading.current_thread().getName() diag = self.createProcessDialog() #diag.isFinished() xbmcgui.Window(10101).setProperty('arret', '0') #self.Memorise.set("VstreamDownloaderWorking", "1") headers = self.oUrlHandler.info() #print headers iTotalSize = -1 if "content-length" in headers: iTotalSize = int(headers["Content-Length"]) chunk = 16 * 1024 TotDown = 0 #mise a jour pour info taille self.__updatedb(TotDown,iTotalSize) self.DIALOG.VSinfo('Téléchargement Démarré') while not (self.processIsCanceled or diag.isFinished()): data = self.oUrlHandler.read(chunk) if not data: print 'DL err' break self.file.write(data) TotDown = TotDown + data.__len__() self.__updatedb(TotDown,iTotalSize) self.__stateCallBackFunction(TotDown, iTotalSize) #if self.Memorise.get("VstreamDownloaderWorking") == "0": # self.processIsCanceled = True if xbmcgui.Window(10101).getProperty('arret') == '1': self.processIsCanceled = True #petite pause, ca ralentit le download mais evite de bouffer 100/100 ressources if not (self.__bFastMode): xbmc.sleep(300) self.oUrlHandler.close() self.file.close() self.__oDialog.close() #On autorise le prochain DL #???????????????? #Memorise.unlock("VstreamDownloaderLock") #fait une pause pour fermer le Dialog xbmc.sleep(900) #if download finish meta = {} meta['path'] = self.__fPath meta['size'] = TotDown meta['totalsize'] = iTotalSize if (TotDown == iTotalSize) and (iTotalSize > 10000): meta['status'] = 2 try: cDb().update_download(meta) self.DIALOG.VSinfo('Téléchargements Termine', self.__sTitle) #print 'Téléchargements Termine : %s' % self.__sTitle self.RefreshDownloadList() except: pass else: meta['status'] = 0 try: cDb().update_download(meta) self.DIALOG.VSinfo('Téléchargements Arrete', self.__sTitle) #print 'Téléchargements Arrete : %s' % self.__sTitle self.RefreshDownloadList() except: pass return #ok tout est bon on contiinu ou pas ? #if Memorise.get('SimpleDownloaderQueue') == '1': if xbmcgui.Window(10101).getProperty('SimpleDownloaderQueue') == '1': print 'Download suivant' tmp = cDownload() data = tmp.GetNextFile() tmp.StartDownload(data)
def AddtoDownloadListandview(self): oInputParameterHandler = cInputParameterHandler() sHosterIdentifier = oInputParameterHandler.getValue('sHosterIdentifier') sMediaUrl = oInputParameterHandler.getValue('sMediaUrl') sFileName = oInputParameterHandler.getValue('sFileName') VSlog("Telechargement " + sMediaUrl) meta = {} meta['url'] = sMediaUrl meta['cat'] = oInputParameterHandler.getValue('sCat') meta['title'] = sFileName meta['icon'] = xbmc.getInfoLabel('ListItem.Art(thumb)') if (self.AddDownload(meta)): #Si pas de telechargement en cours on lance le notre if not self.isDownloading(): row = cDb().get_Download(meta) if row: title = row[0][1] url = urllib.unquote_plus(row[0][2]) path = row[0][3] #thumbnail = urllib.unquote_plus(row[0][4]) #status = row[0][8] if (self.download(url,title,path,True) == True): #Download in fastmode #ok on attend un peu, et on lance le stream tempo = 100 progress_ = progress().VScreate('Creation buffer') while (tempo > 0): #if canceled do nothing if progress_.iscanceled(): break progress_.VSupdate(progress_, 100) tempo = tempo - 1 xbmc.sleep(500) progress_.VSclose(progress_) oGuiElement = cGuiElement() oGuiElement.setSiteName(SITE_IDENTIFIER) oGuiElement.setMediaUrl(path) oGuiElement.setTitle(title) #oGuiElement.getInfoLabel() oPlayer = cPlayer() if not (sys.argv[ 1 ] == '-1'): oPlayer.run(oGuiElement, title, path) else: oPlayer.clearPlayList() oPlayer.addItemToPlaylist(oGuiElement) oPlayer.startPlayer() else: self.DIALOG.VSinfo('Echec du telechargement', 'Erreur') return
def run(self, oGuiElement, sTitle, sUrl): self.totalTime = 0 self.currentTime = 0 sPluginHandle = cPluginHandler().getPluginHandle() oGui = cGui() item = oGui.createListItem(oGuiElement) item.setPath(oGuiElement.getMediaUrl()) #meta = {'label': oGuiElement.getTitle(), 'title': oGuiElement.getTitle()} #item = xbmcgui.ListItem(path=sUrl, iconImage='DefaultVideo.png', thumbnailImage=self.sThumbnail) #item.setInfo(type='Video', infoLabels=meta) #Sous titres if (self.Subtitles_file): try: item.setSubtitles(self.Subtitles_file) VSlog('Load SubTitle :' + str(self.Subtitles_file)) self.SubtitleActive = True except: VSlog("Can't load subtitle:" + str(self.Subtitles_file)) player_conf = self.ADDON.getSetting('playerPlay') #Si lien dash, methode prioritaire if sUrl.endswith('.mpd'): if isKrypton() == True: self.enable_addon('inputstream.adaptive') item.setProperty('inputstreamaddon', 'inputstream.adaptive') item.setProperty('inputstream.adaptive.manifest_type', 'mpd') xbmcplugin.setResolvedUrl(sPluginHandle, True, listitem=item) VSlog('Player use inputstream addon') else: dialog().VSerror('Nécessite kodi 17 minimum') return #1 er mode de lecture elif (player_conf == '0'): self.play(sUrl, item) VSlog('Player use Play() method') #2 eme mode non utilise elif (player_conf == 'neverused'): xbmc.executebuiltin('PlayMedia(' + sUrl + ')') VSlog('Player use PlayMedia() method') #3 eme mode (defaut) else: xbmcplugin.setResolvedUrl(sPluginHandle, True, item) VSlog('Player use setResolvedUrl() method') #Attend que le lecteur demarre, avec un max de 20s if xbmc.getInfoLabel('system.buildversion')[0:2] >= '19': for _ in range(20): if self.playBackEventReceived: break xbmc.sleep(1000) else: for _ in xrange(20): if self.playBackEventReceived: break xbmc.sleep(1000) #active/desactive les sous titres suivant l'option choisie dans la config if (self.SubtitleActive): if (self.ADDON.getSetting('srt-view') == 'true'): self.showSubtitles(True) dialog().VSinfo('Sous-titres chargés', 'Sous-Titres', 5) else: self.showSubtitles(False) dialog().VSinfo('Sous-titres chargés, vous pouvez les activer', 'Sous-Titres', 15) while self.isPlaying() and not self.forcestop: #while not xbmc.abortRequested: try: self.currentTime = self.getTime() self.totalTime = self.getTotalTime() #xbmc.log(str(self.currentTime)) except: pass #break xbmc.sleep(1000) if not self.playBackStoppedEventReceived: self.onPlayBackStopped() #Uniquement avec la lecture avec play() if (player_conf == '0'): r = xbmcplugin.addDirectoryItem(handle=sPluginHandle, url=sUrl, listitem=item, isFolder=False) #xbmcplugin.endOfDirectory(sPluginHandle, True, False, False) return r VSlog('Closing player')
def ProtectstreamBypass(url): #lien commencant par VID_ # Codedurl = url Codedurl = url.replace('http:', 'https:') UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0' session = requests.Session() session.headers.update({ 'User-Agent': UA, 'Referer': URL_MAIN, 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', }) try: response = session.get(url, timeout=5) response.raise_for_status() except requests.exceptions.RequestException as e: print "erreur " + str(e) return '' sHtmlContent = response.text oParser = cParser() sPattern = 'var k=\"([^<>\"]*?)\";' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): dialog().VSinfo('Décodage en cours', "Patientez", 5) xbmc.sleep(5000) postdata = aResult[1][0] headers = { 'User-Agent': UA, 'Accept': '*/*', 'Referer': url, 'Content-Type': 'application/x-www-form-urlencoded', } session.headers.update( headers ) data = {'k': postdata} try: response = session.post('https://www.protect-stream.com/secur2.php', data=data) except requests.exceptions.RequestException as e: print "erreur" + str(e) return '' data = response.text data = data.encode('utf-8', 'ignore') #VSlog(type(data)) #VSlog(repr(data)) #fh = open('c:\\test.txt', "w") #fh.write(data) #fh.close() #Test de fonctionnement aResult = oParser.parse(data, sPattern) if aResult[0]: dialog().VSinfo('Lien encore protegé', "Erreur", 5) return '' #recherche du lien embed sPattern = '<iframe src=["\']([^<>"\']+?)["\']' aResult = oParser.parse(data, sPattern) if (aResult[0] == True): return aResult[1][0] #recherche d'un lien redirigee sPattern = '<a class=.button. href=["\']([^<>"\']+?)["\'] target=._blank.>' aResult = oParser.parse(data, sPattern) if (aResult[0] == True): return aResult[1][0] return ''
def __getMediaLinkForGuest(self): #http:///dl/12345XXYEEEEREERERE UA = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0' headers = { 'User-Agent': UA, 'Host': 'uplea.com', #'Referer': self.__sUrl , 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3' #'Content-Type': 'application/x-www-form-urlencoded' } req = urllib2.Request(self.__sUrl, None, headers) response = urllib2.urlopen(req) sHtmlContent = response.read() head = response.headers response.close() oParser = cParser() #get step urlstep = '' sPattern = '<a href="(\/step\/[^<>"]+)">' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): urlstep = aResult[1][0] #get cookie cookies = '' if 'Set-Cookie' in head: cookies = head['Set-Cookie'] sPattern = '(__cfduid=[0-9a-z]+;).+?(PHPSESSID=[0-9a-z]+)' aResult = oParser.parse(str(cookies), sPattern) if (aResult[0] == True): cookies = str(aResult[1][0][0]) + str(aResult[1][0][1]) url = 'http://uplea.com' + urlstep headers['Cookie'] = cookies headers['Referer'] = self.__sUrl req = urllib2.Request(url, None, headers) response = urllib2.urlopen(req) sHtmlContent = response.read() head = response.headers response.close() #fh = open('c:\\test.txt', "w") #fh.write(sHtmlContent) #fh.close() #waiting time waitingtime = 20 sPattern = "ulCounter\({'timer':([0-9]+)}\);" aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): waitingtime = int(aResult[1][0]) + 2 sPattern = '<a class="button-download" href="([^<>"]+?)">' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): dialog.VSinfo('Waiting time', self.__sDisplayName, waitingtime) xbmc.sleep(waitingtime * 1000) #print aResult[1][0] return True, aResult[1][ 0] + '|User-Agent=' + UA # + '&Referer=' + self.__sUrl return False, False
def __init__(self, *args, **kwargs): self.cptloc = kwargs.get('captcha') self.img = xbmcgui.ControlImage(335, 200, 624, 400, "") xbmc.sleep(500) self.img = xbmcgui.ControlImage(335, 200, 624, 400, self.cptloc) xbmc.sleep(500) bg_image = os.path.join(__addon__.getAddonInfo('path'), 'resources/art/') + "background.png" check_image = os.path.join(__addon__.getAddonInfo('path'), 'resources/art/') + "trans_checked.png" self.ctrlBackgound = xbmcgui.ControlImage(0, 0, 1280, 720, bg_image) self.cancelled = False self.addControl(self.ctrlBackgound) self.msg = kwargs.get( 'msg') + '\nNormalement il devrai y avoir en 3 ou 4 selection' self.roundnum = kwargs.get('roundnum') self.strActionInfo = xbmcgui.ControlLabel(335, 120, 700, 300, "Le theme est : " + self.msg, 'font13', '0xFFFF00FF') self.addControl(self.strActionInfo) self.strActionInfo = xbmcgui.ControlLabel( 335, 20, 724, 400, 'Veuillez selectionnez les images correpondants au themes', 'font40', '0xFFFF00FF') self.addControl(self.strActionInfo) self.addControl(self.img) self.chk = [0] * 9 self.chkbutton = [0] * 9 self.chkstate = [False] * 9 if 1 == 2: self.chk[0] = xbmcgui.ControlCheckMark(335, 190, 220, 150, '1', font='font14', focusTexture=check_image, checkWidth=220, checkHeight=150) self.chk[1] = xbmcgui.ControlCheckMark(335 + 200, 190, 220, 150, '2', font='font14', focusTexture=check_image, checkWidth=220, checkHeight=150) self.chk[2] = xbmcgui.ControlCheckMark(335 + 400, 190, 220, 150, '3', font='font14', focusTexture=check_image, checkWidth=220, checkHeight=150) self.chk[3] = xbmcgui.ControlCheckMark(335, 190 + 130, 220, 150, '4', font='font14', focusTexture=check_image, checkWidth=220, checkHeight=150) self.chk[4] = xbmcgui.ControlCheckMark(335 + 200, 190 + 130, 220, 150, '5', font='font14', focusTexture=check_image, checkWidth=220, checkHeight=150) self.chk[5] = xbmcgui.ControlCheckMark(335 + 400, 190 + 130, 220, 150, '6', font='font14', focusTexture=check_image, checkWidth=220, checkHeight=150) self.chk[6] = xbmcgui.ControlCheckMark(335, 190 + 260, 220, 150, '7', font='font14', focusTexture=check_image, checkWidth=220, checkHeight=150) self.chk[7] = xbmcgui.ControlCheckMark(335 + 200, 190 + 260, 220, 150, '8', font='font14', focusTexture=check_image, checkWidth=220, checkHeight=150) self.chk[8] = xbmcgui.ControlCheckMark(335 + 400, 190 + 260, 220, 150, '9', font='font14', focusTexture=check_image, checkWidth=220, checkHeight=150) else: self.chk[0] = xbmcgui.ControlImage(335, 190, 220, 150, check_image) self.chk[1] = xbmcgui.ControlImage(335 + 200, 190, 220, 150, check_image) self.chk[2] = xbmcgui.ControlImage(335 + 400, 190, 220, 150, check_image) self.chk[3] = xbmcgui.ControlImage(335, 190 + 130, 220, 150, check_image) self.chk[4] = xbmcgui.ControlImage(335 + 200, 190 + 130, 220, 150, check_image) self.chk[5] = xbmcgui.ControlImage(335 + 400, 190 + 130, 220, 150, check_image) self.chk[6] = xbmcgui.ControlImage(335, 190 + 260, 220, 150, check_image) self.chk[7] = xbmcgui.ControlImage(335 + 200, 190 + 260, 220, 150, check_image) self.chk[8] = xbmcgui.ControlImage(335 + 400, 190 + 260, 220, 150, check_image) self.chkbutton[0] = xbmcgui.ControlButton(335, 190, 210, 150, '1', font='font1') self.chkbutton[1] = xbmcgui.ControlButton(335 + 200, 190, 220, 150, '2', font='font1') self.chkbutton[2] = xbmcgui.ControlButton(335 + 400, 190, 220, 150, '3', font='font1') self.chkbutton[3] = xbmcgui.ControlButton(335, 190 + 130, 210, 150, '4', font='font1') self.chkbutton[4] = xbmcgui.ControlButton(335 + 200, 190 + 130, 220, 150, '5', font='font1') self.chkbutton[5] = xbmcgui.ControlButton(335 + 400, 190 + 130, 220, 150, '6', font='font1') self.chkbutton[6] = xbmcgui.ControlButton(335, 190 + 260, 210, 150, '7', font='font1') self.chkbutton[7] = xbmcgui.ControlButton(335 + 200, 190 + 260, 220, 150, '8', font='font1') self.chkbutton[8] = xbmcgui.ControlButton(335 + 400, 190 + 260, 220, 150, '9', font='font1') for obj in self.chk: self.addControl(obj) obj.setVisible(False) for obj in self.chkbutton: self.addControl(obj) self.cancelbutton = xbmcgui.ControlButton(335 + 312 - 100, 610, 100, 40, 'Cancel', alignment=2) self.okbutton = xbmcgui.ControlButton(335 + 312 + 50, 610, 100, 40, 'OK', alignment=2) self.addControl(self.okbutton) self.addControl(self.cancelbutton) self.chkbutton[6].controlDown(self.cancelbutton) self.chkbutton[6].controlUp(self.chkbutton[3]) self.chkbutton[7].controlDown(self.cancelbutton) self.chkbutton[7].controlUp(self.chkbutton[4]) self.chkbutton[8].controlDown(self.okbutton) self.chkbutton[8].controlUp(self.chkbutton[5]) self.chkbutton[6].controlLeft(self.chkbutton[8]) self.chkbutton[6].controlRight(self.chkbutton[7]) self.chkbutton[7].controlLeft(self.chkbutton[6]) self.chkbutton[7].controlRight(self.chkbutton[8]) self.chkbutton[8].controlLeft(self.chkbutton[7]) self.chkbutton[8].controlRight(self.chkbutton[6]) self.chkbutton[3].controlDown(self.chkbutton[6]) self.chkbutton[3].controlUp(self.chkbutton[0]) self.chkbutton[4].controlDown(self.chkbutton[7]) self.chkbutton[4].controlUp(self.chkbutton[1]) self.chkbutton[5].controlDown(self.chkbutton[8]) self.chkbutton[5].controlUp(self.chkbutton[2]) self.chkbutton[3].controlLeft(self.chkbutton[5]) self.chkbutton[3].controlRight(self.chkbutton[4]) self.chkbutton[4].controlLeft(self.chkbutton[3]) self.chkbutton[4].controlRight(self.chkbutton[5]) self.chkbutton[5].controlLeft(self.chkbutton[4]) self.chkbutton[5].controlRight(self.chkbutton[3]) self.chkbutton[0].controlDown(self.chkbutton[3]) self.chkbutton[0].controlUp(self.cancelbutton) self.chkbutton[1].controlDown(self.chkbutton[4]) self.chkbutton[1].controlUp(self.cancelbutton) self.chkbutton[2].controlDown(self.chkbutton[5]) self.chkbutton[2].controlUp(self.okbutton) self.chkbutton[0].controlLeft(self.chkbutton[2]) self.chkbutton[0].controlRight(self.chkbutton[1]) self.chkbutton[1].controlLeft(self.chkbutton[0]) self.chkbutton[1].controlRight(self.chkbutton[2]) self.chkbutton[2].controlLeft(self.chkbutton[1]) self.chkbutton[2].controlRight(self.chkbutton[0]) self.cancelled = False self.setFocus(self.okbutton) self.okbutton.controlLeft(self.cancelbutton) self.okbutton.controlRight(self.cancelbutton) self.cancelbutton.controlLeft(self.okbutton) self.cancelbutton.controlRight(self.okbutton) self.okbutton.controlDown(self.chkbutton[2]) self.okbutton.controlUp(self.chkbutton[8]) self.cancelbutton.controlDown(self.chkbutton[0]) self.cancelbutton.controlUp(self.chkbutton[6])
def AddtoDownloadListandview(self): oInputParameterHandler = cInputParameterHandler() sMediaUrl = oInputParameterHandler.getValue('sMediaUrl') sFileName = oInputParameterHandler.getValue('sFileName') # sHosterIdentifier = oInputParameterHandler.getValue('sHosterIdentifier') VSlog('Téléchargement ' + sMediaUrl) meta = {} meta['url'] = sMediaUrl meta['cat'] = oInputParameterHandler.getValue('sCat') meta['title'] = sFileName meta['icon'] = xbmc.getInfoLabel('ListItem.Art(thumb)') if (self.AddDownload(meta)): #Si pas de telechargement en cours on lance le notre if not self.isDownloading(): row = cDb().get_Download(meta) if row: title = row[0][1] url = urllib.unquote_plus(row[0][2]) path = row[0][3] #thumbnail = urllib.unquote_plus(row[0][4]) #status = row[0][8] if (self.download(url, title, path, True) == True): #Download in fastmode #ok on attend un peu, et on lance le stream tempo = 100 progress_ = progress().VScreate('Bufferisation') while (tempo > 0): #if canceled do nothing if progress_.iscanceled(): break progress_.VSupdate(progress_, 100) tempo = tempo - 1 xbmc.sleep(500) progress_.VSclose(progress_) oGuiElement = cGuiElement() oGuiElement.setSiteName(SITE_IDENTIFIER) oGuiElement.setMediaUrl(path) oGuiElement.setTitle(title) #oGuiElement.getInfoLabel() oPlayer = cPlayer() if not (sys.argv[1] == '-1'): oPlayer.run(oGuiElement, title, path) else: oPlayer.clearPlayList() oPlayer.addItemToPlaylist(oGuiElement) oPlayer.startPlayer() else: self.DIALOG.VSinfo('Echec du téléchargement', 'Erreur') return
def ProtectstreamBypass(url): #lien commencant par VID_ Codedurl = url oRequestHandler = cRequestHandler(Codedurl) sHtmlContent = oRequestHandler.request() oParser = cParser() sPattern = 'var k=\"([^<>\"]*?)\";' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): dialog().VSinfo('Décodage en cours', "Patientez", 5) xbmc.sleep(5000) #postdata = urllib.urlencode( { 'k': aResult[1][0] } ) postdata = 'k=' + aResult[1][0] UA = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0' headers = { 'User-Agent': UA, 'Host': 'www.protect-stream.com', 'Referer': Codedurl, 'Accept': '*/*', 'Connection': 'keep-alive', #'Accept-Encoding' : 'gzip, deflate', #'Accept-Language' : 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3', 'Content-Length': len(postdata), 'Content-Type': 'application/x-www-form-urlencoded' } #VSlog(postdata) #VSlog(str(headers)) req = urllib2.Request('https://www.protect-stream.com/secur2.php', postdata, headers) try: response = urllib2.urlopen(req) except urllib2.URLError, e: print e.read() print e.reason data = response.read() response.close() #fh = open('c:\\test.txt', "w") #fh.write(data) #fh.close() #Test de fonctionnement aResult = oParser.parse(data, sPattern) if aResult[0]: dialog().VSinfo('Lien encore protegé', "Erreur", 5) return '' #recherche du lien embed sPattern = '<iframe src=["\']([^<>"\']+?)["\']' aResult = oParser.parse(data, sPattern) if (aResult[0] == True): return aResult[1][0] #recherche d'un lien redirigee sPattern = '<a class=.button. href=["\']([^<>"\']+?)["\'] target=._blank.>' aResult = oParser.parse(data, sPattern) if (aResult[0] == True): return aResult[1][0]
def ProtectstreamBypass(url): #lien commencant par VID_ # Codedurl = url Codedurl = url.replace('http:', 'https:') UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0' session = requests.Session() session.headers.update({ 'User-Agent': UA, 'Referer': 'https://dpstreaming.to/', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', }) try: response = session.get(url, timeout=5) response.raise_for_status() except requests.exceptions.RequestException as e: print "erreur " + str(e) return '' sHtmlContent = response.text oParser = cParser() sPattern = 'var k=\"([^<>\"]*?)\";' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): dialog().VSinfo('Décodage en cours', "Patientez", 5) xbmc.sleep(5000) postdata = aResult[1][0] headers = { 'User-Agent': UA, 'Accept': '*/*', 'Referer': url, 'Content-Type': 'application/x-www-form-urlencoded', } session.headers.update(headers) data = {'k': postdata} try: response = session.post( 'https://www.protect-stream.com/secur2.php', data=data) except requests.exceptions.RequestException as e: print "erreur" + str(e) return '' data = response.text data = data.encode('utf-8', 'ignore') #VSlog(type(data)) #VSlog(repr(data)) #fh = open('c:\\test.txt', "w") #fh.write(data) #fh.close() #Test de fonctionnement aResult = oParser.parse(data, sPattern) if aResult[0]: dialog().VSinfo('Lien encore protegé', "Erreur", 5) return '' #recherche du lien embed sPattern = '<iframe src=["\']([^<>"\']+?)["\']' aResult = oParser.parse(data, sPattern) if (aResult[0] == True): return aResult[1][0] #recherche d'un lien redirigee sPattern = '<a class=.button. href=["\']([^<>"\']+?)["\'] target=._blank.>' aResult = oParser.parse(data, sPattern) if (aResult[0] == True): return aResult[1][0] return ''
def showHosters(): oGui = cGui() oInputParameterHandler = cInputParameterHandler() sUrl = oInputParameterHandler.getValue('siteUrl') sMovieTitle = oInputParameterHandler.getValue('sMovieTitle') sThumb = oInputParameterHandler.getValue('sThumb') if 'mon-tele' in sUrl: dialog().VSinfo('Décodage en cours', "Patientez", 5) s = requests.Session() response = s.get(sUrl, headers={'User-Agent': UA}) sHtmlContent = str(response.content) cookie_string = "; ".join( [str(x) + "=" + str(y) for x, y in s.cookies.items()]) oParser = cParser() sPattern = '<input type="hidden".+?value="([^"]+)"' aResult = oParser.parse(sHtmlContent, sPattern) from resources.lib import librecaptcha test = librecaptcha.get_token( api_key="6LezIsIZAAAAABMSqc7opxGc3xyCuXtAtV4VlTtN", site_url="https://mon-tele.com/", user_agent=UA, gui=False, debug=False, ) if (aResult[0] == True): data = "_method=" + aResult[1][0] + "&_csrfToken=" + aResult[1][1] + "&ref=&f_n=" + aResult[1][2]\ + "&g-recaptcha-response=" + test + "&_Token%5Bfields%5D=" + Quote(aResult[1][3])\ + "&_Token%5Bunlocked%5D=" + Quote(aResult[1][4]) oRequestHandler = cRequestHandler(sUrl) oRequestHandler.setRequestType(1) oRequestHandler.addHeaderEntry('Referer', sUrl) oRequestHandler.addHeaderEntry( 'Accept', ' text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' ) oRequestHandler.addHeaderEntry('User-Agent', UA) oRequestHandler.addHeaderEntry('Content-Length', len(data)) oRequestHandler.addHeaderEntry( 'Content-Type', "application/x-www-form-urlencoded") oRequestHandler.addHeaderEntry('Cookie', cookie_string) oRequestHandler.addParametersLine(data) sHtmlContent = oRequestHandler.request() oParser = cParser() sPattern = '<input type="hidden".+?value="([^"]+)"' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): data = "_method=" + aResult[1][0] + "&_csrfToken=" + aResult[1][1] + "&ad_form_data="\ + Quote(aResult[1][2]) + "&_Token%5Bfields%5D=" + Quote(aResult[1][3])\ + "&_Token%5Bunlocked%5D=" + Quote(aResult[1][4]) # Obligatoire pour validé les cookies. xbmc.sleep(15000) oRequestHandler = cRequestHandler( 'https://mon-tele.com/obtenirliens/links/go') oRequestHandler.setRequestType(1) oRequestHandler.addHeaderEntry('Referer', sUrl) oRequestHandler.addHeaderEntry( 'Accept', 'application/json, text/javascript, */*; q=0.01') oRequestHandler.addHeaderEntry('User-Agent', UA) oRequestHandler.addHeaderEntry('Content-Length', len(data)) oRequestHandler.addHeaderEntry( 'Content-Type', "application/x-www-form-urlencoded; charset=UTF-8") oRequestHandler.addHeaderEntry('X-Requested-With', 'XMLHttpRequest') oRequestHandler.addHeaderEntry('Cookie', cookie_string) oRequestHandler.addParametersLine(data) sHtmlContent = oRequestHandler.request() sPattern = 'url":"([^"]+)"' aResult = oParser.parse(sHtmlContent, sPattern) if (aResult[0] == True): sHosterUrl = aResult[1][0] oHoster = cHosterGui().checkHoster(sHosterUrl) if (oHoster != False): oHoster.setDisplayName(sMovieTitle) oHoster.setFileName(sMovieTitle) cHosterGui().showHoster(oGui, oHoster, sHosterUrl, sThumb) else: sHosterUrl = sUrl oHoster = cHosterGui().checkHoster(sHosterUrl) if (oHoster != False): oHoster.setDisplayName(sMovieTitle) oHoster.setFileName(sMovieTitle) cHosterGui().showHoster(oGui, oHoster, sHosterUrl, sThumb) oGui.setEndOfDirectory()