diff options
Diffstat (limited to 'pyload/plugin/internal/SimpleHoster.py')
-rw-r--r-- | pyload/plugin/internal/SimpleHoster.py | 30 |
1 files changed, 30 insertions, 0 deletions
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) |