예제 #1
0
    def decrypt(self, pyfile):
        link = getFileURL(self, pyfile.url)

        if not link:
            try:
                link = unquote(re.match(self.__pattern, pyfile.url).group('LINK'))

            except Exception:
                self.prepare()
                self.preload()
                self.checkStatus()

                link = self.getLink()

        if link.strip():
            self.urls = [link]
예제 #2
0
    def decrypt(self, pyfile):
        link = getFileURL(self, pyfile.url)

        if not link:
            try:
                link = urllib.unquote(
                    re.match(self.__pattern, pyfile.url).group('LINK'))

            except Exception:
                self.prepare()
                self.preload()
                self.checkStatus()

                link = self.getLink()

        if link.strip():
            self.urls = [link]
예제 #3
0
    def process(self, pyfile):
        """main function"""

        pyfile.name = self.getInfo(pyfile.url)['name']

        if not pyfile.url.startswith("http"):
            self.fail(_("No plugin matched"))

        for _i in xrange(5):
            try:
                link = getFileURL(self, urllib.unquote(pyfile.url))

                if link:
                    self.download(link, ref=False, disposition=True)
                else:
                    self.fail(_("File not found"))

            except BadHeader, e:
                if e.code is 404:
                    self.offline()

                elif e.code in (401, 403):
                    self.logDebug("Auth required",
                                  "Received HTTP status code: %d" % e.code)

                    account = self.core.accountManager.getAccountPlugin('Http')
                    servers = [x['login'] for x in account.getAllAccounts()]
                    server = urlparse.urlparse(pyfile.url).netloc

                    if server in servers:
                        self.logDebug("Logging on to %s" % server)
                        self.req.addAuth(
                            account.getAccountData(server)['password'])
                    else:
                        pwd = self.getPassword()
                        if ':' in pwd:
                            self.req.addAuth(pwd)
                        else:
                            self.fail(_("Authorization required"))
                else:
                    self.fail(e)
            else:
                break
예제 #4
0
    def process(self, pyfile):
        """main function"""

        pyfile.name = self.getInfo(pyfile.url)['name']

        if not pyfile.url.startswith("http"):
            self.fail(_("No plugin matched"))

        for _i in xrange(5):
            try:
                link = getFileURL(self, unquote(pyfile.url))

                if link:
                    self.download(link, ref=False, disposition=True)
                else:
                    self.fail(_("File not found"))

            except BadHeader, e:
                if e.code is 404:
                    self.offline()

                elif e.code in (401, 403):
                    self.logDebug("Auth required", "Received HTTP status code: %d" % e.code)

                    account = self.core.accountManager.getAccountPlugin('Http')
                    servers = [x['login'] for x in account.getAllAccounts()]
                    server  = urlparse(pyfile.url).netloc

                    if server in servers:
                        self.logDebug("Logging on to %s" % server)
                        self.req.addAuth(account.getAccountData(server)['password'])
                    else:
                        pwd = self.getPassword()
                        if ':' in pwd:
                            self.req.addAuth(pwd)
                        else:
                            self.fail(_("Authorization required"))
                else:
                    self.fail(e)
            else:
                break