diff options
| author | 2010-08-05 13:52:24 +0200 | |
|---|---|---|
| committer | 2010-08-05 13:52:24 +0200 | |
| commit | 23a78c13c0176cc9db27135bc3620170f514a95f (patch) | |
| tree | ca827b97d282d20c3bd509a008a1fa1213c1f472 | |
| parent | config parser fix, UploadedTo premium working (diff) | |
| download | pyload-23a78c13c0176cc9db27135bc3620170f514a95f.tar.xz | |
RapidshareCom premium
| -rw-r--r-- | module/ThreadManager.py | 5 | ||||
| -rw-r--r-- | module/plugins/Account.py | 3 | ||||
| -rw-r--r-- | module/plugins/Plugin.py | 1 | ||||
| -rw-r--r-- | module/plugins/accounts/RapidshareCom.py | 20 | ||||
| -rw-r--r-- | module/plugins/hoster/RapidshareCom.py | 38 | 
5 files changed, 33 insertions, 34 deletions
| diff --git a/module/ThreadManager.py b/module/ThreadManager.py index a48d7e729..5de1aca35 100644 --- a/module/ThreadManager.py +++ b/module/ThreadManager.py @@ -22,6 +22,7 @@ from threading import Event  from subprocess import Popen  from os.path import exists  from time import sleep +from traceback import print_exc  from module.network.Request import getURL  import PluginThread @@ -157,6 +158,8 @@ class ThreadManager:  				job.initPlugin()  			except Exception, e:  				self.log.critical(str(e)) +				if self.core.debug: +				    print_exc()  			if job.plugin.__type__ == "hoster":  				if free: @@ -174,4 +177,4 @@ class ThreadManager: -	
\ No newline at end of file +	 diff --git a/module/plugins/Account.py b/module/plugins/Account.py index af1c4a383..3b18e563f 100644 --- a/module/plugins/Account.py +++ b/module/plugins/Account.py @@ -72,6 +72,9 @@ class Account():          account = self.accounts.items()[randrange(0, len(self.accounts), 1)]          return account +    def canUse(self): +        return len(self.accounts) +          def parseTraffic(self, string): #returns kbyte          string = string.strip().lower()          p = re.compile(r"(\d+[\.,]\d+)(.*)") diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index a6ea7dee7..25323f6ed 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -81,6 +81,7 @@ class Plugin(object):          self.ocr = None  # captcha reader instance          self.account = pyfile.m.core.accountManager.getAccountPlugin(self.__name__) # account handler instance +        if not self.account.canUse(): self.account = None          if self.account:              self.req = self.account.getAccountRequest(self)          else: diff --git a/module/plugins/accounts/RapidshareCom.py b/module/plugins/accounts/RapidshareCom.py index 016c084c9..c0974dab4 100644 --- a/module/plugins/accounts/RapidshareCom.py +++ b/module/plugins/accounts/RapidshareCom.py @@ -27,16 +27,16 @@ class RapidshareCom(Account):      __author_name__ = ("mkaay")      __author_mail__ = ("mkaay@mkaay.de") -    def getAccountInfo(self, name): -        req = self.core.requestFactory.getRequest(self.__name__, name) +    def getAccountInfo(self, user):          data = None -        for account in self.accounts: -            if account[0] == name: -                data = account +        for account in self.accounts.items(): +            if account[0] == user: +                data = account[1]          if not data:              return +        req = self.core.requestFactory.getRequest(self.__name__, user)          api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi" -        api_param_prem = {"sub": "getaccountdetails_v1", "type": "prem", "login": data[0], "password": data[1], "withcookie": 1} +        api_param_prem = {"sub": "getaccountdetails_v1", "type": "prem", "login": user, "password": data["password"], "withcookie": 1}          src = req.load(api_url_base, cookies=False, get=api_param_prem)          if src.startswith("ERROR"):              return @@ -52,10 +52,10 @@ class RapidshareCom(Account):          return out      def login(self): -        for account in self.accounts: -            req = self.core.requestFactory.getRequest(self.__name__, account[0]) +        for user, data in self.accounts.items(): +            req = self.core.requestFactory.getRequest(self.__name__, user)              api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi" -            api_param_prem = {"sub": "getaccountdetails_v1", "type": "prem", "login": account[0], "password": account[1], "withcookie": 1} +            api_param_prem = {"sub": "getaccountdetails_v1", "type": "prem", "login": user, "password": data["password"], "withcookie": 1}              src = req.load(api_url_base, cookies=False, get=api_param_prem)              if src.startswith("ERROR"):                  return @@ -66,7 +66,7 @@ class RapidshareCom(Account):                      continue                  k, v = t.split("=")                  info[k] = v -            cj = self.core.requestFactory.getCookieJar(self.__name__, account[0]) +            cj = self.core.requestFactory.getCookieJar(self.__name__, user)              cj.setCookie("rapidshare.com", "enc", info["cookie"]) diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 2889955ce..fa6dad837 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -23,17 +23,9 @@ class RapidshareCom(Hoster):          self.no_slots = True          self.api_data = None          self.multiDL = False -         -        # self.usePremium = self.config['premium'] -        # if self.usePremium: -            # self.account = self.parent.core.pluginManager.getAccountPlugin(self.__name__) -            # req = self.account.getAccountRequest(self) -            # if req: -                # self.req = req -                # self.multi_dl = True -                # self.req.canContinue = True -            # else: -                # self.usePremium = False +        if self.account: +            self.multiDL = True +            self.req.canContinue = True      def process(self, pyfile):          self.url = self.pyfile.url         @@ -48,15 +40,15 @@ class RapidshareCom(Hoster):          if self.api_data["status"] == "1":              self.pyfile.name = self.get_file_name() -            # if self.usePremium: -                # info = self.account.getAccountInfo(self.account.getAccountData(self)[0]) -                # self.logger.info(_("%s: Use Premium Account (%sGB left)") % (self.__name__, info["trafficleft"]/1000/1000)) -                # if self.api_data["size"] / 1024 > info["trafficleft"]: -                    # self.logger.info(_("%s: Not enough traffic left" % self.__name__)) -                    # self.usePremium = False -                # else: -                    # self.pyfile.status.url = self.parent.url -                    # return True +            if self.account: +                info = self.account.getAccountInfo(self.account.getAccountData(self)[0]) +                self.log.debug(_("%s: Use Premium Account (%sGB left)") % (self.__name__, info["trafficleft"]/1000/1000)) +                if self.api_data["size"] / 1024 > info["trafficleft"]: +                    self.log.info(_("%s: Not enough traffic left" % self.__name__)) +                    self.resetAcount() +                else: +                    self.url = self.api_data["mirror"] +                    return True              self.download_html()              while self.no_slots: @@ -70,7 +62,7 @@ class RapidshareCom(Hoster):              return True          elif self.api_data["status"] == "2": -            self.logger.info(_("Rapidshare: Traffic Share (direct download)")) +            self.log.info(_("Rapidshare: Traffic Share (direct download)"))              self.pyfile.name = self.get_file_name()              # self.pyfile.status.url = self.parent.url              return True @@ -124,7 +116,7 @@ class RapidshareCom(Hoster):          self.html[1] = self.load(file_server_url, cookies=False, post={"dl.start": "Free"})          if re.search(r"is already downloading", self.html[1]): -            self.logger.info(_("Rapidshare: Already downloading, wait 30 minutes")) +            self.log.info(_("Rapidshare: Already downloading, wait 30 minutes"))              return 30 * 60          self.no_slots = False          try: @@ -134,7 +126,7 @@ class RapidshareCom(Hoster):              self.wantReconnect = True          except:              if re.search(r"(Currently a lot of users|no more download slots|servers are overloaded)", self.html[1], re.I) != None: -                self.logger.info(_("Rapidshare: No free slots!")) +                self.log.info(_("Rapidshare: No free slots!"))                  self.no_slots = True                  return time() + 130              self.no_slots = False | 
