diff options
Diffstat (limited to 'pyload/plugin/internal')
-rw-r--r-- | pyload/plugin/internal/BasePlugin.py | 2 | ||||
-rw-r--r-- | pyload/plugin/internal/DeadCrypter.py | 2 | ||||
-rw-r--r-- | pyload/plugin/internal/DeadHoster.py | 2 | ||||
-rw-r--r-- | pyload/plugin/internal/SimpleCrypter.py | 1 | ||||
-rw-r--r-- | pyload/plugin/internal/SimpleHoster.py | 30 | ||||
-rw-r--r-- | pyload/plugin/internal/XFSHoster.py | 8 |
6 files changed, 44 insertions, 1 deletions
diff --git a/pyload/plugin/internal/BasePlugin.py b/pyload/plugin/internal/BasePlugin.py index 996dc8e76..1ddfee122 100644 --- a/pyload/plugin/internal/BasePlugin.py +++ b/pyload/plugin/internal/BasePlugin.py @@ -24,6 +24,8 @@ class BasePlugin(Hoster): @classmethod + + def getInfo(cls, url="", html=""): #@TODO: Move to hoster class in 0.4.10 url = unquote(url) url_p = urlparse(url) diff --git a/pyload/plugin/internal/DeadCrypter.py b/pyload/plugin/internal/DeadCrypter.py index daa7e1a0d..c66a1b5e3 100644 --- a/pyload/plugin/internal/DeadCrypter.py +++ b/pyload/plugin/internal/DeadCrypter.py @@ -16,6 +16,8 @@ class DeadCrypter(_Crypter): @classmethod + + def apiInfo(cls, url="", get={}, post={}): api = super(DeadCrypter, self).apiInfo(url, get, post) api['status'] = 1 diff --git a/pyload/plugin/internal/DeadHoster.py b/pyload/plugin/internal/DeadHoster.py index 2e57decdb..5f00d0128 100644 --- a/pyload/plugin/internal/DeadHoster.py +++ b/pyload/plugin/internal/DeadHoster.py @@ -16,6 +16,8 @@ class DeadHoster(_Hoster): @classmethod + + def apiInfo(cls, url="", get={}, post={}): api = super(DeadHoster, self).apiInfo(url, get, post) api['status'] = 1 diff --git a/pyload/plugin/internal/SimpleCrypter.py b/pyload/plugin/internal/SimpleCrypter.py index ba5cb991c..f6c5aa5e2 100644 --- a/pyload/plugin/internal/SimpleCrypter.py +++ b/pyload/plugin/internal/SimpleCrypter.py @@ -49,7 +49,6 @@ class SimpleCrypter(Crypter, SimpleHoster): and its loadPage method: - def loadPage(self, page_n): return the html of the page number page_n """ diff --git a/pyload/plugin/internal/SimpleHoster.py b/pyload/plugin/internal/SimpleHoster.py index 79b3cac1a..b32cb60c0 100644 --- a/pyload/plugin/internal/SimpleHoster.py +++ b/pyload/plugin/internal/SimpleHoster.py @@ -311,12 +311,16 @@ class SimpleHoster(Hoster): @classmethod + + def parseInfos(cls, urls): #@TODO: Built-in in 0.4.10 core (remove from plugins) for url in urls: url = replace_patterns(url, cls.URL_REPLACEMENTS) yield cls.getInfo(url) @classmethod + + def apiInfo(cls, url="", get={}, post={}): url = urllib.unquote(url) url_p = urlparse.urlparse(url) @@ -328,6 +332,8 @@ class SimpleHoster(Hoster): 'url': url} @classmethod + + def getInfo(cls, url="", html=""): info = cls.apiInfo(url) online = False if info['status'] != 2 else True @@ -406,9 +412,11 @@ class SimpleHoster(Hoster): return info + def setup(self): self.resumeDownload = self.multiDL = self.premium + def prepare(self): self.pyfile.error = "" #@TODO: Remove in 0.4.10 @@ -442,12 +450,14 @@ class SimpleHoster(Hoster): self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) + def preload(self): self.html = self.load(self.pyfile.url, cookies=bool(self.COOKIES), decode=not self.TEXT_ENCODING) if isinstance(self.TEXT_ENCODING, basestring): self.html = unicode(self.html, self.TEXT_ENCODING) + def process(self, pyfile): try: self.prepare() @@ -487,6 +497,7 @@ class SimpleHoster(Hoster): else: raise Fail(e) + def downloadLink(self, link, disposition=True): if link and isinstance(link, basestring): self.correctCaptcha() @@ -498,6 +509,7 @@ class SimpleHoster(Hoster): self.download(link, ref=False, disposition=disposition) + def checkFile(self, rules={}): if self.cTask and not self.lastDownload: self.invalidCaptcha() @@ -538,6 +550,7 @@ class SimpleHoster(Hoster): self.logWarning("Check result: " + errmsg, "Waiting 1 minute and retry") self.retry(3, 60, errmsg) + def checkErrors(self): if not self.html: self.logWarning(_("No html code to check")) @@ -582,6 +595,7 @@ class SimpleHoster(Hoster): self.info.pop('error', None) + def checkStatus(self, getinfo=True): if not self.info or getinfo: self.logDebug("Update file info...") @@ -604,6 +618,7 @@ class SimpleHoster(Hoster): finally: self.logDebug("File status: %s" % statusMap[status]) + def checkNameSize(self, getinfo=True): if not self.info or getinfo: self.logDebug("Update file info...") @@ -631,6 +646,7 @@ class SimpleHoster(Hoster): self.logDebug("File name: %s" % self.pyfile.name, "File size: %s byte" % self.pyfile.size if self.pyfile.size > 0 else "File size: Unknown") + def checkInfo(self): self.checkNameSize() @@ -641,11 +657,14 @@ class SimpleHoster(Hoster): self.checkStatus(getinfo=False) #: Deprecated + + def getFileInfo(self): self.info = {} self.checkInfo() return self.info + def handleDirect(self, pyfile): link = self.directLink(pyfile.url, self.resumeDownload) @@ -655,9 +674,11 @@ class SimpleHoster(Hoster): else: self.logDebug("Direct download link not found") + def handleMulti(self, pyfile): #: Multi-hoster handler pass + def handleFree(self, pyfile): if not hasattr(self, 'LINK_FREE_PATTERN'): self.logError(_("Free download not implemented")) @@ -668,6 +689,7 @@ class SimpleHoster(Hoster): else: self.link = m.group(1) + def handlePremium(self, pyfile): if not hasattr(self, 'LINK_PREMIUM_PATTERN'): self.logError(_("Premium download not implemented")) @@ -680,6 +702,7 @@ class SimpleHoster(Hoster): else: self.link = m.group(1) + 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) @@ -693,9 +716,11 @@ class SimpleHoster(Hoster): self.wait(wait_time, True) self.retry(max_tries=max_tries, reason=_("Download limit reached")) + def parseHtmlForm(self, attr_str="", input_names={}): return parseHtmlForm(attr_str, self.html, input_names) + def checkTrafficLeft(self): if not self.account: return True @@ -711,6 +736,7 @@ class SimpleHoster(Hoster): self.logInfo(_("Filesize: %i KiB, Traffic left for user %s: %i KiB") % (size, self.user, traffic)) return size <= traffic + def getConfig(self, option, default=''): #@TODO: Remove in 0.4.10 """getConfig with default value - sublass may not implements all config options""" try: @@ -719,6 +745,7 @@ class SimpleHoster(Hoster): except KeyError: return default + def retryFree(self): if not self.premium: return @@ -729,8 +756,11 @@ class SimpleHoster(Hoster): raise Retry(_("Fallback to free download")) #@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) diff --git a/pyload/plugin/internal/XFSHoster.py b/pyload/plugin/internal/XFSHoster.py index d2d5fb0dd..4cef261df 100644 --- a/pyload/plugin/internal/XFSHoster.py +++ b/pyload/plugin/internal/XFSHoster.py @@ -52,10 +52,12 @@ class XFSHoster(SimpleHoster): FORM_PATTERN = None FORM_INPUTS_MAP = None #: dict passed as input_names to parseHtmlForm + def setup(self): self.chunkLimit = -1 if self.premium else 1 self.resumeDownload = self.multiDL = self.premium + def prepare(self): """ Initialize important variables """ if not self.HOSTER_DOMAIN: @@ -84,6 +86,7 @@ class XFSHoster(SimpleHoster): if self.DIRECT_LINK is None: self.directDL = self.premium + def handleFree(self, pyfile): for i in xrange(1, 6): self.logDebug("Getting download link: #%d" % i) @@ -111,9 +114,11 @@ class XFSHoster(SimpleHoster): self.link = m.group(1).strip() #@TODO: Remove .strip() in 0.4.10 + def handlePremium(self, pyfile): return self.handleFree(pyfile) + def handleMulti(self, pyfile): if not self.account: self.fail(_("Only registered or premium users can use url leech feature")) @@ -171,6 +176,7 @@ class XFSHoster(SimpleHoster): if 'location' in header: #: Direct download link self.link = header['location'] + def checkErrors(self): m = re.search(self.ERROR_PATTERN, self.html) if m is None: @@ -223,6 +229,7 @@ class XFSHoster(SimpleHoster): else: self.info.pop('error', None) + def getPostParameters(self): if self.FORM_PATTERN or self.FORM_INPUTS_MAP: action, inputs = self.parseHtmlForm(self.FORM_PATTERN or "", self.FORM_INPUTS_MAP or {}) @@ -268,6 +275,7 @@ class XFSHoster(SimpleHoster): return inputs + def handleCaptcha(self, inputs): m = re.search(self.CAPTCHA_PATTERN, self.html) if m: |