def handleFree(self, pyfile): m = re.search('<h2>((Daily )?Download Limit)</h2>', self.html) if m: pyfile.error = m.group(1) self.logWarning(pyfile.error) self.retry(6, (6 * 60 if m.group(2) else 15) * 60, pyfile.error) ajax_url = "http://uploading.com/files/get/?ajax" self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) self.req.http.lastURL = pyfile.url res = json_loads(self.load(ajax_url, post={'action': 'second_page', 'code': self.info['pattern']['ID']})) if 'answer' in res and 'wait_time' in res['answer']: wait_time = int(res['answer']['wait_time']) self.logInfo(_("Waiting %d seconds") % wait_time) self.wait(wait_time) else: self.error(_("No AJAX/WAIT")) res = json_loads(self.load(ajax_url, post={'action': 'get_link', 'code': self.info['pattern']['ID'], 'pass': '******'})) if 'answer' in res and 'link' in res['answer']: url = res['answer']['link'] else: self.error(_("No AJAX/URL")) self.html = self.load(url) m = re.search(r'<form id="file_form" action="(.*?)"', self.html) if m: url = m.group(1) else: self.error(_("No URL")) self.link = url
def handleFree(self, pyfile): m = re.search('<h2>((Daily )?Download Limit)</h2>', self.html) if m: pyfile.error = m.group(1) self.logWarning(pyfile.error) self.retry(6, (6 * 60 if m.group(2) else 15) * 60, pyfile.error) ajax_url = "http://uploading.com/files/get/?ajax" self.req.http.c.setopt(pycurl.HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) self.req.http.lastURL = pyfile.url res = json_loads(self.load(ajax_url, post={'action': 'second_page', 'code': self.info['pattern']['ID']})) if 'answer' in res and 'wait_time' in res['answer']: wait_time = int(res['answer']['wait_time']) self.logInfo(_("Waiting %d seconds") % wait_time) self.wait(wait_time) else: self.error(_("No AJAX/WAIT")) res = json_loads(self.load(ajax_url, post={'action': 'get_link', 'code': self.info['pattern']['ID'], 'pass': '******'})) if 'answer' in res and 'link' in res['answer']: url = res['answer']['link'] else: self.error(_("No AJAX/URL")) self.html = self.load(url) m = re.search(r'<form id="file_form" action="(.*?)"', self.html) if m: url = m.group(1) else: self.error(_("No URL")) self.link = url
def challenge(self, key=None, html=None): if not key: if self.detect_key(html): key = self.key else: errmsg = _("AdYouLike key not found") self.plugin.fail(errmsg) raise TypeError(errmsg) ayl, callback = key # {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, # "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}} ayl = json_loads(ayl) html = self.plugin.req.load("http://api-ayl.appspot.com/challenge", get={'key': ayl['adyoulike']['key'], 'env': ayl['all']['env'], 'callback': callback}) try: challenge = json_loads(re.search(callback + r'\s*\((.+?)\)', html).group(1)) except AttributeError: errmsg = _("AdYouLike challenge pattern not found") self.plugin.fail(errmsg) raise AttributeError(errmsg) self.logDebug("Challenge: %s" % challenge) return self.result(ayl, challenge), challenge
def challenge(self, key=None, html=None): if not key: if self.detect_key(html): key = self.key else: errmsg = _("AdYouLike key not found") self.plugin.fail(errmsg) raise TypeError(errmsg) ayl, callback = key # {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, # "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}} ayl = json_loads(ayl) html = self.plugin.req.load("http://api-ayl.appspot.com/challenge", get={ 'key': ayl['adyoulike']['key'], 'env': ayl['all']['env'], 'callback': callback }) try: challenge = json_loads( re.search(callback + r'\s*\((.+?)\)', html).group(1)) except AttributeError: errmsg = _("AdYouLike challenge pattern not found") self.plugin.fail(errmsg) raise AttributeError(errmsg) self.logDebug("Challenge: %s" % challenge) return self.result(ayl, challenge), challenge
def loadAccountInfo(self, user, req): # It looks like the first API request always fails, so we retry 5 times, it should work on the second try for _i in xrange(5): rep = req.load("https://secure.filecloud.io/api-fetch_apikey.api", post={ "username": user, "password": self.getAccountData(user)['password'] }) rep = json_loads(rep) if rep['status'] == 'ok': break elif rep['status'] == 'error' and rep[ 'message'] == 'no such user or wrong password': self.logError(_("Wrong username or password")) return {"valid": False, "premium": False} else: return {"premium": False} akey = rep['akey'] self.accounts[user]['akey'] = akey # Saved for hoster plugin rep = req.load("http://api.filecloud.io/api-fetch_account_details.api", post={"akey": akey}) rep = json_loads(rep) if rep['is_premium'] == 1: return { "validuntil": float(rep['premium_until']), "trafficleft": -1 } else: return {"premium": False}
def result(self, server, challenge): # Adyoulike.g._jsonp_5579316662423138 # ({"translations":{"fr":{"instructions_visual":"Recopiez « Soonnight » ci-dessous :"}}, # "site_under":true,"clickable":true,"pixels":{"VIDEO_050":[],"DISPLAY":[],"VIDEO_000":[],"VIDEO_100":[], # "VIDEO_025":[],"VIDEO_075":[]},"medium_type":"image/adyoulike", # "iframes":{"big":"<iframe src=\"http://www.soonnight.com/campagn.html\" scrolling=\"no\" # height=\"250\" width=\"300\" frameborder=\"0\"></iframe>"},"shares":{},"id":256, # "token":"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1","formats":{"small":{"y":300,"x":0,"w":300,"h":60}, # "big":{"y":0,"x":0,"w":300,"h":250},"hover":{"y":440,"x":0,"w":300,"h":60}}, # "tid":"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) if isinstance(server, basestring): server = json_loads(server) if isinstance(challenge, basestring): challenge = json_loads(challenge) try: instructions_visual = challenge['translations'][server['all']['lang']]['instructions_visual'] result = re.search(u'«(.+?)»', instructions_visual).group(1).strip() except AttributeError: errmsg = _("AdYouLike result not found") self.plugin.fail(errmsg) raise AttributeError(errmsg) result = {'_ayl_captcha_engine': "adyoulike", '_ayl_env': server['all']['env'], '_ayl_tid': challenge['tid'], '_ayl_token_challenge': challenge['token'], '_ayl_response': response} self.logDebug("Result: %s" % result) return result
def handle_premium(self, pyfile): user, data = self.account.selectAccount() # Get the download link res = self.load("https://premium.rpnet.biz/client_api.php", get={"username": user, "password": data['password'], "action" : "generate", "links" : pyfile.url}) self.logDebug("JSON data: %s" % res) link_status = json_loads(res)['links'][0] #: get the first link... since we only queried one # Check if we only have an id as a HDD link if 'id' in link_status: self.logDebug("Need to wait at least 30 seconds before requery") self.setWait(30) #: wait for 30 seconds self.wait() # Lets query the server again asking for the status on the link, # we need to keep doing this until we reach 100 max_tries = 30 my_try = 0 while (my_try <= max_tries): self.logDebug("Try: %d ; Max Tries: %d" % (my_try, max_tries)) res = self.load("https://premium.rpnet.biz/client_api.php", get={"username": user, "password": data['password'], "action": "downloadInformation", "id": link_status['id']}) self.logDebug("JSON data hdd query: %s" % res) download_status = json_loads(res)['download'] if download_status['status'] == '100': link_status['generated'] = download_status['rpnet_link'] self.logDebug("Successfully downloaded to rpnet HDD: %s" % link_status['generated']) break else: self.logDebug("At %s%% for the file download" % download_status['status']) self.setWait(30) self.wait() my_try += 1 if my_try > max_tries: #: We went over the limit! self.fail(_("Waited for about 15 minutes for download to finish but failed")) if 'generated' in link_status: self.link = link_status['generated'] return elif 'error' in link_status: self.fail(link_status['error']) else: self.fail(_("Something went wrong, not supposed to enter here"))
def process(self, pyfile): if not self.account: self.logError( _("Please enter your %s account or deactivate this plugin") % "Multi-debrid.com") self.fail("No Multi-debrid.com account provided") self.logDebug("Original URL: %s" % pyfile.url) if re.match(self.__pattern__, pyfile.url): new_url = pyfile.url else: page = self.req.load('http://multi-debrid.com/api.php', get={ 'user': self.user, 'pass': self.account.getAccountData( self.user)['password'], 'link': pyfile.url }) self.logDebug("JSON data: " + page) page = json_loads(page) if page['status'] != 'ok': self.fail('Unable to unrestrict link') new_url = page['link'] self.logDebug("Unrestricted URL: " + new_url) self.download(new_url, disposition=True)
def loadAccountInfo(self, user, req): validuntil = None trafficleft = None premium = False sid = None try: sid = self.getAccountData(user).get('sid') assert sid html = req.load("%s/info" % self.API_URL, get={'sid': sid}) self.logDebug("API:USERINFO", html) json = json_loads(html) if json['response_status'] == 200: if "reset_in" in json['response']: self.scheduleRefresh(user, json['response']['reset_in']) validuntil = json['response']['expire_date'] trafficleft = float(json['response']['traffic_left']) premium = True else: self.logError(json['response_details']) except Exception, e: self.logError(e)
def decrypt(self, pyfile): url, result = checkHTMLHeader(pyfile.url) self.logDebug("Location (%d): %s" % (result, url)) if result == 0: # load and parse html html = self.load(pyfile.url) m = re.search(self.LINK_PATTERN, html) if m: # file page self.urls.append("http://www.mediafire.com/file/%s" % m.group(1)) else: # folder page m = re.search(self.FOLDER_KEY_PATTERN, html) if m: folder_key = m.group(1) self.logDebug("FOLDER KEY: %s" % folder_key) json_resp = json_loads(self.load("http://www.mediafire.com/api/folder/get_info.php", get={'folder_key' : folder_key, 'response_format': "json", 'version' : 1})) #self.logInfo(json_resp) if json_resp['response']['result'] == "Success": for link in json_resp['response']['folder_info']['files']: self.urls.append("http://www.mediafire.com/file/%s" % link['quickkey']) else: self.fail(json_resp['response']['message']) elif result == 1: self.offline() else: self.urls.append(url)
def handle_premium(self, pyfile): host = self._get_host(pyfile.url) json_params = json_dumps({ 'link': pyfile.url, 'type': host, 'username': self.user, 'password': self.account.getAccountData(self.user)['password'] }) r = self.load("http://gen.linksnappy.com/genAPI.php", post={'genLinks': json_params}) self.logDebug("JSON data: " + r) j = json_loads(r)['links'][0] if j['error']: self.error(_("Error converting the link")) pyfile.name = j['filename'] self.link = j['generated'] if host in self.SINGLE_CHUNK_HOSTERS: self.chunkLimit = 1 else: self.setup()
def loadHosterList(self, req): json_data = req.load('http://multi-debrid.com/api.php?hosts', decode=True) self.logDebug('JSON data: ' + json_data) json_data = json_loads(json_data) return json_data['hosts']
def handle_premium(self, pyfile): https = "https" if self.getConfig('ssl') else "http" data = self.account.getAccountData(self.user) page = self.load(https + "://api.over-load.me/getdownload.php", get={ 'auth': data['password'], 'link': pyfile.url }) data = json_loads(page) self.logDebug(data) if data['error'] == 1: self.logWarning(data['msg']) self.tempOffline() else: if pyfile.name and pyfile.name.endswith( '.tmp') and data['filename']: pyfile.name = data['filename'] pyfile.size = parseFileSize(data['filesize']) http_repl = ["http://", "https://"] self.link = data['downloadlink'].replace( *http_repl if self.getConfig('ssl') else http_repl[::-1])
def handle_free(self, pyfile): try: song_id = re.search(r'sounds:(\d+)"', self.html).group(1) except Exception: self.error(_("Could not find song id")) try: client_id = re.search(r'"clientID":"(.+?)"', self.html).group(1) except Exception: client_id = "b45b1aa10f1ac2941910a7f0d10f8e28" # url to retrieve the actual song url streams = json_loads(self.load("https://api.soundcloud.com/tracks/%s/streams" % song_id, get={'client_id': client_id})) regex = re.compile(r'[^\d]') http_streams = sorted([(key, value) for key, value in streams.iteritems() if key.startswith('http_')], key=lambda t: regex.sub(t[0], ''), reverse=True) self.logDebug("Streams found: %s" % (http_streams or "None")) if http_streams: stream_name, self.link = http_streams[0 if self.getConfig('quality') == "Higher" else -1] pyfile.name += '.' + stream_name.split('_')[1].lower()
def handleFree(self, pyfile): try: song_id = re.search(r'sounds:(\d+)"', self.html).group(1) except Exception: self.error(_("Could not find song id")) try: client_id = re.search(r'"clientID":"(.+?)"', self.html).group(1) except Exception: client_id = "b45b1aa10f1ac2941910a7f0d10f8e28" # url to retrieve the actual song url streams = json_loads( self.load("https://api.soundcloud.com/tracks/%s/streams" % song_id, get={'client_id': client_id})) regex = re.compile(r'[^\d]') http_streams = sorted( [(key, value) for key, value in streams.iteritems() if key.startswith('http_')], key=lambda t: regex.sub(t[0], ''), reverse=True) self.logDebug("Streams found: %s" % (http_streams or "None")) if http_streams: stream_name, self.link = http_streams[ 0 if self.getConfig('quality') == "Higher" else -1] pyfile.name += '.' + stream_name.split('_')[1].lower()
def api_response(self, api="captcha", post=False, multipart=False): req = getRequest() req.c.setopt(HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) if post: if not isinstance(post, dict): post = {} post.update({"username": self.getConfig('username'), "password": self.getConfig('passkey')}) res = None try: json = req.load("%s%s" % (self.API_URL, api), post=post, multipart=multipart) self.logDebug(json) res = json_loads(json) if "error" in res: raise DeathByCaptchaException(res['error']) elif "status" not in res: raise DeathByCaptchaException(str(res)) except BadHeader, e: if 403 == e.code: raise DeathByCaptchaException('not-logged-in') elif 413 == e.code: raise DeathByCaptchaException('invalid-captcha') elif 503 == e.code: raise DeathByCaptchaException('service-overload') elif e.code in (400, 405): raise DeathByCaptchaException('invalid-request') else: raise
def login(self, user, data, req): page = req.load("http://fastix.ru/api_v2/?sub=get_apikey&email=%s&password=%s" % (user, data["password"])) api = json_loads(page) api = api['apikey'] data["api"] = api if "error_code" in page: self.wrongPassword()
def handle_free(self, pyfile): m = re.search(self.LINK_FREE_PATTERN, self.html) if m is None: self.error(_("LINK_FREE_PATTERN not found")) url = m.group(1) self.logDebug( ('FREEUSER' if m.group(2) == 'download' else 'GUEST') + ' URL', url) res = json_loads(self.load("http://115.com" + url, decode=False)) if "urls" in res: mirrors = res['urls'] elif "data" in res: mirrors = res['data'] else: mirrors = None for mr in mirrors: try: self.link = mr['url'].replace("\\", "") self.logDebug("Trying URL: " + self.link) break except Exception: continue else: self.fail(_("No working link found"))
def getJsonResponse(self, get_dict, post_dict, field): res = json_loads(self.load('https://filepost.com/files/get/', get=get_dict, post=post_dict)) self.logDebug(res) if not 'js' in res: self.error(_("JSON %s 1") % field) # i changed js_answer to res['js'] since js_answer is nowhere set. # i don't know the JSON-HTTP specs in detail, but the previous author # accessed res['js']['error'] as well as js_answer['error']. # see the two lines commented out with "# ~?". if 'error' in res['js']: if res['js']['error'] == 'download_delay': self.retry(wait_time=res['js']['params']['next_download']) # ~? self.retry(wait_time=js_answer['params']['next_download']) elif 'Wrong file password' in res['js']['error'] \ or 'You entered a wrong CAPTCHA code' in res['js']['error'] \ or 'CAPTCHA Code nicht korrekt' in res['js']['error']: return None elif 'CAPTCHA' in res['js']['error']: self.logDebug("Error response is unknown, but mentions CAPTCHA") return None else: self.fail(res['js']['error']) if not 'answer' in res['js'] or not field in res['js']['answer']: self.error(_("JSON %s 2") % field) return res['js']['answer'][field]
def getHosters(self): hostings = json_loads(self.getURL("https://www.rapideo.pl/clipboard.php?json=3").strip()) hostings_domains = [domain for row in hostings for domain in row["domains"] if row["sdownload"] == "0"] self.logDebug(hostings_domains) return hostings_domains
def handleFree(self, pyfile): action, inputs = self.parseHtmlForm('id="frm-downloadDialog-freeDownloadForm"') if not action or not inputs: self.error(_("Free download form not found")) self.logDebug("inputs.keys = " + str(inputs.keys())) # get and decrypt captcha if all(key in inputs for key in ("captcha_value", "captcha_id", "captcha_key")): # Old version - last seen 9.12.2013 self.logDebug('Using "old" version') captcha_value = self.decryptCaptcha("http://img.uloz.to/captcha/%s.png" % inputs['captcha_id']) self.logDebug("CAPTCHA ID: " + inputs['captcha_id'] + ", CAPTCHA VALUE: " + captcha_value) inputs.update({'captcha_id': inputs['captcha_id'], 'captcha_key': inputs['captcha_key'], 'captcha_value': captcha_value}) elif all(key in inputs for key in ("captcha_value", "timestamp", "salt", "hash")): # New version - better to get new parameters (like captcha reload) because of image url - since 6.12.2013 self.logDebug('Using "new" version') xapca = self.load("http://www.ulozto.net/reloadXapca.php", get={'rnd': str(int(time.time()))}) self.logDebug("xapca = " + str(xapca)) data = json_loads(xapca) captcha_value = self.decryptCaptcha(str(data['image'])) self.logDebug("CAPTCHA HASH: " + data['hash'], "CAPTCHA SALT: " + str(data['salt']), "CAPTCHA VALUE: " + captcha_value) inputs.update({'timestamp': data['timestamp'], 'salt': data['salt'], 'hash': data['hash'], 'captcha_value': captcha_value}) else: self.error(_("CAPTCHA form changed")) self.download("http://www.ulozto.net" + action, post=inputs)
def loadHosterList(self, req): json_data = req.load('http://unrestrict.li/api/jdownloader/hosts.php?format=json') json_data = json_loads(json_data) host_list = [element['host'] for element in json_data['result']] return host_list
def getAccountStatus(self, user, req): # Use premiumize.me API v1 (see https://secure.premiumize.me/?show=api) # to retrieve account info and return the parsed json answer answer = req.load( "https://api.premiumize.me/pm-api/v1.php?method=accountstatus¶ms[login]=%s¶ms[pass]=%s" % ( user, self.accounts[user]['password'])) return json_loads(answer)
def getHosters(self): hostings = json_loads(self.getURL("https://www.nopremium.pl/clipboard.php?json=3").strip()) hostings_domains = [domain for row in hostings for domain in row['domains'] if row['sdownload'] == "0"] self.logDebug(hostings_domains) return hostings_domains
def getInfo(urls): result = [] regex = re.compile(DailymotionCom.__pattern) apiurl = "https://api.dailymotion.com/video/%s" request = {"fields": "access_error,status,title"} for url in urls: id = regex.match(url).group('ID') html = getURL(apiurl % id, get=request) info = json_loads(html) name = info['title'] + ".mp4" if "title" in info else url if "error" in info or info['access_error']: status = "offline" else: status = info['status'] if status in ("ready", "published"): status = "online" elif status in ("waiting", "processing"): status = "temp. offline" else: status = "offline" result.append((name, 0, statusMap[status], url)) return result
def process(self, pyfile): if not self.account: self.logError(_("Please enter your %s account or deactivate this plugin") % "Unrestrict.li") self.fail("No Unrestrict.li account provided") self.logDebug("Old URL: %s" % pyfile.url) if re.match(self.__pattern__, pyfile.url): new_url = pyfile.url else: for i in xrange(5): page = self.req.load('https://unrestrict.li/unrestrict.php', post={'link': pyfile.url, 'domain': 'long'}) self.logDebug("JSON data: " + page) if page != '': break if "File offline" in page: self.offline() elif "You are not allowed to download from this host" in page: self.fail("You are not allowed to download from this host") elif "You have reached your daily limit for this host" in page: self.logInfo("Reached daily limit for this host. Waiting until 00:10 GMT+2") self.retry(5, secondsToMidnight(), "Daily limit for this host reached") page = json_loads(page) new_url = page.keys()[0] self.api_data = page[new_url] self.logDebug("New URL: " + new_url) self.download(new_url, disposition=True) if self.getConfig("history"): self.load("https://unrestrict.li/history/&delete=all") self.logInfo("Download history deleted")
def handlePremium(self, pyfile): premium_url = None if self.getClassName() == "FileserveCom": # try api download res = self.load("http://app.fileserve.com/api/download/premium/", post={ "username": self.user, "password": self.account.getAccountData( self.user)['password'], "shorten": self.file_id }, decode=True) if res: res = json_loads(res) if res['error_code'] == "302": premium_url = res['next'] elif res['error_code'] in ["305", "500"]: self.tempOffline() elif res['error_code'] in ["403", "605"]: self.resetAccount() elif res['error_code'] in ["606", "607", "608"]: self.offline() else: self.logError(res['error_code'], res['error_message']) self.download(premium_url or pyfile.url) if not premium_url and self.checkDownload( {"login": re.compile(self.NOT_LOGGED_IN_PATTERN)}): self.account.relogin(self.user) self.retry(reason=_("Not logged in"))
def getAccountStatus(self, user, req): password = self.getAccountData(user)['password'] salt = hashlib.sha256(password).hexdigest() encrypted = PBKDF2(password, salt, iterations=1000).hexread(32) return json_loads(req.load("http://www2.smoozed.com/api/login", get={'auth': user, 'password': encrypted}))
def getHosters(self): json_data = self.getURL( "http://unrestrict.li/api/jdownloader/hosts.php", get={'format': "json"}) json_data = json_loads(json_data) return [element['host'] for element in json_data['result']]
def getInfo(cls, url="", html=""): info = super(YadiSk, cls).getInfo(url, html) if html: if 'idclient' not in info: info['idclient'] = "" for _i in xrange(32): info ['idclient'] += random.choice('0123456abcdef') m = re.search(r'<script id="models-client" type="application/json">(.+?)</script>', html) if m: api_data = json_loads(m.group(1)) try: for sect in api_data: if 'model' in sect: if sect['model'] == "config": info['version'] = sect['data']['version'] info['sk'] = sect['data']['sk'] elif sect['model'] == "resource": info['id'] = sect['data']['id'] info['size'] = sect['data']['meta']['size'] info['name'] = sect['data']['name'] except Exception, e: info['status'] = 8 info['error'] = _("Unexpected server response: %s") % e.message else: info['status'] = 8 info['error'] = _("could not find required json data")
def process(self, pyfile): if not self.account: self.logError(_("Please enter your %s account or deactivate this plugin") % "Fastix") self.fail("No Fastix account provided") self.logDebug("Old URL: %s" % pyfile.url) if re.match(self.__pattern__, pyfile.url): new_url = pyfile.url else: api_key = self.account.getAccountData(self.user) api_key = api_key["api"] url = "http://fastix.ru/api_v2/?apikey=%s&sub=getdirectlink&link=%s" % (api_key, pyfile.url) page = self.load(url) data = json_loads(page) self.logDebug("Json data: %s" % str(data)) if "error\":true" in page: self.offline() else: new_url = data["downloadlink"] self.logDebug("New URL: %s" % new_url) if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown"): #only use when name wasnt already set pyfile.name = self.getFilename(new_url) self.download(new_url, disposition=True) check = self.checkDownload({"error": "<title>An error occurred while processing your request</title>", "empty": re.compile(r"^$")}) if check == "error": self.retry(reason="An error occurred while generating link.", wait_time=60) elif check == "empty": self.retry(reason="Downloaded File was empty.", wait_time=60)
def handlePremium(self, pyfile): premium_url = None if self.__class__.__name__ == "FileserveCom": #try api download res = self.load("http://app.fileserve.com/api/download/premium/", post={"username": self.user, "password": self.account.getAccountData(self.user)['password'], "shorten": self.file_id}, decode=True) if res: res = json_loads(res) if res['error_code'] == "302": premium_url = res['next'] elif res['error_code'] in ["305", "500"]: self.tempOffline() elif res['error_code'] in ["403", "605"]: self.resetAccount() elif res['error_code'] in ["606", "607", "608"]: self.offline() else: self.logError(res['error_code'], res['error_message']) self.download(premium_url or pyfile.url) if not premium_url and self.checkDownload({"login": re.compile(self.NOT_LOGGED_IN_PATTERN)}): self.account.relogin(self.user) self.retry(reason=_("Not logged in"))
def getHosters(self): json_data = self.getURL("http://www.simply-premium.com/api/hosts.php", get={'format': "json", 'online': 1}) json_data = json_loads(json_data) host_list = [element['regex'] for element in json_data['result']] return host_list
def handle_premium(self, pyfile): data = json_loads(self.load("https://real-debrid.com/ajax/unrestrict.php", get={'lang' : "en", 'link' : pyfile.url, 'password': self.getPassword(), 'time' : int(time.time() * 1000)})) self.logDebug("Returned Data: %s" % data) if data['error'] != 0: if data['message'] == "Your file is unavailable on the hoster.": self.offline() else: self.logWarning(data['message']) self.tempOffline() else: if pyfile.name and pyfile.name.endswith('.tmp') and data['file_name']: pyfile.name = data['file_name'] pyfile.size = parseFileSize(data['file_size']) self.link = data['generated_links'][0][-1] if self.getConfig('ssl'): self.link = self.link.replace("http://", "https://") else: self.link = self.link.replace("https://", "http://")
def process(self, pyfile): # Check account if not self.account or not self.account.isUsable(): self.logError(_("Please enter a valid premiumize.me account or deactivate this plugin")) self.fail("No valid premiumize.me account provided") # In some cases hostsers do not supply us with a filename at download, so we are going to set a fall back filename (e.g. for freakshare or xfileshare) self.pyfile.name = self.pyfile.name.split('/').pop() # Remove everthing before last slash # Correction for automatic assigned filename: Removing html at end if needed suffix_to_remove = ["html", "htm", "php", "php3", "asp", "shtm", "shtml", "cfml", "cfm"] temp = self.pyfile.name.split('.') if temp.pop() in suffix_to_remove: self.pyfile.name = ".".join(temp) # Get rewritten link using the premiumize.me api v1 (see https://secure.premiumize.me/?show=api) answer = self.load("https://api.premiumize.me/pm-api/v1.php?method=directdownloadlink¶ms[login]=%s¶ms[pass]=%s¶ms[link]=%s" % (self.account.loginname, self.account.password, self.pyfile.url)) data = json_loads(answer) # Check status and decide what to do status = data['status'] if status == 200: self.download(data['result']['location'], disposition=True) elif status == 400: self.fail("Invalid link") elif status == 404: self.offline() elif status >= 500: self.tempOffline() else: self.fail(data['statusmessage'])
def process(self, pyfile): if not self.account: self.logError( _("Please enter your %s account or deactivate this plugin") % "Real-debrid") self.fail("No Real-debrid account provided") self.logDebug("Real-Debrid: Old URL: %s" % pyfile.url) if re.match(self.__pattern__, pyfile.url): new_url = pyfile.url else: password = self.getPassword().splitlines() if not password: password = "" else: password = password[0] url = "http://real-debrid.com/ajax/unrestrict.php?lang=en&link=%s&password=%s&time=%s" % ( quote(pyfile.url, ""), password, int(time() * 1000)) page = self.load(url) data = json_loads(page) self.logDebug("Returned Data: %s" % data) if data["error"] != 0: if data["message"] == "Your file is unavailable on the hoster.": self.offline() else: self.logWarning(data["message"]) self.tempOffline() else: if self.pyfile.name is not None and self.pyfile.name.endswith( '.tmp') and data["file_name"]: self.pyfile.name = data["file_name"] self.pyfile.size = parseFileSize(data["file_size"]) new_url = data['generated_links'][0][-1] if self.getConfig("https"): new_url = new_url.replace("http://", "https://") else: new_url = new_url.replace("https://", "http://") self.logDebug("Real-Debrid: New URL: %s" % new_url) if pyfile.name.startswith("http") or pyfile.name.startswith( "Unknown") or pyfile.name.endswith('..'): #only use when name wasnt already set pyfile.name = self.getFilename(new_url) self.download(new_url, disposition=True) check = self.checkDownload({ "error": "<title>An error occured while processing your request</title>" }) if check == "error": #usual this download can safely be retried self.retry(reason="An error occured while generating link.", wait_time=60)
def api_response(self, api="captcha", post=False, multipart=False): req = getRequest() req.c.setopt(pycurl.HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) if post: if not isinstance(post, dict): post = {} post.update({"username": self.getConfig('username'), "password": self.getConfig('passkey')}) res = None try: json = req.load("%s%s" % (self.API_URL, api), post=post, multipart=multipart) self.logDebug(json) res = json_loads(json) if "error" in res: raise DeathByCaptchaException(res['error']) elif "status" not in res: raise DeathByCaptchaException(str(res)) except BadHeader, e: if 403 == e.code: raise DeathByCaptchaException('not-logged-in') elif 413 == e.code: raise DeathByCaptchaException('invalid-captcha') elif 503 == e.code: raise DeathByCaptchaException('service-overload') elif e.code in (400, 405): raise DeathByCaptchaException('invalid-request') else: raise
def handlePremium(self, pyfile): data = json_loads(self.load("https://real-debrid.com/ajax/unrestrict.php", get={'lang' : "en", 'link' : pyfile.url, 'password': self.getPassword(), 'time' : int(time.time() * 1000)})) self.logDebug("Returned Data: %s" % data) if data['error'] != 0: if data['message'] == "Your file is unavailable on the hoster.": self.offline() else: self.logWarning(data['message']) self.tempOffline() else: if pyfile.name and pyfile.name.endswith('.tmp') and data['file_name']: pyfile.name = data['file_name'] pyfile.size = parseFileSize(data['file_size']) self.link = data['generated_links'][0][-1] if self.getConfig('ssl'): self.link = self.link.replace("http://", "https://") else: self.link = self.link.replace("https://", "http://")
def getHosters(self): html = self.getURL("http://fastix.ru/api_v2", get={'apikey': "5182964c3f8f9a7f0b00000a_kelmFB4n1IrnCDYuIFn2y", 'sub' : "allowed_sources"}) host_list = json_loads(html) host_list = host_list['allow'] return host_list
def loadAccountInfo(self, user, req): premium = False validuntil = -1 trafficleft = None json_data = req.load( 'http://www.simply-premium.com/api/user.php?format=json') self.logDebug("JSON data: %s" % json_data) json_data = json_loads(json_data) if 'vip' in json_data['result'] and json_data['result']['vip']: premium = True if 'timeend' in json_data['result'] and json_data['result']['timeend']: validuntil = float(json_data['result']['timeend']) if 'remain_traffic' in json_data['result'] and json_data['result'][ 'remain_traffic']: trafficleft = float(json_data['result']['remain_traffic']) return { "premium": premium, "validuntil": validuntil, "trafficleft": trafficleft }
def handle_free(self, pyfile): m = re.search(self.LINK_FREE_PATTERN, self.html) if m is None: self.error(_("LINK_FREE_PATTERN not found")) url = m.group(1) self.logDebug(('FREEUSER' if m.group(2) == 'download' else 'GUEST') + ' URL', url) res = json_loads(self.load("http://115.com" + url, decode=False)) if "urls" in res: mirrors = res['urls'] elif "data" in res: mirrors = res['data'] else: mirrors = None for mr in mirrors: try: self.link = mr['url'].replace("\\", "") self.logDebug("Trying URL: " + self.link) break except Exception: continue else: self.fail(_("No working link found"))
def loadAccountInfo(self, user, req): data = self.getAccountData(user) r = req.load('http://gen.linksnappy.com/lseAPI.php', get={'act': 'USERDETAILS', 'username': user, 'password': hashlib.md5(data['password']).hexdigest()}) self.logDebug("JSON data: " + r) j = json_loads(r) if j['error']: return {"premium": False} validuntil = j['return']['expire'] if validuntil == 'lifetime': validuntil = -1 elif validuntil == 'expired': return {"premium": False} else: validuntil = float(validuntil) if 'trafficleft' not in j['return'] or isinstance(j['return']['trafficleft'], str): trafficleft = -1 else: trafficleft = self.parseTraffic("%d MB" % j['return']['trafficleft']) return {"premium": True, "validuntil": validuntil, "trafficleft": trafficleft}
def loadHosterList(self, req): page = req.load( "http://fastix.ru/api_v2/?apikey=5182964c3f8f9a7f0b00000a_kelmFB4n1IrnCDYuIFn2y&sub=allowed_sources" ) host_list = json_loads(page) host_list = host_list['allow'] return host_list
def process(self, pyfile): if not self.account: self.logError( _("Please enter your %s account or deactivate this plugin") % "Unrestrict.li") self.fail("No Unrestrict.li account provided") self.logDebug("Old URL: %s" % pyfile.url) if re.match(self.__pattern__, pyfile.url): new_url = pyfile.url else: for i in xrange(5): page = self.req.load('https://unrestrict.li/unrestrict.php', post={ 'link': pyfile.url, 'domain': 'long' }) self.logDebug("JSON data: " + page) if page != '': break else: self.logInfo( "Unable to get API data, waiting 1 minute and retry") self.retry(5, 60, "Unable to get API data") if 'Expired session' in page or ("You are not allowed to " "download from this host" in page and self.premium): self.account.relogin(self.user) self.retry() elif "File offline" in page: self.offline() elif "You are not allowed to download from this host" in page: self.fail("You are not allowed to download from this host") elif "You have reached your daily limit for this host" in page: self.logInfo( "Reached daily limit for this host. Waiting until 00:10 GMT+2" ) self.retry(5, secondsToMidnight(), "Daily limit for this host reached") elif "ERROR_HOSTER_TEMPORARILY_UNAVAILABLE" in page: self.logInfo( "Hoster temporarily unavailable, waiting 1 minute and retry" ) self.retry(5, 60, "Hoster is temporarily unavailable") page = json_loads(page) new_url = page.keys()[0] self.api_data = page[new_url] self.logDebug("New URL: " + new_url) if hasattr(self, 'api_data'): self.setNameSize() self.download(new_url, disposition=True) if self.getConfig("history"): self.load("https://unrestrict.li/history/&delete=all") self.logInfo("Download history deleted")
def getAccountStatus(self, user, req): # Use premiumize.me API v1 (see https://secure.premiumize.me/?show=api) # to retrieve account info and return the parsed json answer answer = req.load("https://api.premiumize.me/pm-api/v1.php", get={'method' : "accountstatus", 'params[login]': user, 'params[pass]' : self.getAccountData(user)['password']}) return json_loads(answer)
def getAccountStatus(self, user, req): # Using the rpnet API, check if valid premium account res = req.load("https://premium.rpnet.biz/client_api.php", get={"username": user, "password": self.getAccountData(user)['password'], "action": "showAccountInformation"}) self.logDebug("JSON data: %s" % res) return json_loads(res)
def loadHosterList(self, req): json_data = req.load( 'http://unrestrict.li/api/jdownloader/hosts.php?format=json') json_data = json_loads(json_data) host_list = [element['host'] for element in json_data['result']] return host_list
def getJsonResponse(self, *args, **kwargs): res = self.load(*args, **kwargs) if not res.startswith('{'): self.retry() self.logDebug(res) return json_loads(res)
def handle_free(self, pyfile): self.html = self.load(self.url) action = self.load(self.url, post={"checkDownload": "check"}, decode=True) action = json_loads(action) self.logDebug(action) if "fail" in action: if action['fail'] == "timeLimit": self.html = self.load(self.url, post={"checkDownload": "showError", "errorType": "timeLimit"}, decode=True) self.doLongWait(re.search(self.LONG_WAIT_PATTERN, self.html)) elif action['fail'] == "parallelDownload": self.logWarning(_("Parallel download error, now waiting 60s")) self.retry(wait_time=60, reason=_("parallelDownload")) else: self.fail(_("Download check returned: %s") % action['fail']) elif "success" in action: if action['success'] == "showCaptcha": self.doCaptcha() self.doTimmer() elif action['success'] == "showTimmer": self.doTimmer() else: self.error(_("Unknown server response")) # show download link res = self.load(self.url, post={"downloadLink": "show"}, decode=True) self.logDebug("Show downloadLink response: %s" % res) if "fail" in res: self.error(_("Couldn't retrieve download url")) # this may either download our file or forward us to an error page self.download(self.url, post={"download": "normal"}) self.logDebug(self.req.http.lastEffectiveURL) check = self.checkDownload({"expired": self.LINK_EXPIRED_PATTERN, "wait" : re.compile(self.LONG_WAIT_PATTERN), "limit" : self.DAILY_LIMIT_PATTERN}) if check == "expired": self.logDebug("Download link was expired") self.retry() elif check == "wait": self.doLongWait(self.lastCheck) elif check == "limit": self.logWarning(_("Download limited reached for today")) self.setWait(secondsToMidnight(gmt=2), True) self.wait() self.retry() self.thread.m.reconnecting.wait(3) #: Ease issue with later downloads appearing to be in parallel
def login(self, user, data, req): # Password to use is the API-Password written in http://multi-debrid.com/myaccount self.html = req.load("http://multi-debrid.com/api.php", get={"user": user, "pass": data["password"]}) self.logDebug('JSON data: ' + self.html) self.json_data = json_loads(self.html) if self.json_data['status'] != 'ok': self.logError('Invalid login. The password to use is the API-Password you find in your "My Account" page') self.wrongPassword()