diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-05-01 13:05:40 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-05-01 13:05:40 +0200 |
commit | 095ad393330d9ccb86adac4894fe3280caa44234 (patch) | |
tree | f03b4a5674b4f6e79706350e06543ba565effd85 | |
parent | Use bitmath lib to formatSize (diff) | |
parent | Fix https://github.com/pyload/pyload/issues/1351 (diff) | |
download | pyload-095ad393330d9ccb86adac4894fe3280caa44234.tar.xz |
Merge branch 'stable' into 0.4.10
Conflicts:
module/plugins/hoster/RehostTo.py
module/plugins/hoster/XVideosCom.py
module/plugins/hoster/ZeveraCom.py
module/plugins/internal/CaptchaService.py
pyload/plugin/account/FilefactoryCom.py
pyload/plugin/account/OneFichierCom.py
pyload/plugin/account/WebshareCz.py
pyload/plugin/addon/AntiVirus.py
pyload/plugin/addon/Checksum.py
pyload/plugin/addon/ExtractArchive.py
pyload/plugin/container/CCF.py
pyload/plugin/crypter/Go4UpCom.py
pyload/plugin/hook/BypassCaptcha.py
pyload/plugin/hook/CaptchaBrotherhood.py
pyload/plugin/hook/ExpertDecoders.py
pyload/plugin/hook/ImageTyperz.py
pyload/plugin/hook/XFileSharingPro.py
pyload/plugin/hoster/Ftp.py
pyload/plugin/hoster/GigapetaCom.py
pyload/plugin/hoster/MegaRapidCz.py
pyload/plugin/hoster/MegaRapidoNet.py
pyload/plugin/hoster/MultishareCz.py
pyload/plugin/hoster/NarodRu.py
pyload/plugin/hoster/QuickshareCz.py
pyload/plugin/hoster/RapidgatorNet.py
pyload/plugin/hoster/RapiduNet.py
pyload/plugin/hoster/UnibytesCom.py
pyload/plugin/hoster/UploadingCom.py
pyload/plugin/hoster/WrzucTo.py
pyload/plugin/internal/BasePlugin.py
pyload/plugin/internal/SimpleDereferer.py
pyload/plugin/internal/SimpleHoster.py
pyload/plugin/internal/XFSCrypter.py
pyload/plugin/internal/XFSHoster.py
80 files changed, 817 insertions, 286 deletions
diff --git a/module/plugins/hoster/RehostTo.py b/module/plugins/hoster/RehostTo.py new file mode 100644 index 000000000..9c07364ec --- /dev/null +++ b/module/plugins/hoster/RehostTo.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +import urllib + +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo + + +class RehostTo(MultiHoster): + __name__ = "RehostTo" + __type__ = "hoster" + __version__ = "0.21" + + __pattern__ = r'https?://.*rehost\.to\..+' + __config__ = [("use_premium", "bool", "Use premium account if available", True)] + + __description__ = """Rehost.com multi-hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("RaNaN", "RaNaN@pyload.org")] + + + def handlePremium(self, pyfile): + self.download("http://rehost.to/process_download.php", + get={'user': "cookie", + 'pass': self.account.getAccountInfo(self.user)['session'], + 'dl' : pyfile.url}, + disposition=True) + + +getInfo = create_getInfo(RehostTo) diff --git a/module/plugins/hoster/XVideosCom.py b/module/plugins/hoster/XVideosCom.py new file mode 100644 index 000000000..a8f291824 --- /dev/null +++ b/module/plugins/hoster/XVideosCom.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +import re +import urllib + +from module.plugins.Hoster import Hoster + + +class XVideosCom(Hoster): + __name__ = "XVideos.com" + __type__ = "hoster" + __version__ = "0.10" + + __pattern__ = r'http://(?:www\.)?xvideos\.com/video(\d+)' + + __description__ = """XVideos.com hoster plugin""" + __license__ = "GPLv3" + __authors__ = [] + + + def process(self, pyfile): + site = self.load(pyfile.url) + pyfile.name = "%s (%s).flv" % ( + re.search(r"<h2>([^<]+)<span", site).group(1), + re.match(self.__pattern__, pyfile.url).group(1), + ) + self.download(urllib.unquote(re.search(r"flv_url=([^&]+)&", site).group(1))) diff --git a/module/plugins/hoster/ZeveraCom.py b/module/plugins/hoster/ZeveraCom.py new file mode 100644 index 000000000..617e00e58 --- /dev/null +++ b/module/plugins/hoster/ZeveraCom.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +import re +import urlparse + +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo + + +class ZeveraCom(MultiHoster): + __name__ = "ZeveraCom" + __type__ = "hoster" + __version__ = "0.29" + + __pattern__ = r'https?://(?:www\.)zevera\.com/(getFiles\.ashx|Members/download\.ashx)\?.*ourl=.+' + __config__ = [("use_premium", "bool", "Use premium account if available", True)] + + __description__ = """Zevera.com multi-hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + def handlePremium(self, pyfile): + self.link = "https://%s/getFiles.ashx?ourl=%s" % (self.account.HOSTER_DOMAIN, pyfile.url) + + + def checkFile(self, rules={}): + if self.checkDownload({"error": 'action="ErrorDownload.aspx'}): + self.fail(_("Error response received")) + + return super(ZeveraCom, self).checkFile(rules) + + +getInfo = create_getInfo(ZeveraCom) diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py new file mode 100644 index 000000000..b6afad22a --- /dev/null +++ b/module/plugins/internal/CaptchaService.py @@ -0,0 +1,517 @@ +# -*- coding: utf-8 -*- + +import random +import re +import time +import urlparse + +from base64 import b64encode + +from module.common.json_layer import json_loads +from module.plugins.Plugin import Base + + +#@TODO: Extend (new) Plugin class; remove all `html` args +class CaptchaService(Base): + __name__ = "CaptchaService" + __type__ = "captcha" + __version__ = "0.26" + + __description__ = """Base captcha service plugin""" + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] + + + key = None #: last key detected + + + def __init__(self, plugin): + self.plugin = plugin + super(CaptchaService, self).__init__(plugin.core) + + + def detect_key(self, html=None): + raise NotImplementedError + + + def challenge(self, key=None, html=None): + raise NotImplementedError + + + def result(self, server, challenge): + raise NotImplementedError + + +class ReCaptcha(CaptchaService): + __name__ = "ReCaptcha" + __type__ = "captcha" + __version__ = "0.15" + + __description__ = """ReCaptcha captcha service plugin""" + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org"), + ("Walter Purcaro", "vuolter@gmail.com"), + ("zapp-brannigan", "fuerst.reinje@web.de")] + + + KEY_V2_PATTERN = r'(?:data-sitekey=["\']|["\']sitekey["\']:\s*["\'])([\w-]+)' + KEY_V1_PATTERN = r'(?:recaptcha(?:/api|\.net)/(?:challenge|noscript)\?k=|Recaptcha\.create\s*\(\s*["\'])([\w-]+)' + + + def detect_key(self, html=None): + if not html: + if hasattr(self.plugin, "html") and self.plugin.html: + html = self.plugin.html + else: + errmsg = _("ReCaptcha html not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + m = re.search(self.KEY_V2_PATTERN, html) or re.search(self.KEY_V1_PATTERN, html) + if m: + self.key = m.group(1).strip() + self.logDebug("Key: %s" % self.key) + return self.key + else: + self.logDebug("Key not found") + return None + + + def challenge(self, key=None, html=None, version=None): + if not key: + if self.detect_key(html): + key = self.key + else: + errmsg = _("ReCaptcha key not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + if version in (1, 2): + return getattr(self, "_challenge_v%s" % version)(key) + + elif not html and hasattr(self.plugin, "html") and self.plugin.html: + version = 2 if re.search(self.KEY_V2_PATTERN, self.plugin.html) else 1 + return self.challenge(key, self.plugin.html, version) + + else: + errmsg = _("ReCaptcha html not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + + def _challenge_v1(self, key): + html = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", + get={'k': key}) + try: + challenge = re.search("challenge : '(.+?)',", html).group(1) + server = re.search("server : '(.+?)',", html).group(1) + + except AttributeError: + errmsg = _("ReCaptcha challenge pattern not found") + self.plugin.fail(errmsg) + raise AttributeError(errmsg) + + self.logDebug("Challenge: %s" % challenge) + + return self.result(server, challenge), challenge + + + def result(self, server, challenge): + result = self.plugin.decryptCaptcha("%simage" % server, + get={'c': challenge}, + cookies=True, + forceUser=True, + imgtype="jpg") + + self.logDebug("Result: %s" % result) + + return result + + + def _collectApiInfo(self): + html = self.plugin.req.load("http://www.google.com/recaptcha/api.js") + a = re.search(r'po.src = \'(.*?)\';', html).group(1) + vers = a.split("/")[5] + + self.logDebug("API version: %s" %vers) + + language = a.split("__")[1].split(".")[0] + + self.logDebug("API language: %s" % language) + + html = self.plugin.req.load("https://apis.google.com/js/api.js") + b = re.search(r'"h":"(.*?)","', html).group(1) + jsh = b.decode('unicode-escape') + + self.logDebug("API jsh-string: %s" % jsh) + + return vers, language, jsh + + + def _prepareTimeAndRpc(self): + self.plugin.req.load("http://www.google.com/recaptcha/api2/demo") + + millis = int(round(time.time() * 1000)) + + self.logDebug("Time: %s" % millis) + + rand = random.randint(1, 99999999) + a = "0.%s" % str(rand * 2147483647) + rpc = int(100000000 * float(a)) + + self.logDebug("Rpc-token: %s" % rpc) + + return millis, rpc + + + def _challenge_v2(self, key, parent=None): + if parent is None: + try: + parent = urlparse.urljoin("http://", urlparse.urlparse(self.plugin.pyfile.url).netloc) + + except Exception: + parent = "" + + botguardstring = "!A" + vers, language, jsh = self._collectApiInfo() + millis, rpc = self._prepareTimeAndRpc() + + html = self.plugin.req.load("https://www.google.com/recaptcha/api2/anchor", + get={'k' : key, + 'hl' : language, + 'v' : vers, + 'usegapi' : "1", + 'jsh' : "%s#id=IO_%s" % (jsh, millis), + 'parent' : parent, + 'pfname' : "", + 'rpctoken': rpc}) + + token1 = re.search(r'id="recaptcha-token" value="(.*?)">', html) + self.logDebug("Token #1: %s" % token1.group(1)) + + html = self.plugin.req.load("https://www.google.com/recaptcha/api2/frame", + get={'c' : token1.group(1), + 'hl' : language, + 'v' : vers, + 'bg' : botguardstring, + 'k' : key, + 'usegapi': "1", + 'jsh' : jsh}).decode('unicode-escape') + + token2 = re.search(r'"finput","(.*?)",', html) + self.logDebug("Token #2: %s" % token2.group(1)) + + token3 = re.search(r'"rresp","(.*?)",', html) + self.logDebug("Token #3: %s" % token3.group(1)) + + millis_captcha_loading = int(round(time.time() * 1000)) + captcha_response = self.plugin.decryptCaptcha("https://www.google.com/recaptcha/api2/payload", + get={'c':token3.group(1), 'k':key}, + cookies=True, + forceUser=True) + response = b64encode('{"response":"%s"}' % captcha_response) + + self.logDebug("Result: %s" % response) + + timeToSolve = int(round(time.time() * 1000)) - millis_captcha_loading + timeToSolveMore = timeToSolve + int(float("0." + str(random.randint(1, 99999999))) * 500) + + html = self.plugin.req.load("https://www.google.com/recaptcha/api2/userverify", + post={'k' : key, + 'c' : token3.group(1), + 'response': response, + 't' : timeToSolve, + 'ct' : timeToSolveMore, + 'bg' : botguardstring}) + + token4 = re.search(r'"uvresp","(.*?)",', html) + self.logDebug("Token #4: %s" % token4.group(1)) + + result = token4.group(1) + + return result, None + + +class AdsCaptcha(CaptchaService): + __name__ = "AdsCaptcha" + __type__ = "captcha" + __version__ = "0.08" + + __description__ = """AdsCaptcha captcha service plugin""" + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] + + + CAPTCHAID_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?.*?CaptchaId=(\d+)' + PUBLICKEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?.*?PublicKey=([\w-]+)' + + + def detect_key(self, html=None): + if not html: + if hasattr(self.plugin, "html") and self.plugin.html: + html = self.plugin.html + else: + errmsg = _("AdsCaptcha html not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + m = re.search(self.PUBLICKEY_PATTERN, html) + n = re.search(self.CAPTCHAID_PATTERN, html) + if m and n: + self.key = (m.group(1).strip(), n.group(1).strip()) #: key is the tuple(PublicKey, CaptchaId) + self.logDebug("Key|id: %s | %s" % self.key) + return self.key + else: + self.logDebug("Key or id not found") + return None + + + def challenge(self, key=None, html=None): + if not key: + if self.detect_key(html): + key = self.key + else: + errmsg = _("AdsCaptcha key not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + PublicKey, CaptchaId = key + + html = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", + get={'CaptchaId': CaptchaId, + 'PublicKey': PublicKey}) + try: + challenge = re.search("challenge: '(.+?)',", html).group(1) + server = re.search("server: '(.+?)',", html).group(1) + + except AttributeError: + errmsg = _("AdsCaptcha challenge pattern not found") + self.plugin.fail(errmsg) + raise AttributeError(errmsg) + + self.logDebug("Challenge: %s" % challenge) + + return self.result(server, challenge), challenge + + + def result(self, server, challenge): + result = self.plugin.decryptCaptcha("%sChallenge.aspx" % server, + get={'cid': challenge, 'dummy': random.random()}, + cookies=True, + imgtype="jpg") + + self.logDebug("Result: %s" % result) + + return result + + +class SolveMedia(CaptchaService): + __name__ = "SolveMedia" + __type__ = "captcha" + __version__ = "0.12" + + __description__ = """SolveMedia captcha service plugin""" + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] + + + KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(?:no)?script\?k=(.+?)["\']' + + + def detect_key(self, html=None): + if not html: + if hasattr(self.plugin, "html") and self.plugin.html: + html = self.plugin.html + else: + errmsg = _("SolveMedia html not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + m = re.search(self.KEY_PATTERN, html) + if m: + self.key = m.group(1).strip() + self.logDebug("Key: %s" % self.key) + return self.key + else: + self.logDebug("Key not found") + return None + + + def challenge(self, key=None, html=None): + if not key: + if self.detect_key(html): + key = self.key + else: + errmsg = _("SolveMedia key not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript", + get={'k': key}) + try: + challenge = re.search(r'<input type=hidden name="adcopy_challenge" id="adcopy_challenge" value="(.+?)">', + html).group(1) + server = "http://api.solvemedia.com/papi/media" + + except AttributeError: + errmsg = _("SolveMedia challenge pattern not found") + self.plugin.fail(errmsg) + raise AttributeError(errmsg) + + self.logDebug("Challenge: %s" % challenge) + + result = self.result(server, challenge) + + try: + magic = re.search(r'name="magic" value="(.+?)"', html).group(1) + + except AttributeError: + self.logDebug("Magic code not found") + + else: + if not self._verify(key, magic, result, challenge): + self.logDebug("Captcha code was invalid") + + return result, challenge + + + def _verify(self, key, magic, result, challenge, ref=None): #@TODO: Clean up + if ref is None: + try: + ref = self.plugin.pyfile.url + + except Exception: + ref = "" + + html = self.plugin.req.load("http://api.solvemedia.com/papi/verify.noscript", + post={'adcopy_response' : result, + 'k' : key, + 'l' : "en", + 't' : "img", + 's' : "standard", + 'magic' : magic, + 'adcopy_challenge' : challenge, + 'ref' : ref}) + try: + html = self.plugin.req.load(re.search(r'URL=(.+?)">', html).group(1)) + gibberish = re.search(r'id=gibberish>(.+?)</textarea>', html).group(1) + + except Exception: + return False + + else: + return True + + + def result(self, server, challenge): + result = self.plugin.decryptCaptcha(server, + get={'c': challenge}, + cookies=True, + imgtype="gif") + + self.logDebug("Result: %s" % result) + + return result + + +class AdYouLike(CaptchaService): + __name__ = "AdYouLike" + __type__ = "captcha" + __version__ = "0.05" + + __description__ = """AdYouLike captcha service plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + AYL_PATTERN = r'Adyoulike\.create\s*\((.+?)\)' + CALLBACK_PATTERN = r'(Adyoulike\.g\._jsonp_\d+)' + + + def detect_key(self, html=None): + if not html: + if hasattr(self.plugin, "html") and self.plugin.html: + html = self.plugin.html + else: + errmsg = _("AdYouLike html not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + m = re.search(self.AYL_PATTERN, html) + n = re.search(self.CALLBACK_PATTERN, html) + if m and n: + self.key = (m.group(1).strip(), n.group(1).strip()) + self.logDebug("Ayl|callback: %s | %s" % self.key) + return self.key #: key is the tuple(ayl, callback) + else: + self.logDebug("Ayl or callback not found") + return None + + + 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 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 diff --git a/pyload/plugin/account/FilefactoryCom.py b/pyload/plugin/account/FilefactoryCom.py index 71a040b65..5c80c6e1c 100644 --- a/pyload/plugin/account/FilefactoryCom.py +++ b/pyload/plugin/account/FilefactoryCom.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- +import pycurl import re import time -from pycurl import REFERER - from pyload.plugin.Account import Account @@ -38,7 +37,7 @@ class FilefactoryCom(Account): def login(self, user, data, req): - req.http.c.setopt(REFERER, "http://www.filefactory.com/member/login.php") + req.http.c.setopt(pycurl.REFERER, "http://www.filefactory.com/member/login.php") html = req.load("http://www.filefactory.com/member/signin.php", post={"loginEmail" : user, diff --git a/pyload/plugin/account/LinksnappyCom.py b/pyload/plugin/account/LinksnappyCom.py index 4b91042e2..942cefbee 100644 --- a/pyload/plugin/account/LinksnappyCom.py +++ b/pyload/plugin/account/LinksnappyCom.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from hashlib import md5 +import hashlib from pyload.plugin.Account import Account from pyload.utils import json_loads @@ -18,7 +18,7 @@ class LinksnappyCom(Account): def loadAccountInfo(self, user, req): data = self.getAccountData(user) r = req.load('http://gen.linksnappy.com/lseAPI.php', - get={'act': 'USERDETAILS', 'username': user, 'password': md5(data['password']).hexdigest()}) + get={'act': 'USERDETAILS', 'username': user, 'password': hashlib.md5(data['password']).hexdigest()}) self.logDebug("JSON data: " + r) @@ -50,7 +50,7 @@ class LinksnappyCom(Account): r = req.load("http://gen.linksnappy.com/lseAPI.php", get={'act' : 'USERDETAILS', 'username': user, - 'password': md5(data['password']).hexdigest()}, + 'password': hashlib.md5(data['password']).hexdigest()}, decode=True) if 'Invalid Account Details' in r: diff --git a/pyload/plugin/account/OboomCom.py b/pyload/plugin/account/OboomCom.py index 8b33d0612..4669ca61e 100644 --- a/pyload/plugin/account/OboomCom.py +++ b/pyload/plugin/account/OboomCom.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -import time - try: from beaker.crypto.pbkdf2 import PBKDF2 diff --git a/pyload/plugin/account/OneFichierCom.py b/pyload/plugin/account/OneFichierCom.py index fbe5ed022..531f5f735 100644 --- a/pyload/plugin/account/OneFichierCom.py +++ b/pyload/plugin/account/OneFichierCom.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- +import pycurl import re import time -from pycurl import REFERER - from pyload.plugin.Account import Account @@ -45,7 +44,7 @@ class OneFichierCom(Account): def login(self, user, data, req): - req.http.c.setopt(REFERER, "https://1fichier.com/login.pl?lg=en") + req.http.c.setopt(pycurl.REFERER, "https://1fichier.com/login.pl?lg=en") html = req.load("https://1fichier.com/login.pl?lg=en", post={'mail' : user, diff --git a/pyload/plugin/account/UlozTo.py b/pyload/plugin/account/UlozTo.py index c43246e7d..20f03f907 100644 --- a/pyload/plugin/account/UlozTo.py +++ b/pyload/plugin/account/UlozTo.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urlparse import urljoin +import urlparse from pyload.plugin.Account import Account @@ -37,7 +36,7 @@ class UlozTo(Account): action = re.findall('<form action="(.+?)"', login_page)[1].replace('&', '&') token = re.search('_token_" value="(.+?)"', login_page).group(1) - html = req.load(urljoin("http://www.ulozto.net/", action), + html = req.load(urlparse.urljoin("http://www.ulozto.net/", action), post={'_token_' : token, 'do' : "loginForm-submit", 'login' : u"PÅihlásit", diff --git a/pyload/plugin/account/WebshareCz.py b/pyload/plugin/account/WebshareCz.py index 5cbe6b1b8..c547534ba 100644 --- a/pyload/plugin/account/WebshareCz.py +++ b/pyload/plugin/account/WebshareCz.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- +import hashlib import re import time -from hashlib import md5, sha1 from passlib.hash import md5_crypt from pyload.plugin.Account import Account @@ -51,8 +51,8 @@ class WebshareCz(Account): self.wrongPassword() salt = re.search('<salt>(.+)</salt>', salt).group(1) - password = sha1(md5_crypt.encrypt(data['password'], salt=salt)).hexdigest() - digest = md5(user + ":Webshare:" + password).hexdigest() + password = hashlib.sha1(md5_crypt.encrypt(data['password'], salt=salt)).hexdigest() + digest = hashlib.md5(user + ":Webshare:" + password).hexdigest() login = req.load("https://webshare.cz/api/login/", post={'digest' : digest, diff --git a/pyload/plugin/addon/AntiVirus.py b/pyload/plugin/addon/AntiVirus.py index 87780e337..e2280a0a5 100644 --- a/pyload/plugin/addon/AntiVirus.py +++ b/pyload/plugin/addon/AntiVirus.py @@ -4,6 +4,11 @@ import os import shutil import subprocess +try: + import send2trash +except ImportError: + pass + from pyload.plugin.Addon import Addon, Expose, threaded from pyload.utils import fs_encode, fs_join @@ -11,7 +16,7 @@ from pyload.utils import fs_encode, fs_join class AntiVirus(Addon): __name = "AntiVirus" __type = "addon" - __version = "0.07" + __version = "0.08" #@TODO: add trash option (use Send2Trash lib) __config = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"), @@ -27,16 +32,7 @@ class AntiVirus(Addon): __authors = [("Walter Purcaro", "vuolter@gmail.com")] - def setup(self): - try: - import send2trash - - except ImportError: - self.logDebug("Send2Trash lib not found") - self.trashable = False - else: - self.trashable = True @Expose @@ -76,13 +72,14 @@ class AntiVirus(Addon): if not self.getConfig('deltotrash'): os.remove(file) - elif self.trashable: - send2trash.send2trash(file) - else: - self.logWarning(_("Unable to move file to trash, move to quarantine instead")) - pyfile.setCustomStatus(_("file moving")) - shutil.move(file, self.getConfig('quardir')) + try: + send2trash.send2trash(file) + + except Exception: + self.logWarning(_("Unable to move file to trash, move to quarantine instead")) + pyfile.setCustomStatus(_("file moving")) + shutil.move(file, self.getConfig('quardir')) elif action == "Quarantine": pyfile.setCustomStatus(_("file moving")) diff --git a/pyload/plugin/addon/Checksum.py b/pyload/plugin/addon/Checksum.py index 750dd665e..ada52d56e 100644 --- a/pyload/plugin/addon/Checksum.py +++ b/pyload/plugin/addon/Checksum.py @@ -3,12 +3,10 @@ from __future__ import with_statement import hashlib +import os import re import zlib -from os import remove -from os.path import getsize, isfile, splitext - from pyload.plugin.Addon import Addon from pyload.utils import fs_join, fs_encode @@ -108,13 +106,13 @@ class Checksum(Addon): # download_folder = self.config.get("general", "download_folder") # local_file = fs_encode(fs_join(download_folder, pyfile.package().folder, pyfile.name)) - if not isfile(local_file): + if not os.path.isfile(local_file): self.checkFailed(pyfile, None, "File does not exist") # validate file size if "size" in data: api_size = int(data['size']) - file_size = getsize(local_file) + file_size = os.path.getsize(local_file) if api_size != file_size: self.logWarning(_("File %s has incorrect size: %d B (%d expected)") % (pyfile.name, file_size, api_size)) @@ -156,7 +154,7 @@ class Checksum(Addon): retry_action = self.getConfig('retry_action') if pyfile.plugin.retries < max_tries: if local_file: - remove(local_file) + os.remove(local_file) pyfile.plugin.retry(max_tries, self.getConfig('wait_time'), msg) elif retry_action == "nothing": return @@ -169,13 +167,13 @@ class Checksum(Addon): download_folder = fs_join(self.config.get("general", "download_folder"), pypack.folder, "") for link in pypack.getChildren().itervalues(): - file_type = splitext(link['name'])[1][1:].lower() + file_type = os.path.splitext(link['name'])[1][1:].lower() if file_type not in self.formats: continue hash_file = fs_encode(fs_join(download_folder, link['name'])) - if not isfile(hash_file): + if not os.path.isfile(hash_file): self.logWarning(_("File not found"), link['name']) continue diff --git a/pyload/plugin/addon/ExtractArchive.py b/pyload/plugin/addon/ExtractArchive.py index 616334af2..71802cbfe 100644 --- a/pyload/plugin/addon/ExtractArchive.py +++ b/pyload/plugin/addon/ExtractArchive.py @@ -6,8 +6,6 @@ import os import sys import traceback -from copy import copy - # monkey patch bug in python 2.6 and lower # http://bugs.python.org/issue6122, http://bugs.python.org/issue1236, http://bugs.python.org/issue1731717 if sys.version_info < (2, 7) and os.name != "nt": @@ -48,6 +46,12 @@ if sys.version_info < (2, 7) and os.name != "nt": subprocess.Popen.wait = wait +try: + import send2trash +except ImportError: + pass + +from copy import copy if os.name != "nt": from grp import getgrnam from pwd import getpwnam @@ -109,7 +113,7 @@ class ArchiveQueue(object): class ExtractArchive(Addon): __name = "ExtractArchive" __type = "addon" - __version = "1.41" + __version = "1.42" __config = [("activated" , "bool" , "Activated" , True), ("fullpath" , "bool" , "Extract with full paths" , True), @@ -151,16 +155,6 @@ class ExtractArchive(Addon): self.passwords = [] self.repair = False - try: - import send2trash - - except ImportError: - self.logDebug("Send2Trash lib not found") - self.trashable = False - - else: - self.trashable = True - def activate(self): for p in ("UnRar", "SevenZip", "UnZip"): @@ -475,11 +469,12 @@ class ExtractArchive(Addon): if not deltotrash: os.remove(file) - elif self.trashable: - send2trash.send2trash(file) - else: - self.logWarning(_("Unable to move %s to trash") % os.path.basename(f)) + try: + send2trash.send2trash(file) + + except Exception: + self.logWarning(_("Unable to move %s to trash") % os.path.basename(f)) self.logInfo(name, _("Extracting finished")) extracted_files = archive.files or archive.list() diff --git a/pyload/plugin/addon/IRCInterface.py b/pyload/plugin/addon/IRCInterface.py index 07a07e381..051d30aa9 100644 --- a/pyload/plugin/addon/IRCInterface.py +++ b/pyload/plugin/addon/IRCInterface.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- +import pycurl import re import socket import ssl import time import traceback -from pycurl import FORM_FILE from select import select from threading import Thread @@ -74,7 +74,7 @@ class IRCInterface(Thread, Addon): task.setWaiting(60) html = getURL("http://www.freeimagehosting.net/upload.php", - post={"attached": (FORM_FILE, task.captchaFile)}, multipart=True) + post={"attached": (pycurl.FORM_FILE, task.captchaFile)}, multipart=True) url = re.search(r"\[img\]([^\[]+)\[/img\]\[/url\]", html).group(1) self.response(_("New Captcha Request: %s") % url) diff --git a/pyload/plugin/addon/SkipRev.py b/pyload/plugin/addon/SkipRev.py index 5209da615..b54e66af5 100644 --- a/pyload/plugin/addon/SkipRev.py +++ b/pyload/plugin/addon/SkipRev.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- import re +import urllib +import urlparse from types import MethodType -from urllib import unquote -from urlparse import urlparse from pyload.datatype.File import PyFile from pyload.plugin.Addon import Addon @@ -36,7 +36,7 @@ class SkipRev(Addon): return pyfile.pluginmodule.getInfo([pyfile.url]).next()[0] else: self.logWarning("Unable to grab file name") - return urlparse(unquote(pyfile.url)).path.split('/')[-1] + return urlparse.urlparse(urllib.unquote(pyfile.url)).path.split('/')[-1] def _pyfile(self, link): diff --git a/pyload/plugin/container/CCF.py b/pyload/plugin/container/CCF.py index ef105d8a8..024987174 100644 --- a/pyload/plugin/container/CCF.py +++ b/pyload/plugin/container/CCF.py @@ -2,11 +2,10 @@ from __future__ import with_statement +import MultipartPostHandler import re import urllib2 -from MultipartPostHandler import MultipartPostHandler - from pyload.plugin.Container import Container from pyload.utils import fs_encode, fs_join @@ -26,7 +25,7 @@ class CCF(Container): def decrypt(self, pyfile): fs_filename = fs_encode(pyfile.url.strip()) - opener = urllib2.build_opener(MultipartPostHandler) + opener = urllib2.build_opener(MultipartPostHandler.MultipartPostHandler) dlc_content = opener.open('http://service.jdownloader.net/dlcrypt/getDLC.php', {'src' : "ccf", diff --git a/pyload/plugin/crypter/CloudzillaTo.py b/pyload/plugin/crypter/CloudzillaTo.py index 0990a1efd..7042f7750 100644 --- a/pyload/plugin/crypter/CloudzillaTo.py +++ b/pyload/plugin/crypter/CloudzillaTo.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urlparse import urljoin +import urlparse from pyload.plugin.internal.SimpleCrypter import SimpleCrypter diff --git a/pyload/plugin/crypter/DailymotionComFolder.py b/pyload/plugin/crypter/DailymotionComFolder.py index fe173fe82..06834f9a5 100644 --- a/pyload/plugin/crypter/DailymotionComFolder.py +++ b/pyload/plugin/crypter/DailymotionComFolder.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urlparse import urljoin +import urlparse from pyload.utils import json_loads from pyload.plugin.Crypter import Crypter @@ -24,7 +23,7 @@ class DailymotionComFolder(Crypter): def api_response(self, ref, req=None): - url = urljoin("https://api.dailymotion.com/", ref) + url = urlparse.urljoin("https://api.dailymotion.com/", ref) html = self.load(url, get=req) return json_loads(html) diff --git a/pyload/plugin/crypter/DevhostSt.py b/pyload/plugin/crypter/DevhostSt.py index 46d33885f..7ede22106 100644 --- a/pyload/plugin/crypter/DevhostSt.py +++ b/pyload/plugin/crypter/DevhostSt.py @@ -4,8 +4,7 @@ # http://d-h.st/users/shine/?fld_id=37263#files import re - -from urlparse import urljoin +import urlparse from pyload.plugin.internal.SimpleCrypter import SimpleCrypter @@ -42,7 +41,7 @@ class DevhostSt(SimpleCrypter): p = r'href="(.+?)">Back to \w+<' m = re.search(p, self.html) - html = self.load(urljoin("http://d-h.st", m.group(1)), + html = self.load(urlparse.urljoin("http://d-h.st", m.group(1)), cookies=False) p = '\?fld_id=%s.*?">(.+?)<' % self.info['pattern']['ID'] diff --git a/pyload/plugin/crypter/FilecryptCc.py b/pyload/plugin/crypter/FilecryptCc.py index 33862164a..db939357a 100644 --- a/pyload/plugin/crypter/FilecryptCc.py +++ b/pyload/plugin/crypter/FilecryptCc.py @@ -5,9 +5,9 @@ import binascii import re +import urlparse from Crypto.Cipher import AES -from urlparse import urljoin from pyload.plugin.Crypter import Crypter from pyload.plugin.captcha.ReCaptcha import ReCaptcha @@ -91,7 +91,7 @@ class FilecryptCc(Crypter): if m: #: normal captcha self.logDebug("Captcha-URL: %s" % m.group(1)) - captcha_code = self.decryptCaptcha(urljoin(self.base_url, m.group(1)), + captcha_code = self.decryptCaptcha(urlparse.urljoin(self.base_url, m.group(1)), forceUser=True, imgtype="gif") diff --git a/pyload/plugin/crypter/Go4UpCom.py b/pyload/plugin/crypter/Go4UpCom.py index d20233b99..eef9efddc 100644 --- a/pyload/plugin/crypter/Go4UpCom.py +++ b/pyload/plugin/crypter/Go4UpCom.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urlparse import urljoin +import urlparse from pyload.plugin.internal.SimpleCrypter import SimpleCrypter @@ -10,7 +9,7 @@ from pyload.plugin.internal.SimpleCrypter import SimpleCrypter class Go4UpCom(SimpleCrypter): __name = "Go4UpCom" __type = "crypter" - __version = "0.11" + __version = "0.12" __pattern = r'http://go4up\.com/(dl/\w{12}|rd/\w{12}/\d+)' __config = [("use_premium" , "bool", "Use premium account if available" , True), @@ -30,12 +29,12 @@ class Go4UpCom(SimpleCrypter): OFFLINE_PATTERN = r'>\s*(404 Page Not Found|File not Found|Mirror does not exist)' - def getLinks(self + def getLinks(self): links = [] - m = re.search(r'(/download/gethosts/.+?)"') + m = re.search(r'(/download/gethosts/.+?)"', self.html) if m: - self.html = self.load(urljoin("http://go4up.com/", m.group(1))) + self.html = self.load(urlparse.urljoin("http://go4up.com/", m.group(1))) pages = [self.load(url) for url in re.findall(self.LINK_PATTERN, self.html)] else: pages = [self.html] diff --git a/pyload/plugin/crypter/MultiUpOrg.py b/pyload/plugin/crypter/MultiUpOrg.py index 6d11c95d0..54d9a979d 100644 --- a/pyload/plugin/crypter/MultiUpOrg.py +++ b/pyload/plugin/crypter/MultiUpOrg.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import re -from urlparse import urljoin +import urlparse from pyload.plugin.internal.SimpleCrypter import SimpleCrypter @@ -33,7 +33,7 @@ class MultiUpOrg(SimpleCrypter): pattern = r'style="width:97%;text-align:left".*\n.*href="(.*)"' if m_type == "download": dl_pattern = r'href="(.*)">.*\n.*<h5>DOWNLOAD</h5>' - miror_page = urljoin("http://www.multiup.org", re.search(dl_pattern, self.html).group(1)) + miror_page = urlparse.urljoin("http://www.multiup.org", re.search(dl_pattern, self.html).group(1)) self.html = self.load(miror_page) return re.findall(pattern, self.html) diff --git a/pyload/plugin/crypter/TusfilesNet.py b/pyload/plugin/crypter/TusfilesNet.py index 8bf7cbe21..23d305003 100644 --- a/pyload/plugin/crypter/TusfilesNet.py +++ b/pyload/plugin/crypter/TusfilesNet.py @@ -2,7 +2,7 @@ import math import re -from urlparse import urljoin +import urlparse from pyload.plugin.internal.XFSCrypter import XFSCrypter @@ -28,7 +28,7 @@ class TusfilesNet(XFSCrypter): def loadPage(self, page_n): - return self.load(urljoin(self.pyfile.url, str(page_n)), decode=True) + return self.load(urlparse.urljoin(self.pyfile.url, str(page_n)), decode=True) def handlePages(self, pyfile): diff --git a/pyload/plugin/crypter/UploadedTo.py b/pyload/plugin/crypter/UploadedTo.py index 682bfde8a..895579a26 100644 --- a/pyload/plugin/crypter/UploadedTo.py +++ b/pyload/plugin/crypter/UploadedTo.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urlparse import urljoin +import urlparse from pyload.plugin.internal.SimpleCrypter import SimpleCrypter @@ -31,5 +30,5 @@ class UploadedTo(SimpleCrypter): if m is None: self.error(_("PLAIN_PATTERN not found")) - plain_link = urljoin("http://uploaded.net/", m.group(1)) + plain_link = urlparse.urljoin("http://uploaded.net/", m.group(1)) return self.load(plain_link).split('\n')[:-1] diff --git a/pyload/plugin/crypter/YoutubeComFolder.py b/pyload/plugin/crypter/YoutubeComFolder.py index 220c1dfbb..6873c9148 100644 --- a/pyload/plugin/crypter/YoutubeComFolder.py +++ b/pyload/plugin/crypter/YoutubeComFolder.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urlparse import urljoin +import urlparse from pyload.utils import json_loads from pyload.plugin.Crypter import Crypter @@ -31,7 +30,7 @@ class YoutubeComFolder(Crypter): def api_response(self, ref, req): req.update({"key": self.API_KEY}) - url = urljoin("https://www.googleapis.com/youtube/v3/", ref) + url = urlparse.urljoin("https://www.googleapis.com/youtube/v3/", ref) html = self.load(url, get=req) return json_loads(html) diff --git a/pyload/plugin/hook/BypassCaptcha.py b/pyload/plugin/hook/BypassCaptcha.py index 95be5f3a6..8e8a27d8c 100644 --- a/pyload/plugin/hook/BypassCaptcha.py +++ b/pyload/plugin/hook/BypassCaptcha.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from pycurl import FORM_FILE, LOW_SPEED_TIME +import pycurl from pyload.network.HTTPRequest import BadHeader from pyload.network.RequestFactory import getURL, getRequest @@ -58,14 +58,14 @@ class BypassCaptcha(Hook): req = getRequest() # raise timeout threshold - req.c.setopt(LOW_SPEED_TIME, 80) + req.c.setopt(pycurl.LOW_SPEED_TIME, 80) try: res = req.load(self.SUBMIT_URL, post={'vendor_key': self.PYLOAD_KEY, 'key': self.getConfig('passkey'), 'gen_task_id': "1", - 'file': (FORM_FILE, captcha)}, + 'file': (pycurl.FORM_FILE, captcha)}, multipart=True) finally: req.close() diff --git a/pyload/plugin/hook/CaptchaBrotherhood.py b/pyload/plugin/hook/CaptchaBrotherhood.py index 97e1ff25f..75c7d55b7 100644 --- a/pyload/plugin/hook/CaptchaBrotherhood.py +++ b/pyload/plugin/hook/CaptchaBrotherhood.py @@ -5,14 +5,13 @@ from __future__ import with_statement import StringIO import pycurl import time +import urllib try: from PIL import Image except ImportError: import Image -from urllib import urlencode - from pyload.network.RequestFactory import getURL, getRequest from pyload.plugin.Hook import Hook, threaded @@ -89,10 +88,10 @@ class CaptchaBrotherhood(Hook): req = getRequest() url = "%ssendNewCaptcha.aspx?%s" % (self.API_URL, - urlencode({'username' : self.getConfig('username'), - 'password' : self.getConfig('passkey'), - 'captchaSource': "pyLoad", - 'timeout' : "80"})) + urllib.urlencode({'username' : self.getConfig('username'), + 'password' : self.getConfig('passkey'), + 'captchaSource': "pyLoad", + 'timeout' : "80"})) req.c.setopt(pycurl.URL, url) req.c.setopt(pycurl.POST, 1) diff --git a/pyload/plugin/hook/DeathByCaptcha.py b/pyload/plugin/hook/DeathByCaptcha.py index 71d1ddb0a..670807bf5 100644 --- a/pyload/plugin/hook/DeathByCaptcha.py +++ b/pyload/plugin/hook/DeathByCaptcha.py @@ -2,11 +2,11 @@ from __future__ import with_statement +import pycurl import re import time from base64 import b64encode -from pycurl import FORM_FILE, HTTPHEADER from pyload.utils import json_loads from pyload.network.HTTPRequest import BadHeader @@ -73,7 +73,7 @@ class DeathByCaptcha(Hook): 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]) + req.c.setopt(pycurl.HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) if post: if not isinstance(post, dict): @@ -134,7 +134,7 @@ class DeathByCaptcha(Hook): #@NOTE: Workaround multipart-post bug in HTTPRequest.py if re.match("^\w*$", self.getConfig('passkey')): multipart = True - data = (FORM_FILE, captcha) + data = (pycurl.FORM_FILE, captcha) else: multipart = False with open(captcha, 'rb') as f: diff --git a/pyload/plugin/hook/ExpertDecoders.py b/pyload/plugin/hook/ExpertDecoders.py index 843c786bc..0727c0407 100644 --- a/pyload/plugin/hook/ExpertDecoders.py +++ b/pyload/plugin/hook/ExpertDecoders.py @@ -2,9 +2,10 @@ from __future__ import with_statement +import pycurl +import uuid + from base64 import b64encode -from pycurl import LOW_SPEED_TIME -from uuid import uuid4 from pyload.network.HTTPRequest import BadHeader from pyload.network.RequestFactory import getURL, getRequest @@ -47,7 +48,7 @@ class ExpertDecoders(Hook): @threaded def _processCaptcha(self, task): - task.data['ticket'] = ticket = uuid4() + task.data['ticket'] = ticket = uuid.uuid4() result = None with open(task.captchaFile, 'rb') as f: @@ -55,7 +56,7 @@ class ExpertDecoders(Hook): req = getRequest() # raise timeout threshold - req.c.setopt(LOW_SPEED_TIME, 80) + req.c.setopt(pycurl.LOW_SPEED_TIME, 80) try: result = req.load(self.API_URL, diff --git a/pyload/plugin/hook/ImageTyperz.py b/pyload/plugin/hook/ImageTyperz.py index c134cdaeb..3f0147776 100644 --- a/pyload/plugin/hook/ImageTyperz.py +++ b/pyload/plugin/hook/ImageTyperz.py @@ -2,10 +2,10 @@ from __future__ import with_statement +import pycurl import re from base64 import b64encode -from pycurl import FORM_FILE, LOW_SPEED_TIME from pyload.network.RequestFactory import getURL, getRequest from pyload.plugin.Hook import Hook, threaded @@ -70,13 +70,13 @@ class ImageTyperz(Hook): def submit(self, captcha, captchaType="file", match=None): req = getRequest() # raise timeout threshold - req.c.setopt(LOW_SPEED_TIME, 80) + req.c.setopt(pycurl.LOW_SPEED_TIME, 80) try: #@NOTE: Workaround multipart-post bug in HTTPRequest.py if re.match("^\w*$", self.getConfig('passkey')): multipart = True - data = (FORM_FILE, captcha) + data = (pycurl.FORM_FILE, captcha) else: multipart = False with open(captcha, 'rb') as f: diff --git a/pyload/plugin/hook/XFileSharingPro.py b/pyload/plugin/hook/XFileSharingPro.py index 7fee029da..3c305c74b 100644 --- a/pyload/plugin/hook/XFileSharingPro.py +++ b/pyload/plugin/hook/XFileSharingPro.py @@ -8,7 +8,7 @@ from pyload.plugin.Hook import Hook class XFileSharingPro(Hook): __name = "XFileSharingPro" __type = "hook" - __version = "0.36" + __version = "0.37" __config = [("activated" , "bool", "Activated" , True ), ("use_hoster_list" , "bool", "Load listed hosters only" , False), @@ -35,7 +35,7 @@ class XFileSharingPro(Hook): # NOT TESTED: "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", "linkzhost.com", "mightyupload.com", "rockdizfile.com", "sharebeast.com", "sharerepo.com", "shareswift.com", "uploadbaz.com", "uploadc.com", - "vidbull.com", "zalaa.com", "zomgupload.com", + "vidbull.com", "worldbytez.com", "zalaa.com", "zomgupload.com", # NOT WORKING: "amonshare.com", "banicrazy.info", "boosterking.com", "host4desi.com", "laoupload.com", "rd-fs.com"] CRYPTER_BUILTIN = ["junocloud.me", "rapidfileshare.net"] diff --git a/pyload/plugin/hoster/AlldebridCom.py b/pyload/plugin/hoster/AlldebridCom.py index 9e1e3bc05..7474e62e8 100644 --- a/pyload/plugin/hoster/AlldebridCom.py +++ b/pyload/plugin/hoster/AlldebridCom.py @@ -1,9 +1,7 @@ # -*- coding: utf-8 -*- import re - -from random import randrange -from urllib import unquote +import urllib from pyload.utils import json_loads from pyload.plugin.internal.MultiHoster import MultiHoster diff --git a/pyload/plugin/hoster/DepositfilesCom.py b/pyload/plugin/hoster/DepositfilesCom.py index 1616577cd..e16222856 100644 --- a/pyload/plugin/hoster/DepositfilesCom.py +++ b/pyload/plugin/hoster/DepositfilesCom.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urllib import unquote +import urllib from pyload.plugin.captcha.ReCaptcha import ReCaptcha from pyload.plugin.internal.SimpleHoster import SimpleHoster @@ -67,7 +66,7 @@ class DepositfilesCom(SimpleHoster): m = re.search(self.LINK_FREE_PATTERN, self.html) if m: - self.link = unquote(m.group(1)) + self.link = urllib.unquote(m.group(1)) def handlePremium(self, pyfile): diff --git a/pyload/plugin/hoster/FastixRu.py b/pyload/plugin/hoster/FastixRu.py index 12d0c51bb..dc3b7d6ea 100644 --- a/pyload/plugin/hoster/FastixRu.py +++ b/pyload/plugin/hoster/FastixRu.py @@ -1,9 +1,7 @@ # -*- coding: utf-8 -*- import re - -from random import randrange -from urllib import unquote +import urllib from pyload.utils import json_loads from pyload.plugin.internal.MultiHoster import MultiHoster diff --git a/pyload/plugin/hoster/FastshareCz.py b/pyload/plugin/hoster/FastshareCz.py index a98a7de31..7e688a941 100644 --- a/pyload/plugin/hoster/FastshareCz.py +++ b/pyload/plugin/hoster/FastshareCz.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urlparse import urljoin +import urlparse from pyload.plugin.internal.SimpleHoster import SimpleHoster @@ -55,8 +54,8 @@ class FastshareCz(SimpleHoster): self.error(_("FREE_URL_PATTERN not found")) baseurl = "http://www.fastshare.cz" - captcha = self.decryptCaptcha(urljoin(baseurl, captcha_src)) - self.download(urljoin(baseurl, action), post={'code': captcha, 'btn.x': 77, 'btn.y': 18}) + captcha = self.decryptCaptcha(urlparse.urljoin(baseurl, captcha_src)) + self.download(urlparse.urljoin(baseurl, action), post={'code': captcha, 'btn.x': 77, 'btn.y': 18}) def checkFile(self, rules={}): diff --git a/pyload/plugin/hoster/FileSharkPl.py b/pyload/plugin/hoster/FileSharkPl.py index 2a06fe6a4..5d37a55c6 100644 --- a/pyload/plugin/hoster/FileSharkPl.py +++ b/pyload/plugin/hoster/FileSharkPl.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urlparse import urljoin +import urlparse from pyload.plugin.internal.SimpleHoster import SimpleHoster @@ -78,7 +77,7 @@ class FileSharkPl(SimpleHoster): if m is None: self.error(_("Download url not found")) - link = urljoin("http://fileshark.pl", m.group(1)) + link = urlparse.urljoin("http://fileshark.pl", m.group(1)) self.html = self.load(link) diff --git a/pyload/plugin/hoster/FilefactoryCom.py b/pyload/plugin/hoster/FilefactoryCom.py index 85d014e1e..782b6ba48 100644 --- a/pyload/plugin/hoster/FilefactoryCom.py +++ b/pyload/plugin/hoster/FilefactoryCom.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urlparse import urljoin +import urlparse from pyload.network.RequestFactory import getURL from pyload.plugin.internal.SimpleHoster import SimpleHoster, parseFileInfo diff --git a/pyload/plugin/hoster/FilerNet.py b/pyload/plugin/hoster/FilerNet.py index fbefba8db..be8445fad 100644 --- a/pyload/plugin/hoster/FilerNet.py +++ b/pyload/plugin/hoster/FilerNet.py @@ -6,8 +6,7 @@ import pycurl import re - -from urlparse import urljoin +import urlparse from pyload.plugin.captcha.ReCaptcha import ReCaptcha from pyload.plugin.internal.SimpleHoster import SimpleHoster diff --git a/pyload/plugin/hoster/FlyFilesNet.py b/pyload/plugin/hoster/FlyFilesNet.py index 77c7ed82b..4f1d71d21 100644 --- a/pyload/plugin/hoster/FlyFilesNet.py +++ b/pyload/plugin/hoster/FlyFilesNet.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urllib import unquote +import urllib from pyload.network.RequestFactory import getURL from pyload.plugin.internal.SimpleHoster import SimpleHoster @@ -26,7 +25,7 @@ class FlyFilesNet(SimpleHoster): def process(self, pyfile): name = re.search(self.NAME_PATTERN, pyfile.url).group(1) - pyfile.name = unquote_plus(name) + pyfile.name = urllib.unquote_plus(name) session = re.search(self.SESSION_PATTERN, pyfile.url).group(1) diff --git a/pyload/plugin/hoster/FshareVn.py b/pyload/plugin/hoster/FshareVn.py index 47348f753..05f213680 100644 --- a/pyload/plugin/hoster/FshareVn.py +++ b/pyload/plugin/hoster/FshareVn.py @@ -2,8 +2,7 @@ import re import time - -from urlparse import urljoin +import urlparse from pyload.network.RequestFactory import getURL from pyload.plugin.internal.SimpleHoster import SimpleHoster, parseFileInfo @@ -59,7 +58,7 @@ class FshareVn(SimpleHoster): self.checkErrors() action, inputs = self.parseHtmlForm('frm_download') - url = urljoin(pyfile.url, action) + url = urlparse.urljoin(pyfile.url, action) if not inputs: self.error(_("No FORM")) diff --git a/pyload/plugin/hoster/Ftp.py b/pyload/plugin/hoster/Ftp.py index 1ebfdebd0..d26e3ad0b 100644 --- a/pyload/plugin/hoster/Ftp.py +++ b/pyload/plugin/hoster/Ftp.py @@ -2,9 +2,8 @@ import pycurl import re - -from urllib import quote, unquote -from urlparse import urlparse +import urllib +import urlparse from pyload.plugin.Hoster import Hoster @@ -12,7 +11,7 @@ from pyload.plugin.Hoster import Hoster class Ftp(Hoster): __name = "Ftp" __type = "hoster" - __version = "0.50" + __version = "0.51" __pattern = r'(?:ftps?|sftp)://([\w.-]+(:[\w.-]+)?@)?[\w.-]+(:\d+)?/.+' @@ -26,15 +25,13 @@ class Ftp(Hoster): def setup(self): self.chunkLimit = -1 self.resumeDownload = True - - def process(self, pyfile): - parsed_url = urlparse(pyfile.url) + parsed_url = urlparse.urlparse(pyfile.url) netloc = parsed_url.netloc pyfile.name = parsed_url.path.rpartition('/')[2] try: - pyfile.name = unquote(str(pyfile.name)).decode('utf8') + pyfile.name = urllib.unquote(str(pyfile.name)).decode('utf8') except Exception: pass @@ -67,11 +64,11 @@ class Ftp(Hoster): # Naive ftp directory listing if re.search(r'^25\d.*?"', self.req.http.header, re.M): pyfile.url = pyfile.url.rstrip('/') - pkgname = "/".join(pyfile.package().name, urlparse(pyfile.url).path.rpartition('/')[2]) + pkgname = "/".join(pyfile.package().name, urlparse.urlparse(pyfile.url).path.rpartition('/')[2]) pyfile.url += '/' self.req.http.c.setopt(48, 1) #: CURLOPT_DIRLISTONLY res = self.load(pyfile.url, decode=False) - links = [pyfile.url + quote(x) for x in res.splitlines()] + links = [pyfile.url + urllib.quote(x) for x in res.splitlines()] self.logDebug("LINKS", links) self.core.api.addPackage(pkgname, links) else: diff --git a/pyload/plugin/hoster/GigapetaCom.py b/pyload/plugin/hoster/GigapetaCom.py index c524a0a7c..a85074e79 100644 --- a/pyload/plugin/hoster/GigapetaCom.py +++ b/pyload/plugin/hoster/GigapetaCom.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- +import pycurl +import random import re -from random import randint - from pyload.plugin.internal.SimpleHoster import SimpleHoster @@ -28,7 +28,7 @@ class GigapetaCom(SimpleHoster): def handleFree(self, pyfile): - captcha_key = str(randint(1, 100000000)) + captcha_key = str(random.randint(1, 100000000)) captcha_url = "http://gigapeta.com/img/captcha.gif?x=%s" % captcha_key for _i in xrange(5): diff --git a/pyload/plugin/hoster/HellshareCz.py b/pyload/plugin/hoster/HellshareCz.py index f7e95d273..735ed1f19 100644 --- a/pyload/plugin/hoster/HellshareCz.py +++ b/pyload/plugin/hoster/HellshareCz.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from urlparse import urljoin +import urlparse from pyload.plugin.internal.SimpleHoster import SimpleHoster diff --git a/pyload/plugin/hoster/Keep2ShareCc.py b/pyload/plugin/hoster/Keep2ShareCc.py index 59e5f5c79..05dafffa8 100644 --- a/pyload/plugin/hoster/Keep2ShareCc.py +++ b/pyload/plugin/hoster/Keep2ShareCc.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urlparse import urljoin +import urlparse from pyload.plugin.captcha.ReCaptcha import ReCaptcha from pyload.plugin.internal.SimpleHoster import SimpleHoster @@ -100,7 +99,7 @@ class Keep2ShareCc(SimpleHoster): m = re.search(self.CAPTCHA_PATTERN, self.html) self.logDebug("CAPTCHA_PATTERN found %s" % m) if m: - captcha_url = urljoin("http://keep2s.cc/", m.group(1)) + captcha_url = urlparse.urljoin("http://keep2s.cc/", m.group(1)) post_data['CaptchaForm[code]'] = self.decryptCaptcha(captcha_url) else: recaptcha = ReCaptcha(self) diff --git a/pyload/plugin/hoster/LetitbitNet.py b/pyload/plugin/hoster/LetitbitNet.py index 35f5f9cf4..85fd55b89 100644 --- a/pyload/plugin/hoster/LetitbitNet.py +++ b/pyload/plugin/hoster/LetitbitNet.py @@ -7,8 +7,7 @@ # http://letitbit.net/download/07874.0b5709a7d3beee2408bb1f2eefce/random.bin.html import re - -from urlparse import urljoin +import urlparse from pyload.utils import json_loads, json_dumps from pyload.network.RequestFactory import getURL @@ -66,7 +65,7 @@ class LetitbitNet(SimpleHoster): self.logDebug(action, inputs) inputs['desc'] = "" - self.html = self.load(urljoin("http://letitbit.net/", action), post=inputs) + self.html = self.load(urlparse.urljoin("http://letitbit.net/", action), post=inputs) m = re.search(self.SECONDS_PATTERN, self.html) seconds = int(m.group(1)) if m else 60 diff --git a/pyload/plugin/hoster/LinksnappyCom.py b/pyload/plugin/hoster/LinksnappyCom.py index 2cb14dd51..186639a81 100644 --- a/pyload/plugin/hoster/LinksnappyCom.py +++ b/pyload/plugin/hoster/LinksnappyCom.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urlparse import urlsplit +import urlparse from pyload.utils import json_loads, json_dumps from pyload.plugin.internal.MultiHoster import MultiHoster @@ -52,5 +51,5 @@ class LinksnappyCom(MultiHoster): @staticmethod def _get_host(url): - host = urlsplit(url).netloc + host = urlparse.urlsplit(url).netloc return re.search(r'[\w-]+\.\w+$', host).group(0) diff --git a/pyload/plugin/hoster/MegaCoNz.py b/pyload/plugin/hoster/MegaCoNz.py index 9dea99b23..2d7b40d98 100644 --- a/pyload/plugin/hoster/MegaCoNz.py +++ b/pyload/plugin/hoster/MegaCoNz.py @@ -1,15 +1,15 @@ # -*- coding: utf-8 -*- +import array import os +# import pycurl import random import re -from array import array from base64 import standard_b64decode from Crypto.Cipher import AES from Crypto.Util import Counter -# from pycurl import SSL_CIPHER_LIST from pyload.utils import json_loads, json_dumps from pyload.plugin.Hoster import Hoster @@ -69,10 +69,10 @@ class MegaCoNz(Hoster): def getCipherKey(self, key): """ Construct the cipher key from the given data """ - a = array("I", self.b64_decode(key)) + a = array.array("I", self.b64_decode(key)) - k = array("I", (a[0] ^ a[4], a[1] ^ a[5], a[2] ^ a[6], a[3] ^ a[7])) - iv = a[4:6] + array("I", (0, 0)) + k = array.array("I", (a[0] ^ a[4], a[1] ^ a[5], a[2] ^ a[6], a[3] ^ a[7])) + iv = a[4:6] + array.array("I", (0, 0)) meta_mac = a[6:8] return k, iv, meta_mac @@ -82,7 +82,7 @@ class MegaCoNz(Hoster): """ Dispatch a call to the api, see https://mega.co.nz/#developers """ # generate a session id, no idea where to obtain elsewhere - uid = random.randint(10 << 9, 10 ** 10) + uid = random.random.randint(10 << 9, 10 ** 10) res = self.load(self.API_URL, get={'id': uid}, post=json_dumps([kwargs])) self.logDebug("Api Response: " + res) @@ -145,7 +145,7 @@ class MegaCoNz(Hoster): # block = chunk[i:i+16] # if len(block) % 16: # block += '=' * (16 - (len(block) % 16)) - # block = array("I", block) + # block = array.array("I", block) # chunk_mac = [chunk_mac[0] ^ a_[0], chunk_mac[1] ^ block[1], chunk_mac[2] ^ block[2], chunk_mac[3] ^ block[3]] # chunk_mac = aes_cbc_encrypt_a32(chunk_mac, k) @@ -207,7 +207,7 @@ class MegaCoNz(Hoster): pyfile.name = attr['n'] + self.FILE_SUFFIX pyfile.size = mega['s'] - # self.req.http.c.setopt(SSL_CIPHER_LIST, "RC4-MD5:DEFAULT") + # self.req.http.c.setopt(pycurl.SSL_CIPHER_LIST, "RC4-MD5:DEFAULT") self.download(mega['g']) diff --git a/pyload/plugin/hoster/MegaDebridEu.py b/pyload/plugin/hoster/MegaDebridEu.py index 1c84223b8..4b2604046 100644 --- a/pyload/plugin/hoster/MegaDebridEu.py +++ b/pyload/plugin/hoster/MegaDebridEu.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urllib import unquote_plus +import urllib from pyload.utils import json_loads from pyload.plugin.internal.MultiHoster import MultiHoster diff --git a/pyload/plugin/hoster/MegaRapidCz.py b/pyload/plugin/hoster/MegaRapidCz.py index e8aa1106f..d7ed78202 100644 --- a/pyload/plugin/hoster/MegaRapidCz.py +++ b/pyload/plugin/hoster/MegaRapidCz.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- +import pycurl import re -from pycurl import HTTPHEADER - from pyload.network.HTTPRequest import BadHeader from pyload.network.RequestFactory import getRequest from pyload.plugin.internal.SimpleHoster import SimpleHoster, parseFileInfo @@ -11,7 +10,7 @@ from pyload.plugin.internal.SimpleHoster import SimpleHoster, parseFileInfo def getInfo(urls): h = getRequest() - h.c.setopt(HTTPHEADER, + h.c.setopt(pycurl.HTTPHEADER, ["Accept: text/html", "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0"]) diff --git a/pyload/plugin/hoster/MegaRapidoNet.py b/pyload/plugin/hoster/MegaRapidoNet.py index 54a167b65..1be61f235 100644 --- a/pyload/plugin/hoster/MegaRapidoNet.py +++ b/pyload/plugin/hoster/MegaRapidoNet.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from random import randint +import random from pyload.plugin.internal.MultiHoster import MultiHoster @@ -9,7 +9,7 @@ def random_with_N_digits(n): rand = "0." not_zero = 0 for _i in xrange(1, n + 1): - r = randint(0, 9) + r = random.randint(0, 9) if(r > 0): not_zero += 1 rand += str(r) diff --git a/pyload/plugin/hoster/MultishareCz.py b/pyload/plugin/hoster/MultishareCz.py index 4ee747043..d4546e5f9 100644 --- a/pyload/plugin/hoster/MultishareCz.py +++ b/pyload/plugin/hoster/MultishareCz.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- +import random import re -from random import random - from pyload.plugin.internal.SimpleHoster import SimpleHoster @@ -45,7 +44,7 @@ class MultishareCz(SimpleHoster): if not self.checkTrafficLeft(): self.fail(_("Not enough credit left to download file")) - self.download("http://dl%d.mms.multishare.cz/html/mms_process.php" % round(random() * 10000 * random()), + self.download("http://dl%d.mms.multishare.cz/html/mms_process.php" % round(random.random() * 10000 * random.random()), get={'u_ID' : self.acc_info['u_ID'], 'u_hash': self.acc_info['u_hash'], 'link' : pyfile.url}, diff --git a/pyload/plugin/hoster/NarodRu.py b/pyload/plugin/hoster/NarodRu.py index f3ff38379..456baefec 100644 --- a/pyload/plugin/hoster/NarodRu.py +++ b/pyload/plugin/hoster/NarodRu.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- +import random import re -from random import random - from pyload.plugin.internal.SimpleHoster import SimpleHoster @@ -34,7 +33,7 @@ class NarodRu(SimpleHoster): def handleFree(self, pyfile): for _i in xrange(5): - self.html = self.load('http://narod.ru/disk/getcapchaxml/?rnd=%d' % int(random() * 777)) + self.html = self.load('http://narod.ru/disk/getcapchaxml/?rnd=%d' % int(random.random() * 777)) m = re.search(self.CAPTCHA_PATTERN, self.html) if m is None: diff --git a/pyload/plugin/hoster/NetloadIn.py b/pyload/plugin/hoster/NetloadIn.py index f4421615f..9e05b02c5 100644 --- a/pyload/plugin/hoster/NetloadIn.py +++ b/pyload/plugin/hoster/NetloadIn.py @@ -2,8 +2,7 @@ import re import time - -from urlparse import urljoin +import urlparse from pyload.network.RequestFactory import getURL from pyload.plugin.Hoster import Hoster @@ -230,7 +229,7 @@ class NetloadIn(Hoster): page = None else: - url_captcha_html = urljoin("http://netload.in/", url_captcha_html) + url_captcha_html = urlparse.urljoin("http://netload.in/", url_captcha_html) break self.html = self.load(url_captcha_html) diff --git a/pyload/plugin/hoster/OverLoadMe.py b/pyload/plugin/hoster/OverLoadMe.py index d4636f0f1..85a0f0a1f 100644 --- a/pyload/plugin/hoster/OverLoadMe.py +++ b/pyload/plugin/hoster/OverLoadMe.py @@ -1,9 +1,7 @@ # -*- coding: utf-8 -*- import re - -from random import randrange -from urllib import unquote +import urllib from pyload.utils import json_loads from pyload.plugin.internal.MultiHoster import MultiHoster diff --git a/pyload/plugin/hoster/PremiumTo.py b/pyload/plugin/hoster/PremiumTo.py index 750e965d2..59fd37459 100644 --- a/pyload/plugin/hoster/PremiumTo.py +++ b/pyload/plugin/hoster/PremiumTo.py @@ -2,7 +2,7 @@ from __future__ import with_statement -from os import remove +import os from pyload.plugin.internal.MultiHoster import MultiHoster from pyload.utils import fs_encode @@ -45,7 +45,7 @@ class PremiumTo(MultiHoster): file = fs_encode(self.lastDownload) with open(file, "rb") as f: err = f.read(256).strip() - remove(file) + os.remove(file) if err: self.fail(err) diff --git a/pyload/plugin/hoster/QuickshareCz.py b/pyload/plugin/hoster/QuickshareCz.py index 3dd11f04a..57b419688 100644 --- a/pyload/plugin/hoster/QuickshareCz.py +++ b/pyload/plugin/hoster/QuickshareCz.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- +import pycurl import re - from pyload.plugin.internal.SimpleHoster import SimpleHoster diff --git a/pyload/plugin/hoster/RapidgatorNet.py b/pyload/plugin/hoster/RapidgatorNet.py index 10b6403a1..b05b0d5d0 100644 --- a/pyload/plugin/hoster/RapidgatorNet.py +++ b/pyload/plugin/hoster/RapidgatorNet.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- +import pycurl import re -from pycurl import HTTPHEADER - from pyload.utils import json_loads from pyload.network.HTTPRequest import BadHeader from pyload.plugin.captcha.AdsCaptcha import AdsCaptcha @@ -104,7 +103,7 @@ class RapidgatorNet(SimpleHoster): self.logDebug(jsvars) self.req.http.lastURL = pyfile.url - self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) + self.req.http.c.setopt(pycurl.HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) url = "http://rapidgator.net%s?fid=%s" % ( jsvars.get('startTimerUrl', '/download/AjaxStartTimer'), jsvars['fid']) @@ -117,7 +116,7 @@ class RapidgatorNet(SimpleHoster): jsvars.update(self.getJsonResponse(url)) self.req.http.lastURL = pyfile.url - self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With:"]) + self.req.http.c.setopt(pycurl.HTTPHEADER, ["X-Requested-With:"]) url = "http://rapidgator.net%s" % jsvars.get('captchaUrl', '/download/captcha') self.html = self.load(url) diff --git a/pyload/plugin/hoster/RapiduNet.py b/pyload/plugin/hoster/RapiduNet.py index 7efa606fd..6bbfc171a 100644 --- a/pyload/plugin/hoster/RapiduNet.py +++ b/pyload/plugin/hoster/RapiduNet.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- +import pycurl import re import time -from pycurl import HTTPHEADER - from pyload.utils import json_loads from pyload.plugin.captcha.ReCaptcha import ReCaptcha from pyload.plugin.internal.SimpleHoster import SimpleHoster @@ -40,7 +39,7 @@ class RapiduNet(SimpleHoster): def handleFree(self, pyfile): self.req.http.lastURL = pyfile.url - self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) + self.req.http.c.setopt(pycurl.HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) jsvars = self.getJsonResponse("https://rapidu.net/ajax.php", get={'a': "getLoadTimeToDownload"}, diff --git a/pyload/plugin/hoster/RealdebridCom.py b/pyload/plugin/hoster/RealdebridCom.py index 5e2286974..e9c55fae3 100644 --- a/pyload/plugin/hoster/RealdebridCom.py +++ b/pyload/plugin/hoster/RealdebridCom.py @@ -2,9 +2,7 @@ import re import time - -from random import randrange -from urllib import unquote +import urllib from pyload.utils import json_loads from pyload.plugin.internal.MultiHoster import MultiHoster diff --git a/pyload/plugin/hoster/ShareonlineBiz.py b/pyload/plugin/hoster/ShareonlineBiz.py index dcdeca168..0f5a8692a 100644 --- a/pyload/plugin/hoster/ShareonlineBiz.py +++ b/pyload/plugin/hoster/ShareonlineBiz.py @@ -2,9 +2,8 @@ import re import time - -from urllib import unquote -from urlparse import urlparse +import urllib +import urlparse from pyload.network.RequestFactory import getURL from pyload.plugin.captcha.ReCaptcha import ReCaptcha @@ -38,7 +37,7 @@ class ShareonlineBiz(SimpleHoster): @classmethod def getInfo(cls, url="", html=""): - info = {'name': urlparse(unquote(url)).path.split('/')[-1] or _("Unknown"), 'size': 0, 'status': 3 if url else 1, 'url': url} + info = {'name': urlparse.urlparse(urllib.unquote(url)).path.split('/')[-1] or _("Unknown"), 'size': 0, 'status': 3 if url else 1, 'url': url} if url: info['pattern'] = re.match(cls.__pattern, url).groupdict() diff --git a/pyload/plugin/hoster/ShareplaceCom.py b/pyload/plugin/hoster/ShareplaceCom.py index 08fb966b8..b1361e859 100644 --- a/pyload/plugin/hoster/ShareplaceCom.py +++ b/pyload/plugin/hoster/ShareplaceCom.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urllib import unquote +import urllib from pyload.plugin.Hoster import Hoster @@ -61,7 +60,7 @@ class ShareplaceCom(Hoster): url = re.search(r"var beer = '(.*?)';", self.html) if url: url = url.group(1) - url = unquote( + url = urllib.unquote( url.replace("http://http:/", "").replace("vvvvvvvvv", "").replace("lllllllll", "").replace( "teletubbies", "")) self.logDebug("URL: %s" % url) diff --git a/pyload/plugin/hoster/SpeedyshareCom.py b/pyload/plugin/hoster/SpeedyshareCom.py index b6d0a5898..5133725fd 100644 --- a/pyload/plugin/hoster/SpeedyshareCom.py +++ b/pyload/plugin/hoster/SpeedyshareCom.py @@ -4,8 +4,7 @@ # http://speedy.sh/ep2qY/Zapp-Brannigan.jpg import re - -from urlparse import urljoin +import urlparse from pyload.plugin.internal.SimpleHoster import SimpleHoster diff --git a/pyload/plugin/hoster/TurbobitNet.py b/pyload/plugin/hoster/TurbobitNet.py index 4c07cb84f..a55d824a3 100644 --- a/pyload/plugin/hoster/TurbobitNet.py +++ b/pyload/plugin/hoster/TurbobitNet.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- +import binascii +import pycurl import random import re import time +import urllib from Crypto.Cipher import ARC4 -from binascii import hexlify, unhexlify -from pycurl import HTTPHEADER -from urllib import quote from pyload.network.RequestFactory import getURL from pyload.plugin.captcha.ReCaptcha import ReCaptcha @@ -50,11 +50,11 @@ class TurbobitNet(SimpleHoster): self.solveCaptcha() - self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) + self.req.http.c.setopt(pycurl.HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) self.html = self.load(self.getDownloadUrl(rtUpdate)) - self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With:"]) + self.req.http.c.setopt(pycurl.HTTPHEADER, ["X-Requested-With:"]) m = re.search(self.LINK_FREE_PATTERN, self.html) if m: @@ -134,7 +134,7 @@ class TurbobitNet(SimpleHoster): for b in [1, 3]: self.jscode = "var id = \'%s\';var b = %d;var inn = \'%s\';%sout" % ( - self.info['pattern']['ID'], b, quote(fun), rtUpdate) + self.info['pattern']['ID'], b, urllib.quote(fun), rtUpdate) try: out = self.js.eval(self.jscode) @@ -155,8 +155,8 @@ class TurbobitNet(SimpleHoster): def decrypt(self, data): - cipher = ARC4.new(hexlify('E\x15\xa1\x9e\xa3M\xa0\xc6\xa0\x84\xb6H\x83\xa8o\xa0')) - return unhexlify(cipher.encrypt(unhexlify(data))) + cipher = ARC4.new(binascii.hexlify('E\x15\xa1\x9e\xa3M\xa0\xc6\xa0\x84\xb6H\x83\xa8o\xa0')) + return binascii.unhexlify(cipher.encrypt(binascii.unhexlify(data))) def getLocalTimeString(self): diff --git a/pyload/plugin/hoster/UnibytesCom.py b/pyload/plugin/hoster/UnibytesCom.py index 2c383e383..d8092ae08 100644 --- a/pyload/plugin/hoster/UnibytesCom.py +++ b/pyload/plugin/hoster/UnibytesCom.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- +import pycurl import re - -from urlparse import urljoin - +import urlparse from pyload.plugin.internal.SimpleHoster import SimpleHoster @@ -35,7 +34,7 @@ class UnibytesCom(SimpleHoster): for _i in xrange(8): self.logDebug(action, post_data) - self.html = self.load(urljoin(domain, action), post=post_data, follow_location=False) + self.html = self.load(urlparse.urljoin(domain, action), post=post_data, follow_location=False) m = re.search(r'location:\s*(\S+)', self.req.http.header, re.I) if m: @@ -63,7 +62,7 @@ class UnibytesCom(SimpleHoster): self.wait(m.group(1) if m else 60, False) elif last_step in ("captcha", "last"): - post_data['captcha'] = self.decryptCaptcha(urljoin(domain, "/captcha.jpg")) + post_data['captcha'] = self.decryptCaptcha(urlparse.urljoin(domain, "/captcha.jpg")) else: self.fail(_("No valid captcha code entered")) diff --git a/pyload/plugin/hoster/UpleaCom.py b/pyload/plugin/hoster/UpleaCom.py index fe2aa036e..0459a82ea 100644 --- a/pyload/plugin/hoster/UpleaCom.py +++ b/pyload/plugin/hoster/UpleaCom.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urlparse import urljoin +import urlparse from pyload.plugin.internal.XFSHoster import XFSHoster @@ -48,7 +47,7 @@ class UpleaCom(XFSHoster): if m is None: self.error(_("STEP_PATTERN not found")) - self.html = self.load(urljoin("http://uplea.com/", m.group(1))) + self.html = self.load(urlparse.urljoin("http://uplea.com/", m.group(1))) m = re.search(self.WAIT_PATTERN, self.html) if m: diff --git a/pyload/plugin/hoster/UploadheroCom.py b/pyload/plugin/hoster/UploadheroCom.py index d1c9fd2c7..4a01d5db0 100644 --- a/pyload/plugin/hoster/UploadheroCom.py +++ b/pyload/plugin/hoster/UploadheroCom.py @@ -4,8 +4,7 @@ # http://uploadhero.co/dl/wQBRAVSM import re - -from urlparse import urljoin +import urlparse from pyload.plugin.internal.SimpleHoster import SimpleHoster @@ -44,7 +43,7 @@ class UploadheroCom(SimpleHoster): if m is None: self.error(_("Captcha not found")) - captcha = self.decryptCaptcha(urljoin("http://uploadhero.co", m.group(1))) + captcha = self.decryptCaptcha(urlparse.urljoin("http://uploadhero.co", m.group(1))) self.html = self.load(pyfile.url, get={"code": captcha}) @@ -58,7 +57,7 @@ class UploadheroCom(SimpleHoster): def checkErrors(self): m = re.search(self.IP_BLOCKED_PATTERN, self.html) if m: - self.html = self.load(urljoin("http://uploadhero.co", m.group(1))) + self.html = self.load(urlparse.urljoin("http://uploadhero.co", m.group(1))) m = re.search(self.IP_WAIT_PATTERN, self.html) wait_time = (int(m.group(1)) * 60 + int(m.group(2))) if m else 5 * 60 diff --git a/pyload/plugin/hoster/UploadingCom.py b/pyload/plugin/hoster/UploadingCom.py index 1143a7d99..e6c4cb7de 100644 --- a/pyload/plugin/hoster/UploadingCom.py +++ b/pyload/plugin/hoster/UploadingCom.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- +import pycurl import re -from pycurl import HTTPHEADER - from pyload.utils import json_loads from pyload.plugin.internal.SimpleHoster import SimpleHoster, timestamp @@ -66,7 +65,7 @@ class UploadingCom(SimpleHoster): 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.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']})) diff --git a/pyload/plugin/hoster/WrzucTo.py b/pyload/plugin/hoster/WrzucTo.py index 5d17e3d4b..34306b75f 100644 --- a/pyload/plugin/hoster/WrzucTo.py +++ b/pyload/plugin/hoster/WrzucTo.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- +import pycurl import re -from pycurl import HTTPHEADER - from pyload.plugin.internal.SimpleHoster import SimpleHoster @@ -35,7 +34,7 @@ class WrzucTo(SimpleHoster): if len(data) != 2: self.error(_("No file ID")) - self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) + self.req.http.c.setopt(pycurl.HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) self.req.http.lastURL = pyfile.url self.load("http://www.wrzuc.to/ajax/server/prepair", post={"md5": data['md5']}) diff --git a/pyload/plugin/hoster/XHamsterCom.py b/pyload/plugin/hoster/XHamsterCom.py index 57e2a898c..4be06833b 100644 --- a/pyload/plugin/hoster/XHamsterCom.py +++ b/pyload/plugin/hoster/XHamsterCom.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urllib import unquote +import urllib from pyload.utils import json_loads from pyload.plugin.Hoster import Hoster @@ -83,7 +82,7 @@ class XHamsterCom(Hoster): self.logDebug("long_url = " + long_url) else: if flashvars['file']: - file_url = unquote(flashvars['file']) + file_url = urllib.unquote(flashvars['file']) else: self.error(_("file_url not found")) diff --git a/pyload/plugin/hoster/Xdcc.py b/pyload/plugin/hoster/Xdcc.py index 6943f495e..d7593a936 100644 --- a/pyload/plugin/hoster/Xdcc.py +++ b/pyload/plugin/hoster/Xdcc.py @@ -6,8 +6,6 @@ import struct import sys import time -from os import makedirs -from os.path import exists, join from select import select from pyload.plugin.Hoster import Hoster diff --git a/pyload/plugin/hoster/YourfilesTo.py b/pyload/plugin/hoster/YourfilesTo.py index f5e778741..4ac49d357 100644 --- a/pyload/plugin/hoster/YourfilesTo.py +++ b/pyload/plugin/hoster/YourfilesTo.py @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- -import re - -from urllib import unquote +import reimport urllib from pyload.plugin.Hoster import Hoster @@ -62,7 +60,7 @@ class YourfilesTo(Hoster): url = re.search(r"var bla = '(.*?)';", self.html) if url: url = url.group(1) - url = unquote(url.replace("http://http:/http://", "http://").replace("dumdidum", "")) + url = urllib.unquote(url.replace("http://http:/http://", "http://").replace("dumdidum", "")) return url else: self.error(_("Absolute filepath not found")) diff --git a/pyload/plugin/hoster/YoutubeCom.py b/pyload/plugin/hoster/YoutubeCom.py index 5db9957f8..b6f91fdb0 100644 --- a/pyload/plugin/hoster/YoutubeCom.py +++ b/pyload/plugin/hoster/YoutubeCom.py @@ -2,9 +2,7 @@ import os import re -import subprocess - -from urllib import unquote +import subprocessimport urllib from pyload.plugin.Hoster import Hoster from pyload.plugin.internal.SimpleHoster import replace_patterns @@ -117,7 +115,7 @@ class YoutubeCom(Hoster): streams = re.search(r'"url_encoded_fmt_stream_map":"(.+?)",', html).group(1) streams = [x.split('\u0026') for x in streams.split(',')] streams = [dict((y.split('=', 1)) for y in x) for x in streams] - streams = [(int(x['itag']), unquote(x['url'])) for x in streams] + streams = [(int(x['itag']), urllib.unquote(x['url'])) for x in streams] # self.logDebug("Found links: %s" % streams) diff --git a/pyload/plugin/internal/BasePlugin.py b/pyload/plugin/internal/BasePlugin.py index c5fbde8bb..6be9880fc 100644 --- a/pyload/plugin/internal/BasePlugin.py +++ b/pyload/plugin/internal/BasePlugin.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- import re - -from urllib import unquote -from urlparse import urljoin, urlparse +import urllib +import urlparse from pyload.network.HTTPRequest import BadHeader from pyload.plugin.internal.SimpleHoster import getFileURL @@ -13,7 +12,7 @@ from pyload.plugin.Hoster import Hoster class BasePlugin(Hoster): __name = "BasePlugin" __type = "hoster" - __version = "0.42" + __version = "0.43" __pattern = r'^unmatchable$' @@ -25,8 +24,8 @@ class BasePlugin(Hoster): @classmethod def getInfo(cls, url="", html=""): #@TODO: Move to hoster class in 0.4.10 - url = unquote(url) - url_p = urlparse(url) + url = urllib.unquote(url) + url_p = urlparse.urlparse(url) return {'name' : (url_p.path.split('/')[-1] or url_p.query.split('=', 1)[::-1][0].split('&', 1)[0] or url_p.netloc.split('.', 1)[0]), @@ -39,8 +38,6 @@ class BasePlugin(Hoster): self.chunkLimit = -1 self.multiDL = True self.resumeDownload = True - - def process(self, pyfile): """main function""" @@ -51,7 +48,7 @@ class BasePlugin(Hoster): for _i in xrange(5): try: - link = getFileURL(self, unquote(pyfile.url)) + link = getFileURL(self, urllib.unquote(pyfile.url)) if link: self.download(link, ref=False, disposition=True) @@ -67,7 +64,7 @@ class BasePlugin(Hoster): account = self.core.accountManager.getAccountPlugin('Http') servers = [x['login'] for x in account.getAllAccounts()] - server = urlparse(pyfile.url).netloc + server = urlparse.urlparse(pyfile.url).netloc if server in servers: self.logDebug("Logging on to %s" % server) diff --git a/pyload/plugin/internal/SimpleCrypter.py b/pyload/plugin/internal/SimpleCrypter.py index c6582647f..e22a4df29 100644 --- a/pyload/plugin/internal/SimpleCrypter.py +++ b/pyload/plugin/internal/SimpleCrypter.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urlparse import urljoin, urlparse +import urlparse from pyload.plugin.Crypter import Crypter from pyload.plugin.internal.SimpleHoster import SimpleHoster, replace_patterns, set_cookies @@ -136,10 +135,10 @@ class SimpleCrypter(Crypter, SimpleHoster): Returns the links extracted from self.html You should override this only if it's impossible to extract links using only the LINK_PATTERN. """ - url_p = urlparse(self.pyfile.url) + url_p = urlparse.urlparse(self.pyfile.url) baseurl = "%s://%s" % (url_p.scheme, url_p.netloc) - return [urljoin(baseurl, link) if not urlparse(link).scheme else link \ + return [urlparse.urljoin(baseurl, link) if not urlparse.urlparse(link).scheme else link \ for link in re.findall(self.LINK_PATTERN, self.html)] diff --git a/pyload/plugin/internal/SimpleDereferer.py b/pyload/plugin/internal/SimpleDereferer.py index c82afe0b4..0ec947751 100644 --- a/pyload/plugin/internal/SimpleDereferer.py +++ b/pyload/plugin/internal/SimpleDereferer.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- import re - -from urllib import unquote +import urllib from pyload.plugin.Crypter import Crypter from pyload.plugin.internal.SimpleHoster import getFileURL, set_cookies @@ -49,7 +48,7 @@ class SimpleDereferer(Crypter): if not link: try: - link = unquote(re.match(self.__pattern, pyfile.url).group('LINK')) + link = urllib.unquote(re.match(self.__pattern, pyfile.url).group('LINK')) except Exception: self.prepare() diff --git a/pyload/plugin/internal/SimpleHoster.py b/pyload/plugin/internal/SimpleHoster.py index 8b53559e7..a87986330 100644 --- a/pyload/plugin/internal/SimpleHoster.py +++ b/pyload/plugin/internal/SimpleHoster.py @@ -244,7 +244,7 @@ def secondsToMidnight(gmt=0): class SimpleHoster(Hoster): __name = "SimpleHoster" __type = "hoster" - __version = "1.39" + __version = "1.40" __pattern = r'^unmatchable$' __config = [("use_premium", "bool", "Use premium account if available", True)] @@ -492,8 +492,6 @@ class SimpleHoster(Hoster): self.retryFree() else: raise Fail(e) - - def downloadLink(self, link, disposition=True): if link and isinstance(link, basestring): self.correctCaptcha() diff --git a/pyload/plugin/internal/XFSAccount.py b/pyload/plugin/internal/XFSAccount.py index d8c5a91f1..105df3cd5 100644 --- a/pyload/plugin/internal/XFSAccount.py +++ b/pyload/plugin/internal/XFSAccount.py @@ -2,8 +2,7 @@ import re import time - -from urlparse import urljoin +import urlparse from pyload.plugin.Account import Account from pyload.plugin.internal.SimpleHoster import parseHtmlForm, set_cookies @@ -155,7 +154,7 @@ class XFSAccount(Account): raise Exception(_("Missing HOSTER_DOMAIN")) if not self.LOGIN_URL: - self.LOGIN_URL = urljoin(self.HOSTER_URL, "login.html") + self.LOGIN_URL = urlparse.urljoin(self.HOSTER_URL, "login.html") html = req.load(self.LOGIN_URL, decode=True) action, inputs = parseHtmlForm('name="FL"', html) diff --git a/pyload/plugin/internal/XFSCrypter.py b/pyload/plugin/internal/XFSCrypter.py index 6c3a97405..4297de842 100644 --- a/pyload/plugin/internal/XFSCrypter.py +++ b/pyload/plugin/internal/XFSCrypter.py @@ -6,7 +6,7 @@ from pyload.plugin.internal.SimpleCrypter import SimpleCrypter class XFSCrypter(SimpleCrypter): __name = "XFSCrypter" __type = "crypter" - __version = "0.06" + __version = "0.07" __pattern = r'^unmatchable$' @@ -19,7 +19,7 @@ class XFSCrypter(SimpleCrypter): URL_REPLACEMENTS = [(r'&?per_page=\d+', ""), (r'[?/&]+$', ""), (r'(.+/[^?]+)$', r'\1?'), (r'$', r'&per_page=10000')] - LINK_PATTERN = r'<(?:td|TD).*?>\s*<a href="(.+?)".*?>.+?(?:</a>)?\s*</(?:td|TD)>' + LINK_PATTERN = r'<a href="(.+?)".*?>.+?(?:</a>)?\s*</(?:td|TD)>' NAME_PATTERN = r'<[tT]itle>.*?\: (?P<N>.+) folder</[tT]itle>' OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed)' diff --git a/pyload/plugin/internal/XFSHoster.py b/pyload/plugin/internal/XFSHoster.py index ff8077f81..ca0dca045 100644 --- a/pyload/plugin/internal/XFSHoster.py +++ b/pyload/plugin/internal/XFSHoster.py @@ -1,11 +1,9 @@ # -*- coding: utf-8 -*- +import pycurl +import random import re -import time - -from random import random -from urlparse import urljoin, urlparse - +import urlparse from pyload.plugin.captcha.ReCaptcha import ReCaptcha from pyload.plugin.captcha.SolveMedia import SolveMedia from pyload.plugin.internal.SimpleHoster import SimpleHoster, secondsToMidnight @@ -129,7 +127,7 @@ class XFSHoster(SimpleHoster): action, inputs = self.parseHtmlForm() - upload_id = "%012d" % int(random() * 10 ** 12) + upload_id = "%012d" % int(random.random() * 10 ** 12) action += upload_id + "&js_on=1&utype=prem&upload_type=url" inputs['tos'] = '1' diff --git a/pyload/plugin/ocr/LinksaveIn.py b/pyload/plugin/ocr/LinksaveIn.py index d9cf579af..44ab08592 100644 --- a/pyload/plugin/ocr/LinksaveIn.py +++ b/pyload/plugin/ocr/LinksaveIn.py @@ -5,9 +5,8 @@ try: except ImportError: import Image -from glob import glob -from os import sep -from os.path import abspath, dirname +import glob +import os from pyload.plugin.OCR import OCR @@ -24,7 +23,7 @@ class LinksaveIn(OCR): def __init__(self): OCR.__init__(self) - self.data_dir = dirname(abspath(__file__)) + sep + "LinksaveIn" + sep + self.data_dir = os.path.dirname(os.path.abspath(__file__)) + os.sep + "LinksaveIn" + os.sep def load_image(self, image): @@ -59,7 +58,7 @@ class LinksaveIn(OCR): stat = {} cstat = {} img = self.image.convert("P") - for bgpath in glob(self.data_dir+"bg/*.gif"): + for bgpath in glob.glob(self.data_dir+"bg/*.gif"): stat[bgpath] = 0 bg = Image.open(bgpath) |