def getToken(self): result = self._call('authentication/token/new', '') total = len(result) if (total > 0): url = 'https://www.themoviedb.org/authenticate/' if not xbmc.getCondVisibility('system.platform.android'): #Si possible on ouvre la page automatiquement dans un navigateur internet. webbrowser.open(url + result['request_token']) sText = (self.ADDON.VSlang(30421)) % (url, result['request_token']) DIALOG = dialog() if not DIALOG.VSyesno(sText): return False else: from resources.lib import pyqrcode qr = pyqrcode.create(url + result['request_token']) qr.png( 'special://home/userdata/addon_data/plugin.video.vstream/qrcode.png', scale=5) oSolver = cInputWindowYesNo( captcha= 'special://home/userdata/addon_data/plugin.video.vstream/qrcode.png', msg="Scanner le QRCode pour acceder au lien d'autorisation", roundnum=1) retArg = oSolver.get() DIALOG = dialog() if retArg == "N": return False result = self._call('authentication/session/new', 'request_token=' + result['request_token']) if 'success' in result and result['success']: self.ADDON.setSetting('tmdb_session', str(result['session_id'])) DIALOG.VSinfo(self.ADDON.VSlang(30000)) return else: DIALOG.VSerror('Erreur' + self.ADDON.VSlang(30000)) return # xbmc.executebuiltin('Container.Refresh') return return
def getMediaLink(self): self.oPremiumHandler = cPremiumHandler('uptobox') premium = self.oPremiumHandler.isPremiumModeAvailable() api_call = False SubTitle = "" if premium: self.oPremiumHandler.Authentificate() else: dialog().VSok('Ce hoster demande un login, meme gratuit.') return False, False cookies = GestionCookie().Readcookie("uptobox") s = requests.Session() s.headers.update({"Cookie": cookies}) r = s.get('https://uptobox.com/api/streaming?file_code=' + self.__sUrl.split('/')[-1]).json() if r["statusCode"] != 0: # Erreur dialog().VSinfo(r["data"]) return False, False r1 = s.get(r["data"]["user_url"]).text tok = re.search('token.+?;.+?;(.+?)&', r1).group(1) if not xbmc.getCondVisibility('system.platform.android'): # Si possible on ouvre la page automatiquement dans un navigateur internet. import webbrowser webbrowser.open(r['data']['user_url']) with CountdownDialog("Autorisation nécessaire", "Pour voir cette vidéo, veuillez vous connecter", "Allez sur ce lien : " + r['data']['user_url'], "Et valider le pin : " + r['data']['pin'], True, r["data"]['expired_in'], 10) as cd: js_result = cd.start(self.__check_auth, [r["data"]["check_url"]])["data"] else: from resources.lib import pyqrcode from resources.lib.librecaptcha.gui import cInputWindowYesNo qr = pyqrcode.create(r['data']['user_url']) qr.png('special://home/userdata/addon_data/plugin.video.vstream/qrcode.png', scale=5) oSolver = cInputWindowYesNo(captcha='special://home/userdata/addon_data/plugin.video.vstream/qrcode.png', msg="Scanner le QRCode pour acceder au lien d'autorisation", roundnum=1) retArg = oSolver.get() DIALOG = dialog() if retArg == "N": return False js_result = s.get(r["data"]["check_url"]).json()["data"] #Deux modes de fonctionnement different. if js_result.get("streamLinks").get('src'): api_call = js_result['streamLinks']['src'].replace(".m3u8",".mpd") else: sPattern = "'(.+?)': {(.+?)}" oParser = cParser() aResult = oParser.parse(js_result["streamLinks"], sPattern) url = [] qua = [] api_call = False for aEntry in aResult[1]: QUAL = aEntry[0] d = re.findall("'u*(.+?)': u*'(.+?)'",aEntry[1]) for aEntry1 in d: url.append(aEntry1[1]) qua.append(QUAL + ' (' + aEntry1[0] + ')') # Affichage du tableau api_call = dialog().VSselectqual(qua, url) try: SubTitle = self.checkSubtitle(js_result["subs"]) except: VSlog("Pas de sous-titre") if (api_call): if SubTitle: return True, api_call, SubTitle else: return True, api_call return False, False