diff options
Diffstat (limited to 'module/plugins')
| -rw-r--r-- | module/plugins/Plugin.py | 6 | ||||
| -rw-r--r-- | module/plugins/accounts/HotfileCom.py | 7 | ||||
| -rw-r--r-- | module/plugins/hooks/UpdateManager.py | 4 | ||||
| -rw-r--r-- | module/plugins/hoster/HotfileCom.py | 4 | ||||
| -rw-r--r-- | module/plugins/hoster/UploadedTo.py | 118 | 
5 files changed, 73 insertions, 66 deletions
| diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index af164c3a5..e34543100 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -343,3 +343,9 @@ class Plugin(object):                      if delete:                          remove(self.lastDownload)                      return name + +    def resetAccount(self): +        """ invalidates an account, so it will not be used """ +        if self.account: +            data = self.account.getAccountData(self.user) +            data["valid"] = False diff --git a/module/plugins/accounts/HotfileCom.py b/module/plugins/accounts/HotfileCom.py index 5a3fdd6a5..f623e56f1 100644 --- a/module/plugins/accounts/HotfileCom.py +++ b/module/plugins/accounts/HotfileCom.py @@ -51,12 +51,9 @@ class HotfileCom(Account):      def apiCall(self, method, post={}, user=None):          if user: -            data = None -            for account in self.accounts.items(): -                if account[0] == user: -                    data = account[1] +            data = self.getAccountData(user)          else: -            user, data = self.accounts.items()[0] +            user, data = self.selectAccount()          req = self.getAccountRequest(user) diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 02ba6a6ff..6a1a31ade 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -57,7 +57,7 @@ class UpdateManager(Hook):                  self.log.info(_("***  Get it here: http://pyload.org/download  ***"))                  return True          except: -            self.log.error(_("Not able to connect server")) +            self.log.error(_("Not able to connect server for updates"))              return False @@ -67,7 +67,7 @@ class UpdateManager(Hook):          try:              updates = getURL("http://get.pyload.org/plugins/check/")          except: -            self.log.warning(_("Plugins could not be updated")) +            self.log.warning(_("Not able to connect server for updates"))              return False          updates = updates.splitlines() diff --git a/module/plugins/hoster/HotfileCom.py b/module/plugins/hoster/HotfileCom.py index 78fd14cf6..f3c6b67dd 100644 --- a/module/plugins/hoster/HotfileCom.py +++ b/module/plugins/hoster/HotfileCom.py @@ -53,7 +53,7 @@ class HotfileCom(Hoster):          if not self.account and login:              return          elif self.account and login: -            return self.account.apiCall(method, post) +            return self.account.apiCall(method, post, self.user)          post.update({"action": method})          return self.load("http://api.hotfile.com/", post=post) @@ -79,7 +79,7 @@ class HotfileCom(Hoster):              self.freeDownload()          else: -            dl = self.account.apiCall("getdirectdownloadlink", {"link":self.pyfile.url}) +            dl = self.account.apiCall("getdirectdownloadlink", {"link":self.pyfile.url}, self.user)              self.download(dl)      def downloadHTML(self): diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index 933feab39..4cd98fc3e 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -4,6 +4,7 @@ import re  from module.plugins.Hoster import Hoster  from module.network.Request import getURL  from module.plugins.Plugin import chunks +from module.plugins.ReCaptcha import ReCaptcha  def getInfo(urls):      pattern = re.compile(UploadedTo.__pattern__) @@ -34,57 +35,72 @@ class UploadedTo(Hoster):          self.html = None          self.api_data = None          self.multiDL = False +        self.url = False          if self.account:              self.multiDL = True              self.req.canContinue = True +      def process(self, pyfile): -        self.url = False -        self.pyfile = pyfile -        self.prepare() -        self.proceed() -                 -     -    def getInfo(self): +        self.download_html() + +        if not self.file_exists(): +            self.offline() +          self.download_api_data() -        self.pyfile.name = self.api_data["filename"] -        self.pyfile.sync() - -    def prepare(self):         -        tries = 0 - -        while not self.url: -            self.download_html() - -            if not self.file_exists(): -                self.offline() -                 -            self.download_api_data() -             -            # self.pyfile.name = self.get_file_name() -             -            if self.account: -                info = self.account.getAccountInfo(self.user, True) -                self.log.debug(_("%(name)s: Use Premium Account (%(left)sGB left)") % {"name" :self.__name__, "left" : info["trafficleft"]/1024/1024}) -                if self.api_data["size"]/1024 > info["trafficleft"]: -                    self.log.info(_("%s: Not enough traffic left" % self.__name__)) -                    #self.resetAcount() #@TODO implement -                else: -                    self.url = self.get_file_url() -                    self.pyfile.name = self.get_file_name() -                    return True -                 -            self.url = self.get_file_url() -             -            self.setWait(self.get_waiting_time()) + +        # self.pyfile.name = self.get_file_name() + +        if self.account: +            info = self.account.getAccountInfo(self.user, True) +            self.log.debug(_("%(name)s: Use Premium Account (%(left)sGB left)") % {"name" :self.__name__, "left" : info["trafficleft"]/1024/1024}) +            if self.api_data["size"]/1024 > info["trafficleft"]: +                self.log.info(_("%s: Not enough traffic left" % self.__name__)) +                self.resetAccount() +                self.fail(_("Traffic exceeded")) +            else: +                self.url = self.get_file_url() +                pyfile.name = self.get_file_name() +                self.download(self.url+"?redirect", cookies=True) + +            return True + + +        self.url = self.get_file_url() + +        wait = self.get_waiting_time() +        if wait: +            self.setWait(wait, True)              self.wait() +            self.process(pyfile) +            return +        else: +            self.setWait(30, False) + +        time = re.search(r'name="time" value="([^"]+)', self.html).group(1) +        time_secure = re.search(r'name="time_secure" value="([^"]+)', self.html).group(1) +        file_password = re.search(r'name="file_password" value="([^"]*)', self.html).group(1) + +        challenge = re.search(r"recaptcha/api/challenge\?k=([0-9A-Za-z]+)", self.html) + +        options = {"time": time, "time_secure": time_secure, "file_password": file_password} + +        if challenge: +            re_captcha = ReCaptcha(self) +            challenge, result = re_captcha.challenge(challenge.group(1)) +            options["recaptcha_challenge_field"] = challenge +            options["recaptcha_response_field"] = result + +        self.wait() + +        pyfile.name = self.get_file_name() + +        self.download(self.url, post=options) -            self.pyfile.name = self.get_file_name() +        check = self.checkDownload({"wrong_captcha": "Wrong captcha."}) +        if check == "wrong_captcha": +            self.process(pyfile) -            tries += 1 -            if tries > 5: -                self.fail("Error while preparing DL") -        return True      def download_api_data(self, force=False):          if self.api_data and not force: @@ -113,14 +129,7 @@ class UploadedTo(Hoster):              return 0      def get_file_url(self): -        if self.account: -            self.start_dl = True -            return self.cleanUrl(self.pyfile.url) -        try: -            file_url_pattern = r".*<form name=\"download_form\" method=\"post\" action=\"(.*)\">" -            return re.search(file_url_pattern, self.html).group(1) -        except: -            return None +        return self.cleanUrl(self.pyfile.url)      def get_file_name(self):          try: @@ -139,16 +148,11 @@ class UploadedTo(Hoster):              return False          else:              return True +      def cleanUrl(self, url):          url = url.replace("ul.to/", "uploaded.to/file/")          url = url.replace("/?id=", "/file/")          url = url.replace("?id=", "file/")          url = re.sub("/\?(.*?)&id=", "/file/", url, 1) -        return url -     -    def proceed(self): -        if self.account: -            self.download(self.url+"?redirect", cookies=True) -        else: -            self.download(self.url, cookies=False, post={"download_submit": "Free Download"}) +        return url
\ No newline at end of file | 
