From 0e9ba8a76e88ee98497db8dc7f25d8d160f10fa4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 8 Oct 2014 00:30:48 +0200 Subject: [XFSPAccount] Fix missing COOKIE typecheck --- module/plugins/internal/XFSPAccount.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index b2fb6179e..2cda54615 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -13,7 +13,7 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.09" + __version__ = "0.10" __description__ = """XFileSharingPro base account plugin""" __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), @@ -77,7 +77,8 @@ class XFSPAccount(Account): def login(self, user, data, req): - set_cookies(req.cj, self.COOKIES) + if isinstance(self.COOKIES, list): + set_cookies(req.cj, self.COOKIES) url = urljoin(self.HOSTER_URL, "login.html") html = req.load(url, decode=True) -- cgit v1.2.3 From b7bc4c7a920cb6e768948d8489af40bf36a72810 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 8 Oct 2014 16:04:14 +0200 Subject: [XFileSharingPro] Rename to XFSPHoster --- module/plugins/internal/XFSPHoster.py | 361 ++++++++++++++++++++++++++++++++++ 1 file changed, 361 insertions(+) create mode 100644 module/plugins/internal/XFSPHoster.py (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py new file mode 100644 index 000000000..2376c1b84 --- /dev/null +++ b/module/plugins/internal/XFSPHoster.py @@ -0,0 +1,361 @@ +# -*- coding: utf-8 -*- + +import re + +from pycurl import FOLLOWLOCATION, LOW_SPEED_TIME +from random import random +from urllib import unquote +from urlparse import urlparse + +from module.network.RequestFactory import getURL +from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia +from module.plugins.internal.SimpleHoster import create_getInfo, PluginParseError, replace_patterns, set_cookies, SimpleHoster +from module.utils import html_unescape + + +class XFSPHoster(SimpleHoster): + """ + Common base for XFileSharingPro hosters like EasybytezCom, CramitIn, FiledinoCom... + Some hosters may work straight away when added to __pattern__ + However, most of them will NOT work because they are either down or running a customized version + """ + __name__ = "XFSPHoster" + __type__ = "hoster" + __version__ = "0.37" + + __pattern__ = r'^unmatchable$' + + __description__ = """XFileSharingPro base hoster plugin""" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_NAME = None + + FILE_URL_REPLACEMENTS = [(r'/embed-(\w{12}).*', r'/\1')] #: support embedded files + + COOKIES = [(HOSTER_NAME, "lang", "english")] + + FILE_INFO_PATTERN = r'Filename:(?P[^<]+)\s*.*?\((?P[^<]+)\)' + FILE_NAME_PATTERN = r'[\d\.\,]+) ?(?P\w+)?\)' + + OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed)' + TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)' + + WAIT_PATTERN = r'.*?>(\d+)' + + OVR_LINK_PATTERN = r'

Download Link

\s*]*>([^<]+)' + LINK_PATTERN = None #: final download url pattern + + CAPTCHA_URL_PATTERN = r'(http://[^"\']+?/captchas?/[^"\']+)' + CAPTCHA_DIV_PATTERN = r'>Enter code.*?(.+?)' + RECAPTCHA_PATTERN = None + SOLVEMEDIA_PATTERN = None + + ERROR_PATTERN = r'class=["\']err["\'][^>]*>(.+?)", " ", self.errmsg)) + + if 'wait' in self.errmsg: + wait_time = sum([int(v) * {"hour": 3600, "minute": 60, "second": 1}[u] for v, u in + re.findall(r'(\d+)\s*(hour|minute|second)', self.errmsg)]) + self.wait(wait_time, True) + elif 'captcha' in self.errmsg: + self.invalidCaptcha() + elif 'premium' in self.errmsg and 'require' in self.errmsg: + self.fail("File can be downloaded by premium users only") + elif 'limit' in self.errmsg: + self.wait(1 * 60 * 60, True) + self.retry(25) + elif 'countdown' in self.errmsg or 'Expired' in self.errmsg: + self.retry() + elif 'maintenance' in self.errmsg or 'maintainance' in self.errmsg: + self.tempOffline() + elif 'download files up to' in self.errmsg: + self.fail("File too large for free download") + else: + self.fail(self.errmsg) + + else: + self.errmsg = None + + return self.errmsg + + + def getPostParameters(self): + for _ in xrange(3): + if not self.errmsg: + self.checkErrors() + + if hasattr(self, "FORM_PATTERN"): + action, inputs = self.parseHtmlForm(self.FORM_PATTERN) + else: + action, inputs = self.parseHtmlForm(input_names={"op": re.compile("^download")}) + + if not inputs: + action, inputs = self.parseHtmlForm('F1') + if not inputs: + if self.errmsg: + self.retry() + else: + self.parseError("Form not found") + + self.logDebug(self.HOSTER_NAME, inputs) + + if 'op' in inputs and inputs['op'] in ("download2", "download3"): + if "password" in inputs: + if self.passwords: + inputs['password'] = self.passwords.pop(0) + else: + self.fail("No or invalid passport") + + if not self.premium: + m = re.search(self.WAIT_PATTERN, self.html) + if m: + wait_time = int(m.group(1)) + 1 + self.setWait(wait_time, False) + else: + wait_time = 0 + + self.captcha = self.handleCaptcha(inputs) + + if wait_time: + self.wait() + + self.errmsg = None + return inputs + + else: + inputs['referer'] = self.pyfile.url + + if self.premium: + inputs['method_premium'] = "Premium Download" + if 'method_free' in inputs: + del inputs['method_free'] + else: + inputs['method_free'] = "Free Download" + if 'method_premium' in inputs: + del inputs['method_premium'] + + self.html = self.load(self.pyfile.url, post=inputs, ref=True) + self.errmsg = None + + else: + self.parseError('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN')) + + + def handleCaptcha(self, inputs): + m = re.search(self.CAPTCHA_URL_PATTERN, self.html) + if m: + captcha_url = m.group(1) + inputs['code'] = self.decryptCaptcha(captcha_url) + return 1 + + m = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.DOTALL) + if m: + captcha_div = m.group(1) + self.logDebug(captcha_div) + numerals = re.findall(r'(\d)', html_unescape(captcha_div)) + inputs['code'] = "".join([a[1] for a in sorted(numerals, key=lambda num: int(num[0]))]) + self.logDebug("CAPTCHA", inputs['code'], numerals) + return 2 + + recaptcha = ReCaptcha(self) + try: + captcha_key = re.search(self.RECAPTCHA_PATTERN, self.html).group(1) + except: + captcha_key = recaptcha.detect_key() + + if captcha_key: + self.logDebug("RECAPTCHA KEY: %s" % captcha_key) + inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key) + return 3 + + solvemedia = SolveMedia(self) + try: + captcha_key = re.search(self.SOLVEMEDIA_PATTERN, self.html).group(1) + except: + captcha_key = solvemedia.detect_key() + + if captcha_key: + inputs['adcopy_challenge'], inputs['adcopy_response'] = solvemedia.challenge(captcha_key) + return 4 + + return 0 + + +getInfo = create_getInfo(XFSPHoster) -- cgit v1.2.3 From 1c4bd7a76450052b28dba609c04c5c4fcad0d014 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 8 Oct 2014 16:34:26 +0200 Subject: [XFileSharingPro] Restore --- module/plugins/internal/XFSPAccount.py | 2 +- module/plugins/internal/XFSPHoster.py | 20 +++++--------------- 2 files changed, 6 insertions(+), 16 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 2cda54615..fdbd8829c 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -15,7 +15,7 @@ class XFSPAccount(Account): __type__ = "account" __version__ = "0.10" - __description__ = """XFileSharingPro base account plugin""" + __description__ = """XFileSharingPro account plugin""" __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), ("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 2376c1b84..30cb1536f 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -21,11 +21,11 @@ class XFSPHoster(SimpleHoster): """ __name__ = "XFSPHoster" __type__ = "hoster" - __version__ = "0.37" + __version__ = "0.01" - __pattern__ = r'^unmatchable$' + __pattern__ = None - __description__ = """XFileSharingPro base hoster plugin""" + __description__ = """XFileSharingPro hoster plugin""" __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), ("stickell", "l.stickell@yahoo.it"), ("Walter Purcaro", "vuolter@gmail.com")] @@ -33,7 +33,7 @@ class XFSPHoster(SimpleHoster): HOSTER_NAME = None - FILE_URL_REPLACEMENTS = [(r'/embed-(\w{12}).*', r'/\1')] #: support embedded files + FILE_URL_REPLACEMENTS = [] COOKIES = [(HOSTER_NAME, "lang", "english")] @@ -59,14 +59,7 @@ class XFSPHoster(SimpleHoster): def setup(self): self.chunkLimit = 1 - - if self.__name__ == "XFSPHoster": - self.multiDL = True - self.__pattern__ = self.core.pluginManager.hosterPlugins[self.__name__]['pattern'] - self.HOSTER_NAME = re.match(self.__pattern__, self.pyfile.url).group(1).lower() - self.COOKIES = [(self.HOSTER_NAME, "lang", "english")] - else: - self.resumeDownload = self.multiDL = self.premium + self.resumeDownload = self.multiDL = self.premium def prepare(self): @@ -356,6 +349,3 @@ class XFSPHoster(SimpleHoster): return 4 return 0 - - -getInfo = create_getInfo(XFSPHoster) -- cgit v1.2.3 From ae7a7e66981456e5bbe2b54006d79b6f907be7a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 8 Oct 2014 20:18:13 +0200 Subject: Add __license__ key attribute to plugins --- module/plugins/internal/AbstractExtractor.py | 1 + module/plugins/internal/CaptchaService.py | 4 ++++ module/plugins/internal/DeadCrypter.py | 1 + module/plugins/internal/DeadHoster.py | 1 + module/plugins/internal/MultiHoster.py | 1 + module/plugins/internal/SimpleCrypter.py | 1 + module/plugins/internal/SimpleHoster.py | 1 + module/plugins/internal/UnRar.py | 1 + module/plugins/internal/UnZip.py | 1 + module/plugins/internal/XFSPAccount.py | 1 + module/plugins/internal/XFSPHoster.py | 1 + 11 files changed, 14 insertions(+) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/AbstractExtractor.py b/module/plugins/internal/AbstractExtractor.py index fefeb4ece..2b21ee357 100644 --- a/module/plugins/internal/AbstractExtractor.py +++ b/module/plugins/internal/AbstractExtractor.py @@ -17,6 +17,7 @@ class AbtractExtractor: __version__ = "0.1" __description__ = """Abtract extractor plugin""" + __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index dad537bec..187170660 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -10,6 +10,7 @@ class CaptchaService: __version__ = "0.09" __description__ = """Base captcha service plugin""" + __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] @@ -54,6 +55,7 @@ class ReCaptcha(CaptchaService): __version__ = "0.02" __description__ = """ReCaptcha captcha service plugin""" + __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] @@ -114,6 +116,7 @@ class AdsCaptcha(CaptchaService): __version__ = "0.02" __description__ = """AdsCaptcha captcha service plugin""" + __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] @@ -175,6 +178,7 @@ class SolveMedia(CaptchaService): __version__ = "0.02" __description__ = """SolveMedia captcha service plugin""" + __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] diff --git a/module/plugins/internal/DeadCrypter.py b/module/plugins/internal/DeadCrypter.py index 8886be0a7..760ed61b1 100644 --- a/module/plugins/internal/DeadCrypter.py +++ b/module/plugins/internal/DeadCrypter.py @@ -11,6 +11,7 @@ class DeadCrypter(_Crypter): __pattern__ = None __description__ = """ Crypter is no longer available """ + __license__ = "GPLv3" __authors__ = [("stickell", "l.stickell@yahoo.it")] diff --git a/module/plugins/internal/DeadHoster.py b/module/plugins/internal/DeadHoster.py index fff254de7..2f0a01732 100644 --- a/module/plugins/internal/DeadHoster.py +++ b/module/plugins/internal/DeadHoster.py @@ -19,6 +19,7 @@ class DeadHoster(_Hoster): __pattern__ = None __description__ = """ Hoster is no longer available """ + __license__ = "GPLv3" __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index daab1e855..38a93c6af 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -11,6 +11,7 @@ class MultiHoster(Hook): __version__ = "0.19" __description__ = """Generic MultiHoster plugin""" + __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 2da551ea9..8139d661d 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -15,6 +15,7 @@ class SimpleCrypter(Crypter): __pattern__ = None __description__ = """Simple decrypter plugin""" + __license__ = "GPLv3" __authors__ = [("stickell", "l.stickell@yahoo.it"), ("zoidberg", "zoidberg@mujmail.cz"), ("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 3887f1579..895584af6 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -157,6 +157,7 @@ class SimpleHoster(Hoster): __pattern__ = None __description__ = """Simple hoster plugin""" + __license__ = "GPLv3" __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), ("stickell", "l.stickell@yahoo.it"), ("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 11496b606..d95d55831 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -25,6 +25,7 @@ class UnRar(AbtractExtractor): __version__ = "0.18" __description__ = """Rar extractor plugin""" + __license__ = "GPLv3" __authors__ = [("RaNaN", "RaNaN@pyload.org")] diff --git a/module/plugins/internal/UnZip.py b/module/plugins/internal/UnZip.py index 71f144fc7..52b4bca27 100644 --- a/module/plugins/internal/UnZip.py +++ b/module/plugins/internal/UnZip.py @@ -11,6 +11,7 @@ class UnZip(AbtractExtractor): __version__ = "0.1" __description__ = """Zip extractor plugin""" + __license__ = "GPLv3" __authors__ = [("RaNaN", "RaNaN@pyload.org")] diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index fdbd8829c..18543b9cd 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -16,6 +16,7 @@ class XFSPAccount(Account): __version__ = "0.10" __description__ = """XFileSharingPro account plugin""" + __license__ = "GPLv3" __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), ("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 30cb1536f..fdaa2eb43 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -26,6 +26,7 @@ class XFSPHoster(SimpleHoster): __pattern__ = None __description__ = """XFileSharingPro hoster plugin""" + __license__ = "GPLv3" __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), ("stickell", "l.stickell@yahoo.it"), ("Walter Purcaro", "vuolter@gmail.com")] -- cgit v1.2.3 From d9f3250b1a12e50b681b2232d8153df049b1719d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 10 Oct 2014 14:17:37 +0200 Subject: [XFSPHoster] Update LINK_PATTERN --- module/plugins/internal/XFSPHoster.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index fdaa2eb43..228a55c82 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -21,7 +21,7 @@ class XFSPHoster(SimpleHoster): """ __name__ = "XFSPHoster" __type__ = "hoster" - __version__ = "0.01" + __version__ = "0.02" __pattern__ = None @@ -69,8 +69,8 @@ class XFSPHoster(SimpleHoster): self.fail("Missing HOSTER_NAME") if not self.LINK_PATTERN: - pattr = r'(http://([^/]*?%s|\d+\.\d+\.\d+\.\d+)(:\d+)?(/d/|(?:/files)?/\d+/\w+/)[^"\'<]+)' - self.LINK_PATTERN = pattr % self.HOSTER_NAME + pattern = r'(https?://(www\.)?([^/]*?%s|\d+\.\d+\.\d+\.\d+)(\:\d+)?(/d/|(/files)?/\d+/\w+/).+?)["\'<]' + self.LINK_PATTERN = pattern % self.HOSTER_NAME if isinstance(self.COOKIES, list): set_cookies(self.req.cj, self.COOKIES) -- cgit v1.2.3 From 343e246e94548cf2cc713aed92212e12d28ce658 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 10 Oct 2014 16:00:34 +0200 Subject: [CaptchaService] Fix ReCaptcha KEY pattern --- module/plugins/internal/CaptchaService.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 187170660..9d8fd85f2 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -7,7 +7,7 @@ from random import random class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.09" + __version__ = "0.10" __description__ = """Base captcha service plugin""" __license__ = "GPLv3" @@ -52,15 +52,15 @@ class CaptchaService: class ReCaptcha(CaptchaService): __name__ = "ReCaptcha" - __version__ = "0.02" + __version__ = "0.03" __description__ = """ReCaptcha captcha service plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r"https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P\w+?)" - KEY_AJAX_PATTERN = r"Recaptcha\.create\s*\(\s*[\"'](?P\w+)[\"']\s*," + KEY_PATTERN = r"https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P\w+)" + KEY_AJAX_PATTERN = r"Recaptcha\.create\s*\(\s*[\"'](?P\w+)" def detect_key(self, html=None): -- cgit v1.2.3 From f76e5c2336718dca9da8033ba22cd83c72c7b3b3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 11 Oct 2014 15:14:28 +0200 Subject: Pattern update 1 --- module/plugins/internal/UnRar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index d95d55831..7478d68db 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -32,9 +32,9 @@ class UnRar(AbtractExtractor): CMD = "unrar" # there are some more uncovered rar formats - re_version = re.compile(r"(UNRAR 5[\.\d]+(.*?)freeware)") + re_version = re.compile(r"(UNRAR 5[\d.]+(.*?)freeware)") re_splitfile = re.compile(r"(.*)\.part(\d+)\.rar$", re.I) - re_partfiles = re.compile(r".*\.(rar|r[0-9]+)", re.I) + re_partfiles = re.compile(r".*\.(rar|r\d+)", re.I) re_filelist = re.compile(r"(.+)\s+(\d+)\s+(\d+)\s+") re_filelist5 = re.compile(r"(.+)\s+(\d+)\s+\d\d-\d\d-\d\d\s+\d\d:\d\d\s+(.+)") re_wrongpwd = re.compile("(Corrupt file or wrong password|password incorrect)", re.I) -- cgit v1.2.3 From 8939f015a688a07ec7d0bd14b6a3704f6a2cb4a0 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 11 Oct 2014 15:12:40 +0200 Subject: Pattern update 3 --- module/plugins/internal/CaptchaService.py | 4 ++-- module/plugins/internal/MultiHoster.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 9d8fd85f2..db4ed41a4 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -59,8 +59,8 @@ class ReCaptcha(CaptchaService): __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r"https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P\w+)" - KEY_AJAX_PATTERN = r"Recaptcha\.create\s*\(\s*[\"'](?P\w+)" + KEY_PATTERN = r'https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P\w+)' + KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\'](?P\w+)' def detect_key(self, html=None): diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index 38a93c6af..4ef43bc31 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -152,9 +152,9 @@ class MultiHoster(Hook): self.logDebug("New Hosters", ", ".join(sorted(self.new_supported))) # create new regexp - regexp = r".*(%s).*" % "|".join([x.replace(".", "\\.") for x in self.new_supported]) + regexp = r'.*(%s).*' % "|".join([x.replace(".", "\\.") for x in self.new_supported]) if hasattr(klass, "__pattern__") and isinstance(klass.__pattern__, basestring) and '://' in klass.__pattern__: - regexp = r"%s|%s" % (klass.__pattern__, regexp) + regexp = r'%s|%s' % (klass.__pattern__, regexp) self.logDebug("Regexp", regexp) -- cgit v1.2.3 From 0adc51cf4c58aa3e0f1073c28b9a8781a298fe89 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 11 Oct 2014 22:59:24 +0200 Subject: [CaptchaService] Fix KEY pattern --- module/plugins/internal/CaptchaService.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index db4ed41a4..b2b549617 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -7,7 +7,7 @@ from random import random class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.10" + __version__ = "0.11" __description__ = """Base captcha service plugin""" __license__ = "GPLv3" @@ -52,15 +52,15 @@ class CaptchaService: class ReCaptcha(CaptchaService): __name__ = "ReCaptcha" - __version__ = "0.03" + __version__ = "0.04" __description__ = """ReCaptcha captcha service plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r'https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P\w+)' - KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\'](?P\w+)' + KEY_PATTERN = r'https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P[\w-]+)' + KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\'](?P[\w-]+)' def detect_key(self, html=None): @@ -175,14 +175,14 @@ class AdsCaptcha(CaptchaService): class SolveMedia(CaptchaService): __name__ = "SolveMedia" - __version__ = "0.02" + __version__ = "0.03" __description__ = """SolveMedia captcha service plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r'http://api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P.+?)"' + KEY_PATTERN = r'http://api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P.+?)["\']' def challenge(self, key=None): -- cgit v1.2.3 From 818ae3ce2c5ee6f47da2f508c786c3e2ab20ad45 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 12 Oct 2014 23:30:34 +0200 Subject: [XFileSharingPro] Match option --- module/plugins/internal/XFSPHoster.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 228a55c82..40bf26cfa 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -14,11 +14,6 @@ from module.utils import html_unescape class XFSPHoster(SimpleHoster): - """ - Common base for XFileSharingPro hosters like EasybytezCom, CramitIn, FiledinoCom... - Some hosters may work straight away when added to __pattern__ - However, most of them will NOT work because they are either down or running a customized version - """ __name__ = "XFSPHoster" __type__ = "hoster" __version__ = "0.02" -- cgit v1.2.3 From 77ef3e137d2d9222d0f8965adf374e6712123a99 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 14 Oct 2014 13:07:19 +0200 Subject: [XFSPHoster] TEXT_ENCODING support --- module/plugins/internal/XFSPHoster.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 40bf26cfa..e7348d966 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -16,7 +16,7 @@ from module.utils import html_unescape class XFSPHoster(SimpleHoster): __name__ = "XFSPHoster" __type__ = "hoster" - __version__ = "0.02" + __version__ = "0.03" __pattern__ = None @@ -90,7 +90,7 @@ class XFSPHoster(SimpleHoster): # Due to a 0.4.9 core bug self.load would use cookies even if # cookies=False. Workaround using getURL to avoid cookies. # Can be reverted in 0.4.10 as the cookies bug has been fixed. - self.html = getURL(pyfile.url, decode=True, cookies=self.COOKIES) + self.html = getURL(pyfile.url, decode=not self.TEXT_ENCODING, cookies=self.COOKIES) self.file_info = self.getFileInfo() except PluginParseError: self.file_info = None -- cgit v1.2.3 From 388a2f6478d42e423f1f8442d8539983f3762f22 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 14 Oct 2014 13:38:49 +0200 Subject: Improve unit detection in size pattern --- module/plugins/internal/XFSPHoster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index e7348d966..f1a250f85 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -35,7 +35,7 @@ class XFSPHoster(SimpleHoster): FILE_INFO_PATTERN = r'Filename:(?P[^<]+)\s*.*?\((?P[^<]+)\)' FILE_NAME_PATTERN = r'[\d\.\,]+) ?(?P\w+)?\)' + FILE_SIZE_PATTERN = r'You have requested .*\((?P[\d\.\,]+) ?(?P[\w^_]+)?\)' OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed)' TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)' -- cgit v1.2.3 From 93106fbef7579707e2918bcd9694e4a21b37d390 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 15 Oct 2014 02:04:25 +0200 Subject: [XFSPAccount] Improve TRAFFIC_LEFT_PATTERN --- module/plugins/internal/XFSPAccount.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 18543b9cd..9191b71a0 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -13,7 +13,7 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.10" + __version__ = "0.11" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -26,8 +26,12 @@ class XFSPAccount(Account): COOKIES = None #: or list of tuples [(domain, name, value)] VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(.+?)' - TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?(?P.+?)' + + TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+)\s*(?P[\w^_]+)\s*' + TRAFFIC_LEFT_UNIT = "MB" #: used only if no group was found + LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' + # PREMIUM_PATTERN = r'>Renew premium<' @@ -61,13 +65,18 @@ class XFSPAccount(Account): try: traffic = re.search(self.TRAFFIC_LEFT_PATTERN, html).groupdict() - trafficsize = traffic['S'] + traffic['U'] if 'U' in traffic else traffic['S'] - if "Unlimited" in trafficsize: + if "Unlimited" in traffic['S']: trafficleft = -1 if premium is None: premium = True else: - trafficleft = parseFileSize(trafficsize) + if 'U' in traffic: + unit = traffic['U'] + elif isinstance(self.TRAFFIC_LEFT_UNIT, basestring): + unit = self.TRAFFIC_LEFT_UNIT + else: + unit = None + trafficleft = parseFileSize(traffic['S'], unit) except: pass -- cgit v1.2.3 From 268b16c9ecc588e6e884749e3fe715431367d1c9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 15 Oct 2014 13:42:32 +0200 Subject: [XFSPAccount] Fix TRAFFIC_LEFT_PATTERN --- module/plugins/internal/XFSPAccount.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 9191b71a0..f75422ca1 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -13,7 +13,7 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.11" + __version__ = "0.12" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -27,7 +27,7 @@ class XFSPAccount(Account): VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(.+?)' - TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+)\s*(?P[\w^_]+)\s*' + TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+)\s*(?:(?P[\w^_]+)\s*)?' TRAFFIC_LEFT_UNIT = "MB" #: used only if no group was found LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' -- cgit v1.2.3 From 9a4aa10da480d9bb07592352fb22ebd2acf5dc84 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Oct 2014 20:51:35 +0200 Subject: New internal plugin XFSPCrypter --- module/plugins/internal/XFSPCrypter.py | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 module/plugins/internal/XFSPCrypter.py (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPCrypter.py b/module/plugins/internal/XFSPCrypter.py new file mode 100644 index 000000000..4c5fff4f3 --- /dev/null +++ b/module/plugins/internal/XFSPCrypter.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.SimpleCrypter import SimpleCrypter + + +class XFSPCrypter(SimpleCrypter): + __name__ = "XFSPCrypter" + __type__ = "crypter" + __version__ = "0.01" + + __pattern__ = None + + __description__ = """XFileSharingPro decrypter plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_NAME = None + + URL_REPLACEMENTS = [(r'[?/&]+$', r''), (r'(.+/[^?]*)$', r'\1?'), (r'$', r'&per_page=10000')] + + COOKIES = [(HOSTER_NAME, "lang", "english")] + + LINK_PATTERN = None + TITLE_PATTERN = r'<[tT]itle>.*?\: (.+) folder' + + OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed)' + TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)' + + + def prepare(self): + if not self.HOSTER_NAME: + self.fail("Missing HOSTER_NAME") + + if not self.LINK_PATTERN: + pattern = r'.+?(?:)?\s*' + self.LINK_PATTERN = pattern % self.HOSTER_NAME + + super(XFSPCrypter, self).prepare() -- cgit v1.2.3 From fac6b2007a93101f8441810118f3c8d10a3db13a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Oct 2014 20:53:31 +0200 Subject: [SimpleCrypter] Fix missing LINK_PATTERN --- module/plugins/internal/SimpleCrypter.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 8139d661d..73329ed65 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -51,6 +51,8 @@ class SimpleCrypter(Crypter): return the html of the page number page_n """ + LINK_PATTERN = None + TITLE_REPLACEMENTS = [("&#?\w+;", fixup)] URL_REPLACEMENTS = [] -- cgit v1.2.3 From 6f47e10a9acf00eea4b47e5b364e75e78027809c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 18 Oct 2014 13:46:19 +0200 Subject: [XFSPCrypter] Better LINK_PATTERN --- module/plugins/internal/XFSPCrypter.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPCrypter.py b/module/plugins/internal/XFSPCrypter.py index 4c5fff4f3..372657d2d 100644 --- a/module/plugins/internal/XFSPCrypter.py +++ b/module/plugins/internal/XFSPCrypter.py @@ -6,7 +6,7 @@ from module.plugins.internal.SimpleCrypter import SimpleCrypter class XFSPCrypter(SimpleCrypter): __name__ = "XFSPCrypter" __type__ = "crypter" - __version__ = "0.01" + __version__ = "0.02" __pattern__ = None @@ -21,19 +21,8 @@ class XFSPCrypter(SimpleCrypter): COOKIES = [(HOSTER_NAME, "lang", "english")] - LINK_PATTERN = None + LINK_PATTERN = r'<(?:td|TD) [^>]*>\s*]*>.+?(?:)?\s*' TITLE_PATTERN = r'<[tT]itle>.*?\: (.+) folder' OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed)' TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)' - - - def prepare(self): - if not self.HOSTER_NAME: - self.fail("Missing HOSTER_NAME") - - if not self.LINK_PATTERN: - pattern = r'.+?(?:)?\s*' - self.LINK_PATTERN = pattern % self.HOSTER_NAME - - super(XFSPCrypter, self).prepare() -- cgit v1.2.3 From 5224a71f0dc30d640754a9fa64c7c54fa3ec4fb9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 18 Oct 2014 13:48:21 +0200 Subject: [XFSPAccount] Set HOSTER_NAME (instead HOSTER_URL) as the mandatory attribute --- module/plugins/internal/XFSPAccount.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index f75422ca1..713bf827d 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -13,7 +13,7 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.12" + __version__ = "0.13" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -21,9 +21,19 @@ class XFSPAccount(Account): ("Walter Purcaro", "vuolter@gmail.com")] - HOSTER_URL = None + """ + Following patterns should be defined by each hoster: - COOKIES = None #: or list of tuples [(domain, name, value)] + HOSTER_URL: (optional) + example: HOSTER_URL = r'linestorage.com' + + PREMIUM_PATTERN: (optional) Checks if the account is premium + example: PREMIUM_PATTERN = r'>Renew premium<' + """ + + HOSTER_NAME = None + + COOKIES = [(HOSTER_NAME, "lang", "english")] #: or list of tuples [(domain, name, value)] VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(.+?)' @@ -32,7 +42,10 @@ class XFSPAccount(Account): LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' - # PREMIUM_PATTERN = r'>Renew premium<' + + def init(self): + if not hasattr(self, "HOSTER_URL"): + self.HOSTER_URL = "http://%s/" % self.HOSTER_NAME def loadAccountInfo(self, user, req): -- cgit v1.2.3 From d0aa0ece5e506469f631b388f6c38eaaa63b63c9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 18 Oct 2014 13:52:01 +0200 Subject: Tiny code cosmetics --- module/plugins/internal/SimpleHoster.py | 10 +++++----- module/plugins/internal/XFSPHoster.py | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 895584af6..c2bc4909e 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -166,18 +166,18 @@ class SimpleHoster(Hoster): """ Following patterns should be defined by each hoster: - FILE_INFO_PATTERN: Name and Size of the file + FILE_INFO_PATTERN: (optional) Name and Size of the file example: FILE_INFO_PATTERN = r'(?Pfile_name) (?Pfile_size) (?Psize_unit)' or - FILE_NAME_PATTERN: Name that will be set for the file + FILE_NAME_PATTERN: (optional) Name that will be set for the file example: FILE_NAME_PATTERN = r'(?Pfile_name)' - FILE_SIZE_PATTERN: Size that will be checked for the file + FILE_SIZE_PATTERN: (optional) Size that will be checked for the file example: FILE_SIZE_PATTERN = r'(?Pfile_size) (?Psize_unit)' - OFFLINE_PATTERN: Checks if the file is yet available online + OFFLINE_PATTERN: (optional) Checks if the file is yet available online example: OFFLINE_PATTERN = r'File (deleted|not found)' - TEMP_OFFLINE_PATTERN: Checks if the file is temporarily offline + TEMP_OFFLINE_PATTERN: (optional) Checks if the file is temporarily offline example: TEMP_OFFLINE_PATTERN = r'Server (maintenance|maintainance)' PREMIUM_ONLY_PATTERN: (optional) Checks if the file can be downloaded only with a premium account diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index f1a250f85..abf71b033 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -330,7 +330,7 @@ class XFSPHoster(SimpleHoster): captcha_key = recaptcha.detect_key() if captcha_key: - self.logDebug("RECAPTCHA KEY: %s" % captcha_key) + self.logDebug("ReCaptcha key: %s" % captcha_key) inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key) return 3 @@ -341,6 +341,7 @@ class XFSPHoster(SimpleHoster): captcha_key = solvemedia.detect_key() if captcha_key: + self.logDebug("SolveMedia key: %s" % captcha_key) inputs['adcopy_challenge'], inputs['adcopy_response'] = solvemedia.challenge(captcha_key) return 4 -- cgit v1.2.3 From e2f481deb624709764768454f7cf8222b8b45af7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 18 Oct 2014 15:23:30 +0200 Subject: [SimpleCrypter] Fix account association --- module/plugins/internal/SimpleCrypter.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 73329ed65..fe644cbda 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -10,7 +10,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.13" + __version__ = "0.14" __pattern__ = None @@ -63,6 +63,15 @@ class SimpleCrypter(Crypter): LOGIN_PREMIUM = False + def init(self): + self.account = self.core.accountManager.getAccountPlugin((self.__name__ + ".py").replace("Folder.py", "")) + + if self.account and self.account.canUse(): + self.user, data = self.account.selectAccount() + self.req = self.account.getAccountRequest(self.user) + self.premium = self.account.isPremium(self.user) + + def prepare(self): if self.LOGIN_ACCOUNT and not self.account: self.fail('Required account not found!') -- cgit v1.2.3 From b9cd4eb41e9b8753bca4b5a8334d7242eab98371 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 18 Oct 2014 17:44:49 +0200 Subject: [SimpleCrypter] Fix account routine --- module/plugins/internal/SimpleCrypter.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index fe644cbda..3c1dc3244 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -10,7 +10,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.14" + __version__ = "0.15" __pattern__ = None @@ -64,12 +64,15 @@ class SimpleCrypter(Crypter): def init(self): - self.account = self.core.accountManager.getAccountPlugin((self.__name__ + ".py").replace("Folder.py", "")) + account_name = (self.__name__ + ".py").replace("Folder.py", "").replace(".py", "") + account = self.core.accountManager.getAccountPlugin(account_name) - if self.account and self.account.canUse(): - self.user, data = self.account.selectAccount() - self.req = self.account.getAccountRequest(self.user) - self.premium = self.account.isPremium(self.user) + if account and account.canUse(): + self.user, data = account.selectAccount() + self.req = account.getAccountRequest(self.user) + self.premium = account.isPremium(self.user) + + self.account = account def prepare(self): -- cgit v1.2.3 From bb1f6b3cbfc34914a1a336f8f5a2e15b57e2b5f5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Oct 2014 14:35:53 +0200 Subject: parseError -> error now calls Fail instead Exception --- module/plugins/internal/SimpleCrypter.py | 9 +++++---- module/plugins/internal/SimpleHoster.py | 29 ++++++++++------------------- module/plugins/internal/XFSPHoster.py | 17 +++++++++-------- 3 files changed, 24 insertions(+), 31 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 3c1dc3244..b45e503d5 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -3,14 +3,15 @@ import re from module.plugins.Crypter import Crypter -from module.plugins.internal.SimpleHoster import PluginParseError, replace_patterns, set_cookies +from module.plugins.Plugin import Fail +from module.plugins.internal.SimpleHoster import replace_patterns, set_cookies from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.15" + __version__ = "0.16" __pattern__ = None @@ -156,5 +157,5 @@ class SimpleCrypter(Crypter): self.package_links += self.getLinks() - def parseError(self, msg): - raise PluginParseError(msg) + def error(self, reason): + raise Fail("Parse error (%s) - crypter plugin may be out of date" % reason) diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index c2bc4909e..bbd37e978 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -8,7 +8,8 @@ from urlparse import urlparse from module.network.CookieJar import CookieJar from module.network.RequestFactory import getURL from module.plugins.Hoster import Hoster -from module.utils import fixup, html_unescape, parseFileSize +from module.plugins.Plugin import Fail +reasonfrom module.utils import fixup, html_unescape, parseFileSize def replace_patterns(string, ruleslist): @@ -139,20 +140,10 @@ def timestamp(): return int(time() * 1000) -class PluginParseError(Exception): - - def __init__(self, msg): - Exception.__init__(self) - self.value = 'Parse error (%s) - plugin may be out of date' % msg - - def __str__(self): - return repr(self.value) - - class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "0.38" + __version__ = "0.39" __pattern__ = None @@ -249,7 +240,7 @@ class SimpleHoster(Hoster): self.tempOffline() elif status != 2: self.logDebug(self.file_info) - self.parseError('File info') + self.error('File info') if name: self.pyfile.name = name @@ -272,7 +263,7 @@ class SimpleHoster(Hoster): try: m = re.search(self.LINK_FREE_PATTERN, self.html) if m is None: - self.parseError("Free download link not found") + self.error("Free download link not found") link = m.group(1) except Exception, e: @@ -288,7 +279,7 @@ class SimpleHoster(Hoster): try: m = re.search(self.LINK_PREMIUM_PATTERN, self.html) if m is None: - self.parseError("Premium download link not found") + self.error("Premium download link not found") link = m.group(1) except Exception, e: @@ -297,10 +288,6 @@ class SimpleHoster(Hoster): self.download(link, ref=True, cookies=True, disposition=True) - def parseError(self, msg): - raise PluginParseError(msg) - - def longWait(self, wait_time=None, max_tries=3): if wait_time and isinstance(wait_time, (int, long, float)): time_str = "%dh %dm" % divmod(wait_time / 60, 60) @@ -334,3 +321,7 @@ class SimpleHoster(Hoster): if seconds: self.setWait(seconds, reconnect) super(SimpleHoster, self).wait() + + + def error(self, reason): + raise Fail("Parse error (%s) - hoster plugin may be out of date" % reason) diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index abf71b033..0b656c67c 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -9,14 +9,15 @@ from urlparse import urlparse from module.network.RequestFactory import getURL from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia -from module.plugins.internal.SimpleHoster import create_getInfo, PluginParseError, replace_patterns, set_cookies, SimpleHoster +from module.plugins.internal.SimpleHoster import create_getInfo, replace_patterns, set_cookies, SimpleHoster +from module.plugins.Plugin import Fail from module.utils import html_unescape class XFSPHoster(SimpleHoster): __name__ = "XFSPHoster" __type__ = "hoster" - __version__ = "0.03" + __version__ = "0.04" __pattern__ = None @@ -92,7 +93,7 @@ class XFSPHoster(SimpleHoster): # Can be reverted in 0.4.10 as the cookies bug has been fixed. self.html = getURL(pyfile.url, decode=not self.TEXT_ENCODING, cookies=self.COOKIES) self.file_info = self.getFileInfo() - except PluginParseError: + except Fail: self.file_info = None self.location = self.getDirectDownloadLink() @@ -163,7 +164,7 @@ class XFSPHoster(SimpleHoster): self.html = self.load(self.pyfile.url, post=self.getPostParameters()) m = re.search(self.LINK_PATTERN, self.html) if m is None: - self.parseError('LINK_PATTERN not found') + self.error('LINK_PATTERN not found') self.startDownload(m.group(1)) @@ -184,7 +185,7 @@ class XFSPHoster(SimpleHoster): action, inputs = self.parseHtmlForm('F1') if not inputs: - self.parseError('TEXTAREA not found') + self.error('TEXTAREA not found') self.logDebug(self.HOSTER_NAME, inputs) if inputs['st'] == 'OK': self.html = self.load(action, post=inputs) @@ -196,7 +197,7 @@ class XFSPHoster(SimpleHoster): #get easybytez.com link for uploaded file m = re.search(self.OVR_LINK_PATTERN, self.html) if m is None: - self.parseError('OVR_LINK_PATTERN not found') + self.error('OVR_LINK_PATTERN not found') self.pyfile.url = m.group(1) header = self.load(self.pyfile.url, just_header=True) if 'location' in header: # Direct link @@ -261,7 +262,7 @@ class XFSPHoster(SimpleHoster): if self.errmsg: self.retry() else: - self.parseError("Form not found") + self.error("Form not found") self.logDebug(self.HOSTER_NAME, inputs) @@ -304,7 +305,7 @@ class XFSPHoster(SimpleHoster): self.errmsg = None else: - self.parseError('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN')) + self.error('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN')) def handleCaptcha(self, inputs): -- cgit v1.2.3 From 4bfdf03e804fcafabab0ff08b2b6ef1daec2cf91 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Oct 2014 15:11:18 +0200 Subject: Improve error method --- module/plugins/internal/SimpleCrypter.py | 7 +++++-- module/plugins/internal/SimpleHoster.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index b45e503d5..f1def8118 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -157,5 +157,8 @@ class SimpleCrypter(Crypter): self.package_links += self.getLinks() - def error(self, reason): - raise Fail("Parse error (%s) - crypter plugin may be out of date" % reason) + def error(self, reason=None, type="parse"): + if reason: + raise Fail("%s error: %s | Plugin may be out of date" % (type.capitalize(), reason)) + else: + raise Fail("%s error | Plugin out of date" % type.capitalize()) diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index bbd37e978..fe9b2d523 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -323,5 +323,8 @@ class SimpleHoster(Hoster): super(SimpleHoster, self).wait() - def error(self, reason): - raise Fail("Parse error (%s) - hoster plugin may be out of date" % reason) + def error(self, reason=None, type="parse"): + if reason: + raise Fail("%s error: %s | Plugin may be out of date" % (type.capitalize(), reason)) + else: + raise Fail("%s error | Plugin out of date" % type.capitalize()) -- cgit v1.2.3 From 1f48f481740863c7697064bde286a78e977e4a1b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Oct 2014 15:12:06 +0200 Subject: Update other plugins to support self.error --- module/plugins/internal/CaptchaService.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index b2b549617..203dda82e 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -7,7 +7,7 @@ from random import random class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.11" + __version__ = "0.12" __description__ = """Base captcha service plugin""" __license__ = "GPLv3" @@ -52,7 +52,7 @@ class CaptchaService: class ReCaptcha(CaptchaService): __name__ = "ReCaptcha" - __version__ = "0.04" + __version__ = "0.05" __description__ = """ReCaptcha captcha service plugin""" __license__ = "GPLv3" @@ -99,7 +99,7 @@ class ReCaptcha(CaptchaService): challenge = re.search("challenge : '(.+?)',", js).group(1) server = re.search("server : '(.+?)',", js).group(1) except: - self.plugin.parseError("ReCaptcha challenge pattern not found") + self.plugin.error("ReCaptcha challenge pattern not found") result = self.result(server, challenge) @@ -113,7 +113,7 @@ class ReCaptcha(CaptchaService): class AdsCaptcha(CaptchaService): __name__ = "AdsCaptcha" - __version__ = "0.02" + __version__ = "0.03" __description__ = """AdsCaptcha captcha service plugin""" __license__ = "GPLv3" @@ -161,7 +161,7 @@ class AdsCaptcha(CaptchaService): challenge = re.search("challenge: '(.+?)',", js).group(1) server = re.search("server: '(.+?)',", js).group(1) except: - self.plugin.parseError("AdsCaptcha challenge pattern not found") + self.plugin.error("AdsCaptcha challenge pattern not found") result = self.result(server, challenge) @@ -175,7 +175,7 @@ class AdsCaptcha(CaptchaService): class SolveMedia(CaptchaService): __name__ = "SolveMedia" - __version__ = "0.03" + __version__ = "0.04" __description__ = """SolveMedia captcha service plugin""" __license__ = "GPLv3" @@ -200,7 +200,7 @@ class SolveMedia(CaptchaService): html).group(1) server = "http://api.solvemedia.com/papi/media" except: - self.plugin.parseError("SolveMedia challenge pattern not found") + self.plugin.error("SolveMedia challenge pattern not found") result = self.result(server, challenge) -- cgit v1.2.3 From 39b304c6495e6a77562e9ce2c9cdf921851c668a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Oct 2014 16:28:10 +0200 Subject: Fixes --- module/plugins/internal/SimpleHoster.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index fe9b2d523..c62ef53b4 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -9,7 +9,7 @@ from module.network.CookieJar import CookieJar from module.network.RequestFactory import getURL from module.plugins.Hoster import Hoster from module.plugins.Plugin import Fail -reasonfrom module.utils import fixup, html_unescape, parseFileSize +from module.utils import fixup, html_unescape, parseFileSize def replace_patterns(string, ruleslist): @@ -143,7 +143,7 @@ def timestamp(): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "0.39" + __version__ = "0.40" __pattern__ = None -- cgit v1.2.3 From f70cd18b0c7cb303597a06becc791035f7fd7bd6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 20 Oct 2014 02:20:56 +0200 Subject: [XFSPAccount] Fixed broken login due missing HOSTER_URL --- module/plugins/internal/XFSPAccount.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 713bf827d..c2d779c29 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -13,7 +13,7 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.13" + __version__ = "0.14" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -43,6 +43,11 @@ class XFSPAccount(Account): LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' + def __init__(self, manager, accounts): #@TODO: remove in 0.4.10 + self.init() + return super(XFSPAccount, self).__init__(manager, accounts) + + def init(self): if not hasattr(self, "HOSTER_URL"): self.HOSTER_URL = "http://%s/" % self.HOSTER_NAME -- cgit v1.2.3 From 4e0e93fe8a9c9a98f3f299afacf07fbc855ef88b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 20 Oct 2014 12:59:27 +0200 Subject: Preload self.html --- module/plugins/internal/SimpleCrypter.py | 10 +++++----- module/plugins/internal/SimpleHoster.py | 11 ++++------- module/plugins/internal/XFSPHoster.py | 9 +++------ 3 files changed, 12 insertions(+), 18 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index f1def8118..b09ee6ac2 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -2,6 +2,7 @@ import re +from module.network.RequestFactory import getURL from module.plugins.Crypter import Crypter from module.plugins.Plugin import Fail from module.plugins.internal.SimpleHoster import replace_patterns, set_cookies @@ -11,7 +12,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.16" + __version__ = "0.17" __pattern__ = None @@ -86,14 +87,13 @@ class SimpleCrypter(Crypter): if isinstance(self.COOKIES, list): set_cookies(self.req.cj, self.COOKIES) + url = self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) + self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=self.COOKIES) + def decrypt(self, pyfile): self.prepare() - pyfile.url = replace_patterns(pyfile.url, self.URL_REPLACEMENTS) - - self.html = self.load(pyfile.url, decode=not self.TEXT_ENCODING) - self.checkOnline() package_name, folder_name = self.getPackageNameAndFolder() diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index c62ef53b4..6fc61460a 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -204,17 +204,16 @@ class SimpleHoster(Hoster): def prepare(self): if isinstance(self.COOKIES, list): set_cookies(self.req.cj, self.COOKIES) + self.req.setOption("timeout", 120) + url = self.pyfile.url = replace_patterns(self.pyfile.url, self.FILE_URL_REPLACEMENTS) + self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=self.COOKIES) + def process(self, pyfile): self.prepare() - pyfile.url = replace_patterns(pyfile.url, self.FILE_URL_REPLACEMENTS) - - # Due to a 0.4.9 core bug self.load would keep previous cookies even if overridden by cookies parameter. - # Workaround using getURL. Can be reverted in 0.4.10 as the cookies bug has been fixed. - self.html = getURL(pyfile.url, decode=not self.TEXT_ENCODING, cookies=self.COOKIES) premium_only = hasattr(self, 'PREMIUM_ONLY_PATTERN') and re.search(self.PREMIUM_ONLY_PATTERN, self.html) if not premium_only: # Usually premium only pages doesn't show the file information self.getFileInfo() @@ -224,8 +223,6 @@ class SimpleHoster(Hoster): elif premium_only: self.fail("This link require a premium account") else: - # This line is required due to the getURL workaround. Can be removed in 0.4.10 - self.html = self.load(pyfile.url, decode=not self.TEXT_ENCODING) self.handleFree() diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 0b656c67c..14c8302e1 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -75,12 +75,13 @@ class XFSPHoster(SimpleHoster): self.errmsg = None self.passwords = self.getPassword().splitlines() + url = self.pyfile.url = replace_patterns(self.pyfile.url, self.FILE_URL_REPLACEMENTS) + self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=self.COOKIES) + def process(self, pyfile): self.prepare() - pyfile.url = replace_patterns(pyfile.url, self.FILE_URL_REPLACEMENTS) - if not re.match(self.__pattern__, pyfile.url): if self.premium: self.handleOverriden() @@ -88,10 +89,6 @@ class XFSPHoster(SimpleHoster): self.fail("Only premium users can download from other hosters with %s" % self.HOSTER_NAME) else: try: - # Due to a 0.4.9 core bug self.load would use cookies even if - # cookies=False. Workaround using getURL to avoid cookies. - # Can be reverted in 0.4.10 as the cookies bug has been fixed. - self.html = getURL(pyfile.url, decode=not self.TEXT_ENCODING, cookies=self.COOKIES) self.file_info = self.getFileInfo() except Fail: self.file_info = None -- cgit v1.2.3 From 99f1eff391ca832740d1d519e8d6724a00fba952 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 02:04:46 +0200 Subject: [SimpleCrypter] Fix missing TEXT_ENCODING routine --- module/plugins/internal/SimpleCrypter.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index b09ee6ac2..e2e08bb1b 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -12,7 +12,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.17" + __version__ = "0.18" __pattern__ = None @@ -88,7 +88,7 @@ class SimpleCrypter(Crypter): set_cookies(self.req.cj, self.COOKIES) url = self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) - self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=self.COOKIES) + self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) def decrypt(self, pyfile): @@ -127,6 +127,9 @@ class SimpleCrypter(Crypter): def getPackageNameAndFolder(self): + if isinstance(self.TEXT_ENCODING, basestring): + self.html = unicode(html, self.TEXT_ENCODING) + if hasattr(self, 'TITLE_PATTERN'): try: m = re.search(self.TITLE_PATTERN, self.html) -- cgit v1.2.3 From b409e7782d48830489f47cc2364b4728d98f363a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 02:06:31 +0200 Subject: Improve COOKIES parsing --- module/plugins/internal/SimpleHoster.py | 5 +++-- module/plugins/internal/XFSPHoster.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 6fc61460a..74910692f 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -67,7 +67,7 @@ def parseHtmlForm(attr_str, html, input_names=None): return {}, None # no matching form found -def parseFileInfo(self, url='', html=''): +def parseFileInfo(self, url="", html=""): info = {"name": url, "size": 0, "status": 3} if hasattr(self, "pyfile"): @@ -129,6 +129,7 @@ def create_getInfo(plugin): cj = CookieJar(plugin.__name__) if isinstance(plugin.COOKIES, list): set_cookies(cj, plugin.COOKIES) + file_info = parseFileInfo(plugin, url, getURL(replace_patterns(url, plugin.FILE_URL_REPLACEMENTS), decode=not plugin.TEXT_ENCODING, cookies=cj)) yield file_info @@ -208,7 +209,7 @@ class SimpleHoster(Hoster): self.req.setOption("timeout", 120) url = self.pyfile.url = replace_patterns(self.pyfile.url, self.FILE_URL_REPLACEMENTS) - self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=self.COOKIES) + self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) def process(self, pyfile): diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 14c8302e1..5d75e41a7 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -76,7 +76,7 @@ class XFSPHoster(SimpleHoster): self.passwords = self.getPassword().splitlines() url = self.pyfile.url = replace_patterns(self.pyfile.url, self.FILE_URL_REPLACEMENTS) - self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=self.COOKIES) + self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) def process(self, pyfile): -- cgit v1.2.3 From 6badd4f1f210d2e9385c4d73c5b41ee5a6f04e65 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 09:59:16 +0200 Subject: Improve error method + fix TEXT_ENCODING in SimpleCrypter --- module/plugins/internal/SimpleCrypter.py | 15 +++++++++------ module/plugins/internal/SimpleHoster.py | 9 +++++---- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index e2e08bb1b..2ea8d302b 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -2,6 +2,8 @@ import re +from traceback import print_exc + from module.network.RequestFactory import getURL from module.plugins.Crypter import Crypter from module.plugins.Plugin import Fail @@ -12,7 +14,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.18" + __version__ = "0.19" __pattern__ = None @@ -65,6 +67,7 @@ class SimpleCrypter(Crypter): LOGIN_PREMIUM = False + #@TODO: remove in 0.4.10 def init(self): account_name = (self.__name__ + ".py").replace("Folder.py", "").replace(".py", "") account = self.core.accountManager.getAccountPlugin(account_name) @@ -128,7 +131,7 @@ class SimpleCrypter(Crypter): def getPackageNameAndFolder(self): if isinstance(self.TEXT_ENCODING, basestring): - self.html = unicode(html, self.TEXT_ENCODING) + self.html = unicode(self.html, self.TEXT_ENCODING) if hasattr(self, 'TITLE_PATTERN'): try: @@ -160,8 +163,8 @@ class SimpleCrypter(Crypter): self.package_links += self.getLinks() + #@TODO: remove in 0.4.10 def error(self, reason=None, type="parse"): - if reason: - raise Fail("%s error: %s | Plugin may be out of date" % (type.capitalize(), reason)) - else: - raise Fail("%s error | Plugin out of date" % type.capitalize()) + raise Fail("%s error%s | Plugin out of date" % (type.capitalize(), ':' + str(reason) if reason else "")) + if self.core.debug: + print_exc() diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 74910692f..17543ba8d 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -3,6 +3,7 @@ import re from time import time +from traceback import print_exc from urlparse import urlparse from module.network.CookieJar import CookieJar @@ -321,8 +322,8 @@ class SimpleHoster(Hoster): super(SimpleHoster, self).wait() + #@TODO: remove in 0.4.10 def error(self, reason=None, type="parse"): - if reason: - raise Fail("%s error: %s | Plugin may be out of date" % (type.capitalize(), reason)) - else: - raise Fail("%s error | Plugin out of date" % type.capitalize()) + raise Fail("%s error%s | Plugin out of date" % (type.capitalize(), ':' + str(reason) if reason else "")) + if self.core.debug: + print_exc() -- cgit v1.2.3 From fe5c86946dfc2c539b4e2a59128275c1fe506493 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 14:31:45 +0200 Subject: [CaptchaService] Fix KEY_PATTERN --- module/plugins/internal/CaptchaService.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 203dda82e..28374899d 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -7,7 +7,7 @@ from random import random class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.12" + __version__ = "0.13" __description__ = """Base captcha service plugin""" __license__ = "GPLv3" @@ -52,14 +52,14 @@ class CaptchaService: class ReCaptcha(CaptchaService): __name__ = "ReCaptcha" - __version__ = "0.05" + __version__ = "0.06" __description__ = """ReCaptcha captcha service plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r'https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P[\w-]+)' + KEY_PATTERN = r'recaptcha/api/challenge\?k=(?P[\w-]+)' KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\'](?P[\w-]+)' @@ -113,15 +113,15 @@ class ReCaptcha(CaptchaService): class AdsCaptcha(CaptchaService): __name__ = "AdsCaptcha" - __version__ = "0.03" + __version__ = "0.04" __description__ = """AdsCaptcha captcha service plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] - ID_PATTERN = r'http://api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(?P\d+)' - KEY_PATTERN = r'http://api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=(?P[\w-]+)' + ID_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(?P\d+)' + KEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=(?P[\w-]+)' def detect_key(self, html=None): @@ -175,14 +175,14 @@ class AdsCaptcha(CaptchaService): class SolveMedia(CaptchaService): __name__ = "SolveMedia" - __version__ = "0.04" + __version__ = "0.05" __description__ = """SolveMedia captcha service plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r'http://api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P.+?)["\']' + KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P.+?)["\']' def challenge(self, key=None): -- cgit v1.2.3 From 1b096b2eb2634e8dea80b06ab9ecde206b198b35 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 19:47:00 +0200 Subject: Spare code cosmetics --- module/plugins/internal/CaptchaService.py | 22 +++++++++++----------- module/plugins/internal/SimpleCrypter.py | 2 +- module/plugins/internal/SimpleHoster.py | 2 +- module/plugins/internal/XFSPHoster.py | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 28374899d..6d3fc0feb 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -16,7 +16,7 @@ class CaptchaService: KEY_PATTERN = None - key = None + key = None #: last key detected def __init__(self, plugin): @@ -28,7 +28,7 @@ class CaptchaService: if hasattr(self.plugin, "html") and self.plugin.html: html = self.plugin.html else: - errmsg = "%s html missing" % self.__name__ + errmsg = "%s html not found" % self.__name__ self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -68,7 +68,7 @@ class ReCaptcha(CaptchaService): if hasattr(self.plugin, "html") and self.plugin.html: html = self.plugin.html else: - errmsg = "ReCaptcha html missing" + errmsg = "ReCaptcha not found" self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -86,10 +86,10 @@ class ReCaptcha(CaptchaService): def challenge(self, key=None): if not key: - if self.key: + if self.detect_key(): key = self.key else: - errmsg = "ReCaptcha key missing" + errmsg = "ReCaptcha key not found" self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -129,7 +129,7 @@ class AdsCaptcha(CaptchaService): if hasattr(self.plugin, "html") and self.plugin.html: html = self.plugin.html else: - errmsg = "AdsCaptcha html missing" + errmsg = "AdsCaptcha html not found" self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -144,12 +144,12 @@ class AdsCaptcha(CaptchaService): return None - def challenge(self, key=None): #: key is tuple(CaptchaId, PublicKey) + def challenge(self, key=None): #: key is a tuple(CaptchaId, PublicKey) if not key: - if self.key: + if self.detect_key(): key = self.key else: - errmsg = "AdsCaptcha key missing" + errmsg = "AdsCaptcha key not found" self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -187,10 +187,10 @@ class SolveMedia(CaptchaService): def challenge(self, key=None): if not key: - if self.key: + if self.detect_key(): key = self.key else: - errmsg = "SolveMedia key missing" + errmsg = "SolveMedia key not found" self.plugin.fail(errmsg) raise TypeError(errmsg) diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 2ea8d302b..613ffce1f 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -165,6 +165,6 @@ class SimpleCrypter(Crypter): #@TODO: remove in 0.4.10 def error(self, reason=None, type="parse"): - raise Fail("%s error%s | Plugin out of date" % (type.capitalize(), ':' + str(reason) if reason else "")) + raise Fail("%s error%s | Plugin out of date" % (type.capitalize(), ': ' + str(reason) if reason else "")) if self.core.debug: print_exc() diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 17543ba8d..a8a44d953 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -324,6 +324,6 @@ class SimpleHoster(Hoster): #@TODO: remove in 0.4.10 def error(self, reason=None, type="parse"): - raise Fail("%s error%s | Plugin out of date" % (type.capitalize(), ':' + str(reason) if reason else "")) + raise Fail("%s error%s | Plugin out of date" % (type.capitalize(), ': ' + str(reason) if reason else "")) if self.core.debug: print_exc() diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 5d75e41a7..91a69116c 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -46,7 +46,7 @@ class XFSPHoster(SimpleHoster): OVR_LINK_PATTERN = r'

