diff options
Diffstat (limited to 'module/plugins/internal')
-rw-r--r-- | module/plugins/internal/AbstractExtractor.py | 8 | ||||
-rw-r--r-- | module/plugins/internal/CaptchaService.py | 38 | ||||
-rw-r--r-- | module/plugins/internal/DeadCrypter.py | 5 | ||||
-rw-r--r-- | module/plugins/internal/DeadHoster.py | 7 | ||||
-rw-r--r-- | module/plugins/internal/MultiHoster.py | 31 | ||||
-rw-r--r-- | module/plugins/internal/SimpleCrypter.py | 76 | ||||
-rw-r--r-- | module/plugins/internal/SimpleHoster.py | 78 | ||||
-rw-r--r-- | module/plugins/internal/UnRar.py | 36 | ||||
-rw-r--r-- | module/plugins/internal/UnZip.py | 24 | ||||
-rw-r--r-- | module/plugins/internal/XFSPAccount.py | 37 |
10 files changed, 163 insertions, 177 deletions
diff --git a/module/plugins/internal/AbstractExtractor.py b/module/plugins/internal/AbstractExtractor.py index 0ecc11f06..d1d1a09cb 100644 --- a/module/plugins/internal/AbstractExtractor.py +++ b/module/plugins/internal/AbstractExtractor.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - class ArchiveError(Exception): pass @@ -14,9 +13,14 @@ class WrongPassword(Exception): class AbtractExtractor: - + __name__ = "AbtractExtractor" __version__ = "0.1" + __description__ = """Abtract extractor plugin""" + __author_name__ = "pyLoad Team" + __author_mail__ = "admin@pyload.org" + + @staticmethod def checkDeps(): """ Check if system statisfy dependencies diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 400484d26..b247ba654 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -1,45 +1,36 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. +import re - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. +from random import random - @author: zoidberg -""" -import re -from random import random +class CaptchaService: + __name__ = "CaptchaService" + __version__ = "0.05" + __description__ = """Captcha service plugin""" + __author_name__ = "pyLoad Team" + __author_mail__ = "admin@pyload.org" -class CaptchaService(): - __version__ = "0.04" def __init__(self, plugin): self.plugin = plugin -class ReCaptcha(): +class ReCaptcha: RECAPTCHA_KEY_PATTERN = r"https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P<key>\w+)" RECAPTCHA_KEY_AJAX_PATTERN = r"Recaptcha\.create\s*\(\s*[\"'](?P<key>\w+)[\"']\s*," recaptcha_key = None + def __init__(self, plugin): self.plugin = plugin def detect_key(self, html): m = re.search(self.RECAPTCHA_KEY_PATTERN, html) - if not m: + if m is None: m = re.search(self.RECAPTCHA_KEY_AJAX_PATTERN, html) if m: self.recaptcha_key = m.group('key') @@ -48,9 +39,9 @@ class ReCaptcha(): return None def challenge(self, key=None): - if not key and self.recaptcha_key: + if key is None and self.recaptcha_key: key = self.recaptcha_key - elif not (key or self.recaptcha_key): + else: raise TypeError("ReCaptcha key not found") js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={"k": key}, cookies=True) @@ -70,6 +61,7 @@ class ReCaptcha(): class AdsCaptcha(CaptchaService): + def challenge(self, src): js = self.plugin.req.load(src, cookies=True) @@ -88,8 +80,6 @@ class AdsCaptcha(CaptchaService): class SolveMedia(CaptchaService): - def __init__(self, plugin): - self.plugin = plugin def challenge(self, src): html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript?k=%s" % src, cookies=True) diff --git a/module/plugins/internal/DeadCrypter.py b/module/plugins/internal/DeadCrypter.py index 10eccb9bd..296de739d 100644 --- a/module/plugins/internal/DeadCrypter.py +++ b/module/plugins/internal/DeadCrypter.py @@ -6,11 +6,14 @@ from module.plugins.Crypter import Crypter as _Crypter class DeadCrypter(_Crypter): __name__ = "DeadCrypter" __type__ = "crypter" - __pattern__ = None __version__ = "0.01" + + __pattern__ = None + __description__ = """Crypter is no longer available""" __author_name__ = "stickell" __author_mail__ = "l.stickell@yahoo.it" + def setup(self): self.fail("Crypter is no longer available") diff --git a/module/plugins/internal/DeadHoster.py b/module/plugins/internal/DeadHoster.py index 201835e2b..35a948824 100644 --- a/module/plugins/internal/DeadHoster.py +++ b/module/plugins/internal/DeadHoster.py @@ -4,19 +4,24 @@ from module.plugins.Hoster import Hoster as _Hoster def create_getInfo(plugin): + def getInfo(urls): yield [('#N/A: ' + url, 0, 1, url) for url in urls] + return getInfo class DeadHoster(_Hoster): __name__ = "DeadHoster" __type__ = "hoster" - __pattern__ = None __version__ = "0.11" + + __pattern__ = None + __description__ = """Hoster is no longer available""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" + def setup(self): self.fail("Hoster is no longer available") diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index ec80116d6..6bcad293c 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -2,16 +2,18 @@ import re -from module.utils import remove_chars from module.plugins.Hook import Hook +from module.utils import remove_chars class MultiHoster(Hook): - """ - Generic MultiHoster plugin - """ + __name__ = "MultiHoster" + __type__ = "hook" + __version__ = "0.20" - __version__ = "0.20" + __description__ = """Generic MultiHoster plugin""" + __author_name__ = "pyLoad Team" + __author_mail__ = "admin@pyload.org" replacements = [("2shared.com", "twoshared.com"), ("4shared.com", "fourshared.com"), ("cloudnator.com", "shragle.com"), ("ifile.it", "filecloud.io"), ("easy-share.com", "crocko.com"), ("freakshare.net", "freakshare.com"), @@ -20,6 +22,7 @@ class MultiHoster(Hook): ignored = [] interval = 24 * 60 * 60 #: reload hosters daily + def setup(self): self.hosters = [] self.supported = [] @@ -139,8 +142,8 @@ class MultiHoster(Hook): self.logDebug("Overwritten Hosters: %s" % ", ".join(sorted(self.supported))) for hoster in self.supported: dict = self.core.pluginManager.hosterPlugins[hoster] - dict["new_module"] = module - dict["new_name"] = self.__name__ + dict['new_module'] = module + dict['new_name'] = self.__name__ if excludedList: self.logInfo("The following hosters were not overwritten - account exists: %s" % ", ".join(sorted(excludedList))) @@ -156,17 +159,17 @@ class MultiHoster(Hook): self.logDebug("Regexp: %s" % regexp) dict = self.core.pluginManager.hosterPlugins[self.__name__] - dict["pattern"] = regexp - dict["re"] = re.compile(regexp) + dict['pattern'] = regexp + dict['re'] = re.compile(regexp) def unloadHoster(self, hoster): dict = self.core.pluginManager.hosterPlugins[hoster] if "module" in dict: - del dict["module"] + del dict['module'] if "new_module" in dict: - del dict["new_module"] - del dict["new_name"] + del dict['new_module'] + del dict['new_name'] def unload(self): """Remove override for all hosters. Scheduler job is removed by hookmanager""" @@ -176,8 +179,8 @@ class MultiHoster(Hook): # reset pattern klass = getattr(self.core.pluginManager.getPlugin(self.__name__), self.__name__) dict = self.core.pluginManager.hosterPlugins[self.__name__] - dict["pattern"] = getattr(klass, '__pattern__', r"^unmatchable$") - dict["re"] = re.compile(dict["pattern"]) + 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""" diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index b1a18f5e0..0b99feb42 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -1,65 +1,68 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re from module.plugins.Crypter import Crypter +from module.plugins.internal.SimpleHoster import PluginParseError, replace_patterns, set_cookies from module.utils import html_unescape -from module.plugins.internal.SimpleHoster import replace_patterns class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" - __version__ = "0.07" - __pattern__ = None __type__ = "crypter" + __version__ = "0.10" + + __pattern__ = None + __description__ = """Simple decrypter plugin""" - __author_name__ = ("stickell", "zoidberg") - __author_mail__ = ("l.stickell@yahoo.it", "zoidberg@mujmail.cz") + __author_name__ = ("stickell", "zoidberg", "Walter Purcaro") + __author_mail__ = ("l.stickell@yahoo.it", "zoidberg@mujmail.cz", "vuolter@gmail.com") + """ - These patterns should be defined by each crypter: + Following patterns should be defined by each crypter: - LINK_PATTERN: group(1) must be a download link - example: <div class="link"><a href="(http://speedload.org/\w+) + LINK_PATTERN: group(1) must be a download link or a regex to catch more links + example: LINK_PATTERN = r'<div class="link"><a href="(http://speedload.org/\w+)' + + TITLE_PATTERN: (optional) The group defined by 'title' should be the title + example: TITLE_PATTERN = r'<title>Files of: (?P<title>[^<]+) folder</title>' + + OFFLINE_PATTERN: (optional) Checks if the file is yet available online + example: OFFLINE_PATTERN = r'File (deleted|not found)' + + TEMP_OFFLINE_PATTERN: (optional) Checks if the file is temporarily offline + example: TEMP_OFFLINE_PATTERN = r'Server maintainance' - TITLE_PATTERN: (optional) the group defined by 'title' should be the title - example: <title>Files of: (?P<title>[^<]+) folder</title> If it's impossible to extract the links using the LINK_PATTERN only you can override the getLinks method. If the links are disposed on multiple pages you need to define a pattern: - PAGES_PATTERN: the group defined by 'pages' must be the total number of pages + PAGES_PATTERN: The group defined by 'pages' must be the total number of pages + example: PAGES_PATTERN = r'Pages: (?P<pages>\d+)' and a function: - loadPage(self, page_n): - must return the html of the page number 'page_n' + loadPage(self, page_n): + return the html of the page number 'page_n' """ - FILE_URL_REPLACEMENTS = [] + URL_REPLACEMENTS = [] + + SH_COOKIES = True # or False or list of tuples [(domain, name, value)] + + + def setup(self): + if isinstance(self.SH_COOKIES, list): + set_cookies(self.req.cj, self.SH_COOKIES) def decrypt(self, pyfile): - pyfile.url = replace_patterns(pyfile.url, self.FILE_URL_REPLACEMENTS) + pyfile.url = replace_patterns(pyfile.url, self.URL_REPLACEMENTS) self.html = self.load(pyfile.url, decode=True) + self.checkOnline() + package_name, folder_name = self.getPackageNameAndFolder() self.package_links = self.getLinks() @@ -81,6 +84,12 @@ class SimpleCrypter(Crypter): """ return re.findall(self.LINK_PATTERN, self.html) + def checkOnline(self): + if hasattr(self, "OFFLINE_PATTERN") and re.search(self.OFFLINE_PATTERN, self.html): + self.offline() + elif hasattr(self, "TEMP_OFFLINE_PATTERN") and re.search(self.TEMP_OFFLINE_PATTERN, self.html): + self.tempOffline() + def getPackageNameAndFolder(self): if hasattr(self, 'TITLE_PATTERN'): m = re.search(self.TITLE_PATTERN, self.html) @@ -104,3 +113,6 @@ class SimpleCrypter(Crypter): for p in xrange(2, pages + 1): self.html = self.loadPage(p) self.package_links += self.getLinks() + + def parseError(self, msg): + raise PluginParseError(msg) diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index f10433e78..ec9cf1b70 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -1,29 +1,14 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" -from urlparse import urlparse import re + from time import time +from urlparse import urlparse -from module.plugins.Hoster import Hoster -from module.utils import html_unescape, fixup, parseFileSize -from module.network.RequestFactory import getURL 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 def replace_patterns(string, ruleslist): @@ -55,7 +40,7 @@ def parseHtmlForm(attr_str, html, input_names=None): name = parseHtmlTagAttrValue("name", inputtag.group(1)) if name: value = parseHtmlTagAttrValue("value", inputtag.group(1)) - if value is None: + if not value: inputs[name] = inputtag.group(3) or '' else: inputs[name] = value @@ -98,9 +83,12 @@ def parseFileInfo(self, url='', html=''): if hasattr(self, "html"): self.html = html - if hasattr(self, "FILE_OFFLINE_PATTERN") and re.search(self.FILE_OFFLINE_PATTERN, html): - # File offline + 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: @@ -136,6 +124,7 @@ def parseFileInfo(self, url='', html=''): def create_getInfo(plugin): + def getInfo(urls): for url in urls: cj = CookieJar(plugin.__name__) @@ -153,6 +142,7 @@ def timestamp(): class PluginParseError(Exception): + def __init__(self, msg): Exception.__init__(self) self.value = 'Parse error (%s) - plugin may be out of date' % msg @@ -163,31 +153,45 @@ class PluginParseError(Exception): class SimpleHoster(Hoster): __name__ = "SimpleHoster" - __version__ = "0.33" - __pattern__ = None __type__ = "hoster" + __version__ = "0.35" + + __pattern__ = None + __description__ = """Simple hoster plugin""" __author_name__ = ("zoidberg", "stickell") __author_mail__ = ("zoidberg@mujmail.cz", "l.stickell@yahoo.it") + """ - These patterns should be defined by each hoster: - FILE_INFO_PATTERN = r'(?P<N>file_name) (?P<S>file_size) (?P<U>units)' - or FILE_NAME_PATTERN = r'(?P<N>file_name)' - and FILE_SIZE_PATTERN = r'(?P<S>file_size) (?P<U>units)' - FILE_OFFLINE_PATTERN = r'File (deleted|not found)' - TEMP_OFFLINE_PATTERN = r'Server maintainance' - - You can also define a PREMIUM_ONLY_PATTERN to detect links that can be downloaded only with a premium account. + Following patterns should be defined by each hoster: + + FILE_INFO_PATTERN: Name and Size of the file + example: FILE_INFO_PATTERN = r'(?P<N>file_name) (?P<S>file_size) (?P<U>size_unit)' + or + FILE_NAME_PATTERN: Name that will be set for the file + example: FILE_NAME_PATTERN = r'(?P<N>file_name)' + FILE_SIZE_PATTERN: Size that will be checked for the file + example: FILE_SIZE_PATTERN = r'(?P<S>file_size) (?P<U>size_unit)' + + OFFLINE_PATTERN: 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 + example: TEMP_OFFLINE_PATTERN = r'Server maintainance' + + PREMIUM_ONLY_PATTERN: (optional) Checks if the file can be downloaded only with a premium account + example: PREMIUM_ONLY_PATTERN = r'Premium account required' """ - FILE_SIZE_REPLACEMENTS = [] FILE_NAME_REPLACEMENTS = [("&#?\w+;", fixup)] + FILE_SIZE_REPLACEMENTS = [] FILE_URL_REPLACEMENTS = [] SH_BROKEN_ENCODING = False # Set to True or encoding name if encoding in http header is not correct SH_COOKIES = True # or False or list of tuples [(domain, name, value)] SH_CHECK_TRAFFIC = False # True = force check traffic left for a premium account + def init(self): self.file_info = {} @@ -223,13 +227,13 @@ class SimpleHoster(Hoster): def getFileInfo(self): self.logDebug("URL: %s" % self.pyfile.url) - if hasattr(self, "TEMP_OFFLINE_PATTERN") and re.search(self.TEMP_OFFLINE_PATTERN, self.html): - self.tempOffline() name, size, status = parseFileInfo(self)[:3] if status == 1: self.offline() + elif status == 6: + self.tempOffline() elif status != 2: self.logDebug(self.file_info) self.parseError('File info') @@ -274,7 +278,7 @@ class SimpleHoster(Hoster): return parseHtmlForm(attr_str, self.html, input_names) def checkTrafficLeft(self): - traffic = self.account.getAccountInfo(self.user, True)["trafficleft"] + traffic = self.account.getAccountInfo(self.user, True)['trafficleft'] if traffic == -1: return True size = self.pyfile.size / 1024 diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index e3765602b..19c278735 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -1,37 +1,27 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: RaNaN -""" - import os import re -from os.path import join + from glob import glob -from subprocess import Popen, PIPE +from os.path import join from string import digits +from subprocess import Popen, PIPE -from module.utils import save_join, decode from module.plugins.internal.AbstractExtractor import AbtractExtractor, WrongPassword, ArchiveError, CRCError +from module.utils import save_join, decode class UnRar(AbtractExtractor): __name__ = "UnRar" __version__ = "0.16" + __description__ = """Rar extractor plugin""" + __author_name__ = "RaNaN" + __author_mail__ = "RaNaN@pyload.org" + + CMD = "unrar" + # there are some more uncovered rar formats re_version = re.compile(r"(UNRAR 5[\.\d]+(.*?)freeware)") re_splitfile = re.compile(r"(.*)\.part(\d+)\.rar$", re.I) @@ -39,7 +29,7 @@ class UnRar(AbtractExtractor): 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) - CMD = "unrar" + @staticmethod def checkDeps(): @@ -200,8 +190,8 @@ class UnRar(AbtractExtractor): args.append("-y") # set a password - if "password" in kwargs and kwargs["password"]: - args.append("-p%s" % kwargs["password"]) + if "password" in kwargs and kwargs['password']: + args.append("-p%s" % kwargs['password']) else: args.append("-p-") diff --git a/module/plugins/internal/UnZip.py b/module/plugins/internal/UnZip.py index 501962442..e339434f9 100644 --- a/module/plugins/internal/UnZip.py +++ b/module/plugins/internal/UnZip.py @@ -1,24 +1,7 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: RaNaN -""" - -import zipfile import sys +import zipfile from module.plugins.internal.AbstractExtractor import AbtractExtractor @@ -27,6 +10,11 @@ class UnZip(AbtractExtractor): __name__ = "UnZip" __version__ = "0.1" + __description__ = """Zip extractor plugin""" + __author_name__ = "RaNaN" + __author_mail__ = "RaNaN@pyload.org" + + @staticmethod def checkDeps(): return sys.version_info[:2] >= (2, 6) diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py index 76aff54f0..5c0bfc893 100644 --- a/module/plugins/internal/XFSPAccount.py +++ b/module/plugins/internal/XFSPAccount.py @@ -1,24 +1,9 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re + from time import mktime, strptime + from module.plugins.Account import Account from module.plugins.internal.SimpleHoster import parseHtmlForm from module.utils import parseFileSize @@ -26,8 +11,9 @@ from module.utils import parseFileSize class XFSPAccount(Account): __name__ = "XFSPAccount" - __version__ = "0.06" __type__ = "account" + __version__ = "0.06" + __description__ = """XFileSharingPro base account plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" @@ -39,25 +25,26 @@ class XFSPAccount(Account): LOGIN_FAIL_PATTERN = r'Incorrect Login or Password|>Error<' PREMIUM_PATTERN = r'>Renew premium<' + def loadAccountInfo(self, user, req): html = req.load(self.MAIN_PAGE + "?op=my_account", decode=True) validuntil = trafficleft = None premium = True if re.search(self.PREMIUM_PATTERN, html) else False - found = re.search(self.VALID_UNTIL_PATTERN, html) - if found: + m = re.search(self.VALID_UNTIL_PATTERN, html) + if m: premium = True trafficleft = -1 try: - self.logDebug(found.group(1)) - validuntil = mktime(strptime(found.group(1), "%d %B %Y")) + self.logDebug(m.group(1)) + validuntil = mktime(strptime(m.group(1), "%d %B %Y")) except Exception, e: self.logError(e) else: - found = re.search(self.TRAFFIC_LEFT_PATTERN, html) - if found: - trafficleft = found.group(1) + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + if m: + trafficleft = m.group(1) if "Unlimited" in trafficleft: premium = True else: |