diff options
| author | 2014-12-10 18:24:25 +0100 | |
|---|---|---|
| committer | 2014-12-10 18:24:25 +0100 | |
| commit | 10afb4ce9d155bdb05016b0661be3c4c3aa6b4f1 (patch) | |
| tree | 1590669c02be79d11a0a3b68bdce3d2cb29fe992 | |
| parent | Merge branch 'stable' into 0.4.10 (diff) | |
| download | pyload-10afb4ce9d155bdb05016b0661be3c4c3aa6b4f1.tar.xz | |
Fix previous merge
32 files changed, 202 insertions, 504 deletions
diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py deleted file mode 100644 index 965799e8e..000000000 --- a/module/plugins/internal/CaptchaService.py +++ /dev/null @@ -1,332 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from random import random - -from module.common.json_layer import json_loads - - -class CaptchaService: -    __name__    = "CaptchaService" -    __version__ = "0.16" - -    __description__ = """Base captcha service plugin""" -    __license__     = "GPLv3" -    __authors__     = [("pyLoad Team", "admin@pyload.org")] - - -    KEY_PATTERN = None - -    key = None  #: last key detected - - -    def __init__(self, plugin): -        self.plugin = plugin - - -    def detect_key(self, html=None): -        if not html: -            if hasattr(self.plugin, "html") and self.plugin.html: -                html = self.plugin.html -            else: -                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) - -        m = re.search(self.KEY_PATTERN, html) -        if m: -            self.key = m.group(1).strip() -            self.plugin.logDebug("%s key: %s" % (self.__name__, self.key)) -            return self.key -        else: -            self.plugin.logDebug("%s key not found" % self.__name__) -            return None - - -    def challenge(self, key=None): -        raise NotImplementedError - - -    def result(self, server, challenge): -        raise NotImplementedError - - -class ReCaptcha(CaptchaService): -    __name__    = "ReCaptcha" -    __version__ = "0.08" - -    __description__ = """ReCaptcha captcha service plugin""" -    __license__     = "GPLv3" -    __authors__     = [("pyLoad Team", "admin@pyload.org")] - - -    KEY_PATTERN      = r'recaptcha(?:/api|\.net)/(?:challenge|noscript)\?k=([\w-]+)' -    KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\']([\w-]+)' - - -    def detect_key(self, html=None): -        if not html: -            if hasattr(self.plugin, "html") and self.plugin.html: -                html = self.plugin.html -            else: -                errmsg = _("ReCaptcha html not found") -                self.plugin.fail(errmsg) -                raise TypeError(errmsg) - -        m = re.search(self.KEY_PATTERN, html) or re.search(self.KEY_AJAX_PATTERN, html) -        if m: -            self.key = m.group(1).strip() -            self.plugin.logDebug("ReCaptcha key: %s" % self.key) -            return self.key -        else: -            self.plugin.logDebug("ReCaptcha key not found") -            return None - - -    def challenge(self, key=None): -        if not key: -            if self.detect_key(): -                key = self.key -            else: -                errmsg = _("ReCaptcha key not found") -                self.plugin.fail(errmsg) -                raise TypeError(errmsg) - -        html = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}) -        try: -            challenge = re.search("challenge : '(.+?)',", html).group(1) -            server    = re.search("server : '(.+?)',", html).group(1) -        except: -            errmsg = _("ReCaptcha challenge pattern not found") -            self.plugin.fail(errmsg) -            raise ValueError(errmsg) - -        self.plugin.logDebug("ReCaptcha challenge: %s" % challenge) - -        return challenge, self.result(server, challenge) - - -    def result(self, server, challenge): -        result = self.plugin.decryptCaptcha("%simage" % server, -                                            get={'c': challenge}, -                                            cookies=True, -                                            forceUser=True, -                                            imgtype="jpg") - -        self.plugin.logDebug("ReCaptcha result: %s" % result) - -        return result - - -class AdsCaptcha(CaptchaService): -    __name__    = "AdsCaptcha" -    __version__ = "0.06" - -    __description__ = """AdsCaptcha captcha service plugin""" -    __license__     = "GPLv3" -    __authors__     = [("pyLoad Team", "admin@pyload.org")] - - -    CAPTCHAID_PATTERN  = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(\d+)' -    PUBLICKEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=([\w-]+)' - - -    def detect_key(self, html=None): -        if not html: -            if hasattr(self.plugin, "html") and self.plugin.html: -                html = self.plugin.html -            else: -                errmsg = _("AdsCaptcha html not found") -                self.plugin.fail(errmsg) -                raise TypeError(errmsg) - -        m = re.search(self.PUBLICKEY_PATTERN, html) -        n = re.search(self.CAPTCHAID_PATTERN, html) -        if m and n: -            self.key = (m.group(1).strip(), n.group(1).strip())  #: key is the tuple(PublicKey, CaptchaId) -            self.plugin.logDebug("AdsCaptcha key|id: %s | %s" % self.key) -            return self.key -        else: -            self.plugin.logDebug("AdsCaptcha key or id not found") -            return None - - -    def challenge(self, key=None): -        if not key: -            if self.detect_key(): -                key = self.key -            else: -                errmsg = _("AdsCaptcha key not found") -                self.plugin.fail(errmsg) -                raise TypeError(errmsg) - -        PublicKey, CaptchaId = key - -        html = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}) -        try: -            challenge = re.search("challenge: '(.+?)',", html).group(1) -            server    = re.search("server: '(.+?)',", html).group(1) -        except: -            errmsg = _("AdsCaptcha challenge pattern not found") -            self.plugin.fail(errmsg) -            raise ValueError(errmsg) - -        self.plugin.logDebug("AdsCaptcha challenge: %s" % challenge) - -        return challenge, self.result(server, challenge) - - -    def result(self, server, challenge): -        result = self.plugin.decryptCaptcha("%sChallenge.aspx" % server, -                                            get={'cid': challenge, 'dummy': random()}, -                                            cookies=True, -                                            imgtype="jpg") - -        self.plugin.logDebug("AdsCaptcha result: %s" % result) - -        return result - - -class SolveMedia(CaptchaService): -    __name__    = "SolveMedia" -    __version__ = "0.06" - -    __description__ = """SolveMedia captcha service plugin""" -    __license__     = "GPLv3" -    __authors__     = [("pyLoad Team", "admin@pyload.org")] - - -    KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(?:no)?script\?k=(.+?)["\']' - - -    def challenge(self, key=None): -        if not key: -            if self.detect_key(): -                key = self.key -            else: -                errmsg = _("SolveMedia key not found") -                self.plugin.fail(errmsg) -                raise TypeError(errmsg) - -        html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key}) -        try: -            challenge = re.search(r'<input type=hidden name="adcopy_challenge" id="adcopy_challenge" value="([^"]+)">', -                                  html).group(1) -            server    = "http://api.solvemedia.com/papi/media" -        except: -            errmsg = _("SolveMedia challenge pattern not found") -            self.plugin.fail(errmsg) -            raise ValueError(errmsg) - -        self.plugin.logDebug("SolveMedia challenge: %s" % challenge) - -        return challenge, self.result(server, challenge) - - -    def result(self, server, challenge): -        result = self.plugin.decryptCaptcha(server, get={'c': challenge}, imgtype="gif") - -        self.plugin.logDebug("SolveMedia result: %s" % result) - -        return result - - -class AdYouLike(CaptchaService): -    __name__    = "AdYouLike" -    __version__ = "0.02" - -    __description__ = """AdYouLike captcha service plugin""" -    __license__     = "GPLv3" -    __authors__     = [("Walter Purcaro", "vuolter@gmail.com")] - - -    AYL_PATTERN      = r'Adyoulike\.create\s*\((.+?)\)' -    CALLBACK_PATTERN = r'(Adyoulike\.g\._jsonp_\d+)' - - -    def detect_key(self, html=None): -        if not html: -            if hasattr(self.plugin, "html") and self.plugin.html: -                html = self.plugin.html -            else: -                errmsg = _("AdYouLike html not found") -                self.plugin.fail(errmsg) -                raise TypeError(errmsg) - -        m = re.search(self.AYL_PATTERN, html) -        n = re.search(self.CALLBACK_PATTERN, html) -        if m and n: -            self.key = (m.group(1).strip(), n.group(1).strip()) -            self.plugin.logDebug("AdYouLike ayl|callback: %s | %s" % self.key) -            return self.key   #: key is the tuple(ayl, callback) -        else: -            self.plugin.logDebug("AdYouLike ayl or callback not found") -            return None - - -    def challenge(self, key=None): -        if not key: -            if self.detect_key(): -                key = self.key -            else: -                errmsg = _("AdYouLike key not found") -                self.plugin.fail(errmsg) -                raise TypeError(errmsg) - -        ayl, callback = key - -        # {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, -        # "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}} -        ayl = json_loads(ayl) - -        html = self.plugin.req.load("http://api-ayl.appspot.com/challenge", -                                    get={'key'     : ayl['adyoulike']['key'], -                                         'env'     : ayl['all']['env'], -                                         'callback': callback}) -        try: -            challenge = json_loads(re.search(callback + r'\s*\((.+?)\)', html).group(1)) -        except: -            errmsg = _("AdYouLike challenge pattern not found") -            self.plugin.fail(errmsg) -            raise ValueError(errmsg) - -        self.plugin.logDebug("AdYouLike challenge: %s" % challenge) - -        return self.result(ayl, challenge) - - -    def result(self, server, challenge): -        # Adyoulike.g._jsonp_5579316662423138 -        # ({"translations":{"fr":{"instructions_visual":"Recopiez « Soonnight » ci-dessous :"}}, -        # "site_under":true,"clickable":true,"pixels":{"VIDEO_050":[],"DISPLAY":[],"VIDEO_000":[],"VIDEO_100":[], -        # "VIDEO_025":[],"VIDEO_075":[]},"medium_type":"image/adyoulike", -        # "iframes":{"big":"<iframe src=\"http://www.soonnight.com/campagn.html\" scrolling=\"no\" -        # height=\"250\" width=\"300\" frameborder=\"0\"></iframe>"},"shares":{},"id":256, -        # "token":"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1","formats":{"small":{"y":300,"x":0,"w":300,"h":60}, -        # "big":{"y":0,"x":0,"w":300,"h":250},"hover":{"y":440,"x":0,"w":300,"h":60}}, -        # "tid":"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) - -        if isinstance(server, basestring): -            server = json_loads(server) - -        if isinstance(challenge, basestring): -            challenge = json_loads(challenge) - -        try: -            instructions_visual = challenge['translations'][server['all']['lang']]['instructions_visual'] -            result = re.search(u'«(.+?)»', instructions_visual).group(1).strip() -        except: -            errmsg = _("AdYouLike result not found") -            self.plugin.fail(errmsg) -            raise ValueError(errmsg) - -        result = {'_ayl_captcha_engine' : "adyoulike", -                  '_ayl_env'            : server['all']['env'], -                  '_ayl_tid'            : challenge['tid'], -                  '_ayl_token_challenge': challenge['token'], -                  '_ayl_response'       : response} - -        self.plugin.logDebug("AdYouLike result: %s" % result) - -        return result diff --git a/pyload/plugins/addon/Checksum.py b/pyload/plugins/addon/Checksum.py index 11154ac0f..ce50d1b28 100644 --- a/pyload/plugins/addon/Checksum.py +++ b/pyload/plugins/addon/Checksum.py @@ -63,11 +63,6 @@ class Checksum(Addon):                 'default': r'^(?P<hash>[0-9A-Fa-f]+)\s+\*?(?P<name>.+)$'} -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def coreReady(self):          if not self.getConfig("check_checksum"):              self.logInfo(_("Checksum validation is disabled in plugin configuration")) diff --git a/pyload/plugins/addon/ClickAndLoad.py b/pyload/plugins/addon/ClickAndLoad.py index cad6e5c13..1f55b15dd 100644 --- a/pyload/plugins/addon/ClickAndLoad.py +++ b/pyload/plugins/addon/ClickAndLoad.py @@ -33,10 +33,14 @@ class ClickAndLoad(Addon):                         ("Walter Purcaro", "vuolter@gmail.com")] -    def coreReady(self): +    def setup(self):          self.interval = 300 +    def coreReady(self): +        self.initPeriodical() + +      def periodical(self):          webip   = "0.0.0.0" if self.getConfig("extern") else "127.0.0.1"          webport = self.config['webinterface']['port'] @@ -64,8 +68,7 @@ class ClickAndLoad(Addon):                  self.logDebug(e)          else: +            self.core.scheduler.removeJob(self.cb)              t = Thread(target=forward, args=[client, server])              t.setDaemon(True)              t.start() -            self.interval = -1 - diff --git a/pyload/plugins/addon/DeleteFinished.py b/pyload/plugins/addon/DeleteFinished.py index 6c2ba38d8..43908b9a3 100644 --- a/pyload/plugins/addon/DeleteFinished.py +++ b/pyload/plugins/addon/DeleteFinished.py @@ -9,8 +9,7 @@ class DeleteFinished(Addon):      __type__    = "addon"      __version__ = "1.11" -    __config__ = [("activated" , "bool", "Activated"                         , False  ), -                  ('interval'  , 'int' , 'Delete every (hours)'              , '72'   ), +    __config__ = [('interval'  , 'int' , 'Delete every (hours)'              , '72'   ),                    ('deloffline', 'bool', 'Delete packages with offline links', 'False')]      __description__ = """Automatically delete all finished packages from queue""" @@ -75,5 +74,6 @@ class DeleteFinished(Addon):      def setup(self): +        self.interval = 0          self.m = self.manager          self.removeEvent = self.m.removeEvent diff --git a/pyload/plugins/addon/DownloadScheduler.py b/pyload/plugins/addon/DownloadScheduler.py index ba7b14467..c1f1fca11 100644 --- a/pyload/plugins/addon/DownloadScheduler.py +++ b/pyload/plugins/addon/DownloadScheduler.py @@ -21,11 +21,6 @@ class DownloadScheduler(Addon):                         ("stickell", "l.stickell@yahoo.it")] -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def setup(self):          self.cb = None  #: callback to scheduler job; will be by removed AddonManager when addon unloaded diff --git a/pyload/plugins/addon/ExternalScripts.py b/pyload/plugins/addon/ExternalScripts.py index 1360e52de..af863abb0 100644 --- a/pyload/plugins/addon/ExternalScripts.py +++ b/pyload/plugins/addon/ExternalScripts.py @@ -29,11 +29,6 @@ class ExternalScripts(Addon):                    "allDownloadsFinished", "allDownloadsProcessed"] -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def setup(self):          self.scripts = {} diff --git a/pyload/plugins/addon/ExtractArchive.py b/pyload/plugins/addon/ExtractArchive.py index 938de0447..60b66740c 100644 --- a/pyload/plugins/addon/ExtractArchive.py +++ b/pyload/plugins/addon/ExtractArchive.py @@ -83,11 +83,6 @@ class ExtractArchive(Addon):      event_list = ["allDownloadsProcessed"] -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def setup(self):          self.plugins = []          self.passwords = [] diff --git a/pyload/plugins/addon/HotFolder.py b/pyload/plugins/addon/HotFolder.py index b16c02cf8..ff714d69e 100644 --- a/pyload/plugins/addon/HotFolder.py +++ b/pyload/plugins/addon/HotFolder.py @@ -31,6 +31,10 @@ class HotFolder(Addon):          self.interval = 10 +    def coreReady(self): +        self.initPeriodical() + +      def periodical(self):          folder = fs_encode(self.getConfig("folder")) diff --git a/pyload/plugins/addon/IRCInterface.py b/pyload/plugins/addon/IRCInterface.py index 5392b01a8..bba8f86d8 100644 --- a/pyload/plugins/addon/IRCInterface.py +++ b/pyload/plugins/addon/IRCInterface.py @@ -44,11 +44,6 @@ class IRCInterface(Thread, Addon):          self.setDaemon(True) -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def coreReady(self):          self.abort = False          self.more = [] diff --git a/pyload/plugins/addon/MergeFiles.py b/pyload/plugins/addon/MergeFiles.py index 2efc221dc..0c9b05283 100644 --- a/pyload/plugins/addon/MergeFiles.py +++ b/pyload/plugins/addon/MergeFiles.py @@ -26,13 +26,7 @@ class MergeFiles(Addon):      BUFFER_SIZE = 4096 -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def setup(self): -        # nothing to do          pass diff --git a/pyload/plugins/addon/MultiHome.py b/pyload/plugins/addon/MultiHome.py index bcb51254d..3450cab27 100644 --- a/pyload/plugins/addon/MultiHome.py +++ b/pyload/plugins/addon/MultiHome.py @@ -10,18 +10,13 @@ class MultiHome(Addon):      __type__    = "addon"      __version__ = "0.12" -    __config__ = [("interfaces", "str" , "Interfaces", "None")] +    __config__ = [("interfaces", "str", "Interfaces", "None")]      __description__ = """Ip address changer"""      __license__     = "GPLv3"      __authors__     = [("mkaay", "mkaay@mkaay.de")] -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def setup(self):          self.register = {}          self.interfaces = [] diff --git a/pyload/plugins/addon/RestartFailed.py b/pyload/plugins/addon/RestartFailed.py index 861223f3d..f8d9da9cc 100644 --- a/pyload/plugins/addon/RestartFailed.py +++ b/pyload/plugins/addon/RestartFailed.py @@ -38,7 +38,7 @@ class RestartFailed(Addon):      def setup(self): -        self.interval = self.MIN_INTERVAL +        self.interval = 0      def coreReady(self): diff --git a/module/plugins/hooks/RestartSlow.py b/pyload/plugins/addon/RestartSlow.py index 587799235..f3c98c461 100644 --- a/module/plugins/hooks/RestartSlow.py +++ b/pyload/plugins/addon/RestartSlow.py @@ -2,12 +2,12 @@  import pycurl -from module.plugins.Hook import Hook +from module.plugins.Addon import Addon -class RestartSlow(Hook): +class RestartSlow(Addon):      __name__    = "RestartSlow" -    __type__    = "hook" +    __type__    = "addon"      __version__ = "0.02"      __config__ = [("free_limit"   , "int" ,  "Transfer speed threshold in kilobytes"                     , 100 ), @@ -28,10 +28,6 @@ class RestartSlow(Hook):          self.info = {'chunk': {}} -    def initPeriodical(self): -        pass - -      def periodical(self):          if not self.pyfile.req.dl:              return @@ -58,4 +54,4 @@ class RestartSlow(Hook):          if self.cb or (self.getConfig("safe_mode") and not pyfile.plugin.resumeDownload):              return -        super(RestartSlow, self).initPeriodical() +        self.initPeriodical() diff --git a/pyload/plugins/addon/SkipRev.py b/pyload/plugins/addon/SkipRev.py index 66ddc89d2..cf716c509 100644 --- a/pyload/plugins/addon/SkipRev.py +++ b/pyload/plugins/addon/SkipRev.py @@ -19,11 +19,6 @@ class SkipRev(Adoon):      __authors__     = [("Walter Purcaro", "vuolter@gmail.com")] -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def _setup(self):          super(self.pyfile.plugin, self).setup()          if self.pyfile.hasStatus("skipped"): diff --git a/pyload/plugins/addon/UnSkipOnFail.py b/pyload/plugins/addon/UnSkipOnFail.py index a0b3ec540..aade5a91e 100644 --- a/pyload/plugins/addon/UnSkipOnFail.py +++ b/pyload/plugins/addon/UnSkipOnFail.py @@ -19,11 +19,6 @@ class UnSkipOnFail(Addon):      __authors__     = [("hagg", None)] -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def downloadFailed(self, pyfile):          pyfile_name = basename(pyfile.name)          pid = pyfile.package().id diff --git a/pyload/plugins/addon/UpdateManager.py b/pyload/plugins/addon/UpdateManager.py index 97fa4a399..577345d69 100644 --- a/pyload/plugins/addon/UpdateManager.py +++ b/pyload/plugins/addon/UpdateManager.py @@ -66,7 +66,7 @@ class UpdateManager(Addon):      def setup(self):          self.cb2      = None -        self.interval = self.MIN_INTERVAL +        self.interval = 0          self.updating = False          self.info     = {'pyload': False, 'version': None, 'plugins': False}          self.mtimes   = {}  #: store modification time for each plugin diff --git a/pyload/plugins/addon/WindowsPhoneToastNotify.py b/pyload/plugins/addon/WindowsPhoneToastNotify.py index fbaa89ea4..dc618d2d4 100644 --- a/pyload/plugins/addon/WindowsPhoneToastNotify.py +++ b/pyload/plugins/addon/WindowsPhoneToastNotify.py @@ -21,11 +21,6 @@ class WindowsPhoneToastNotify(Addon):      __authors__     = [("Andy Voigt", "phone-support@hotmail.de")] -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def getXmlData(self):          myxml = ("<?xml version='1.0' encoding='utf-8'?> <wp:Notification xmlns:wp='WPNotification'> "                   "<wp:Toast> <wp:Text1>Pyload Mobile</wp:Text1> <wp:Text2>Captcha waiting!</wp:Text2> " diff --git a/pyload/plugins/addon/XMPPInterface.py b/pyload/plugins/addon/XMPPInterface.py index 5bbff8915..7f91befd3 100644 --- a/pyload/plugins/addon/XMPPInterface.py +++ b/pyload/plugins/addon/XMPPInterface.py @@ -14,8 +14,7 @@ class XMPPInterface(IRCInterface, JabberClient):      __type__    = "addon"      __version__ = "0.11" -    __config__ = [("activated", "bool", "Activated"                           , False                                    ), -                  ("jid"      , "str" , "Jabber ID"                           , "user@exmaple-jabber-server.org"         ), +    __config__ = [("jid"      , "str" , "Jabber ID"                           , "user@exmaple-jabber-server.org"         ),                    ("pw"       , "str" , "Password"                            , ""                                       ),                    ("tls"      , "bool", "Use TLS"                             , False                                    ),                    ("owners"   , "str" , "List of JIDs accepting commands from", "me@icq-gateway.org;some@msn-gateway.org"), diff --git a/pyload/plugins/captcha/AdYouLike.py b/pyload/plugins/captcha/AdYouLike.py new file mode 100644 index 000000000..c129693da --- /dev/null +++ b/pyload/plugins/captcha/AdYouLike.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.plugins.internal.Captcha import Captcha +from pyload.utils import json_loads + + +class AdYouLike(Captcha): +    __name__    = "AdYouLike" +    __type__    = "captcha" +    __version__ = "0.02" + +    __description__ = """AdYouLike captcha service plugin""" +    __license__     = "GPLv3" +    __authors__     = [("Walter Purcaro", "vuolter@gmail.com")] + + +    AYL_PATTERN      = r'Adyoulike\.create\s*\((.+?)\)' +    CALLBACK_PATTERN = r'(Adyoulike\.g\._jsonp_\d+)' + + +    def detect_key(self, html=None): +        if not html: +            if hasattr(self.plugin, "html") and self.plugin.html: +                html = self.plugin.html +            else: +                errmsg = _("AdYouLike html not found") +                self.plugin.fail(errmsg) +                raise TypeError(errmsg) + +        m = re.search(self.AYL_PATTERN, html) +        n = re.search(self.CALLBACK_PATTERN, html) +        if m and n: +            self.key = (m.group(1).strip(), n.group(1).strip()) +            self.plugin.logDebug("AdYouLike ayl|callback: %s | %s" % self.key) +            return self.key   #: key is the tuple(ayl, callback) +        else: +            self.plugin.logDebug("AdYouLike ayl or callback not found") +            return None + + +    def challenge(self, key=None): +        if not key: +            if self.detect_key(): +                key = self.key +            else: +                errmsg = _("AdYouLike key not found") +                self.plugin.fail(errmsg) +                raise TypeError(errmsg) + +        ayl, callback = key + +        # {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, +        # "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}} +        ayl = json_loads(ayl) + +        html = self.plugin.req.load("http://api-ayl.appspot.com/challenge", +                                    get={'key'     : ayl['adyoulike']['key'], +                                         'env'     : ayl['all']['env'], +                                         'callback': callback}) +        try: +            challenge = json_loads(re.search(callback + r'\s*\((.+?)\)', html).group(1)) +        except: +            errmsg = _("AdYouLike challenge pattern not found") +            self.plugin.error(errmsg) +            raise ValueError(errmsg) + +        self.plugin.logDebug("AdYouLike challenge: %s" % challenge) + +        return self.result(ayl, challenge) + + +    def result(self, server, challenge): +        # Adyoulike.g._jsonp_5579316662423138 +        # ({"translations":{"fr":{"instructions_visual":"Recopiez « Soonnight » ci-dessous :"}}, +        # "site_under":true,"clickable":true,"pixels":{"VIDEO_050":[],"DISPLAY":[],"VIDEO_000":[],"VIDEO_100":[], +        # "VIDEO_025":[],"VIDEO_075":[]},"medium_type":"image/adyoulike", +        # "iframes":{"big":"<iframe src=\"http://www.soonnight.com/campagn.html\" scrolling=\"no\" +        # height=\"250\" width=\"300\" frameborder=\"0\"></iframe>"},"shares":{},"id":256, +        # "token":"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1","formats":{"small":{"y":300,"x":0,"w":300,"h":60}, +        # "big":{"y":0,"x":0,"w":300,"h":250},"hover":{"y":440,"x":0,"w":300,"h":60}}, +        # "tid":"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) + +        if isinstance(server, basestring): +            server = json_loads(server) + +        if isinstance(challenge, basestring): +            challenge = json_loads(challenge) + +        try: +            instructions_visual = challenge['translations'][server['all']['lang']]['instructions_visual'] +            result = re.search(u'«(.+?)»', instructions_visual).group(1).strip() +        except: +            errmsg = _("AdYouLike result not found") +            self.plugin.error(errmsg) +            raise ValueError(errmsg) + +        result = {'_ayl_captcha_engine' : "adyoulike", +                  '_ayl_env'            : server['all']['env'], +                  '_ayl_tid'            : challenge['tid'], +                  '_ayl_token_challenge': challenge['token'], +                  '_ayl_response'       : response} + +        self.plugin.logDebug("AdYouLike result: %s" % result) + +        return result diff --git a/pyload/plugins/captcha/AdsCaptcha.py b/pyload/plugins/captcha/AdsCaptcha.py index fe8fec29b..3f14ebdc0 100644 --- a/pyload/plugins/captcha/AdsCaptcha.py +++ b/pyload/plugins/captcha/AdsCaptcha.py @@ -10,15 +10,15 @@ from pyload.plugins.internal.Captcha import Captcha  class AdsCaptcha(Captcha):      __name__    = "AdsCaptcha"      __type__    = "captcha" -    __version__ = "0.05" +    __version__ = "0.06"      __description__ = """AdsCaptcha captcha service plugin"""      __license__     = "GPLv3"      __authors__     = [("pyLoad Team", "admin@pyload.org")] -    ID_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(?P<ID>\d+)' -    KEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=(?P<KEY>[\w-]+)' +    CAPTCHAID_PATTERN  = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(\d+)' +    PUBLICKEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=([\w-]+)'      def detect_key(self, html=None): @@ -27,45 +27,51 @@ class AdsCaptcha(Captcha):                  html = self.plugin.html              else:                  errmsg = _("AdsCaptcha html not found") -                self.plugin.error(errmsg) +                self.plugin.fail(errmsg)                  raise TypeError(errmsg) -        m = re.search(self.ID_PATTERN, html) -        n = re.search(self.KEY_PATTERN, html) +        m = re.search(self.PUBLICKEY_PATTERN, html) +        n = re.search(self.CAPTCHAID_PATTERN, html)          if m and n: -            self.key = (m.group("ID"), m.group("KEY")) -            self.plugin.logDebug("AdsCaptcha id|key: %s | %s" % self.key) +            self.key = (m.group(1).strip(), n.group(1).strip())  #: key is the tuple(PublicKey, CaptchaId) +            self.plugin.logDebug("AdsCaptcha key|id: %s | %s" % self.key)              return self.key          else: -            self.plugin.logDebug("AdsCaptcha id or key not found") +            self.plugin.logDebug("AdsCaptcha key or id not found")              return None -    def challenge(self, key=None):  #: key is a tuple(CaptchaId, PublicKey) +    def challenge(self, key=None):          if not key:              if self.detect_key():                  key = self.key              else:                  errmsg = _("AdsCaptcha key not found") -                self.plugin.error(errmsg) +                self.plugin.fail(errmsg)                  raise TypeError(errmsg) -        CaptchaId, PublicKey = key +        PublicKey, CaptchaId = key -        js = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}) +        html = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey})          try: -            challenge = re.search("challenge: '(.+?)',", js).group(1) -            server = re.search("server: '(.+?)',", js).group(1) -        except Exception: -            self.plugin.error(_("AdsCaptcha challenge pattern not found")) +            challenge = re.search("challenge: '(.+?)',", html).group(1) +            server    = re.search("server: '(.+?)',", html).group(1) +        except: +            errmsg = _("AdsCaptcha challenge pattern not found") +            self.plugin.error(errmsg) +            raise ValueError(errmsg) -        result = self.result(server, challenge) +        self.plugin.logDebug("AdsCaptcha challenge: %s" % challenge) -        self.plugin.logDebug("AdsCaptcha result: %s" % result, "challenge: %s" % challenge) - -        return challenge, result +        return challenge, self.result(server, challenge)      def result(self, server, challenge): -        return self.plugin.decryptCaptcha("%sChallenge.aspx" % server, get={'cid': challenge, 'dummy': random()}, -                                          cookies=True, imgtype="jpg") +        result = self.plugin.decryptCaptcha("%sChallenge.aspx" % server, +                                            get={'cid': challenge, 'dummy': random()}, +                                            cookies=True, +                                            imgtype="jpg") + +        self.plugin.logDebug("AdsCaptcha result: %s" % result) + +        return result diff --git a/pyload/plugins/captcha/ReCaptcha.py b/pyload/plugins/captcha/ReCaptcha.py index 8e4d8c27c..cce8bbb84 100644 --- a/pyload/plugins/captcha/ReCaptcha.py +++ b/pyload/plugins/captcha/ReCaptcha.py @@ -15,8 +15,8 @@ class ReCaptcha(Captcha):      __authors__     = [("pyLoad Team", "admin@pyload.org")] -    KEY_PATTERN = r'recaptcha(/api|\.net)/(challenge|noscript)\?k=(?P<KEY>[\w-]+)' -    KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\'](?P<KEY>[\w-]+)' +    KEY_PATTERN      = r'recaptcha(?:/api|\.net)/(?:challenge|noscript)\?k=([\w-]+)' +    KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\']([\w-]+)'      def detect_key(self, html=None): @@ -25,12 +25,12 @@ class ReCaptcha(Captcha):                  html = self.plugin.html              else:                  errmsg = _("ReCaptcha html not found") -                self.plugin.error(errmsg) +                self.plugin.fail(errmsg)                  raise TypeError(errmsg)          m = re.search(self.KEY_PATTERN, html) or re.search(self.KEY_AJAX_PATTERN, html)          if m: -            self.key = m.group("KEY") +            self.key = m.group(1).strip()              self.plugin.logDebug("ReCaptcha key: %s" % self.key)              return self.key          else: @@ -44,23 +44,30 @@ class ReCaptcha(Captcha):                  key = self.key              else:                  errmsg = _("ReCaptcha key not found") -                self.plugin.error(errmsg) +                self.plugin.fail(errmsg)                  raise TypeError(errmsg) -        js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}) +        html = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key})          try: -            challenge = re.search("challenge : '(.+?)',", js).group(1) -            server = re.search("server : '(.+?)',", js).group(1) -        except Exception: -            self.plugin.error(_("ReCaptcha challenge pattern not found")) +            challenge = re.search("challenge : '(.+?)',", html).group(1) +            server    = re.search("server : '(.+?)',", html).group(1) +        except: +            errmsg = _("ReCaptcha challenge pattern not found") +            self.plugin.error(errmsg) +            raise ValueError(errmsg) -        result = self.result(server, challenge) +        self.plugin.logDebug("ReCaptcha challenge: %s" % challenge) -        self.plugin.logDebug("ReCaptcha result: %s" % result, "challenge: %s" % challenge) - -        return challenge, result +        return challenge, self.result(server, challenge)      def result(self, server, challenge): -        return self.plugin.decryptCaptcha("%simage" % server, get={'c': challenge}, -                                          cookies=True, forceUser=True, imgtype="jpg") +        result = self.plugin.decryptCaptcha("%simage" % server, +                                            get={'c': challenge}, +                                            cookies=True, +                                            forceUser=True, +                                            imgtype="jpg") + +        self.plugin.logDebug("ReCaptcha result: %s" % result) + +        return result diff --git a/pyload/plugins/captcha/SolveMedia.py b/pyload/plugins/captcha/SolveMedia.py index 5d5f6ea9a..843aa35e0 100644 --- a/pyload/plugins/captcha/SolveMedia.py +++ b/pyload/plugins/captcha/SolveMedia.py @@ -15,7 +15,7 @@ class SolveMedia(Captcha):      __authors__     = [("pyLoad Team", "admin@pyload.org")] -    KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P<KEY>.+?)["\']' +    KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(?:no)?script\?k=(.+?)["\']'      def challenge(self, key=None): @@ -24,23 +24,27 @@ class SolveMedia(Captcha):                  key = self.key              else:                  errmsg = _("SolveMedia key not found") -                self.plugin.error(errmsg) +                self.plugin.fail(errmsg)                  raise TypeError(errmsg)          html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key})          try:              challenge = re.search(r'<input type=hidden name="adcopy_challenge" id="adcopy_challenge" value="([^"]+)">',                                    html).group(1) -            server = "http://api.solvemedia.com/papi/media" -        except Exception: -            self.plugin.error(_("SolveMedia challenge pattern not found")) +            server    = "http://api.solvemedia.com/papi/media" +        except: +            errmsg = _("SolveMedia challenge pattern not found") +            self.plugin.error(errmsg) +            raise ValueError(errmsg) -        result = self.result(server, challenge) +        self.plugin.logDebug("SolveMedia challenge: %s" % challenge) -        self.plugin.logDebug("SolveMedia result: %s" % result, "challenge: %s" % challenge) - -        return challenge, result +        return challenge, self.result(server, challenge)      def result(self, server, challenge): -        return self.plugin.decryptCaptcha(server, get={'c': challenge}, imgtype="gif") +        result = self.plugin.decryptCaptcha(server, get={'c': challenge}, imgtype="gif") + +        self.plugin.logDebug("SolveMedia result: %s" % result) + +        return result diff --git a/pyload/plugins/hook/BypassCaptcha.py b/pyload/plugins/hook/BypassCaptcha.py index b6e237b37..728abf6ed 100644 --- a/pyload/plugins/hook/BypassCaptcha.py +++ b/pyload/plugins/hook/BypassCaptcha.py @@ -47,11 +47,6 @@ class BypassCaptcha(Hook):      GETCREDITS_URL = "http://bypasscaptcha.com/ex_left.php" -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def getCredits(self):          res = getURL(self.GETCREDITS_URL, post={"key": self.getConfig("passkey")}) diff --git a/pyload/plugins/hook/Captcha9kw.py b/pyload/plugins/hook/Captcha9kw.py index ed1b27646..9f0f80c2d 100644 --- a/pyload/plugins/hook/Captcha9kw.py +++ b/pyload/plugins/hook/Captcha9kw.py @@ -39,11 +39,6 @@ class Captcha9kw(Hook):      API_URL = "http://www.9kw.eu/index.cgi" -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def coreReady(self):          if self.getConfig("ssl"):              self.API_URL = self.API_URL.replace("http://", "https://") diff --git a/pyload/plugins/hook/CaptchaBrotherhood.py b/pyload/plugins/hook/CaptchaBrotherhood.py index 1f3aebd85..355081630 100644 --- a/pyload/plugins/hook/CaptchaBrotherhood.py +++ b/pyload/plugins/hook/CaptchaBrotherhood.py @@ -53,11 +53,6 @@ class CaptchaBrotherhood(Hook):      API_URL = "http://www.captchabrotherhood.com/" -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def getCredits(self):          res = getURL(self.API_URL + "askCredits.aspx",                       get={"username": self.getConfig("username"), "password": self.getConfig("passkey")}) diff --git a/pyload/plugins/hook/DeathByCaptcha.py b/pyload/plugins/hook/DeathByCaptcha.py index dc737020c..c076bdcee 100644 --- a/pyload/plugins/hook/DeathByCaptcha.py +++ b/pyload/plugins/hook/DeathByCaptcha.py @@ -66,11 +66,6 @@ class DeathByCaptcha(Hook):      API_URL = "http://api.dbcapi.me/api/" -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def call_api(self, api="captcha", post=False, multipart=False):          req = getRequest()          req.c.setopt(HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) diff --git a/pyload/plugins/hook/ExpertDecoders.py b/pyload/plugins/hook/ExpertDecoders.py index dbd03c30c..c9da38fe9 100644 --- a/pyload/plugins/hook/ExpertDecoders.py +++ b/pyload/plugins/hook/ExpertDecoders.py @@ -28,11 +28,6 @@ class ExpertDecoders(Hook):      API_URL = "http://www.fasttypers.org/imagepost.ashx" -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def getCredits(self):          res = getURL(self.API_URL, post={"key": self.getConfig("passkey"), "action": "balance"}) diff --git a/pyload/plugins/hook/ImageTyperz.py b/pyload/plugins/hook/ImageTyperz.py index c0b046787..5e35a61e4 100644 --- a/pyload/plugins/hook/ImageTyperz.py +++ b/pyload/plugins/hook/ImageTyperz.py @@ -49,11 +49,6 @@ class ImageTyperz(Hook):      GETCREDITS_URL = "http://captchatypers.com/Forms/RequestBalance.ashx" -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def getCredits(self):          res = getURL(self.GETCREDITS_URL,                       post={'action': "REQUESTBALANCE", diff --git a/pyload/plugins/hook/LinkdecrypterCom.py b/pyload/plugins/hook/LinkdecrypterCom.py index 15697e0a2..e99d79b7f 100644 --- a/pyload/plugins/hook/LinkdecrypterCom.py +++ b/pyload/plugins/hook/LinkdecrypterCom.py @@ -17,11 +17,6 @@ class LinkdecrypterCom(Hook):      __authors__     = [("zoidberg", "zoidberg@mujmail.cz")] -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def coreReady(self):          try:              self.loadPatterns() diff --git a/pyload/plugins/hook/XFileSharingPro.py b/pyload/plugins/hook/XFileSharingPro.py index fc8c37127..17baed8b2 100644 --- a/pyload/plugins/hook/XFileSharingPro.py +++ b/pyload/plugins/hook/XFileSharingPro.py @@ -10,12 +10,12 @@ class XFileSharingPro(Hook):      __type__    = "hook"      __version__ = "0.26" -    __config__ = [("activated", "bool", "Activated", True), -                  ("use_hoster_list", "bool", "Load listed hosters only", True), -                  ("use_crypter_list", "bool", "Load listed crypters only", False), -                  ("use_builtin_list", "bool", "Load built-in plugin list", True), -                  ("hoster_list", "str", "Hoster list (comma separated)", ""), -                  ("crypter_list", "str", "Crypter list (comma separated)", "")] +    __config__ = [("activated"       , "bool", "Activated"                     , True ), +                  ("use_hoster_list" , "bool", "Load listed hosters only"      , True ), +                  ("use_crypter_list", "bool", "Load listed crypters only"     , False), +                  ("use_builtin_list", "bool", "Load built-in plugin list"     , True ), +                  ("hoster_list"     , "str" , "Hoster list (comma separated)" , ""   ), +                  ("crypter_list"    , "str" , "Crypter list (comma separated)", ""   )]      __description__ = """Load XFileSharingPro based hosters and crypter which don't need a own plugin to run"""      __license__     = "GPLv3" @@ -44,11 +44,6 @@ class XFileSharingPro(Hook):          # self.loadPattern() -    #@TODO: Remove in 0.4.10 -    def initPeriodical(self): -        pass - -      def coreReady(self):          self.loadPattern() diff --git a/pyload/plugins/internal/Addon.py b/pyload/plugins/internal/Addon.py index b126b97d6..ed5a72af8 100644 --- a/pyload/plugins/internal/Addon.py +++ b/pyload/plugins/internal/Addon.py @@ -52,7 +52,7 @@ class Addon(Base):          #: Callback of periodical job task, used by AddonManager          self.cb = None -        self.interval = -1  #: disabled +        self.interval = 60          #: `AddonManager`          self.manager = manager @@ -77,7 +77,7 @@ class Addon(Base):          self.setup() -        self.initPeriodical() +        # self.initPeriodical()      def initPeriodical(self, delay=0, threaded=False): diff --git a/pyload/plugins/internal/MultiHoster.py b/pyload/plugins/internal/MultiHoster.py index 4d466d350..44b2da565 100644 --- a/pyload/plugins/internal/MultiHoster.py +++ b/pyload/plugins/internal/MultiHoster.py @@ -16,8 +16,6 @@ class MultiHoster(Addon):      __authors__     = [("pyLoad Team", "admin@pyload.org")] -    interval = 12 * 60 * 60  #: reload hosters every 12h -      HOSTER_REPLACEMENTS = [("1fichier.com", "onefichier.com"), ("2shared.com", "twoshared.com"),                             ("4shared.com", "fourshared.com"), ("cloudnator.com", "shragle.com"),                             ("easy-share.com", "crocko.com"), ("freakshare.net", "freakshare.com"), @@ -29,6 +27,7 @@ class MultiHoster(Addon):      def setup(self): +        self.interval      = 12 * 60 * 60  #: reload hosters every 12h          self.hosters       = []          self.supported     = []          self.new_supported = [] @@ -105,10 +104,6 @@ class MultiHoster(Addon):              self.periodical() -    def initPeriodical(self): -        pass - -      def periodical(self):          """reload hoster list periodically"""          self.logInfo(_("Reloading supported hoster list"))  | 
