Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)