def _error(self, reason, type): if not reason and not type: type = "unknown" msg = _("%s error") % type.strip().capitalize() if type else _("Error") msg += (": %s" % reason.strip()) if reason else "" msg += _(" | Plugin may be out of date") raise Fail(msg)
def process(self, pyfile): try: self.prepare() if self.directDL: self.checkInfo() self.logDebug("Looking for direct download link...") self.handleDirect(pyfile) if not self.link and not self.lastDownload: self.preload() self.checkErrors() self.checkStatus(getinfo=False) if self.premium and (not self.CHECK_TRAFFIC or self.checkTrafficLeft()): self.logDebug("Handled as premium download") self.handlePremium(pyfile) elif not self.LOGIN_ACCOUNT or (not self.CHECK_TRAFFIC or self.checkTrafficLeft()): self.logDebug("Handled as free download") self.handleFree(pyfile) self.downloadLink(self.link, True) self.checkFile() except Fail, e: #@TODO: Move to PluginThread in 0.4.10 if self.premium: self.logWarning(_("Premium download failed")) self.retryFree() elif self.getConfig('revertfailed', True) \ and "new_module" in self.core.pluginManager.hosterPlugins[self.getClassName()]: hdict = self.core.pluginManager.hosterPlugins[ self.getClassName()] tmp_module = hdict['new_module'] tmp_name = hdict['new_name'] hdict.pop('new_module', None) hdict.pop('new_name', None) pyfile.initPlugin() hdict['new_module'] = tmp_module hdict['new_name'] = tmp_name raise Retry(_("Revert to original hoster plugin")) else: raise Fail(e)
def write(self, buf): """ writes response """ if self.rep.tell() > 1000000 or self.abort: rep = self.getResponse() if self.abort: raise Abort with open("response.dump", "wb") as f: f.write(rep) raise Fail("Loaded url exceeded size limit") else: self.rep.write(buf)
def process(self, pyfile): try: self.prepare() self.checkInfo() if self.directDL: self.logDebug("Looking for direct download link...") self.handle_direct(pyfile) if self.multihost and not self.link and not self.lastDownload: self.logDebug("Looking for leeched download link...") self.handle_multi(pyfile) if not self.link and not self.lastDownload: self.MULTI_HOSTER = False self.retry(1, reason="Multi hoster fails") if not self.link and not self.lastDownload: self.preload() self.checkInfo() if self.premium and (not self.CHECK_TRAFFIC or self.checkTrafficLeft()): self.logDebug("Handled as premium download") self.handle_premium(pyfile) elif not self.LOGIN_ACCOUNT or (not self.CHECK_TRAFFIC or self.checkTrafficLeft()): self.logDebug("Handled as free download") self.handle_free(pyfile) self.downloadLink(self.link, self.DISPOSITION) self.checkFile() except Fail, e: #@TODO: Move to PluginThread in 0.4.10 if self.getConfig('fallback', True) and self.premium: self.logWarning(_("Premium download failed"), e) self.retryFree() else: raise Fail(e)