Download Link

\s*]*>([^<]+)' LINK_PATTERN = None #: final download url pattern - CAPTCHA_URL_PATTERN = r'(http://[^"\']+?/captchas?/[^"\']+)' + CAPTCHA_PATTERN = r'(http://[^"\']+?/captchas?/[^"\']+)' CAPTCHA_DIV_PATTERN = r'>Enter code.*?(.+?)' RECAPTCHA_PATTERN = None SOLVEMEDIA_PATTERN = None @@ -306,7 +306,7 @@ class XFSPHoster(SimpleHoster): def handleCaptcha(self, inputs): - m = re.search(self.CAPTCHA_URL_PATTERN, self.html) + m = re.search(self.CAPTCHA_PATTERN, self.html) if m: captcha_url = m.group(1) inputs['code'] = self.decryptCaptcha(captcha_url) -- cgit v1.2.3 From 0eb6e7ec4a1144dcca824d8add049787d3da1762 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 19:44:59 +0200 Subject: Two space before function declaration --- module/plugins/internal/AbstractExtractor.py | 8 ++++++++ module/plugins/internal/MultiHoster.py | 11 +++++++++++ module/plugins/internal/SimpleCrypter.py | 1 + module/plugins/internal/UnZip.py | 3 +++ 4 files changed, 23 insertions(+) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/AbstractExtractor.py b/module/plugins/internal/AbstractExtractor.py index 2b21ee357..8282e6ff5 100644 --- a/module/plugins/internal/AbstractExtractor.py +++ b/module/plugins/internal/AbstractExtractor.py @@ -28,6 +28,7 @@ class AbtractExtractor: """ return True + @staticmethod def getTargets(files_ids): """ Filter suited targets from list of filename id tuple list @@ -36,6 +37,7 @@ class AbtractExtractor: """ raise NotImplementedError + def __init__(self, m, file, out, fullpath, overwrite, excludefiles, renice): """Initialize extractor for specific file @@ -55,10 +57,12 @@ class AbtractExtractor: self.renice = renice self.files = [] #: Store extracted files here + def init(self): """ Initialize additional data structures """ pass + def checkArchive(self): """Check if password if needed. Raise ArchiveError if integrity is questionable. @@ -68,6 +72,7 @@ class AbtractExtractor: """ return False + def checkPassword(self, password): """ Check if the given password is/might be correct. If it can not be decided at this point return true. @@ -77,6 +82,7 @@ class AbtractExtractor: """ return True + def extract(self, progress, password=None): """Extract the archive. Raise specific errors in case of failure. @@ -89,6 +95,7 @@ class AbtractExtractor: """ raise NotImplementedError + def getDeleteFiles(self): """Return list of files to delete, do *not* delete them here. @@ -96,6 +103,7 @@ class AbtractExtractor: """ raise NotImplementedError + def getExtractedFiles(self): """Populate self.files at some point while extracting""" return self.files diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index 4ef43bc31..5aadf6f2e 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -28,6 +28,7 @@ class MultiHoster(Hook): self.supported = [] self.new_supported = [] + def getConfig(self, option, default=''): """getConfig with default value - sublass may not implements all config options""" try: @@ -35,6 +36,7 @@ class MultiHoster(Hook): except KeyError: return default + def getHosterCached(self): if not self.hosters: @@ -61,6 +63,7 @@ class MultiHoster(Hook): return self.hosters + def toHosterSet(self, hosters): hosters = set((str(x).strip().lower() for x in hosters)) @@ -72,6 +75,7 @@ class MultiHoster(Hook): hosters.discard('') return hosters + def getHoster(self): """Load list of supported hoster @@ -79,6 +83,7 @@ class MultiHoster(Hook): """ raise NotImplementedError + def coreReady(self): if self.cb: self.core.scheduler.removeJob(self.cb) @@ -94,9 +99,11 @@ class MultiHoster(Hook): else: self.periodical() + def initPeriodical(self): pass + def periodical(self): """reload hoster list periodically""" self.logInfo(_("Reloading supported hoster list")) @@ -112,6 +119,7 @@ class MultiHoster(Hook): for hoster in old_supported: self.unloadHoster(hoster) + def overridePlugins(self): pluginMap = {} for name in self.core.pluginManager.hosterPlugins.keys(): @@ -162,6 +170,7 @@ class MultiHoster(Hook): dict['pattern'] = regexp dict['re'] = re.compile(regexp) + def unloadHoster(self, hoster): dict = self.core.pluginManager.hosterPlugins[hoster] if "module" in dict: @@ -171,6 +180,7 @@ class MultiHoster(Hook): del dict['new_module'] del dict['new_name'] + def unload(self): """Remove override for all hosters. Scheduler job is removed by hookmanager""" for hoster in self.supported: @@ -182,6 +192,7 @@ class MultiHoster(Hook): dict['pattern'] = getattr(klass, "__pattern__", r'^unmatchable$') dict['re'] = re.compile(dict['pattern']) + def downloadFailed(self, pyfile): """remove plugin override if download fails but not if file is offline/temp.offline""" if pyfile.hasStatus("failed") and self.getConfig("unloadFailing", True): diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 613ffce1f..6c00a2267 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -51,6 +51,7 @@ class SimpleCrypter(Crypter): and its loadPage method: + def loadPage(self, page_n): return the html of the page number page_n """ diff --git a/module/plugins/internal/UnZip.py b/module/plugins/internal/UnZip.py index 52b4bca27..ec493bcd8 100644 --- a/module/plugins/internal/UnZip.py +++ b/module/plugins/internal/UnZip.py @@ -19,6 +19,7 @@ class UnZip(AbtractExtractor): def checkDeps(): return sys.version_info[:2] >= (2, 6) + @staticmethod def getTargets(files_ids): result = [] @@ -29,10 +30,12 @@ class UnZip(AbtractExtractor): return result + def extract(self, progress, password=None): z = zipfile.ZipFile(self.file) self.files = z.namelist() z.extractall(self.out) + def getDeleteFiles(self): return [self.file] -- cgit v1.2.3 From 85ba09f7bd27461ab5900487fd9da705cc7ff3a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 21:14:50 +0200 Subject: [CaptchaService] Update ReCaptcha KEY_PATTERN --- module/plugins/internal/CaptchaService.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 6d3fc0feb..11b34755b 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -7,7 +7,7 @@ from random import random class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.13" + __version__ = "0.14" __description__ = """Base captcha service plugin""" __license__ = "GPLv3" @@ -52,14 +52,14 @@ class CaptchaService: class ReCaptcha(CaptchaService): __name__ = "ReCaptcha" - __version__ = "0.06" + __version__ = "0.07" __description__ = """ReCaptcha captcha service plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r'recaptcha/api/challenge\?k=(?P[\w-]+)' + KEY_PATTERN = r'recaptcha(/api|\.net)/(challenge|noscript)\?k=(?P[\w-]+)' KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\'](?P[\w-]+)' -- cgit v1.2.3 From e41f3d7f9bac5c5923d5e3e4ae4b373f6c90dc16 Mon Sep 17 00:00:00 2001 From: guidobelix Date: Wed, 22 Oct 2014 21:41:11 +0200 Subject: Broken TRAFFIC_LEFT_PATTERN in RapidfileshareNet and TusfilesNet account --- module/plugins/internal/XFSPAccount.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index c2d779c29..d420adbb6 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -98,10 +98,7 @@ class XFSPAccount(Account): except: pass - if premium is None: - premium = False - - return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} + return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium or False} def login(self, user, data, req): -- cgit v1.2.3 From 822fc8edc732248e5e79bf5a0ef9555bcc56b21c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 23:08:05 +0200 Subject: [XFSPAccount] Better HOSTER_URL --- module/plugins/internal/XFSPAccount.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index d420adbb6..5e2a0afc4 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -13,7 +13,7 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.14" + __version__ = "0.15" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -50,7 +50,7 @@ class XFSPAccount(Account): def init(self): if not hasattr(self, "HOSTER_URL"): - self.HOSTER_URL = "http://%s/" % self.HOSTER_NAME + self.HOSTER_URL = "http://www.%s/" % self.HOSTER_NAME.replace("www.", "", 1) def loadAccountInfo(self, user, req): -- cgit v1.2.3 From 7b67f68c1636014fe02286da71bdc6c13dc3eeee Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 23 Oct 2014 00:50:23 +0200 Subject: Simplify captcha challenge calls --- module/plugins/internal/CaptchaService.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 11b34755b..a1ec633e8 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -29,7 +29,7 @@ class CaptchaService: html = self.plugin.html else: errmsg = "%s html not found" % self.__name__ - self.plugin.fail(errmsg) + self.plugin.fail(errmsg) #@TODO: replace all plugin.fail(errmsg) with plugin.error(errmsg) in 0.4.10 raise TypeError(errmsg) m = re.search(self.KEY_PATTERN, html) @@ -72,9 +72,7 @@ class ReCaptcha(CaptchaService): self.plugin.fail(errmsg) raise TypeError(errmsg) - m = re.search(self.KEY_PATTERN, html) - if m is None: - m = re.search(self.KEY_AJAX_PATTERN, html) + m = re.search(self.KEY_PATTERN, html) or re.search(self.KEY_AJAX_PATTERN, html) if m: self.key = m.group("KEY") self.plugin.logDebug("ReCaptcha key: %s" % self.key) -- cgit v1.2.3 From 8e89cb7781ec3b135feeb750f6321bbc85e89d67 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 23 Oct 2014 22:54:40 +0200 Subject: Fix error method --- module/plugins/internal/SimpleCrypter.py | 4 ++-- module/plugins/internal/SimpleHoster.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 6c00a2267..402a641ea 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -165,7 +165,7 @@ class SimpleCrypter(Crypter): #@TODO: remove in 0.4.10 - def error(self, reason=None, type="parse"): - raise Fail("%s error%s | Plugin out of date" % (type.capitalize(), ': ' + str(reason) if reason else "")) + def error(self, reason="", type="parse"): if self.core.debug: print_exc() + raise Fail("%s error%s | Plugin may be out of date" % (type.strip().capitalize(), ': ' + reason.strip() if reason else "")) diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index a8a44d953..be3e3c8fc 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -323,7 +323,7 @@ class SimpleHoster(Hoster): #@TODO: remove in 0.4.10 - def error(self, reason=None, type="parse"): - raise Fail("%s error%s | Plugin out of date" % (type.capitalize(), ': ' + str(reason) if reason else "")) + def error(self, reason="", type="parse"): if self.core.debug: print_exc() + raise Fail("%s error%s | Plugin may be out of date" % (type.strip().capitalize(), ': ' + reason.strip() if reason else "")) -- cgit v1.2.3 From 29de13dc5098cc9214f3f8f111da140a22e3e2ff Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 25 Oct 2014 01:15:58 +0200 Subject: Use parseTraffic instead parseFileSize in accounts --- module/plugins/internal/XFSPAccount.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 5e2a0afc4..e54fda987 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -7,13 +7,12 @@ from time import mktime, strptime from module.plugins.Account import Account from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies -from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.15" + __version__ = "0.16" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -94,7 +93,7 @@ class XFSPAccount(Account): unit = self.TRAFFIC_LEFT_UNIT else: unit = None - trafficleft = parseFileSize(traffic['S'], unit) + trafficleft = self.parseTraffic(traffic['S'], unit) except: pass -- cgit v1.2.3 From c41d4ec4c5935ee702a44e919730971028bf5724 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 25 Oct 2014 01:16:52 +0200 Subject: Fix and improve plugins logging --- module/plugins/internal/SimpleHoster.py | 2 ++ module/plugins/internal/XFSPHoster.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index be3e3c8fc..51010d569 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -221,10 +221,12 @@ class SimpleHoster(Hoster): self.getFileInfo() if self.premium and (not self.FORCE_CHECK_TRAFFIC or self.checkTrafficLeft()): + self.logDebug("Handle as premium download") self.handlePremium() elif premium_only: self.fail("This link require a premium account") else: + self.logDebug("Handle as free download") self.handleFree() diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 91a69116c..87a82beaf 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -102,8 +102,10 @@ class XFSPHoster(SimpleHoster): if self.location: self.startDownload(self.location) elif self.premium: + self.logDebug("Handle as premium download") self.handlePremium() else: + self.logDebug("Handle as free download") self.handleFree() @@ -126,7 +128,6 @@ class XFSPHoster(SimpleHoster): def handleFree(self): url = self.getDownloadLink() - self.logDebug("Download URL: %s" % url) self.startDownload(url) @@ -312,7 +313,7 @@ class XFSPHoster(SimpleHoster): inputs['code'] = self.decryptCaptcha(captcha_url) return 1 - m = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.DOTALL) + m = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.S) if m: captcha_div = m.group(1) self.logDebug(captcha_div) -- cgit v1.2.3 From 4da90891eb2544ac15a7d512aba8cb357f68ee5f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 25 Oct 2014 01:11:29 +0200 Subject: Spare code cosmetics --- module/plugins/internal/UnRar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 7478d68db..d8bb6f251 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -168,9 +168,9 @@ class UnRar(AbtractExtractor): def getDeleteFiles(self): if ".part" in basename(self.file): - return glob(re.sub("(?<=\.part)([01]+)", "*", self.file, re.IGNORECASE)) + return glob(re.sub("(?<=\.part)([01]+)", "*", self.file, re.I)) # get files which matches .r* and filter unsuited files out - parts = glob(re.sub(r"(?<=\.r)ar$", "*", self.file, re.IGNORECASE)) + parts = glob(re.sub(r"(?<=\.r)ar$", "*", self.file, re.I)) return filter(lambda x: self.re_partfiles.match(x), parts) -- cgit v1.2.3 From e3f5280529921100f48bb8a79853bf480c7611e4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 25 Oct 2014 02:53:05 +0200 Subject: Replace single quotes with doubles in self.error and self.fail msg --- module/plugins/internal/SimpleCrypter.py | 6 +++--- module/plugins/internal/SimpleHoster.py | 2 +- module/plugins/internal/XFSPHoster.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 402a641ea..3cbb0f70a 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -83,10 +83,10 @@ class SimpleCrypter(Crypter): def prepare(self): if self.LOGIN_ACCOUNT and not self.account: - self.fail('Required account not found!') + self.fail("Required account not found!") if self.LOGIN_PREMIUM and not self.premium: - self.fail('Required premium account not found!') + self.fail("Required premium account not found!") if isinstance(self.COOKIES, list): set_cookies(self.req.cj, self.COOKIES) @@ -112,7 +112,7 @@ class SimpleCrypter(Crypter): if self.package_links: self.packages = [(package_name, self.package_links, folder_name)] else: - self.fail('Could not extract any links') + self.fail("Could not extract any links") def getLinks(self): diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 51010d569..951a05783 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -241,7 +241,7 @@ class SimpleHoster(Hoster): self.tempOffline() elif status != 2: self.logDebug(self.file_info) - self.error('File info') + self.error("File info") if name: self.pyfile.name = name diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 87a82beaf..fd39bed02 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -162,7 +162,7 @@ class XFSPHoster(SimpleHoster): self.html = self.load(self.pyfile.url, post=self.getPostParameters()) m = re.search(self.LINK_PATTERN, self.html) if m is None: - self.error('LINK_PATTERN not found') + self.error("LINK_PATTERN not found") self.startDownload(m.group(1)) @@ -183,7 +183,7 @@ class XFSPHoster(SimpleHoster): action, inputs = self.parseHtmlForm('F1') if not inputs: - self.error('TEXTAREA not found') + self.error("TEXTAREA not found") self.logDebug(self.HOSTER_NAME, inputs) if inputs['st'] == 'OK': self.html = self.load(action, post=inputs) @@ -195,7 +195,7 @@ class XFSPHoster(SimpleHoster): #get easybytez.com link for uploaded file m = re.search(self.OVR_LINK_PATTERN, self.html) if m is None: - self.error('OVR_LINK_PATTERN not found') + self.error("OVR_LINK_PATTERN not found") self.pyfile.url = m.group(1) header = self.load(self.pyfile.url, just_header=True) if 'location' in header: # Direct link @@ -303,7 +303,7 @@ class XFSPHoster(SimpleHoster): self.errmsg = None else: - self.error('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN')) + self.error("FORM: %s" % (inputs['op'] if 'op' in inputs else 'UNKNOWN')) def handleCaptcha(self, inputs): -- cgit v1.2.3 From 1c4bf83881d2a22da3773666a580d51f6b57bfd1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 25 Oct 2014 03:07:21 +0200 Subject: Avoid gettext conflict due variable `_` --- module/plugins/internal/XFSPHoster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index fd39bed02..19cddba64 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -245,7 +245,7 @@ class XFSPHoster(SimpleHoster): def getPostParameters(self): - for _ in xrange(3): + for _i in xrange(3): if not self.errmsg: self.checkErrors() -- cgit v1.2.3 From 9f2ebe486a3e155fb6a60e07cccb77ab6a772eb2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 26 Oct 2014 02:31:54 +0200 Subject: Extend translation support in plugins + a lot of code cosmetics and typo fixes --- module/plugins/internal/CaptchaService.py | 12 ++++++------ module/plugins/internal/SimpleCrypter.py | 6 +++--- module/plugins/internal/SimpleHoster.py | 12 ++++++------ module/plugins/internal/XFSPHoster.py | 26 +++++++++++++------------- 4 files changed, 28 insertions(+), 28 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index a1ec633e8..aa8758344 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -28,7 +28,7 @@ class CaptchaService: if hasattr(self.plugin, "html") and self.plugin.html: html = self.plugin.html else: - errmsg = "%s html not found" % self.__name__ + errmsg = _("%s html not found") % self.__name__ self.plugin.fail(errmsg) #@TODO: replace all plugin.fail(errmsg) with plugin.error(errmsg) in 0.4.10 raise TypeError(errmsg) @@ -68,7 +68,7 @@ class ReCaptcha(CaptchaService): if hasattr(self.plugin, "html") and self.plugin.html: html = self.plugin.html else: - errmsg = "ReCaptcha not found" + errmsg = _("ReCaptcha html not found") self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -87,7 +87,7 @@ class ReCaptcha(CaptchaService): if self.detect_key(): key = self.key else: - errmsg = "ReCaptcha key not found" + errmsg = _("ReCaptcha key not found") self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -127,7 +127,7 @@ class AdsCaptcha(CaptchaService): if hasattr(self.plugin, "html") and self.plugin.html: html = self.plugin.html else: - errmsg = "AdsCaptcha html not found" + errmsg = _("AdsCaptcha html not found") self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -147,7 +147,7 @@ class AdsCaptcha(CaptchaService): if self.detect_key(): key = self.key else: - errmsg = "AdsCaptcha key not found" + errmsg = _("AdsCaptcha key not found") self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -188,7 +188,7 @@ class SolveMedia(CaptchaService): if self.detect_key(): key = self.key else: - errmsg = "SolveMedia key not found" + errmsg = _("SolveMedia key not found") self.plugin.fail(errmsg) raise TypeError(errmsg) diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 3cbb0f70a..61286449d 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -83,10 +83,10 @@ class SimpleCrypter(Crypter): def prepare(self): if self.LOGIN_ACCOUNT and not self.account: - self.fail("Required account not found!") + self.fail(_("Required account not found!")) if self.LOGIN_PREMIUM and not self.premium: - self.fail("Required premium account not found!") + self.fail(_("Required premium account not found!")) if isinstance(self.COOKIES, list): set_cookies(self.req.cj, self.COOKIES) @@ -112,7 +112,7 @@ class SimpleCrypter(Crypter): if self.package_links: self.packages = [(package_name, self.package_links, folder_name)] else: - self.fail("Could not extract any links") + self.fail(_("Could not extract any links")) def getLinks(self): diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 951a05783..135d3c9d9 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -224,7 +224,7 @@ class SimpleHoster(Hoster): self.logDebug("Handle as premium download") self.handlePremium() elif premium_only: - self.fail("This link require a premium account") + self.fail(_("This link require a premium account")) else: self.logDebug("Handle as free download") self.handleFree() @@ -241,7 +241,7 @@ class SimpleHoster(Hoster): self.tempOffline() elif status != 2: self.logDebug(self.file_info) - self.error("File info") + self.error(_("File info")) if name: self.pyfile.name = name @@ -259,12 +259,12 @@ class SimpleHoster(Hoster): def handleFree(self): if not hasattr(self, 'LINK_FREE_PATTERN'): - self.fail("Free download not implemented") + self.fail(_("Free download not implemented")) try: m = re.search(self.LINK_FREE_PATTERN, self.html) if m is None: - self.error("Free download link not found") + self.error(_("Free download link not found")) link = m.group(1) except Exception, e: @@ -275,12 +275,12 @@ class SimpleHoster(Hoster): def handlePremium(self): if not hasattr(self, 'LINK_PREMIUM_PATTERN'): - self.fail("Premium download not implemented") + self.fail(_("Premium download not implemented")) try: m = re.search(self.LINK_PREMIUM_PATTERN, self.html) if m is None: - self.error("Premium download link not found") + self.error(_("Premium download link not found")) link = m.group(1) except Exception, e: diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 19cddba64..0ea5a95c5 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -62,7 +62,7 @@ class XFSPHoster(SimpleHoster): def prepare(self): """ Initialize important variables """ if not self.HOSTER_NAME: - self.fail("Missing HOSTER_NAME") + self.fail(_("Missing HOSTER_NAME")) if not self.LINK_PATTERN: pattern = r'(https?://(www\.)?([^/]*?%s|\d+\.\d+\.\d+\.\d+)(\:\d+)?(/d/|(/files)?/\d+/\w+/).+?)["\'<]' @@ -86,7 +86,7 @@ class XFSPHoster(SimpleHoster): if self.premium: self.handleOverriden() else: - self.fail("Only premium users can download from other hosters with %s" % self.HOSTER_NAME) + self.fail(_("Only premium users can download from other hosters with %s") % self.HOSTER_NAME) else: try: self.file_info = self.getFileInfo() @@ -151,9 +151,9 @@ class XFSPHoster(SimpleHoster): else: if self.errmsg and 'captcha' in self.errmsg: - self.fail("No valid captcha code entered") + self.fail(_("No valid captcha code entered")) else: - self.fail("Download link not found") + self.fail(_("Download link not found")) return m.group(1) @@ -162,7 +162,7 @@ class XFSPHoster(SimpleHoster): self.html = self.load(self.pyfile.url, post=self.getPostParameters()) m = re.search(self.LINK_PATTERN, self.html) if m is None: - self.error("LINK_PATTERN not found") + self.error(_("LINK_PATTERN not found")) self.startDownload(m.group(1)) @@ -183,19 +183,19 @@ class XFSPHoster(SimpleHoster): action, inputs = self.parseHtmlForm('F1') if not inputs: - self.error("TEXTAREA not found") + self.error(_("TEXTAREA not found")) self.logDebug(self.HOSTER_NAME, inputs) if inputs['st'] == 'OK': self.html = self.load(action, post=inputs) elif inputs['st'] == 'Can not leech file': self.retry(max_tries=20, wait_time=3 * 60, reason=inputs['st']) else: - self.fail(inputs['st']) + self.fail(_(inputs['st'])) #get easybytez.com link for uploaded file m = re.search(self.OVR_LINK_PATTERN, self.html) if m is None: - self.error("OVR_LINK_PATTERN not found") + self.error(_("OVR_LINK_PATTERN not found")) self.pyfile.url = m.group(1) header = self.load(self.pyfile.url, just_header=True) if 'location' in header: # Direct link @@ -225,7 +225,7 @@ class XFSPHoster(SimpleHoster): elif 'captcha' in self.errmsg: self.invalidCaptcha() elif 'premium' in self.errmsg and 'require' in self.errmsg: - self.fail("File can be downloaded by premium users only") + self.fail(_("File can be downloaded by premium users only")) elif 'limit' in self.errmsg: self.wait(1 * 60 * 60, True) self.retry(25) @@ -234,7 +234,7 @@ class XFSPHoster(SimpleHoster): elif 'maintenance' in self.errmsg or 'maintainance' in self.errmsg: self.tempOffline() elif 'download files up to' in self.errmsg: - self.fail("File too large for free download") + self.fail(_("File too large for free download")) else: self.fail(self.errmsg) @@ -260,7 +260,7 @@ class XFSPHoster(SimpleHoster): if self.errmsg: self.retry() else: - self.error("Form not found") + self.error(_("Form not found")) self.logDebug(self.HOSTER_NAME, inputs) @@ -269,7 +269,7 @@ class XFSPHoster(SimpleHoster): if self.passwords: inputs['password'] = self.passwords.pop(0) else: - self.fail("No or invalid passport") + self.fail(_("No or invalid passport")) if not self.premium: m = re.search(self.WAIT_PATTERN, self.html) @@ -303,7 +303,7 @@ class XFSPHoster(SimpleHoster): self.errmsg = None else: - self.error("FORM: %s" % (inputs['op'] if 'op' in inputs else 'UNKNOWN')) + self.error(_("FORM: %s") % (inputs['op'] if 'op' in inputs else _("UNKNOWN"))) def handleCaptcha(self, inputs): -- cgit v1.2.3 From 8e1663b2c6c0367e9b9afa08412ad896faa996b5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 26 Oct 2014 02:44:28 +0100 Subject: [XFSPHoster] Fix checkErrors --- module/plugins/internal/XFSPHoster.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 0ea5a95c5..00666ec2b 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -17,7 +17,7 @@ from module.utils import html_unescape class XFSPHoster(SimpleHoster): __name__ = "XFSPHoster" __type__ = "hoster" - __version__ = "0.04" + __version__ = "0.05" __pattern__ = None @@ -188,7 +188,7 @@ class XFSPHoster(SimpleHoster): if inputs['st'] == 'OK': self.html = self.load(action, post=inputs) elif inputs['st'] == 'Can not leech file': - self.retry(max_tries=20, wait_time=3 * 60, reason=inputs['st']) + self.retry(20, 3 * 60, inputs['st']) else: self.fail(_(inputs['st'])) @@ -196,12 +196,14 @@ class XFSPHoster(SimpleHoster): m = re.search(self.OVR_LINK_PATTERN, self.html) if m is None: self.error(_("OVR_LINK_PATTERN not found")) + self.pyfile.url = m.group(1) + header = self.load(self.pyfile.url, just_header=True) if 'location' in header: # Direct link self.startDownload(self.pyfile.url) else: - self.retry() + self.retry(reason="OVR link location not found") def startDownload(self, link): @@ -227,10 +229,10 @@ class XFSPHoster(SimpleHoster): elif 'premium' in self.errmsg and 'require' in self.errmsg: self.fail(_("File can be downloaded by premium users only")) elif 'limit' in self.errmsg: - self.wait(1 * 60 * 60, True) - self.retry(25) + self.wantReconnect = True + self.retry(25, 1 * 60 * 60, "Download limit exceeded") elif 'countdown' in self.errmsg or 'Expired' in self.errmsg: - self.retry() + self.retry(reason="Link expired") elif 'maintenance' in self.errmsg or 'maintainance' in self.errmsg: self.tempOffline() elif 'download files up to' in self.errmsg: @@ -246,8 +248,7 @@ class XFSPHoster(SimpleHoster): def getPostParameters(self): for _i in xrange(3): - if not self.errmsg: - self.checkErrors() + self.checkErrors() if hasattr(self, "FORM_PATTERN"): action, inputs = self.parseHtmlForm(self.FORM_PATTERN) @@ -258,7 +259,7 @@ class XFSPHoster(SimpleHoster): action, inputs = self.parseHtmlForm('F1') if not inputs: if self.errmsg: - self.retry() + self.retry(reason=self.errmsg) else: self.error(_("Form not found")) -- cgit v1.2.3 From e92919794e2c7e49e015fee8dfc906404fa0e541 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 26 Oct 2014 19:35:43 +0100 Subject: [XFSPAccount] Improve VALID_UNTIL_PATTERN --- module/plugins/internal/XFSPAccount.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index e54fda987..69b5cfc22 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -12,7 +12,7 @@ from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.16" + __version__ = "0.17" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -34,7 +34,7 @@ class XFSPAccount(Account): COOKIES = [(HOSTER_NAME, "lang", "english")] #: or list of tuples [(domain, name, value)] - VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(.+?)' + VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?([^><]+)' TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+)\s*(?:(?P[\w^_]+)\s*)?' TRAFFIC_LEFT_UNIT = "MB" #: used only if no group was found -- cgit v1.2.3 From 8f0303277fce7471539508f7a8fad033e5e87076 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 26 Oct 2014 19:36:46 +0100 Subject: [SimpleHoster][SimpleCrypter] Clean error method --- module/plugins/internal/SimpleCrypter.py | 7 ++----- module/plugins/internal/SimpleHoster.py | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 61286449d..9e1b11f7b 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -7,7 +7,7 @@ from traceback import print_exc from module.network.RequestFactory import getURL from module.plugins.Crypter import Crypter from module.plugins.Plugin import Fail -from module.plugins.internal.SimpleHoster import replace_patterns, set_cookies +from module.plugins.internal.SimpleHoster import _error, replace_patterns, set_cookies from module.utils import fixup, html_unescape @@ -164,8 +164,5 @@ class SimpleCrypter(Crypter): self.package_links += self.getLinks() - #@TODO: remove in 0.4.10 def error(self, reason="", type="parse"): - if self.core.debug: - print_exc() - raise Fail("%s error%s | Plugin may be out of date" % (type.strip().capitalize(), ': ' + reason.strip() if reason else "")) + return _error(reason, type) diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 135d3c9d9..84a77a312 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -13,6 +13,20 @@ from module.plugins.Plugin import Fail from module.utils import fixup, html_unescape, parseFileSize +#@TODO: Remove in 0.4.10 and redirect to self.error instead +def _error(self, reason="", type=""): + if not reason and not type: + type = "unknown" + + msg = _("%s error") % type.strip().capitalize() if type else _("Error") + msg += ": " + reason.strip() if reason else "" + msg += _(" | Plugin may be out of date") + + if self.core.debug: + print_exc() + raise Fail(msg) + + def replace_patterns(string, ruleslist): for r in ruleslist: rf, rt = r @@ -324,8 +338,5 @@ class SimpleHoster(Hoster): super(SimpleHoster, self).wait() - #@TODO: remove in 0.4.10 def error(self, reason="", type="parse"): - if self.core.debug: - print_exc() - raise Fail("%s error%s | Plugin may be out of date" % (type.strip().capitalize(), ': ' + reason.strip() if reason else "")) + return _error(reason, type) -- cgit v1.2.3 From f6aed08062c3b6a4dad09d238a32ef5ab58479a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 26 Oct 2014 20:49:31 +0100 Subject: [SimpleHoster][SimpleCrypter] Bump up __version__ --- module/plugins/internal/SimpleCrypter.py | 2 +- module/plugins/internal/SimpleHoster.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 9e1b11f7b..31102b6fa 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -14,7 +14,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.19" + __version__ = "0.20" __pattern__ = None diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 84a77a312..87ebfc533 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -159,7 +159,7 @@ def timestamp(): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "0.40" + __version__ = "0.41" __pattern__ = None -- cgit v1.2.3 From d99e7039744c67ddbe56a09eeaa636f7d62e98a8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 26 Oct 2014 21:10:38 +0100 Subject: [XFSPHoster] Improve ERROR_PATTERN --- module/plugins/internal/XFSPHoster.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 00666ec2b..edbe8a0a2 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -17,7 +17,7 @@ from module.utils import html_unescape class XFSPHoster(SimpleHoster): __name__ = "XFSPHoster" __type__ = "hoster" - __version__ = "0.05" + __version__ = "0.06" __pattern__ = None @@ -51,7 +51,7 @@ class XFSPHoster(SimpleHoster): RECAPTCHA_PATTERN = None SOLVEMEDIA_PATTERN = None - ERROR_PATTERN = r'class=["\']err["\'][^>]*>(.+?)]*>|<[Cc]enter>)(.+?)(?:["\']| Date: Mon, 27 Oct 2014 01:16:51 +0100 Subject: [SimpleHoster] Direct download link support --- module/plugins/internal/SimpleHoster.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 87ebfc533..ca84dc33e 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -159,7 +159,7 @@ def timestamp(): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "0.41" + __version__ = "0.42" __pattern__ = None @@ -208,6 +208,8 @@ class SimpleHoster(Hoster): COOKIES = True #: or False or list of tuples [(domain, name, value)] FORCE_CHECK_TRAFFIC = False #: Set to True to force checking traffic left for premium account + CHECK_DIRECT_DOWNLOAD = True #: Search for a direct download link in the page header (premium only) + def init(self): self.file_info = {} @@ -223,15 +225,22 @@ class SimpleHoster(Hoster): self.req.setOption("timeout", 120) - url = self.pyfile.url = replace_patterns(self.pyfile.url, self.FILE_URL_REPLACEMENTS) - self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) + self.pyfile.url = replace_patterns(self.pyfile.url, self.FILE_URL_REPLACEMENTS) + self.html = getURL(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) def process(self, pyfile): self.prepare() + if self.CHECK_DIRECT_DOWNLOAD and self.premium: + header = self.load(self.pyfile.url, just_header=True) + if 'location' in header: + self.logDebug("Direct download link detected") + self.download(header['location'], ref=True, cookies=True, disposition=True) + return + premium_only = hasattr(self, 'PREMIUM_ONLY_PATTERN') and re.search(self.PREMIUM_ONLY_PATTERN, self.html) - if not premium_only: # Usually premium only pages doesn't show the file information + if not premium_only: #: Usually premium only pages doesn't show the file information self.getFileInfo() if self.premium and (not self.FORCE_CHECK_TRAFFIC or self.checkTrafficLeft()): @@ -282,7 +291,7 @@ class SimpleHoster(Hoster): link = m.group(1) except Exception, e: - self.logError(str(e)) + self.fail(str(e)) else: self.download(link, ref=True, cookies=True, disposition=True) @@ -298,7 +307,7 @@ class SimpleHoster(Hoster): link = m.group(1) except Exception, e: - self.logError(str(e)) + self.fail(str(e)) else: self.download(link, ref=True, cookies=True, disposition=True) @@ -308,14 +317,14 @@ class SimpleHoster(Hoster): time_str = "%dh %dm" % divmod(wait_time / 60, 60) else: wait_time = 900 - time_str = "(unknown time)" + time_str = _("(unknown time)") max_tries = 100 self.logInfo(_("Download limit reached, reconnect or wait %s") % time_str) self.setWait(wait_time, True) self.wait() - self.retry(max_tries=max_tries, reason="Download limit reached") + self.retry(max_tries=max_tries, reason=_("Download limit reached")) def parseHtmlForm(self, attr_str='', input_names=None): -- cgit v1.2.3 From 146fe1e309c33ab149bfaf58ad86c0dd4fb9b156 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 27 Oct 2014 01:18:45 +0100 Subject: Spare code cosmetics --- module/plugins/internal/SimpleCrypter.py | 4 ++-- module/plugins/internal/XFSPHoster.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 31102b6fa..f6783cffb 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -91,8 +91,8 @@ class SimpleCrypter(Crypter): if isinstance(self.COOKIES, list): set_cookies(self.req.cj, self.COOKIES) - url = self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) - self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) + self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) + self.html = getURL(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) def decrypt(self, pyfile): diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index edbe8a0a2..44b2006ae 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -201,9 +201,9 @@ class XFSPHoster(SimpleHoster): header = self.load(self.pyfile.url, just_header=True) if 'location' in header: # Direct link - self.startDownload(self.pyfile.url) + self.startDownload(header['location']) else: - self.retry(reason="OVR link location not found") + self.retry(reason=_("OVR link location not found")) def startDownload(self, link): @@ -232,7 +232,7 @@ class XFSPHoster(SimpleHoster): self.wantReconnect = True self.retry(25, 1 * 60 * 60, "Download limit exceeded") elif 'countdown' in self.errmsg or 'Expired' in self.errmsg: - self.retry(reason="Link expired") + self.retry(reason=_("Link expired")) elif 'maintenance' in self.errmsg or 'maintainance' in self.errmsg: self.tempOffline() elif 'download files up to' in self.errmsg: -- cgit v1.2.3 From aa0751bcfd995e308bcd586a6965c75e68b1274b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 27 Oct 2014 23:05:13 +0100 Subject: Code cosmetics --- module/plugins/internal/DeadCrypter.py | 9 +++++---- module/plugins/internal/DeadHoster.py | 9 +++++---- module/plugins/internal/MultiHoster.py | 9 ++++++--- module/plugins/internal/SimpleCrypter.py | 15 +++++++-------- module/plugins/internal/SimpleHoster.py | 13 +++++++------ module/plugins/internal/XFSPAccount.py | 10 +++++----- module/plugins/internal/XFSPCrypter.py | 9 +++++---- module/plugins/internal/XFSPHoster.py | 13 +++++++------ 8 files changed, 47 insertions(+), 40 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/DeadCrypter.py b/module/plugins/internal/DeadCrypter.py index 760ed61b1..9267f4c2e 100644 --- a/module/plugins/internal/DeadCrypter.py +++ b/module/plugins/internal/DeadCrypter.py @@ -4,15 +4,16 @@ from module.plugins.Crypter import Crypter as _Crypter class DeadCrypter(_Crypter): - __name__ = "DeadCrypter" - __type__ = "crypter" + __name__ = "DeadCrypter" + __type__ = "crypter" __version__ = "0.02" __pattern__ = None + __config__ = [] __description__ = """ Crypter is no longer available """ - __license__ = "GPLv3" - __authors__ = [("stickell", "l.stickell@yahoo.it")] + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it")] def setup(self): diff --git a/module/plugins/internal/DeadHoster.py b/module/plugins/internal/DeadHoster.py index 2f0a01732..6633a8f1c 100644 --- a/module/plugins/internal/DeadHoster.py +++ b/module/plugins/internal/DeadHoster.py @@ -12,15 +12,16 @@ def create_getInfo(plugin): class DeadHoster(_Hoster): - __name__ = "DeadHoster" - __type__ = "hoster" + __name__ = "DeadHoster" + __type__ = "hoster" __version__ = "0.12" __pattern__ = None + __config__ = [] __description__ = """ Hoster is no longer available """ - __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] def setup(self): diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index 5aadf6f2e..112736b0c 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -7,12 +7,15 @@ from module.utils import remove_chars class MultiHoster(Hook): - __name__ = "AbtractExtractor" + __name__ = "AbtractExtractor" + __type__ = "hook" __version__ = "0.19" + __config__ = [] + __description__ = """Generic MultiHoster plugin""" - __license__ = "GPLv3" - __authors__ = [("pyLoad Team", "admin@pyload.org")] + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] replacements = [("2shared.com", "twoshared.com"), ("4shared.com", "fourshared.com"), ("cloudnator.com", "shragle.com"), diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index f6783cffb..bfa2e6408 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -12,17 +12,18 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): - __name__ = "SimpleCrypter" - __type__ = "crypter" + __name__ = "SimpleCrypter" + __type__ = "crypter" __version__ = "0.20" __pattern__ = None + __config__ = [] __description__ = """Simple decrypter plugin""" - __license__ = "GPLv3" - __authors__ = [("stickell", "l.stickell@yahoo.it"), - ("zoidberg", "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com")] + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it"), + ("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com")] """ @@ -111,8 +112,6 @@ class SimpleCrypter(Crypter): if self.package_links: self.packages = [(package_name, self.package_links, folder_name)] - else: - self.fail(_("Could not extract any links")) def getLinks(self): diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index ca84dc33e..782655007 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -157,17 +157,18 @@ def timestamp(): class SimpleHoster(Hoster): - __name__ = "SimpleHoster" - __type__ = "hoster" + __name__ = "SimpleHoster" + __type__ = "hoster" __version__ = "0.42" __pattern__ = None + __config__ = [] __description__ = """Simple hoster plugin""" - __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("stickell", "l.stickell@yahoo.it"), - ("Walter Purcaro", "vuolter@gmail.com")] + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com")] """ diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 69b5cfc22..574bdd920 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -10,14 +10,14 @@ from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies class XFSPAccount(Account): - __name__ = "XFSPAccount" - __type__ = "account" + __name__ = "XFSPAccount" + __type__ = "account" __version__ = "0.17" __description__ = """XFileSharingPro account plugin""" - __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com")] + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com")] """ diff --git a/module/plugins/internal/XFSPCrypter.py b/module/plugins/internal/XFSPCrypter.py index 372657d2d..52b6aed34 100644 --- a/module/plugins/internal/XFSPCrypter.py +++ b/module/plugins/internal/XFSPCrypter.py @@ -4,15 +4,16 @@ from module.plugins.internal.SimpleCrypter import SimpleCrypter class XFSPCrypter(SimpleCrypter): - __name__ = "XFSPCrypter" - __type__ = "crypter" + __name__ = "XFSPCrypter" + __type__ = "crypter" __version__ = "0.02" __pattern__ = None + __config__ = [] __description__ = """XFileSharingPro decrypter plugin""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] HOSTER_NAME = None diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 44b2006ae..46529eaa8 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -15,17 +15,18 @@ from module.utils import html_unescape class XFSPHoster(SimpleHoster): - __name__ = "XFSPHoster" - __type__ = "hoster" + __name__ = "XFSPHoster" + __type__ = "hoster" __version__ = "0.06" __pattern__ = None + __config__ = [] __description__ = """XFileSharingPro hoster plugin""" - __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("stickell", "l.stickell@yahoo.it"), - ("Walter Purcaro", "vuolter@gmail.com")] + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com")] HOSTER_NAME = None -- cgit v1.2.3 From 483febe8e8711e644593ca758d1ba4c02c4dfde7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 27 Oct 2014 23:10:50 +0100 Subject: [XFSPAccount] Improve VALID_UNTIL_PATTERN --- module/plugins/internal/XFSPAccount.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 574bdd920..7b6215653 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -12,7 +12,7 @@ from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.17" + __version__ = "0.18" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -34,7 +34,7 @@ class XFSPAccount(Account): COOKIES = [(HOSTER_NAME, "lang", "english")] #: or list of tuples [(domain, name, value)] - VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?([^><]+)' + VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?([^><]+)' TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+)\s*(?:(?P[\w^_]+)\s*)?' TRAFFIC_LEFT_UNIT = "MB" #: used only if no group was found @@ -64,7 +64,7 @@ class XFSPAccount(Account): m = re.search(self.VALID_UNTIL_PATTERN, html) if m: - expiredate = m.group(1) + expiredate = m.group(1).strip() self.logDebug("Expire date: " + expiredate) try: -- cgit v1.2.3 From c6c902698bb62f845e7be3156ec6b62d74200fec Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 27 Oct 2014 23:15:36 +0100 Subject: [XFSPAccount] Fix missing gmtime import --- module/plugins/internal/XFSPAccount.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 7b6215653..ec62e5c1e 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -3,7 +3,7 @@ import re from urlparse import urljoin -from time import mktime, strptime +from time import gmtime, mktime, strptime from module.plugins.Account import Account from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies @@ -12,7 +12,7 @@ from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.18" + __version__ = "0.19" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" -- cgit v1.2.3 From 97cf4aee358bf95d5e77b5efd4e9e470c9631185 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 04:00:09 +0100 Subject: [XFSPAccount] Improve VALID_UNTIL_PATTERN 2 --- module/plugins/internal/XFSPAccount.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index ec62e5c1e..5f15a4659 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -12,7 +12,7 @@ from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.19" + __version__ = "0.20" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -34,7 +34,7 @@ class XFSPAccount(Account): COOKIES = [(HOSTER_NAME, "lang", "english")] #: or list of tuples [(domain, name, value)] - VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?([^><]+)' + VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(\d{2} [\w^_]+ \d{4})' TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+)\s*(?:(?P[\w^_]+)\s*)?' TRAFFIC_LEFT_UNIT = "MB" #: used only if no group was found @@ -70,7 +70,7 @@ class XFSPAccount(Account): try: validuntil = mktime(strptime(expiredate, "%d %B %Y")) except Exception, e: - self.logError(e) + self.logError(str(e)) else: if validuntil > mktime(gmtime()): premium = True -- cgit v1.2.3 From 885f8ed782e64d9e73367905e642a84d0a8999f1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 04:01:38 +0100 Subject: Update __config__ --- module/plugins/internal/DeadCrypter.py | 1 - module/plugins/internal/DeadHoster.py | 1 - module/plugins/internal/MultiHoster.py | 2 -- module/plugins/internal/SimpleCrypter.py | 3 ++- module/plugins/internal/SimpleHoster.py | 1 - module/plugins/internal/XFSPCrypter.py | 1 - module/plugins/internal/XFSPHoster.py | 1 - 7 files changed, 2 insertions(+), 8 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/DeadCrypter.py b/module/plugins/internal/DeadCrypter.py index 9267f4c2e..91cdf6036 100644 --- a/module/plugins/internal/DeadCrypter.py +++ b/module/plugins/internal/DeadCrypter.py @@ -9,7 +9,6 @@ class DeadCrypter(_Crypter): __version__ = "0.02" __pattern__ = None - __config__ = [] __description__ = """ Crypter is no longer available """ __license__ = "GPLv3" diff --git a/module/plugins/internal/DeadHoster.py b/module/plugins/internal/DeadHoster.py index 6633a8f1c..2d91b1d2d 100644 --- a/module/plugins/internal/DeadHoster.py +++ b/module/plugins/internal/DeadHoster.py @@ -17,7 +17,6 @@ class DeadHoster(_Hoster): __version__ = "0.12" __pattern__ = None - __config__ = [] __description__ = """ Hoster is no longer available """ __license__ = "GPLv3" diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index 112736b0c..5c787e2d6 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -11,8 +11,6 @@ class MultiHoster(Hook): __type__ = "hook" __version__ = "0.19" - __config__ = [] - __description__ = """Generic MultiHoster plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index bfa2e6408..50d647dee 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -17,7 +17,8 @@ class SimpleCrypter(Crypter): __version__ = "0.20" __pattern__ = None - __config__ = [] + __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] __description__ = """Simple decrypter plugin""" __license__ = "GPLv3" diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 782655007..3d2bcda86 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -162,7 +162,6 @@ class SimpleHoster(Hoster): __version__ = "0.42" __pattern__ = None - __config__ = [] __description__ = """Simple hoster plugin""" __license__ = "GPLv3" diff --git a/module/plugins/internal/XFSPCrypter.py b/module/plugins/internal/XFSPCrypter.py index 52b6aed34..378b78d02 100644 --- a/module/plugins/internal/XFSPCrypter.py +++ b/module/plugins/internal/XFSPCrypter.py @@ -9,7 +9,6 @@ class XFSPCrypter(SimpleCrypter): __version__ = "0.02" __pattern__ = None - __config__ = [] __description__ = """XFileSharingPro decrypter plugin""" __license__ = "GPLv3" diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 46529eaa8..5452b9444 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -20,7 +20,6 @@ class XFSPHoster(SimpleHoster): __version__ = "0.06" __pattern__ = None - __config__ = [] __description__ = """XFileSharingPro hoster plugin""" __license__ = "GPLv3" -- cgit v1.2.3 From 6a5b13502648cf51007c15948b778e5a9d54ad20 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 04:52:39 +0100 Subject: [SimpleCrypter][SimpleHoster] Fix typo in _error method call --- module/plugins/internal/SimpleCrypter.py | 4 ++-- module/plugins/internal/SimpleHoster.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 50d647dee..2fa0c2df3 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -14,7 +14,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.20" + __version__ = "0.21" __pattern__ = None __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -165,4 +165,4 @@ class SimpleCrypter(Crypter): def error(self, reason="", type="parse"): - return _error(reason, type) + return _error(self, reason, type) diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 3d2bcda86..e0b31416a 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -159,7 +159,7 @@ def timestamp(): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "0.42" + __version__ = "0.43" __pattern__ = None @@ -348,4 +348,4 @@ class SimpleHoster(Hoster): def error(self, reason="", type="parse"): - return _error(reason, type) + return _error(self, reason, type) -- cgit v1.2.3 From 302616d94f76ab8794b58d3d54b780cc58e86b06 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 04:58:47 +0100 Subject: Code cosmetics: items() -> iteritems() --- module/plugins/internal/MultiHoster.py | 2 +- module/plugins/internal/SimpleHoster.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index 5c787e2d6..3596641b0 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -126,7 +126,7 @@ class MultiHoster(Hook): for name in self.core.pluginManager.hosterPlugins.keys(): pluginMap[name.lower()] = name - accountList = [name.lower() for name, data in self.core.accountManager.accounts.items() if data] + accountList = [name.lower() for name, data in self.core.accountManager.accounts.iteritems() if data] excludedList = [] for hoster in self.getHosterCached(): diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index e0b31416a..9e270ff3d 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -62,7 +62,7 @@ def parseHtmlForm(attr_str, html, input_names=None): if isinstance(input_names, dict): # check input attributes - for key, val in input_names.items(): + for key, val in input_names.iteritems(): if key in inputs: if isinstance(val, basestring) and inputs[key] == val: continue -- cgit v1.2.3 From 1a6d4ab20645e8dda3f0c61d10ecbcc16312eec7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 16:02:14 +0100 Subject: [SimpleCrypter] Wait method --- module/plugins/internal/SimpleCrypter.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 2fa0c2df3..1f41a7e5a 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -7,14 +7,14 @@ from traceback import print_exc from module.network.RequestFactory import getURL from module.plugins.Crypter import Crypter from module.plugins.Plugin import Fail -from module.plugins.internal.SimpleHoster import _error, replace_patterns, set_cookies +from module.plugins.internal.SimpleHoster import _error, _wait, replace_patterns, set_cookies from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.21" + __version__ = "0.22" __pattern__ = None __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -164,5 +164,10 @@ class SimpleCrypter(Crypter): self.package_links += self.getLinks() + #@TODO: Remove in 0.4.10 + def wait(self, seconds=0, reconnect=None): + return _wait(self, seconds, reconnect) + + def error(self, reason="", type="parse"): return _error(self, reason, type) -- cgit v1.2.3 From 8447df36b147bab1c3caa70aaa67732115ad735b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 16:03:14 +0100 Subject: [SimpleHoster] Improve wait method --- module/plugins/internal/SimpleHoster.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 9e270ff3d..c47a715f0 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -14,7 +14,7 @@ from module.utils import fixup, html_unescape, parseFileSize #@TODO: Remove in 0.4.10 and redirect to self.error instead -def _error(self, reason="", type=""): +def _error(self, reason, type): if not reason and not type: type = "unknown" @@ -27,6 +27,13 @@ def _error(self, reason="", type=""): raise Fail(msg) +#@TODO: Remove in 0.4.10 +def _wait(self, seconds, reconnect): + if seconds: + self.setWait(seconds, reconnect) + super(SimpleHoster, self).wait() + + def replace_patterns(string, ruleslist): for r in ruleslist: rf, rt = r @@ -159,7 +166,7 @@ def timestamp(): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "0.43" + __version__ = "0.44" __pattern__ = None @@ -341,10 +348,8 @@ class SimpleHoster(Hoster): #@TODO: Remove in 0.4.10 - def wait(self, seconds=False, reconnect=False): - if seconds: - self.setWait(seconds, reconnect) - super(SimpleHoster, self).wait() + def wait(self, seconds=0, reconnect=None): + return _wait(self, seconds, reconnect) def error(self, reason="", type="parse"): -- cgit v1.2.3 From 8b3589dd394d81177bf4680dddb5bdb9506b89ea Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 16:04:10 +0100 Subject: Update plugins to last changes --- module/plugins/internal/XFSPHoster.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 5452b9444..9e14fffbc 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -229,8 +229,8 @@ class XFSPHoster(SimpleHoster): elif 'premium' in self.errmsg and 'require' in self.errmsg: self.fail(_("File can be downloaded by premium users only")) elif 'limit' in self.errmsg: - self.wantReconnect = True - self.retry(25, 1 * 60 * 60, "Download limit exceeded") + self.wait(1 * 60 * 60, True) + self.retry(25, reason="Download limit exceeded") elif 'countdown' in self.errmsg or 'Expired' in self.errmsg: self.retry(reason=_("Link expired")) elif 'maintenance' in self.errmsg or 'maintainance' in self.errmsg: @@ -275,7 +275,7 @@ class XFSPHoster(SimpleHoster): if not self.premium: m = re.search(self.WAIT_PATTERN, self.html) if m: - wait_time = int(m.group(1)) + 1 + wait_time = int(m.group(1)) self.setWait(wait_time, False) else: wait_time = 0 -- cgit v1.2.3 From 34984dae733c3f3d47b41a0acfba3724d53c65a1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 16:52:10 +0100 Subject: Code cosmetics: plugin class attributes --- module/plugins/internal/AbstractExtractor.py | 6 +++--- module/plugins/internal/CaptchaService.py | 24 ++++++++++++------------ module/plugins/internal/UnRar.py | 6 +++--- module/plugins/internal/UnZip.py | 6 +++--- 4 files changed, 21 insertions(+), 21 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/AbstractExtractor.py b/module/plugins/internal/AbstractExtractor.py index 8282e6ff5..8a69ebb56 100644 --- a/module/plugins/internal/AbstractExtractor.py +++ b/module/plugins/internal/AbstractExtractor.py @@ -13,12 +13,12 @@ class WrongPassword(Exception): class AbtractExtractor: - __name__ = "AbtractExtractor" + __name__ = "AbtractExtractor" __version__ = "0.1" __description__ = """Abtract extractor plugin""" - __license__ = "GPLv3" - __authors__ = [("pyLoad Team", "admin@pyload.org")] + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] @staticmethod diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index aa8758344..2143e23df 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -6,12 +6,12 @@ from random import random class CaptchaService: - __name__ = "CaptchaService" + __name__ = "CaptchaService" __version__ = "0.14" __description__ = """Base captcha service plugin""" - __license__ = "GPLv3" - __authors__ = [("pyLoad Team", "admin@pyload.org")] + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] KEY_PATTERN = None @@ -51,12 +51,12 @@ class CaptchaService: class ReCaptcha(CaptchaService): - __name__ = "ReCaptcha" + __name__ = "ReCaptcha" __version__ = "0.07" __description__ = """ReCaptcha captcha service plugin""" - __license__ = "GPLv3" - __authors__ = [("pyLoad Team", "admin@pyload.org")] + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] KEY_PATTERN = r'recaptcha(/api|\.net)/(challenge|noscript)\?k=(?P[\w-]+)' @@ -110,12 +110,12 @@ class ReCaptcha(CaptchaService): class AdsCaptcha(CaptchaService): - __name__ = "AdsCaptcha" + __name__ = "AdsCaptcha" __version__ = "0.04" __description__ = """AdsCaptcha captcha service plugin""" - __license__ = "GPLv3" - __authors__ = [("pyLoad Team", "admin@pyload.org")] + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] ID_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(?P\d+)' @@ -172,12 +172,12 @@ class AdsCaptcha(CaptchaService): class SolveMedia(CaptchaService): - __name__ = "SolveMedia" + __name__ = "SolveMedia" __version__ = "0.05" __description__ = """SolveMedia captcha service plugin""" - __license__ = "GPLv3" - __authors__ = [("pyLoad Team", "admin@pyload.org")] + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P.+?)["\']' diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index d8bb6f251..12bd84d20 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -21,12 +21,12 @@ def renice(pid, value): class UnRar(AbtractExtractor): - __name__ = "UnRar" + __name__ = "UnRar" __version__ = "0.18" __description__ = """Rar extractor plugin""" - __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org")] + __license__ = "GPLv3" + __authors__ = [("RaNaN", "RaNaN@pyload.org")] CMD = "unrar" diff --git a/module/plugins/internal/UnZip.py b/module/plugins/internal/UnZip.py index ec493bcd8..e754141a1 100644 --- a/module/plugins/internal/UnZip.py +++ b/module/plugins/internal/UnZip.py @@ -7,12 +7,12 @@ from module.plugins.internal.AbstractExtractor import AbtractExtractor class UnZip(AbtractExtractor): - __name__ = "UnZip" + __name__ = "UnZip" __version__ = "0.1" __description__ = """Zip extractor plugin""" - __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org")] + __license__ = "GPLv3" + __authors__ = [("RaNaN", "RaNaN@pyload.org")] @staticmethod -- cgit v1.2.3 From 227a0eb5157875e75a385118ec3485b044ccdb8a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 21:55:21 +0100 Subject: Improve loadAccountInfo stuff --- module/plugins/internal/XFSPAccount.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 5f15a4659..db8f92aec 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -12,7 +12,7 @@ from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.20" + __version__ = "0.21" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -27,7 +27,7 @@ class XFSPAccount(Account): example: HOSTER_URL = r'linestorage.com' PREMIUM_PATTERN: (optional) Checks if the account is premium - example: PREMIUM_PATTERN = r'>Renew premium<' + example: PREMIUM_PATTERN = r'>Renew premium' """ HOSTER_NAME = None @@ -74,7 +74,6 @@ class XFSPAccount(Account): else: if validuntil > mktime(gmtime()): premium = True - trafficleft = -1 else: if premium is False: #: registered account type (not premium) validuntil = -1 -- cgit v1.2.3 From 86e0fc7bfdb22f944b772e69c92bf7938d9a3117 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 30 Oct 2014 17:22:30 +0100 Subject: [XFSPHoster] Partially rewritten Now with ddl support --- module/plugins/internal/XFSPHoster.py | 107 +++++++++------------------------- 1 file changed, 28 insertions(+), 79 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py index 9e14fffbc..72a4a9d8c 100644 --- a/module/plugins/internal/XFSPHoster.py +++ b/module/plugins/internal/XFSPHoster.py @@ -4,10 +4,7 @@ import re from pycurl import FOLLOWLOCATION, LOW_SPEED_TIME from random import random -from urllib import unquote -from urlparse import urlparse -from module.network.RequestFactory import getURL from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia from module.plugins.internal.SimpleHoster import create_getInfo, replace_patterns, set_cookies, SimpleHoster from module.plugins.Plugin import Fail @@ -17,7 +14,7 @@ from module.utils import html_unescape class XFSPHoster(SimpleHoster): __name__ = "XFSPHoster" __type__ = "hoster" - __version__ = "0.06" + __version__ = "0.07" __pattern__ = None @@ -68,80 +65,47 @@ class XFSPHoster(SimpleHoster): pattern = r'(https?://(www\.)?([^/]*?%s|\d+\.\d+\.\d+\.\d+)(\:\d+)?(/d/|(/files)?/\d+/\w+/).+?)["\'<]' self.LINK_PATTERN = pattern % self.HOSTER_NAME - if isinstance(self.COOKIES, list): - set_cookies(self.req.cj, self.COOKIES) - self.captcha = None self.errmsg = None self.passwords = self.getPassword().splitlines() - url = self.pyfile.url = replace_patterns(self.pyfile.url, self.FILE_URL_REPLACEMENTS) - self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) - + return super(XFSPHoster, self).prepare() - def process(self, pyfile): - self.prepare() - - if not re.match(self.__pattern__, pyfile.url): - if self.premium: - self.handleOverriden() - else: - self.fail(_("Only premium users can download from other hosters with %s") % self.HOSTER_NAME) - else: - try: - self.file_info = self.getFileInfo() - except Fail: - self.file_info = None - - self.location = self.getDirectDownloadLink() - - if not self.file_info: - pyfile.name = html_unescape(unquote(urlparse( - self.location if self.location else pyfile.url).path.split("/")[-1])) - - if self.location: - self.startDownload(self.location) - elif self.premium: - self.logDebug("Handle as premium download") - self.handlePremium() - else: - self.logDebug("Handle as free download") - self.handleFree() + def handleFree(self): + link = self.getDownloadLink() - def getDirectDownloadLink(self): - """ Get download link for premium users with direct download enabled """ - self.req.http.lastURL = self.pyfile.url + if link: + if self.captcha: + self.correctCaptcha() - self.req.http.c.setopt(FOLLOWLOCATION, 0) - self.html = self.load(self.pyfile.url, decode=True) - self.header = self.req.http.header - self.req.http.c.setopt(FOLLOWLOCATION, 1) + self.download(link, ref=True, cookies=True, disposition=True) - location = None - m = re.search(r"Location\s*:\s*(.*)", self.header, re.I) - if m and re.match(self.LINK_PATTERN, m.group(1)): - location = m.group(1).strip() + elif self.errmsg and "captcha" in self.errmsg: + self.error(_("No valid captcha code entered")) - return location + else: + self.error(_("Download link not found")) - def handleFree(self): - url = self.getDownloadLink() - self.startDownload(url) + def handlePremium(self): + return self.handleFree() def getDownloadLink(self): for i in xrange(5): self.logDebug("Getting download link: #%d" % i) + data = self.getPostParameters() self.req.http.c.setopt(FOLLOWLOCATION, 0) + self.html = self.load(self.pyfile.url, post=data, ref=True, decode=True) self.header = self.req.http.header + self.req.http.c.setopt(FOLLOWLOCATION, 1) - m = re.search(r"Location\s*:\s*(.*)", self.header, re.I) + m = re.search(r"Location\s*:\s*(.+)", self.header, re.I) if m: break @@ -149,23 +113,10 @@ class XFSPHoster(SimpleHoster): if m: break - else: - if self.errmsg and 'captcha' in self.errmsg: - self.fail(_("No valid captcha code entered")) - else: - self.fail(_("Download link not found")) - return m.group(1) - def handlePremium(self): - self.html = self.load(self.pyfile.url, post=self.getPostParameters()) - m = re.search(self.LINK_PATTERN, self.html) - if m is None: - self.error(_("LINK_PATTERN not found")) - self.startDownload(m.group(1)) - - + #@TODO: Re-enable def handleOverriden(self): #only tested with easybytez.com self.html = self.load("http://www.%s/" % self.HOSTER_NAME) @@ -199,21 +150,13 @@ class XFSPHoster(SimpleHoster): self.pyfile.url = m.group(1) - header = self.load(self.pyfile.url, just_header=True) + header = self.load(self.pyfile.url, just_header=True, decode=True) if 'location' in header: # Direct link - self.startDownload(header['location']) + self.download(header['location'], ref=True, cookies=True, disposition=True) else: self.retry(reason=_("OVR link location not found")) - def startDownload(self, link): - link = link.strip() - if self.captcha: - self.correctCaptcha() - self.logDebug("DIRECT LINK: %s" % link) - self.download(link, disposition=True) - - def checkErrors(self): m = re.search(self.ERROR_PATTERN, self.html) if m: @@ -224,22 +167,28 @@ class XFSPHoster(SimpleHoster): wait_time = sum([int(v) * {"hour": 3600, "minute": 60, "second": 1}[u] for v, u in re.findall(r'(\d+)\s*(hour|minute|second)', self.errmsg)]) self.wait(wait_time, True) + elif 'captcha' in self.errmsg: self.invalidCaptcha() + elif 'premium' in self.errmsg and 'require' in self.errmsg: self.fail(_("File can be downloaded by premium users only")) + elif 'limit' in self.errmsg: self.wait(1 * 60 * 60, True) self.retry(25, reason="Download limit exceeded") + elif 'countdown' in self.errmsg or 'Expired' in self.errmsg: self.retry(reason=_("Link expired")) + elif 'maintenance' in self.errmsg or 'maintainance' in self.errmsg: self.tempOffline() + elif 'download files up to' in self.errmsg: self.fail(_("File too large for free download")) + else: self.fail(self.errmsg) - else: self.errmsg = None -- cgit v1.2.3 From 71be42ba4635ef49c1cc7690be8805f00bc35e3c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 30 Oct 2014 17:23:18 +0100 Subject: [XFSPAccount] Fix and improve loadAccountInfo --- module/plugins/internal/XFSPAccount.py | 43 ++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index db8f92aec..381e919e6 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -12,7 +12,7 @@ from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies class XFSPAccount(Account): __name__ = "XFSPAccount" __type__ = "account" - __version__ = "0.21" + __version__ = "0.22" __description__ = """XFileSharingPro account plugin""" __license__ = "GPLv3" @@ -34,9 +34,9 @@ class XFSPAccount(Account): COOKIES = [(HOSTER_NAME, "lang", "english")] #: or list of tuples [(domain, name, value)] - VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(\d{2} [\w^_]+ \d{4})' + VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(\d{1,2} [\w^_]+ \d{4})' - TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+)\s*(?:(?P[\w^_]+)\s*)?' + TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+|[Uu]nlimited)\s*(?:(?P[\w^_]+)\s*)?' TRAFFIC_LEFT_UNIT = "MB" #: used only if no group was found LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' @@ -48,6 +48,9 @@ class XFSPAccount(Account): def init(self): + # if not self.HOSTER_NAME: + # self.fail(_("Missing HOSTER_NAME")) + if not hasattr(self, "HOSTER_URL"): self.HOSTER_URL = "http://www.%s/" % self.HOSTER_NAME.replace("www.", "", 1) @@ -79,22 +82,26 @@ class XFSPAccount(Account): validuntil = -1 premium = False - try: - traffic = re.search(self.TRAFFIC_LEFT_PATTERN, html).groupdict() - if "Unlimited" in traffic['S']: - trafficleft = -1 - if premium is None: - premium = True - else: - if 'U' in traffic: - unit = traffic['U'] - elif isinstance(self.TRAFFIC_LEFT_UNIT, basestring): - unit = self.TRAFFIC_LEFT_UNIT + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + if m: + try: + traffic = m.groupdict() + if "nlimited" in traffic['S']: + trafficleft = -1 + if premium is None: + premium = True else: - unit = None - trafficleft = self.parseTraffic(traffic['S'], unit) - except: - pass + if 'U' in traffic: + unit = traffic['U'] + elif isinstance(self.TRAFFIC_LEFT_UNIT, basestring): + unit = self.TRAFFIC_LEFT_UNIT + else: + unit = "" + + trafficleft = self.parseTraffic(traffic['S'] + unit) + + except Exception, e: + self.logDebug(str(e)) return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium or False} -- cgit v1.2.3 From fe64575ff079037d0db827e9067d5a5f6dffb1dd Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 30 Oct 2014 17:24:09 +0100 Subject: [SimpleCrypter] Fix cookies support --- module/plugins/internal/SimpleCrypter.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 1f41a7e5a..e586580d7 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -4,7 +4,6 @@ import re from traceback import print_exc -from module.network.RequestFactory import getURL from module.plugins.Crypter import Crypter from module.plugins.Plugin import Fail from module.plugins.internal.SimpleHoster import _error, _wait, replace_patterns, set_cookies @@ -14,7 +13,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.22" + __version__ = "0.23" __pattern__ = None __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -94,7 +93,7 @@ class SimpleCrypter(Crypter): set_cookies(self.req.cj, self.COOKIES) self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) - self.html = getURL(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) + self.html = self.load(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) def decrypt(self, pyfile): -- cgit v1.2.3 From 56ff5aff808975456163c027c670844baeebc2a8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 30 Oct 2014 17:16:09 +0100 Subject: [SimpleHoster] Fix checkTrafficLeft, ddl routine and cookies support --- module/plugins/internal/SimpleHoster.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index c47a715f0..de21f4d3c 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -166,7 +166,7 @@ def timestamp(): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "0.44" + __version__ = "0.45" __pattern__ = None @@ -233,19 +233,20 @@ class SimpleHoster(Hoster): self.req.setOption("timeout", 120) self.pyfile.url = replace_patterns(self.pyfile.url, self.FILE_URL_REPLACEMENTS) - self.html = getURL(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) - - - def process(self, pyfile): - self.prepare() if self.CHECK_DIRECT_DOWNLOAD and self.premium: - header = self.load(self.pyfile.url, just_header=True) + header = self.load(self.pyfile.url, just_header=True, decode=True) if 'location' in header: self.logDebug("Direct download link detected") self.download(header['location'], ref=True, cookies=True, disposition=True) return + self.html = self.load(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) + + + def process(self, pyfile): + self.prepare() + premium_only = hasattr(self, 'PREMIUM_ONLY_PATTERN') and re.search(self.PREMIUM_ONLY_PATTERN, self.html) if not premium_only: #: Usually premium only pages doesn't show the file information self.getFileInfo() @@ -340,11 +341,15 @@ class SimpleHoster(Hoster): def checkTrafficLeft(self): traffic = self.account.getAccountInfo(self.user, True)['trafficleft'] - if traffic == -1: + + if traffic is None: + return False + elif traffic == -1: return True - size = self.pyfile.size / 1024 - self.logInfo(_("Filesize: %i KiB, Traffic left for user %s: %i KiB") % (size, self.user, traffic)) - return size <= traffic + else: + size = self.pyfile.size / 1024 + self.logInfo(_("Filesize: %i KiB, Traffic left for user %s: %i KiB") % (size, self.user, traffic)) + return size <= traffic #@TODO: Remove in 0.4.10 -- cgit v1.2.3 From 7d21001f0495102a2948912d5416dbd3362dc446 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 1 Nov 2014 18:50:11 +0100 Subject: [SimpleCrypter] Move TEXT_ENCODING check to prepare routine --- module/plugins/internal/SimpleCrypter.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index e586580d7..86e8077e7 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -13,7 +13,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.23" + __version__ = "0.24" __pattern__ = None __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -93,8 +93,12 @@ class SimpleCrypter(Crypter): set_cookies(self.req.cj, self.COOKIES) self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) + self.html = self.load(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) + if isinstance(self.TEXT_ENCODING, basestring): + self.html = unicode(self.html, self.TEXT_ENCODING) + def decrypt(self, pyfile): self.prepare() @@ -130,9 +134,6 @@ class SimpleCrypter(Crypter): def getPackageNameAndFolder(self): - if isinstance(self.TEXT_ENCODING, basestring): - self.html = unicode(self.html, self.TEXT_ENCODING) - if hasattr(self, 'TITLE_PATTERN'): try: m = re.search(self.TITLE_PATTERN, self.html) -- cgit v1.2.3 From 011c308fdce25df396824ea97c2bf634b976c8d8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 1 Nov 2014 18:51:19 +0100 Subject: [SimpleHoster] Fix and improve ddl detection, parseFileInfo and getInfo --- module/plugins/internal/SimpleHoster.py | 122 +++++++++++++++++++++----------- 1 file changed, 80 insertions(+), 42 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index de21f4d3c..e601759cf 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -90,27 +90,30 @@ def parseHtmlForm(attr_str, html, input_names=None): def parseFileInfo(self, url="", html=""): - info = {"name": url, "size": 0, "status": 3} - - if hasattr(self, "pyfile"): + if not url and hasattr(self, "pyfile"): url = self.pyfile.url - if hasattr(self, "req") and self.req.http.code == '404': - info['status'] = 1 - else: - if not html and hasattr(self, "html"): - html = self.html - if isinstance(self.TEXT_ENCODING, basestring): - html = unicode(html, self.TEXT_ENCODING) - if hasattr(self, "html"): - self.html = html + info = {"name": url, "size": 0, "status": 3} + if not html: + if url: + return tuple(create_getInfo(self)([url])) + elif hasattr(self, "html"): + if hasattr(self, "req") and self.req.http.code == '404': + info['status'] = 1 + else: + html = self.html + + if html: if hasattr(self, "OFFLINE_PATTERN") and re.search(self.OFFLINE_PATTERN, html): info['status'] = 1 + elif hasattr(self, "FILE_OFFLINE_PATTERN") and re.search(self.FILE_OFFLINE_PATTERN, html): #@TODO: Remove in 0.4.10 info['status'] = 1 + elif hasattr(self, "TEMP_OFFLINE_PATTERN") and re.search(self.TEMP_OFFLINE_PATTERN, html): info['status'] = 6 + else: online = False try: @@ -128,18 +131,23 @@ def parseFileInfo(self, url="", html=""): if online: # File online, return name and size info['status'] = 2 + if 'N' in info: info['name'] = replace_patterns(info['N'].strip(), self.FILE_NAME_REPLACEMENTS) + if 'S' in info: size = replace_patterns(info['S'] + info['U'] if 'U' in info else info['S'], self.FILE_SIZE_REPLACEMENTS) info['size'] = parseFileSize(size) + elif isinstance(info['size'], basestring): unit = info['units'] if 'units' in info else None info['size'] = parseFileSize(info['size'], unit) - if hasattr(self, "file_info"): - self.file_info = info + if not hasattr(self, "file_info"): + self.file_info = {} + + self.file_info.update(info) return info['name'], info['size'], info['status'], url @@ -148,13 +156,23 @@ def create_getInfo(plugin): def getInfo(urls): for url in urls: - cj = CookieJar(plugin.__name__) - if isinstance(plugin.COOKIES, list): + if hasattr(plugin, "COOKIES") and isinstance(plugin.COOKIES, list): + cj = CookieJar(plugin.__name__) set_cookies(cj, plugin.COOKIES) + else: + cj = None - file_info = parseFileInfo(plugin, url, getURL(replace_patterns(url, plugin.FILE_URL_REPLACEMENTS), - decode=not plugin.TEXT_ENCODING, cookies=cj)) - yield file_info + if hasattr(plugin, "FILE_URL_REPLACEMENTS"): + url = replace_patterns(url, plugin.FILE_URL_REPLACEMENTS) + + if hasattr(plugin, "TEXT_ENCODING"): + html = getURL(url, cookies=bool(cj), decode=not plugin.TEXT_ENCODING) + if isinstance(plugin.TEXT_ENCODING, basestring): + html = unicode(html, plugin.TEXT_ENCODING) + else: + html = getURL(url, cookies=bool(cj), decode=True) + + yield parseFileInfo(plugin, url, html) return getInfo @@ -166,7 +184,7 @@ def timestamp(): class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "0.45" + __version__ = "0.46" __pattern__ = None @@ -215,11 +233,10 @@ class SimpleHoster(Hoster): COOKIES = True #: or False or list of tuples [(domain, name, value)] FORCE_CHECK_TRAFFIC = False #: Set to True to force checking traffic left for premium account - CHECK_DIRECT_DOWNLOAD = True #: Search for a direct download link in the page header (premium only) - def init(self): self.file_info = {} + self.html = "" #@TODO: Remove in 0.4.10 def setup(self): @@ -234,31 +251,53 @@ class SimpleHoster(Hoster): self.pyfile.url = replace_patterns(self.pyfile.url, self.FILE_URL_REPLACEMENTS) - if self.CHECK_DIRECT_DOWNLOAD and self.premium: - header = self.load(self.pyfile.url, just_header=True, decode=True) - if 'location' in header: - self.logDebug("Direct download link detected") - self.download(header['location'], ref=True, cookies=True, disposition=True) - return + if self.premium: + direct_link = self.getDirectLink(self.pyfile.url) + if direct_link: + return direct_link self.html = self.load(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) + if isinstance(self.TEXT_ENCODING, basestring): + self.html = unicode(self.html, self.TEXT_ENCODING) + def process(self, pyfile): - self.prepare() + direct_link = self.prepare() - premium_only = hasattr(self, 'PREMIUM_ONLY_PATTERN') and re.search(self.PREMIUM_ONLY_PATTERN, self.html) - if not premium_only: #: Usually premium only pages doesn't show the file information - self.getFileInfo() + if isinstance(direct_link, basestring): + self.download(direct_link, ref=True, cookies=True, disposition=True) + + elif self.html is None: + self.fail(_("Attribute html should never be set to None")) - if self.premium and (not self.FORCE_CHECK_TRAFFIC or self.checkTrafficLeft()): - self.logDebug("Handle as premium download") - self.handlePremium() - elif premium_only: - self.fail(_("This link require a premium account")) else: - self.logDebug("Handle as free download") - self.handleFree() + premium_only = hasattr(self, 'PREMIUM_ONLY_PATTERN') and re.search(self.PREMIUM_ONLY_PATTERN, self.html) + if not premium_only and 'status' not in self.file_info: #: Usually premium only pages doesn't show the file information + self.getFileInfo() + + if self.premium and (not self.FORCE_CHECK_TRAFFIC or self.checkTrafficLeft()): + self.logDebug("Handled as premium download") + self.handlePremium() + elif premium_only: + self.fail(_("Link require a premium account to be handled")) + else: + self.logDebug("Handled as free download") + self.handleFree() + + + def getDirectLink(self, url): + self.req.http.c.setopt(FOLLOWLOCATION, 0) + + html = self.load(url, ref=True, decode=True) + + self.req.http.c.setopt(FOLLOWLOCATION, 1) + + if parseFileInfo(self, url, html)[2] != 2: + try + return re.search(r"Location\s*:\s*(.+)", self.req.http.header, re.I).group(1) + except: + pass def getFileInfo(self): @@ -271,8 +310,7 @@ class SimpleHoster(Hoster): elif status == 6: self.tempOffline() elif status != 2: - self.logDebug(self.file_info) - self.error(_("File info")) + self.error(_("File info: %s") % self.file_info) if name: self.pyfile.name = name @@ -284,7 +322,7 @@ class SimpleHoster(Hoster): else: self.logError(_("File size not parsed")) - self.logDebug("FILE NAME: %s FILE SIZE: %s" % (self.pyfile.name, self.pyfile.size)) + self.logDebug("FILE NAME: %s" % self.pyfile.name, "FILE SIZE: %d" % self.pyfile.size) return self.file_info -- cgit v1.2.3 From 11fcb4ebb1d3f38e8a49f316308520ebcf8cf658 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 1 Nov 2014 22:20:06 +0100 Subject: [SimpleHoster] Fix typo --- module/plugins/internal/SimpleHoster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index e601759cf..1d85dc01b 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -294,7 +294,7 @@ class SimpleHoster(Hoster): self.req.http.c.setopt(FOLLOWLOCATION, 1) if parseFileInfo(self, url, html)[2] != 2: - try + try: return re.search(r"Location\s*:\s*(.+)", self.req.http.header, re.I).group(1) except: pass -- cgit v1.2.3 From 7e759ef2d5dbb30da9752b72146bf4ff240821a8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 2 Nov 2014 22:34:38 +0100 Subject: Update internal XFS plugins --- module/plugins/internal/XFSAccount.py | 127 ++++++++++++++ module/plugins/internal/XFSCrypter.py | 29 ++++ module/plugins/internal/XFSHoster.py | 299 +++++++++++++++++++++++++++++++++ module/plugins/internal/XFSPAccount.py | 127 -------------- module/plugins/internal/XFSPCrypter.py | 28 --- module/plugins/internal/XFSPHoster.py | 297 -------------------------------- 6 files changed, 455 insertions(+), 452 deletions(-) create mode 100644 module/plugins/internal/XFSAccount.py create mode 100644 module/plugins/internal/XFSCrypter.py create mode 100644 module/plugins/internal/XFSHoster.py delete mode 100644 module/plugins/internal/XFSPAccount.py delete mode 100644 module/plugins/internal/XFSPCrypter.py delete mode 100644 module/plugins/internal/XFSPHoster.py (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/XFSAccount.py b/module/plugins/internal/XFSAccount.py new file mode 100644 index 000000000..597964d4c --- /dev/null +++ b/module/plugins/internal/XFSAccount.py @@ -0,0 +1,127 @@ +# -*- coding: utf-8 -*- + +import re + +from urlparse import urljoin +from time import gmtime, mktime, strptime + +from module.plugins.Account import Account +from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies + + +class XFSAccount(Account): + __name__ = "XFSAccount" + __type__ = "account" + __version__ = "0.23" + + __description__ = """XFileSharing account plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + """ + Following patterns should be defined by each hoster: + + HOSTER_URL: (optional) + example: HOSTER_URL = r'linestorage.com' + + PREMIUM_PATTERN: (optional) Checks if the account is premium + example: PREMIUM_PATTERN = r'>Renew premium' + """ + + HOSTER_DOMAIN = None + + COOKIES = [(HOSTER_DOMAIN, "lang", "english")] #: or list of tuples [(domain, name, value)] + + VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(\d{1,2} [\w^_]+ \d{4})' + + TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+|[Uu]nlimited)\s*(?:(?P[\w^_]+)\s*)?' + TRAFFIC_LEFT_UNIT = "MB" #: used only if no group was found + + LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' + + + def __init__(self, manager, accounts): #@TODO: remove in 0.4.10 + self.init() + return super(XFSAccount, self).__init__(manager, accounts) + + + def init(self): + # if not self.HOSTER_DOMAIN: + # self.fail(_("Missing HOSTER_DOMAIN")) + + if not hasattr(self, "HOSTER_URL"): + self.HOSTER_URL = "http://www.%s/" % self.HOSTER_DOMAIN.replace("www.", "", 1) + + + def loadAccountInfo(self, user, req): + html = req.load(self.HOSTER_URL, get={'op': "my_account"}, decode=True) + + validuntil = None + trafficleft = None + premium = None + + if hasattr(self, "PREMIUM_PATTERN"): + premium = True if re.search(self.PREMIUM_PATTERN, html) else False + + m = re.search(self.VALID_UNTIL_PATTERN, html) + if m: + expiredate = m.group(1).strip() + self.logDebug("Expire date: " + expiredate) + + try: + validuntil = mktime(strptime(expiredate, "%d %B %Y")) + except Exception, e: + self.logError(str(e)) + else: + if validuntil > mktime(gmtime()): + premium = True + else: + if premium is False: #: registered account type (not premium) + validuntil = -1 + premium = False + + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + if m: + try: + traffic = m.groupdict() + if "nlimited" in traffic['S']: + trafficleft = -1 + if premium is None: + premium = True + else: + if 'U' in traffic: + unit = traffic['U'] + elif isinstance(self.TRAFFIC_LEFT_UNIT, basestring): + unit = self.TRAFFIC_LEFT_UNIT + else: + unit = "" + + trafficleft = self.parseTraffic(traffic['S'] + unit) + + except Exception, e: + self.logDebug(str(e)) + + return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium or False} + + + def login(self, user, data, req): + if isinstance(self.COOKIES, list): + set_cookies(req.cj, self.COOKIES) + + url = urljoin(self.HOSTER_URL, "login.html") + html = req.load(url, decode=True) + + action, inputs = parseHtmlForm('name="FL"', html) + if not inputs: + inputs = {'op': "login", + 'redirect': self.HOSTER_URL} + + inputs.update({'login': user, + 'password': data['password']}) + + html = req.load(self.HOSTER_URL, post=inputs, decode=True) + + if re.search(self.LOGIN_FAIL_PATTERN, html): + self.wrongPassword() diff --git a/module/plugins/internal/XFSCrypter.py b/module/plugins/internal/XFSCrypter.py new file mode 100644 index 000000000..5a126707b --- /dev/null +++ b/module/plugins/internal/XFSCrypter.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.SimpleCrypter import SimpleCrypter + + +class XFSCrypter(SimpleCrypter): + __name__ = "XFSCrypter" + __type__ = "crypter" + __version__ = "0.03" + + __pattern__ = None + + __description__ = """XFileSharing decrypter plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = None + HOSTER_NAME = None + + URL_REPLACEMENTS = [(r'[?/&]+$', r''), (r'(.+/[^?]*)$', r'\1?'), (r'$', r'&per_page=10000')] + + COOKIES = [(HOSTER_DOMAIN, "lang", "english")] + + LINK_PATTERN = r'<(?:td|TD) [^>]*>\s*]*>.+?(?:)?\s*' + NAME_PATTERN = r'<[tT]itle>.*?\: (.+) folder' + + OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed)' + TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)' diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py new file mode 100644 index 000000000..b7a407a19 --- /dev/null +++ b/module/plugins/internal/XFSHoster.py @@ -0,0 +1,299 @@ +# -*- coding: utf-8 -*- + +import re + +from pycurl import FOLLOWLOCATION, LOW_SPEED_TIME +from random import random + +from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia +from module.plugins.internal.SimpleHoster import create_getInfo, replace_patterns, set_cookies, SimpleHoster +from module.plugins.Plugin import Fail +from module.utils import html_unescape + + +class XFSHoster(SimpleHoster): + __name__ = "XFSHoster" + __type__ = "hoster" + __version__ = "0.08" + + __pattern__ = None + + __description__ = """XFileSharing hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = None + HOSTER_NAME = None + + COOKIES = [(HOSTER_DOMAIN, "lang", "english")] + + INFO_PATTERN = r'Filename:(?P[^<]+)\s*.*?\((?P[^<]+)\)' + NAME_PATTERN = r'[\d\.\,]+) ?(?P[\w^_]+)?\)' + + OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed)' + TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)' + + WAIT_PATTERN = r'.*?>(\d+)' + + OVR_LINK_PATTERN = r'

Download Link

\s*]*>([^<]+)' + LINK_PATTERN = None #: final download url pattern + + CAPTCHA_PATTERN = r'(http://[^"\']+?/captchas?/[^"\']+)' + CAPTCHA_DIV_PATTERN = r'>Enter code.*?(.+?)' + RECAPTCHA_PATTERN = None + SOLVEMEDIA_PATTERN = None + + ERROR_PATTERN = r'(?:class=["\']err["\'][^>]*>|<[Cc]enter>)(.+?)(?:["\']|", " ", self.errmsg)) + + if 'wait' in self.errmsg: + wait_time = sum([int(v) * {"hour": 3600, "minute": 60, "second": 1}[u] for v, u in + re.findall(r'(\d+)\s*(hour|minute|second)', self.errmsg)]) + self.wait(wait_time, True) + + elif 'captcha' in self.errmsg: + self.invalidCaptcha() + + elif 'premium' in self.errmsg and 'require' in self.errmsg: + self.fail(_("File can be downloaded by premium users only")) + + elif 'limit' in self.errmsg: + self.wait(1 * 60 * 60, True) + self.retry(25, reason="Download limit exceeded") + + elif 'countdown' in self.errmsg or 'Expired' in self.errmsg: + self.retry(reason=_("Link expired")) + + elif 'maintenance' in self.errmsg or 'maintainance' in self.errmsg: + self.tempOffline() + + elif 'download files up to' in self.errmsg: + self.fail(_("File too large for free download")) + + else: + self.fail(self.errmsg) + else: + self.errmsg = None + + return self.errmsg + + + def getPostParameters(self): + for _i in xrange(3): + self.checkErrors() + + if hasattr(self, "FORM_PATTERN"): + action, inputs = self.parseHtmlForm(self.FORM_PATTERN) + else: + action, inputs = self.parseHtmlForm(input_names={"op": re.compile("^download")}) + + if not inputs: + action, inputs = self.parseHtmlForm('F1') + if not inputs: + if self.errmsg: + self.retry(reason=self.errmsg) + else: + self.error(_("Form not found")) + + self.logDebug(inputs) + + if 'op' in inputs and inputs['op'] in ("download2", "download3"): + if "password" in inputs: + if self.passwords: + inputs['password'] = self.passwords.pop(0) + else: + self.fail(_("No or invalid passport")) + + if not self.premium: + m = re.search(self.WAIT_PATTERN, self.html) + if m: + wait_time = int(m.group(1)) + self.setWait(wait_time, False) + else: + wait_time = 0 + + self.captcha = self.handleCaptcha(inputs) + + if wait_time: + self.wait() + + self.errmsg = None + return inputs + + else: + inputs['referer'] = self.pyfile.url + + if self.premium: + inputs['method_premium'] = "Premium Download" + if 'method_free' in inputs: + del inputs['method_free'] + else: + inputs['method_free'] = "Free Download" + if 'method_premium' in inputs: + del inputs['method_premium'] + + self.html = self.load(self.pyfile.url, post=inputs, ref=True) + self.errmsg = None + + else: + self.error(_("FORM: %s") % (inputs['op'] if 'op' in inputs else _("UNKNOWN"))) + + + def handleCaptcha(self, inputs): + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m: + captcha_url = m.group(1) + inputs['code'] = self.decryptCaptcha(captcha_url) + return 1 + + m = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.S) + if m: + captcha_div = m.group(1) + self.logDebug(captcha_div) + numerals = re.findall(r'(\d)', html_unescape(captcha_div)) + inputs['code'] = "".join([a[1] for a in sorted(numerals, key=lambda num: int(num[0]))]) + self.logDebug("Captcha code: %s" % inputs['code'], numerals) + return 2 + + recaptcha = ReCaptcha(self) + try: + captcha_key = re.search(self.RECAPTCHA_PATTERN, self.html).group(1) + except: + captcha_key = recaptcha.detect_key() + + if captcha_key: + self.logDebug("ReCaptcha key: %s" % captcha_key) + inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key) + return 3 + + solvemedia = SolveMedia(self) + try: + captcha_key = re.search(self.SOLVEMEDIA_PATTERN, self.html).group(1) + except: + captcha_key = solvemedia.detect_key() + + if captcha_key: + self.logDebug("SolveMedia key: %s" % captcha_key) + inputs['adcopy_challenge'], inputs['adcopy_response'] = solvemedia.challenge(captcha_key) + return 4 + + return 0 diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py deleted file mode 100644 index 381e919e6..000000000 --- a/module/plugins/internal/XFSPAccount.py +++ /dev/null @@ -1,127 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from urlparse import urljoin -from time import gmtime, mktime, strptime - -from module.plugins.Account import Account -from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies - - -class XFSPAccount(Account): - __name__ = "XFSPAccount" - __type__ = "account" - __version__ = "0.22" - - __description__ = """XFileSharingPro account plugin""" - __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com")] - - - """ - Following patterns should be defined by each hoster: - - HOSTER_URL: (optional) - example: HOSTER_URL = r'linestorage.com' - - PREMIUM_PATTERN: (optional) Checks if the account is premium - example: PREMIUM_PATTERN = r'>Renew premium' - """ - - HOSTER_NAME = None - - COOKIES = [(HOSTER_NAME, "lang", "english")] #: or list of tuples [(domain, name, value)] - - VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(\d{1,2} [\w^_]+ \d{4})' - - TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?\s*(?P[\d.,]+|[Uu]nlimited)\s*(?:(?P[\w^_]+)\s*)?' - TRAFFIC_LEFT_UNIT = "MB" #: used only if no group was found - - LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' - - - def __init__(self, manager, accounts): #@TODO: remove in 0.4.10 - self.init() - return super(XFSPAccount, self).__init__(manager, accounts) - - - def init(self): - # if not self.HOSTER_NAME: - # self.fail(_("Missing HOSTER_NAME")) - - if not hasattr(self, "HOSTER_URL"): - self.HOSTER_URL = "http://www.%s/" % self.HOSTER_NAME.replace("www.", "", 1) - - - def loadAccountInfo(self, user, req): - html = req.load(self.HOSTER_URL, get={'op': "my_account"}, decode=True) - - validuntil = None - trafficleft = None - premium = None - - if hasattr(self, "PREMIUM_PATTERN"): - premium = True if re.search(self.PREMIUM_PATTERN, html) else False - - m = re.search(self.VALID_UNTIL_PATTERN, html) - if m: - expiredate = m.group(1).strip() - self.logDebug("Expire date: " + expiredate) - - try: - validuntil = mktime(strptime(expiredate, "%d %B %Y")) - except Exception, e: - self.logError(str(e)) - else: - if validuntil > mktime(gmtime()): - premium = True - else: - if premium is False: #: registered account type (not premium) - validuntil = -1 - premium = False - - m = re.search(self.TRAFFIC_LEFT_PATTERN, html) - if m: - try: - traffic = m.groupdict() - if "nlimited" in traffic['S']: - trafficleft = -1 - if premium is None: - premium = True - else: - if 'U' in traffic: - unit = traffic['U'] - elif isinstance(self.TRAFFIC_LEFT_UNIT, basestring): - unit = self.TRAFFIC_LEFT_UNIT - else: - unit = "" - - trafficleft = self.parseTraffic(traffic['S'] + unit) - - except Exception, e: - self.logDebug(str(e)) - - return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium or False} - - - def login(self, user, data, req): - if isinstance(self.COOKIES, list): - set_cookies(req.cj, self.COOKIES) - - url = urljoin(self.HOSTER_URL, "login.html") - html = req.load(url, decode=True) - - action, inputs = parseHtmlForm('name="FL"', html) - if not inputs: - inputs = {'op': "login", - 'redirect': self.HOSTER_URL} - - inputs.update({'login': user, - 'password': data['password']}) - - html = req.load(self.HOSTER_URL, post=inputs, decode=True) - - if re.search(self.LOGIN_FAIL_PATTERN, html): - self.wrongPassword() diff --git a/module/plugins/internal/XFSPCrypter.py b/module/plugins/internal/XFSPCrypter.py deleted file mode 100644 index 378b78d02..000000000 --- a/module/plugins/internal/XFSPCrypter.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.internal.SimpleCrypter import SimpleCrypter - - -class XFSPCrypter(SimpleCrypter): - __name__ = "XFSPCrypter" - __type__ = "crypter" - __version__ = "0.02" - - __pattern__ = None - - __description__ = """XFileSharingPro decrypter plugin""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - - - HOSTER_NAME = None - - URL_REPLACEMENTS = [(r'[?/&]+$', r''), (r'(.+/[^?]*)$', r'\1?'), (r'$', r'&per_page=10000')] - - COOKIES = [(HOSTER_NAME, "lang", "english")] - - LINK_PATTERN = r'<(?:td|TD) [^>]*>\s*]*>.+?(?:)?\s*' - TITLE_PATTERN = r'<[tT]itle>.*?\: (.+) folder' - - OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed)' - TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)' diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py deleted file mode 100644 index 72a4a9d8c..000000000 --- a/module/plugins/internal/XFSPHoster.py +++ /dev/null @@ -1,297 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from pycurl import FOLLOWLOCATION, LOW_SPEED_TIME -from random import random - -from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia -from module.plugins.internal.SimpleHoster import create_getInfo, replace_patterns, set_cookies, SimpleHoster -from module.plugins.Plugin import Fail -from module.utils import html_unescape - - -class XFSPHoster(SimpleHoster): - __name__ = "XFSPHoster" - __type__ = "hoster" - __version__ = "0.07" - - __pattern__ = None - - __description__ = """XFileSharingPro hoster plugin""" - __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), - ("stickell", "l.stickell@yahoo.it"), - ("Walter Purcaro", "vuolter@gmail.com")] - - - HOSTER_NAME = None - - FILE_URL_REPLACEMENTS = [] - - COOKIES = [(HOSTER_NAME, "lang", "english")] - - FILE_INFO_PATTERN = r'Filename:(?P[^<]+)\s*.*?\((?P[^<]+)\)' - FILE_NAME_PATTERN = r'[\d\.\,]+) ?(?P[\w^_]+)?\)' - - OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed)' - TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)' - - WAIT_PATTERN = r'.*?>(\d+)' - - OVR_LINK_PATTERN = r'

Download Link

\s*]*>([^<]+)' - LINK_PATTERN = None #: final download url pattern - - CAPTCHA_PATTERN = r'(http://[^"\']+?/captchas?/[^"\']+)' - CAPTCHA_DIV_PATTERN = r'>Enter code.*?(.+?)' - RECAPTCHA_PATTERN = None - SOLVEMEDIA_PATTERN = None - - ERROR_PATTERN = r'(?:class=["\']err["\'][^>]*>|<[Cc]enter>)(.+?)(?:["\']|", " ", self.errmsg)) - - if 'wait' in self.errmsg: - wait_time = sum([int(v) * {"hour": 3600, "minute": 60, "second": 1}[u] for v, u in - re.findall(r'(\d+)\s*(hour|minute|second)', self.errmsg)]) - self.wait(wait_time, True) - - elif 'captcha' in self.errmsg: - self.invalidCaptcha() - - elif 'premium' in self.errmsg and 'require' in self.errmsg: - self.fail(_("File can be downloaded by premium users only")) - - elif 'limit' in self.errmsg: - self.wait(1 * 60 * 60, True) - self.retry(25, reason="Download limit exceeded") - - elif 'countdown' in self.errmsg or 'Expired' in self.errmsg: - self.retry(reason=_("Link expired")) - - elif 'maintenance' in self.errmsg or 'maintainance' in self.errmsg: - self.tempOffline() - - elif 'download files up to' in self.errmsg: - self.fail(_("File too large for free download")) - - else: - self.fail(self.errmsg) - else: - self.errmsg = None - - return self.errmsg - - - def getPostParameters(self): - for _i in xrange(3): - self.checkErrors() - - if hasattr(self, "FORM_PATTERN"): - action, inputs = self.parseHtmlForm(self.FORM_PATTERN) - else: - action, inputs = self.parseHtmlForm(input_names={"op": re.compile("^download")}) - - if not inputs: - action, inputs = self.parseHtmlForm('F1') - if not inputs: - if self.errmsg: - self.retry(reason=self.errmsg) - else: - self.error(_("Form not found")) - - self.logDebug(self.HOSTER_NAME, inputs) - - if 'op' in inputs and inputs['op'] in ("download2", "download3"): - if "password" in inputs: - if self.passwords: - inputs['password'] = self.passwords.pop(0) - else: - self.fail(_("No or invalid passport")) - - if not self.premium: - m = re.search(self.WAIT_PATTERN, self.html) - if m: - wait_time = int(m.group(1)) - self.setWait(wait_time, False) - else: - wait_time = 0 - - self.captcha = self.handleCaptcha(inputs) - - if wait_time: - self.wait() - - self.errmsg = None - return inputs - - else: - inputs['referer'] = self.pyfile.url - - if self.premium: - inputs['method_premium'] = "Premium Download" - if 'method_free' in inputs: - del inputs['method_free'] - else: - inputs['method_free'] = "Free Download" - if 'method_premium' in inputs: - del inputs['method_premium'] - - self.html = self.load(self.pyfile.url, post=inputs, ref=True) - self.errmsg = None - - else: - self.error(_("FORM: %s") % (inputs['op'] if 'op' in inputs else _("UNKNOWN"))) - - - def handleCaptcha(self, inputs): - m = re.search(self.CAPTCHA_PATTERN, self.html) - if m: - captcha_url = m.group(1) - inputs['code'] = self.decryptCaptcha(captcha_url) - return 1 - - m = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.S) - if m: - captcha_div = m.group(1) - self.logDebug(captcha_div) - numerals = re.findall(r'(\d)', html_unescape(captcha_div)) - inputs['code'] = "".join([a[1] for a in sorted(numerals, key=lambda num: int(num[0]))]) - self.logDebug("CAPTCHA", inputs['code'], numerals) - return 2 - - recaptcha = ReCaptcha(self) - try: - captcha_key = re.search(self.RECAPTCHA_PATTERN, self.html).group(1) - except: - captcha_key = recaptcha.detect_key() - - if captcha_key: - self.logDebug("ReCaptcha key: %s" % captcha_key) - inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key) - return 3 - - solvemedia = SolveMedia(self) - try: - captcha_key = re.search(self.SOLVEMEDIA_PATTERN, self.html).group(1) - except: - captcha_key = solvemedia.detect_key() - - if captcha_key: - self.logDebug("SolveMedia key: %s" % captcha_key) - inputs['adcopy_challenge'], inputs['adcopy_response'] = solvemedia.challenge(captcha_key) - return 4 - - return 0 -- cgit v1.2.3 From 4ec11afb741149ea86e6ba647862b461d54c747c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 2 Nov 2014 22:37:19 +0100 Subject: Update internal Simple plugins --- module/plugins/internal/SimpleCrypter.py | 18 +++++---- module/plugins/internal/SimpleHoster.py | 67 +++++++++++++++++++------------- 2 files changed, 50 insertions(+), 35 deletions(-) (limited to 'module/plugins/internal') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 86e8077e7..1690b50c2 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -32,8 +32,8 @@ class SimpleCrypter(Crypter): LINK_PATTERN: group(1) must be a download link or a regex to catch more links example: LINK_PATTERN = r'