diff options
49 files changed, 149 insertions, 158 deletions
diff --git a/module/plugins/hoster/AlldebridCom.py b/module/plugins/hoster/AlldebridCom.py index c6c4365c7..1a8bd8376 100644 --- a/module/plugins/hoster/AlldebridCom.py +++ b/module/plugins/hoster/AlldebridCom.py @@ -3,9 +3,8 @@ import re import urllib -from module.common.json_layer import json_loads from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -from module.plugins.internal.Plugin import parse_size +from module.plugins.internal.utils import json, parse_size class AlldebridCom(MultiHoster): @@ -31,7 +30,7 @@ class AlldebridCom(MultiHoster): def handle_premium(self, pyfile): password = self.get_password() - data = json_loads(self.load("http://www.alldebrid.com/service.php", + data = json.loads(self.load("http://www.alldebrid.com/service.php", get={'link': pyfile.url, 'json': "true", 'pw': password})) self.log_debug("Json data", data) diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py index ea56caef4..43de3a8b8 100644 --- a/module/plugins/hoster/CzshareCom.py +++ b/module/plugins/hoster/CzshareCom.py @@ -5,8 +5,8 @@ import re -from module.plugins.internal.Plugin import parse_size from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.utils import parse_size class CzshareCom(SimpleHoster): diff --git a/module/plugins/hoster/DailymotionCom.py b/module/plugins/hoster/DailymotionCom.py index 1634bb12d..0affea97e 100644 --- a/module/plugins/hoster/DailymotionCom.py +++ b/module/plugins/hoster/DailymotionCom.py @@ -3,7 +3,7 @@ import re from module.PyFile import statusMap -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.network.RequestFactory import getURL as get_url from module.plugins.internal.Hoster import Hoster @@ -17,7 +17,7 @@ def get_info(urls): for url in urls: id = regex.match(url).group('ID') html = get_url(apiurl % id, get=request) - info = json_loads(html) + info = json.loads(html) name = info['title'] + ".mp4" if "title" in info else url diff --git a/module/plugins/hoster/DlFreeFr.py b/module/plugins/hoster/DlFreeFr.py index b6e618235..e8b70f479 100644 --- a/module/plugins/hoster/DlFreeFr.py +++ b/module/plugins/hoster/DlFreeFr.py @@ -91,7 +91,7 @@ class DlFreeFr(SimpleHoster): self.offline() else: - self.fail(_("Invalid return code: ") + str(headers.get('code'))) + self.fail(_("Invalid return code: %s") % headers.get('code')) def handle_free(self, pyfile): diff --git a/module/plugins/hoster/EuroshareEu.py b/module/plugins/hoster/EuroshareEu.py index 7ec6dc428..be5c0480f 100644 --- a/module/plugins/hoster/EuroshareEu.py +++ b/module/plugins/hoster/EuroshareEu.py @@ -22,7 +22,7 @@ class EuroshareEu(SimpleHoster): NAME_PATTERN = r'<h1 class="nazev-souboru">(?P<N>.+?)</h1>' SIZE_PATTERN = r'<p class="posledni vpravo">.*\| (?P<S>.+?) (?P<U>.+?)</p>' - + OFFLINE_PATTERN = ur'<h2>S.bor sa nena.iel</h2>|Požadovaná stránka neexistuje!' LINK_FREE_PATTERN = r'onclick="return checkLoad\(\);" href="(.+?)" class="tlacitko velky"' @@ -40,8 +40,10 @@ class EuroshareEu(SimpleHoster): self.link = pyfile.url.rstrip('/') + "/download/" - check = self.check_file({'login': re.compile(self.ERROR_PATTERN), - 'json' : re.compile(r'\{"status":"error".*?"message":"(.*?)"')}) + check = self.check_file({ + 'login': re.compile(self.ERROR_PATTERN), + 'json' : re.compile(r'\{"status":"error".*?"message":"(.*?)"') + }) if check == "login" or (check == "json" and self.last_check.group(1) == "Access token expired"): self.account.relogin() diff --git a/module/plugins/hoster/ExtabitCom.py b/module/plugins/hoster/ExtabitCom.py index 0311ada4b..b27cf8faf 100644 --- a/module/plugins/hoster/ExtabitCom.py +++ b/module/plugins/hoster/ExtabitCom.py @@ -2,7 +2,7 @@ import re -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, seconds_to_midnight @@ -54,7 +54,7 @@ class ExtabitCom(SimpleHoster): get_data = {'type': "recaptcha"} get_data['capture'], get_data['challenge'] = recaptcha.challenge(captcha_key) - res = json_loads(self.load("http://extabit.com/file/%s/" % fileID, get=get_data)) + res = json.loads(self.load("http://extabit.com/file/%s/" % fileID, get=get_data)) if "ok" in res: self.captcha.correct() diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index dac8e9404..aeb8e6184 100644 --- a/module/plugins/hoster/FastixRu.py +++ b/module/plugins/hoster/FastixRu.py @@ -3,7 +3,7 @@ import re import urllib -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo @@ -32,7 +32,7 @@ class FastixRu(MultiHoster): get={'apikey': self.account.get_data('apikey'), 'sub' : "getdirectlink", 'link' : pyfile.url}) - data = json_loads(self.html) + data = json.loads(self.html) self.log_debug("Json data", data) diff --git a/module/plugins/hoster/FilecloudIo.py b/module/plugins/hoster/FilecloudIo.py index c83813111..ca6eefe29 100644 --- a/module/plugins/hoster/FilecloudIo.py +++ b/module/plugins/hoster/FilecloudIo.py @@ -2,7 +2,7 @@ import re -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -71,7 +71,7 @@ class FilecloudIo(SimpleHoster): json_url = "http://filecloud.io/download-request.json" res = self.load(json_url, post=data) self.log_debug(res) - res = json_loads(res) + res = json.loads(res) if "error" in res and res['error']: self.fail(res) @@ -84,7 +84,7 @@ class FilecloudIo(SimpleHoster): json_url = "http://filecloud.io/download-request.json" res = self.load(json_url, post=data) self.log_debug(res) - res = json_loads(res) + res = json.loads(res) if "retry" in res and res['retry']: self.retry_captcha() @@ -114,7 +114,7 @@ class FilecloudIo(SimpleHoster): rep = self.load("http://api.filecloud.io/api-fetch_download_url.api", post={'akey': akey, 'ukey': ukey}) self.log_debug("FetchDownloadUrl: " + rep) - rep = json_loads(rep) + rep = json.loads(rep) if rep['status'] == "ok": self.link = rep['download_url'] else: diff --git a/module/plugins/hoster/FilefactoryCom.py b/module/plugins/hoster/FilefactoryCom.py index e608d6db0..c7fd68aca 100644 --- a/module/plugins/hoster/FilefactoryCom.py +++ b/module/plugins/hoster/FilefactoryCom.py @@ -63,8 +63,10 @@ class FilefactoryCom(SimpleHoster): def check_download(self): - check = self.check_file({'multiple': "You are currently downloading too many files at once.", - 'error' : '<div id="errorMessage">'}) + check = self.check_file({ + 'multiple': "You are currently downloading too many files at once.", + 'error' : '<div id="errorMessage">' + }) if check == "multiple": self.log_debug("Parallel downloads detected; waiting 15 minutes") diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py index 10af73ff9..fd010e35f 100644 --- a/module/plugins/hoster/FilepostCom.py +++ b/module/plugins/hoster/FilepostCom.py @@ -3,7 +3,7 @@ import re import time -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -81,7 +81,7 @@ class FilepostCom(SimpleHoster): def get_json_response(self, get_dict, post_dict, field): - res = json_loads(self.load('https://filepost.com/files/get/', get=get_dict, post=post_dict)) + res = json.loads(self.load('https://filepost.com/files/get/', get=get_dict, post=post_dict)) self.log_debug(res) diff --git a/module/plugins/hoster/FilesMailRu.py b/module/plugins/hoster/FilesMailRu.py index eae9ec1c4..ddaa15fc2 100644 --- a/module/plugins/hoster/FilesMailRu.py +++ b/module/plugins/hoster/FilesMailRu.py @@ -105,9 +105,7 @@ class FilesMailRu(Hoster): #: so i set it to check every download because sometimes there are downloads #: that contain the HTML-Text and 60MB ZEROs after that in a xyzfile.part1.rar file #: (Loading 100MB in to ram is not an option) - check = self.check_file({'html': "<meta name="}, read_size=50000) - if check == "html": - self.log_info(_( - "There was HTML Code in the Downloaded File (%s)...redirect error? The Download will be restarted." % - self.pyfile.name)) + if self.check_file({'html': "<meta name="}, read_size=50000) is "html": + self.log_info(_("There was HTML Code in the Downloaded File (%s)...redirect error? The Download will be restarted." % + self.pyfile.name)) self.retry() diff --git a/module/plugins/hoster/FileserveCom.py b/module/plugins/hoster/FileserveCom.py index c6abbc843..836954985 100644 --- a/module/plugins/hoster/FileserveCom.py +++ b/module/plugins/hoster/FileserveCom.py @@ -2,12 +2,11 @@ import re -from module.common.json_layer import json_loads from module.network.RequestFactory import getURL as get_url from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.Hoster import Hoster -from module.plugins.internal.Plugin import chunks, parse_size from module.plugins.internal.SimpleHoster import seconds_to_midnight +from module.plugins.internal.utils import chunks, json, parse_size def check_file(plugin, urls): @@ -84,7 +83,7 @@ class FileserveCom(Hoster): def handle_free(self): self.html = self.load(self.url) action = self.load(self.url, post={'checkDownload': "check"}) - action = json_loads(action) + action = json.loads(action) self.log_debug(action) if "fail" in action: @@ -162,7 +161,7 @@ class FileserveCom(Hoster): recaptcha = ReCaptcha(self) response, challenge = recaptcha.challenge(captcha_key) - res = json_loads(self.load(self.URLS[2], + res = json.loads(self.load(self.URLS[2], post={'recaptcha_challenge_field' : challenge, 'recaptcha_response_field' : response, 'recaptcha_shortencode_field': self.file_id})) @@ -187,7 +186,7 @@ class FileserveCom(Hoster): 'password': self.account.get_login('password'), 'shorten': self.file_id}) if res: - res = json_loads(res) + res = json.loads(res) if res['error_code'] == "302": premium_url = res['next'] @@ -205,7 +204,8 @@ class FileserveCom(Hoster): self.download(premium_url or self.pyfile.url) - if not premium_url and self.check_file({'login': re.compile(self.NOT_LOGGED_IN_PATTERN)}): + if not premium_url and \ + self.check_file({'login': re.compile(self.NOT_LOGGED_IN_PATTERN)}): self.account.relogin() self.retry(msg=_("Not logged in")) diff --git a/module/plugins/hoster/FreakshareCom.py b/module/plugins/hoster/FreakshareCom.py index bb3daf35d..5bf66f181 100644 --- a/module/plugins/hoster/FreakshareCom.py +++ b/module/plugins/hoster/FreakshareCom.py @@ -45,11 +45,13 @@ class FreakshareCom(Hoster): self.download(pyfile.url, post=self.req_opts) - check = self.check_file({'bad' : "bad try", - 'paralell' : "> Sorry, you cant download more then 1 files at time. <", - 'empty' : "Warning: Unknown: Filename cannot be empty", - 'wrong_captcha' : "Wrong Captcha!", - 'downloadserver': "No Downloadserver. Please try again later!"}) + check = self.check_file({ + 'bad' : "bad try", + 'paralell' : "> Sorry, you cant download more then 1 files at time. <", + 'empty' : "Warning: Unknown: Filename cannot be empty", + 'wrong_captcha' : "Wrong Captcha!", + 'downloadserver': "No Downloadserver. Please try again later!" + }) if check == "bad": self.fail(_("Bad Try")) diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index c30ad3c37..fc975329b 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -2,10 +2,9 @@ import pycurl import re -import urllib import urlparse -from module.plugins.internal.Hoster import Hoster +from module.plugins.internal.Hoster import Hoster, parse_name class Ftp(Hoster): @@ -25,20 +24,15 @@ class Ftp(Hoster): def setup(self): - self.chunk_limit = -1 + self.chunk_limit = -1 self.resume_download = True def process(self, pyfile): - p_url = urlparse.urlparse(pyfile.url) + p_url = urlparse.urlparse(pyfile.url) netloc = p_url.netloc - pyfile.name = p_url.path.rpartition('/')[2] - try: - pyfile.name = urllib.unquote(str(pyfile.name)).decode('utf8') - - except Exception: - pass + pyfile.name = parse_name(p_url.path.rpartition('/')[2]) if not "@" in netloc: self.log_debug("Auth required") @@ -74,6 +68,7 @@ class Ftp(Hoster): m = re.search(r"Content-Length:\s*(\d+)", res) if m is not None: pyfile.size = int(m.group(1)) + self.download(pyfile.url) else: diff --git a/module/plugins/hoster/GoogledriveCom.py b/module/plugins/hoster/GoogledriveCom.py index 27141dbe8..e9886a427 100644 --- a/module/plugins/hoster/GoogledriveCom.py +++ b/module/plugins/hoster/GoogledriveCom.py @@ -7,7 +7,7 @@ import re import urlparse from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.utils import html_unescape +from module.plugins.internal.utils import html_unescape class GoogledriveCom(SimpleHoster): @@ -45,12 +45,12 @@ class GoogledriveCom(SimpleHoster): return link = self.fixurl(link, "https://docs.google.com/") - direct_link = self.direct_link(link, False) + dl = self.is_download(link, redirect=False) - if not direct_link: + if not dl: self.html = self.load(link) else: - self.link = direct_link + self.link = dl break diff --git a/module/plugins/hoster/LetitbitNet.py b/module/plugins/hoster/LetitbitNet.py index 7ac1a7d71..6ee31d8c7 100644 --- a/module/plugins/hoster/LetitbitNet.py +++ b/module/plugins/hoster/LetitbitNet.py @@ -9,7 +9,7 @@ import re import urlparse -from module.common.json_layer import json_loads, json_dumps +from module.plugins.internal.utils import json from module.network.RequestFactory import getURL as get_url from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, seconds_to_midnight @@ -18,8 +18,8 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, seconds_to_midnig def api_response(url): json_data = ["yw7XQy2v9", ["download/info", {'link': url}]] api_rep = get_url("http://api.letitbit.net/json", - post={'r': json_dumps(json_data)}) - return json_loads(api_rep) + post={'r': json.dumps(json_data)}) + return json.loads(api_rep) def get_info(urls): @@ -108,7 +108,7 @@ class LetitbitNet(SimpleHoster): self.wait(seconds_to_midnight(), True) elif res.startswith('['): - urls = json_loads(res) + urls = json.loads(res) elif res.startswith('http://'): urls = [res] @@ -123,9 +123,9 @@ class LetitbitNet(SimpleHoster): premium_key = self.account.get_login('password') json_data = [self.account.user, ["download/direct_links", {'pass': premium_key, 'link': pyfile.url}]] - api_rep = self.load('http://api.letitbit.net/json', post={'r': json_dumps(json_data)}) + api_rep = self.load('http://api.letitbit.net/json', post={'r': json.dumps(json_data)}) self.log_debug("API Data: " + api_rep) - api_rep = json_loads(api_rep) + api_rep = json.loads(api_rep) if api_rep['status'] == "FAIL": self.fail(api_rep['data']) diff --git a/module/plugins/hoster/LinksnappyCom.py b/module/plugins/hoster/LinksnappyCom.py index aa9d9bdcb..7e373e1f1 100644 --- a/module/plugins/hoster/LinksnappyCom.py +++ b/module/plugins/hoster/LinksnappyCom.py @@ -3,7 +3,7 @@ import re import urlparse -from module.common.json_layer import json_loads, json_dumps +from module.plugins.internal.utils import json from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo @@ -25,7 +25,7 @@ class LinksnappyCom(MultiHoster): def handle_premium(self, pyfile): host = self._get_host(pyfile.url) - json_params = json_dumps({'link' : pyfile.url, + json_params = json.dumps({'link' : pyfile.url, 'type' : host, 'username': self.account.user, 'password': self.account.get_login('password')}) @@ -35,7 +35,7 @@ class LinksnappyCom(MultiHoster): self.log_debug("JSON data: " + r) - j = json_loads(r)['links'][0] + j = json.loads(r)['links'][0] if j['error']: self.error(_("Error converting the link")) diff --git a/module/plugins/hoster/LolabitsEs.py b/module/plugins/hoster/LolabitsEs.py index 18c845d8e..9522a5606 100644 --- a/module/plugins/hoster/LolabitsEs.py +++ b/module/plugins/hoster/LolabitsEs.py @@ -3,7 +3,7 @@ import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.utils import html_unescape +from module.plugins.internal.utils import html_unescape class LolabitsEs(SimpleHoster): diff --git a/module/plugins/hoster/LuckyShareNet.py b/module/plugins/hoster/LuckyShareNet.py index dc8f6448b..47fc9d4a8 100644 --- a/module/plugins/hoster/LuckyShareNet.py +++ b/module/plugins/hoster/LuckyShareNet.py @@ -2,7 +2,7 @@ import re -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -38,7 +38,7 @@ class LuckyShareNet(SimpleHoster): self.error(_("Unable to detect wait time between free downloads")) elif 'Hash expired' in rep: self.retry(msg=_("Hash expired")) - return json_loads(rep) + return json.loads(rep) #@TODO: There should be a filesize limit for free downloads @@ -48,14 +48,14 @@ class LuckyShareNet(SimpleHoster): self.log_debug("JSON: " + rep) - json = self.parse_json(rep) - self.wait(json['time']) + jso = self.parse_json(rep) + self.wait(jso['time']) recaptcha = ReCaptcha(self) response, challenge = recaptcha.challenge() rep = self.load(r"http://luckyshare.net/download/verify/challenge/%s/response/%s/hash/%s" % - (challenge, response, json['hash'])) + (challenge, response, jso['hash'])) self.log_debug("JSON: " + rep) @@ -64,9 +64,9 @@ class LuckyShareNet(SimpleHoster): elif 'link' in rep: self.captcha.correct() - json.update(self.parse_json(rep)) - if json['link']: - self.link = json['link'] + jso.update(self.parse_json(rep)) + if jso['link']: + self.link = jso['link'] getInfo = create_getInfo(LuckyShareNet) diff --git a/module/plugins/hoster/MegaCoNz.py b/module/plugins/hoster/MegaCoNz.py index 36ad929f4..95b86ab96 100644 --- a/module/plugins/hoster/MegaCoNz.py +++ b/module/plugins/hoster/MegaCoNz.py @@ -2,18 +2,18 @@ import array import os -# import pycurl import random import re +# import pycurl + from base64 import standard_b64decode from Crypto.Cipher import AES from Crypto.Util import Counter -from module.common.json_layer import json_loads, json_dumps from module.plugins.internal.Hoster import Hoster -from module.utils import decode, fs_decode, fs_encode +from module.plugins.internal.utils import decode, encode, json ############################ General errors ################################### @@ -89,9 +89,9 @@ class MegaCoNz(Hoster): #: Generate a session id, no idea where to obtain elsewhere uid = random.randint(10 << 9, 10 ** 10) - res = self.load(self.API_URL, get={'id': uid}, post=json_dumps([kwargs])) + res = self.load(self.API_URL, get={'id': uid}, post=json.dumps([kwargs])) self.log_debug("Api Response: " + res) - return json_loads(res) + return json.loads(res) def decrypt_attr(self, data, key): @@ -104,7 +104,7 @@ class MegaCoNz(Hoster): self.fail(_("Decryption failed")) #: Data is padded, 0-bytes must be stripped - return json_loads(re.search(r'{.+?}', attr).group(0)) + return json.loads(re.search(r'{.+?}', attr).group(0)) def decrypt_file(self, key): @@ -122,7 +122,7 @@ class MegaCoNz(Hoster): self.pyfile.setStatus("decrypting") self.pyfile.setProgress(0) - file_crypted = fs_encode(self.last_download) + file_crypted = encode(self.last_download) file_decrypted = file_crypted.rsplit(self.FILE_SUFFIX)[0] try: @@ -169,7 +169,7 @@ class MegaCoNz(Hoster): # self.fail(_("Checksum mismatch")) os.remove(file_crypted) - self.last_download = fs_decode(file_decrypted) + self.last_download = decode(file_decrypted) def check_error(self, code): diff --git a/module/plugins/hoster/MegaDebridEu.py b/module/plugins/hoster/MegaDebridEu.py index b6c7c513c..82d1cbb5a 100644 --- a/module/plugins/hoster/MegaDebridEu.py +++ b/module/plugins/hoster/MegaDebridEu.py @@ -3,7 +3,7 @@ import re import urllib -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo @@ -34,7 +34,7 @@ class MegaDebridEu(MultiHoster): user, info = self.account.select() jsonResponse = self.load(self.API_URL, get={'action': 'connectUser', 'login': user, 'password': info['login']['password']}) - res = json_loads(jsonResponse) + res = json.loads(jsonResponse) if res['response_code'] == "ok": self.token = res['token'] @@ -55,7 +55,7 @@ class MegaDebridEu(MultiHoster): get={'action': 'getLink', 'token': self.token}, post={'link': pyfile.url}) - res = json_loads(jsonResponse) + res = json.loads(jsonResponse) if res['response_code'] == "ok": self.link = res['debridLink'][1:-1] diff --git a/module/plugins/hoster/MegacrypterCom.py b/module/plugins/hoster/MegacrypterCom.py index 655258e1d..78b4e7789 100644 --- a/module/plugins/hoster/MegacrypterCom.py +++ b/module/plugins/hoster/MegacrypterCom.py @@ -2,7 +2,7 @@ import re -from module.common.json_layer import json_loads, json_dumps +from module.plugins.internal.utils import json from module.plugins.hoster.MegaCoNz import MegaCoNz @@ -29,10 +29,10 @@ class MegacrypterCom(MegaCoNz): """ Dispatch a call to the api, see megacrypter.com/api_doc """ - self.log_debug("JSON request: " + json_dumps(kwargs)) - res = self.load(self.API_URL, post=json_dumps(kwargs)) + self.log_debug("JSON request: " + json.dumps(kwargs)) + res = self.load(self.API_URL, post=json.dumps(kwargs)) self.log_debug("API Response: " + res) - return json_loads(res) + return json.loads(res) def process(self, pyfile): diff --git a/module/plugins/hoster/MultishareCz.py b/module/plugins/hoster/MultishareCz.py index d6c31dcb0..d82b82e34 100644 --- a/module/plugins/hoster/MultishareCz.py +++ b/module/plugins/hoster/MultishareCz.py @@ -41,7 +41,7 @@ class MultishareCz(SimpleHoster): def handle_multi(self, pyfile): self.html = self.load('http://www.multishare.cz/html/mms_ajax.php', post={'link': pyfile.url}) - self.check_info() + self.update_info() if not self.check_traffic(): self.fail(_("Not enough credit left to download file")) diff --git a/module/plugins/hoster/MyfastfileCom.py b/module/plugins/hoster/MyfastfileCom.py index 2885a5634..05a2fedc6 100644 --- a/module/plugins/hoster/MyfastfileCom.py +++ b/module/plugins/hoster/MyfastfileCom.py @@ -2,7 +2,7 @@ import re -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo @@ -33,7 +33,7 @@ class MyfastfileCom(MultiHoster): 'link': pyfile.url}) self.log_debug("JSON data: " + self.html) - self.html = json_loads(self.html) + self.html = json.loads(self.html) if self.html['status'] != 'ok': self.fail(_("Unable to unrestrict link")) diff --git a/module/plugins/hoster/MyvideoDe.py b/module/plugins/hoster/MyvideoDe.py index 5df1669b8..bf3a52db9 100644 --- a/module/plugins/hoster/MyvideoDe.py +++ b/module/plugins/hoster/MyvideoDe.py @@ -3,7 +3,7 @@ import re from module.plugins.internal.Hoster import Hoster -from module.utils import html_unescape +from module.plugins.internal.utils import html_unescape class MyvideoDe(Hoster): diff --git a/module/plugins/hoster/NoPremiumPl.py b/module/plugins/hoster/NoPremiumPl.py index c4f07fbae..42077e0c9 100644 --- a/module/plugins/hoster/NoPremiumPl.py +++ b/module/plugins/hoster/NoPremiumPl.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.internal.MultiHoster import MultiHoster @@ -70,7 +70,7 @@ class NoPremiumPl(MultiHoster): self.temp_offline("Query error #1") try: - parsed = json_loads(data) + parsed = json.loads(data) except Exception: self.temp_offline("Data not found") diff --git a/module/plugins/hoster/OboomCom.py b/module/plugins/hoster/OboomCom.py index a73d646e1..69ed616a2 100644 --- a/module/plugins/hoster/OboomCom.py +++ b/module/plugins/hoster/OboomCom.py @@ -5,7 +5,7 @@ import re -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.internal.Hoster import Hoster from module.plugins.captcha.ReCaptcha import ReCaptcha @@ -50,7 +50,7 @@ class OboomCom(Hoster): def load_url(self, url, get=None): if get is None: get = {} - return json_loads(self.load(url, get)) + return json.loads(self.load(url, get)) def get_file_id(self, url): diff --git a/module/plugins/hoster/OpenloadIo.py b/module/plugins/hoster/OpenloadIo.py index 8fff581fe..0f4127e19 100644 --- a/module/plugins/hoster/OpenloadIo.py +++ b/module/plugins/hoster/OpenloadIo.py @@ -1,16 +1,16 @@ # -*- coding: utf-8 -*- -import json import re from module.network.RequestFactory import getURL from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.utils import json class OpenloadIo(SimpleHoster): __name__ = "OpenloadIo" __type__ = "hoster" - __version__ = "0.10" + __version__ = "0.11" __status__ = "testing" __pattern__ = r'https?://(?:www\.)?openload\.(co|io)/(f|embed)/(?P<ID>[\w\-]+)' @@ -38,12 +38,12 @@ class OpenloadIo(SimpleHoster): @classmethod def api_info(cls, url): - file_id = cls.info['pattern']['ID'] + file_id = re.match(cls.__pattern__, url).group('ID') info_json = cls._load_json(cls._FILE_INFO_URI_PATTERN.format(file_id)) file_info = info_json['result'][file_id] - return {'name' : file_info['name'], - 'size' : file_info['size']} + return {'name': file_info['name'], + 'size': file_info['size']} def setup(self): diff --git a/module/plugins/hoster/OverLoadMe.py b/module/plugins/hoster/OverLoadMe.py index b03d263b9..5a335353a 100644 --- a/module/plugins/hoster/OverLoadMe.py +++ b/module/plugins/hoster/OverLoadMe.py @@ -3,9 +3,8 @@ import re import urllib -from module.common.json_layer import json_loads from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -from module.plugins.internal.Plugin import parse_size +from module.plugins.internal.utils import json, parse_size class OverLoadMe(MultiHoster): @@ -34,7 +33,7 @@ class OverLoadMe(MultiHoster): get={'auth': data['password'], 'link': pyfile.url}) - data = json_loads(page) + data = json.loads(page) self.log_debug(data) diff --git a/module/plugins/hoster/PremiumTo.py b/module/plugins/hoster/PremiumTo.py index 874e19c93..acfc9d1e4 100644 --- a/module/plugins/hoster/PremiumTo.py +++ b/module/plugins/hoster/PremiumTo.py @@ -5,7 +5,7 @@ from __future__ import with_statement import os from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -from module.utils import fs_encode +from module.plugins.internal.utils import encode class PremiumTo(MultiHoster): @@ -45,7 +45,7 @@ class PremiumTo(MultiHoster): err = "" if self.req.http.code == "420": #: Custom error code send - fail - file = fs_encode(self.last_download) + file = encode(self.last_download) with open(file, "rb") as f: err = f.read(256).strip() os.remove(file) diff --git a/module/plugins/hoster/PremiumizeMe.py b/module/plugins/hoster/PremiumizeMe.py index 918526355..02937f74f 100644 --- a/module/plugins/hoster/PremiumizeMe.py +++ b/module/plugins/hoster/PremiumizeMe.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo @@ -35,7 +35,7 @@ class PremiumizeMe(MultiHoster): user, info = self.account.select() #: Get rewritten link using the premiumize.me api v1 (see https://secure.premiumize.me/?show=api) - data = json_loads(self.load("http://api.premiumize.me/pm-api/v1.php", #@TODO: Revert to `https` in 0.4.10 + data = json.loads(self.load("http://api.premiumize.me/pm-api/v1.php", #@TODO: Revert to `https` in 0.4.10 get={'method' : "directdownloadlink", 'params[login]': user, 'params[pass]' : info['login']['password'], diff --git a/module/plugins/hoster/RPNetBiz.py b/module/plugins/hoster/RPNetBiz.py index af3d41946..e61cfaf86 100644 --- a/module/plugins/hoster/RPNetBiz.py +++ b/module/plugins/hoster/RPNetBiz.py @@ -3,7 +3,7 @@ import re from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json class RPNetBiz(MultiHoster): @@ -36,7 +36,7 @@ class RPNetBiz(MultiHoster): 'links' : pyfile.url}) self.log_debug("JSON data: %s" % res) - link_status = json_loads(res)['links'][0] #: Get the first link... since we only queried one + 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: @@ -54,7 +54,7 @@ class RPNetBiz(MultiHoster): 'action' : "downloadInformation", 'id' : link_status['id']}) self.log_debug("JSON data hdd query: %s" % res) - download_status = json_loads(res)['download'] + download_status = json.loads(res)['download'] if download_status['status'] == "100": link_status['generated'] = download_status['rpnet_link'] diff --git a/module/plugins/hoster/RapideoPl.py b/module/plugins/hoster/RapideoPl.py index 7a5c25297..8493b41c5 100644 --- a/module/plugins/hoster/RapideoPl.py +++ b/module/plugins/hoster/RapideoPl.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.internal.MultiHoster import MultiHoster @@ -70,7 +70,7 @@ class RapideoPl(MultiHoster): self.temp_offline("Query error #1") try: - parsed = json_loads(data) + parsed = json.loads(data) except Exception: self.temp_offline("Data not found") diff --git a/module/plugins/hoster/RapidgatorNet.py b/module/plugins/hoster/RapidgatorNet.py index bb4622386..0c515bb2f 100644 --- a/module/plugins/hoster/RapidgatorNet.py +++ b/module/plugins/hoster/RapidgatorNet.py @@ -3,7 +3,7 @@ import pycurl import re -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.network.HTTPRequest import BadHeader from module.plugins.captcha.AdsCaptcha import AdsCaptcha from module.plugins.captcha.ReCaptcha import ReCaptcha @@ -65,13 +65,13 @@ class RapidgatorNet(SimpleHoster): def api_response(self, cmd): try: - json = self.load('%s/%s' % (self.API_URL, cmd), + html = self.load('%s/%s' % (self.API_URL, cmd), get={'sid': self.sid, 'url': self.pyfile.url}) - self.log_debug("API:%s" % cmd, json, "SID: %s" % self.sid) - json = json_loads(json) - status = json['response_status'] - msg = json['response_details'] + self.log_debug("API:%s" % cmd, html, "SID: %s" % self.sid) + jso = json.loads(html) + status = jso['response_status'] + msg = jso['response_details'] except BadHeader, e: self.log_error("API: %s" % cmd, e, "SID: %s" % self.sid) @@ -79,7 +79,7 @@ class RapidgatorNet(SimpleHoster): msg = e if status == 200: - return json['response'] + return jso['response'] elif status == 423: self.account.empty() @@ -156,7 +156,7 @@ class RapidgatorNet(SimpleHoster): if not res.startswith('{'): self.retry() self.log_debug(url, res) - return json_loads(res) + return json.loads(res) getInfo = create_getInfo(RapidgatorNet) diff --git a/module/plugins/hoster/RapiduNet.py b/module/plugins/hoster/RapiduNet.py index d86cb4184..3469fdd2a 100644 --- a/module/plugins/hoster/RapiduNet.py +++ b/module/plugins/hoster/RapiduNet.py @@ -4,7 +4,7 @@ import pycurl import re import time -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.captcha.ReCaptcha import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -78,7 +78,7 @@ class RapiduNet(SimpleHoster): self.log_debug(res) - return json_loads(res) + return json.loads(res) getInfo = create_getInfo(RapiduNet) diff --git a/module/plugins/hoster/RealdebridCom.py b/module/plugins/hoster/RealdebridCom.py index a8685d0f8..544d2fd12 100644 --- a/module/plugins/hoster/RealdebridCom.py +++ b/module/plugins/hoster/RealdebridCom.py @@ -4,9 +4,8 @@ import re import time import urllib -from module.common.json_layer import json_loads from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo -from module.plugins.internal.Plugin import parse_size +from module.plugins.internal.utils import json, parse_size class RealdebridCom(MultiHoster): @@ -30,7 +29,7 @@ class RealdebridCom(MultiHoster): def handle_premium(self, pyfile): - data = json_loads(self.load("https://real-debrid.com/ajax/unrestrict.php", + data = json.loads(self.load("https://real-debrid.com/ajax/unrestrict.php", get={'lang' : "en", 'link' : pyfile.url, 'password': self.get_password(), diff --git a/module/plugins/hoster/RedtubeCom.py b/module/plugins/hoster/RedtubeCom.py index b5897ac80..757a06d50 100644 --- a/module/plugins/hoster/RedtubeCom.py +++ b/module/plugins/hoster/RedtubeCom.py @@ -3,7 +3,7 @@ import re from module.plugins.internal.Hoster import Hoster -from module.utils import html_unescape +from module.plugins.internal.utils import html_unescape class RedtubeCom(Hoster): diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index 1cf1d5508..0ced1fae8 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -38,12 +38,10 @@ class ShareonlineBiz(SimpleHoster): @classmethod def api_info(cls, url): - info = super(ShareonlineBiz, cls).api_info(url) - + info = {} field = get_url("http://api.share-online.biz/linkcheck.php", get={'md5' : "1", 'links': re.match(cls.__pattern__, url).group("ID")}).split(";") - try: if field[1] == "OK": info['fileid'] = field[0] diff --git a/module/plugins/hoster/SmoozedCom.py b/module/plugins/hoster/SmoozedCom.py index 5676e6190..8a03e637c 100644 --- a/module/plugins/hoster/SmoozedCom.py +++ b/module/plugins/hoster/SmoozedCom.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.internal.MultiHoster import MultiHoster @@ -40,7 +40,7 @@ class SmoozedCom(MultiHoster): get_data = {'session_key': self.account.get_data('session'), 'url' : pyfile.url} - data = json_loads(self.load("http://www2.smoozed.com/api/check", get=get_data)) + data = json.loads(self.load("http://www2.smoozed.com/api/check", get=get_data)) if data['state'] != "ok": self.fail(data['message']) diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index 90c8acc11..d5d1a85ac 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -3,7 +3,7 @@ import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json class SoundcloudCom(SimpleHoster): @@ -40,7 +40,7 @@ class SoundcloudCom(SimpleHoster): client_id = "b45b1aa10f1ac2941910a7f0d10f8e28" #: Url to retrieve the actual song url - streams = json_loads(self.load("https://api.soundcloud.com/tracks/%s/streams" % song_id, + streams = json.loads(self.load("https://api.soundcloud.com/tracks/%s/streams" % song_id, get={'client_id': client_id})) regex = re.compile(r'[^\d]') diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py index ce63107e8..5dc7f8d03 100644 --- a/module/plugins/hoster/UlozTo.py +++ b/module/plugins/hoster/UlozTo.py @@ -3,7 +3,7 @@ import re import time -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.internal.Plugin import timestamp from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -75,7 +75,7 @@ class UlozTo(SimpleHoster): xapca = xapca.replace('sound":"', 'sound":"http:').replace('image":"', 'image":"http:') self.log_debug("xapca: %s" % xapca) - data = json_loads(xapca) + data = json.loads(xapca) captcha_value = self.captcha.decrypt(data['image']) self.log_debug("CAPTCHA HASH: " + data['hash'], "CAPTCHA SALT: %s" % data['salt'], "CAPTCHA VALUE: " + captcha_value) diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index c3c2ade08..a6486f4c3 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -42,7 +42,7 @@ class UploadedTo(SimpleHoster): @classmethod def api_info(cls, url): - info = super(UploadedTo, cls).api_info(url) + info = {} for _i in xrange(5): html = get_url("http://uploaded.net/api/filemultiple", diff --git a/module/plugins/hoster/UploadingCom.py b/module/plugins/hoster/UploadingCom.py index 3ca91e652..0c693f348 100644 --- a/module/plugins/hoster/UploadingCom.py +++ b/module/plugins/hoster/UploadingCom.py @@ -3,7 +3,7 @@ import pycurl import re -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.internal.Plugin import encode, timestamp from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -71,7 +71,7 @@ class UploadingCom(SimpleHoster): 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']})) + 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']) @@ -80,7 +80,7 @@ class UploadingCom(SimpleHoster): else: self.error(_("No AJAX/WAIT")) - res = json_loads(self.load(ajax_url, post={'action': 'get_link', 'code': self.info['pattern']['ID'], 'pass': 'false'})) + res = json.loads(self.load(ajax_url, post={'action': 'get_link', 'code': self.info['pattern']['ID'], 'pass': 'false'})) if 'answer' in res and 'link' in res['answer']: url = res['answer']['link'] diff --git a/module/plugins/hoster/WebshareCz.py b/module/plugins/hoster/WebshareCz.py index eb91974d7..84b487304 100644 --- a/module/plugins/hoster/WebshareCz.py +++ b/module/plugins/hoster/WebshareCz.py @@ -24,19 +24,17 @@ class WebshareCz(SimpleHoster): @classmethod def api_info(cls, url): - info = super(WebshareCz, cls).api_info(url) + info = {} + api = get_url("https://webshare.cz/api/file_info/", + post={'ident': re.match(cls.__pattern__, url).group('ID'), + 'wst' : ""}) - info['pattern'] = re.match(cls.__pattern__, url).groupdict() - - api_data = get_url("https://webshare.cz/api/file_info/", - post={'ident': info['pattern']['ID'], 'wst': ""}) - - if not re.search(r'<status>OK', api_data): + if not re.search(r'<status>OK', api): info['status'] = 1 else: info['status'] = 2 - info['name'] = re.search(r'<name>(.+?)<', api_data).group(1) - info['size'] = re.search(r'<size>(.+?)<', api_data).group(1) + info['name'] = re.search(r'<name>(.+?)<', api).group(1) + info['size'] = re.search(r'<size>(.+?)<', api).group(1) return info diff --git a/module/plugins/hoster/XHamsterCom.py b/module/plugins/hoster/XHamsterCom.py index 1673797cc..075fa693e 100644 --- a/module/plugins/hoster/XHamsterCom.py +++ b/module/plugins/hoster/XHamsterCom.py @@ -3,7 +3,7 @@ import re import urllib -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.internal.Hoster import Hoster @@ -62,7 +62,7 @@ class XHamsterCom(Hoster): self.error(_("flashvar not found")) j = clean_json(json_flashvar.group(1)) - flashvars = json_loads(j) + flashvars = json.loads(j) if flashvars['srv']: srv_url = flashvars['srv'] + '/' diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index e107caf51..a308f1c17 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -9,8 +9,7 @@ import time from select import select from module.plugins.internal.Hoster import Hoster -# from module.utils import decode -from module.utils import save_join as fs_join +from module.plugins.internal.utils import fs_join class Xdcc(Hoster): @@ -189,8 +188,8 @@ class Xdcc(Hoster): self.pyfile.name = packname - download_folder = self.pyload.config.get("general", "download_folder") - filename = fs_join(download_folder, packname) + dl_folder = self.pyload.config.get("general", "download_folder") + filename = fs_join(dl_folder, packname) self.log_info(_("Downloading %s from %s:%d") % (packname, ip, port)) diff --git a/module/plugins/hoster/YadiSk.py b/module/plugins/hoster/YadiSk.py index 4e582219d..e2fb060ca 100644 --- a/module/plugins/hoster/YadiSk.py +++ b/module/plugins/hoster/YadiSk.py @@ -3,7 +3,7 @@ import re import random -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -36,7 +36,7 @@ class YadiSk(SimpleHoster): m = re.search(r'<script id="models-client" type="application/json">(.+?)</script>', html) if m is not None: - api_data = json_loads(m.group(1)) + api_data = json.loads(m.group(1)) try: for sect in api_data: if 'model' in sect: @@ -80,7 +80,7 @@ class YadiSk(SimpleHoster): 'sk' : self.info['sk'], 'id.0' : self.info['id']}) - self.link = json_loads(self.html)['models'][0]['data']['file'] + self.link = json.loads(self.html)['models'][0]['data']['file'] except Exception: pass diff --git a/module/plugins/hoster/YibaishiwuCom.py b/module/plugins/hoster/YibaishiwuCom.py index 11f907e33..969f44e92 100644 --- a/module/plugins/hoster/YibaishiwuCom.py +++ b/module/plugins/hoster/YibaishiwuCom.py @@ -3,7 +3,7 @@ import re import urlparse -from module.common.json_layer import json_loads +from module.plugins.internal.utils import json from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -38,7 +38,7 @@ class YibaishiwuCom(SimpleHoster): self.log_debug(('FREEUSER' if m.group(2) == "download" else 'GUEST') + ' URL', url) - res = json_loads(self.load(urlparse.urljoin("http://115.com/", url), decode=False)) + res = json.loads(self.load(urlparse.urljoin("http://115.com/", url), decode=False)) if "urls" in res: mirrors = res['urls'] diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 47317a029..4c48bee9d 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -7,7 +7,7 @@ import urllib from module.plugins.internal.Hoster import Hoster from module.plugins.internal.Plugin import replace_patterns, which -from module.utils import html_unescape +from module.plugins.internal.utils import html_unescape class YoutubeCom(Hoster): |