diff options
author | mkaay <mkaay@mkaay.de> | 2010-05-07 17:31:29 +0200 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2010-05-07 17:31:29 +0200 |
commit | 4c6fbd8177a7499608b177d64297dc5117a8dd9a (patch) | |
tree | 903187b2fb69eabe3b6f59c31e2d9f245bdd0412 /module | |
parent | better rapidshare traffic share handling (diff) | |
download | pyload-4c6fbd8177a7499608b177d64297dc5117a8dd9a.tar.xz |
UploadedTo account plugin
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/Account.py | 14 | ||||
-rw-r--r-- | module/plugins/accounts/UploadedTo.py | 18 | ||||
-rw-r--r-- | module/plugins/hoster/RapidshareCom.py | 5 | ||||
-rw-r--r-- | module/plugins/hoster/UploadedTo.py | 24 |
4 files changed, 47 insertions, 14 deletions
diff --git a/module/plugins/Account.py b/module/plugins/Account.py index ab3ad9ec5..2ed2325c9 100644 --- a/module/plugins/Account.py +++ b/module/plugins/Account.py @@ -18,6 +18,7 @@ """ from random import randrange +import re class Account(): __name__ = "Account" @@ -72,3 +73,16 @@ class Account(): else: account = self.register[plugin] return account + + def parseTraffic(self, string): #returns kbyte + string = string.strip().lower() + p = re.compile(r"(\d+[\.,]\d+)(.*)") + m = p.match(string) + if m: + traffic = float(m.group(1).replace(",", ".")) + unit = m.group(2).strip() + if unit == "gb" or unit == "gig" or unit == "gbyte" or unit == "gigabyte": + traffic *= 1024*1024 + elif unit == "mb" or unit == "megabyte" or unit == "mbyte" or unit == "mib": + traffic *= 1024 + return traffic diff --git a/module/plugins/accounts/UploadedTo.py b/module/plugins/accounts/UploadedTo.py index a477fa6b1..9c0d90747 100644 --- a/module/plugins/accounts/UploadedTo.py +++ b/module/plugins/accounts/UploadedTo.py @@ -18,6 +18,8 @@ """ from module.plugins.Account import Account +import re +from time import strptime, mktime class UploadedTo(Account): __name__ = "UploadedTo" @@ -27,8 +29,20 @@ class UploadedTo(Account): __author_name__ = ("mkaay") __author_mail__ = ("mkaay@mkaay.de") - def getAccountInfo(self): - pass + def getAccountInfo(self, name): + req = self.core.requestFactory.getRequest(self.__name__, name) + data = None + for account in self.accounts: + if account[0] == name: + data = account + if not data: + return + html = req.load("http://uploaded.to/", cookies=True) + raw_traffic = re.search(r"Traffic left: </span><span class=.*?>(.*?)</span>", html).group(1) + raw_valid = re.search(r"Valid until: </span> <span class=.*?>(.*?)</span>", html).group(1) + traffic = int(self.parseTraffic(raw_traffic)) + validuntil = int(mktime(strptime(raw_valid.strip(), "%d-%m-%Y %H:%M"))) + return {"login":name, "validuntil":validuntil, "trafficleft":traffic} def login(self): for account in self.accounts: diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index c1f691af8..63058b044 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -43,7 +43,6 @@ class RapidshareCom(Hoster): self.start_dl = False def prepare(self, thread): - self.req.clear_cookies() self.no_slots = True self.want_reconnect = False @@ -53,9 +52,9 @@ class RapidshareCom(Hoster): if self.usePremium: info = self.account.getAccountInfo(self.account.getAccountData(self)[0]) - self.logger.info(_("Rapidshare: Use Premium Account (%sGB left)") % (info["trafficleft"]/1024/1024)) + self.logger.info(_("%s: Use Premium Account (%sGB left)") % (self.__name__, info["trafficleft"]/1024/1024)) if self.api_data["size"] / 1024 > info["trafficleft"]: - self.logger.info(_("Rapidshare: Not enough traffic left")) + self.logger.info(_("%s: Not enough traffic left" % self.__name__)) self.usePremium = False else: self.pyfile.status.url = self.parent.url diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index 43f54c099..1ac277447 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -24,7 +24,8 @@ class UploadedTo(Hoster): self.read_config() self.account = None self.multi_dl = False - if self.config['premium']: + self.usePremium = self.config['premium'] + if self.usePremium: self.account = self.parent.core.pluginManager.getAccountPlugin(self.__name__) req = self.account.getAccountRequest(self) if req: @@ -32,7 +33,7 @@ class UploadedTo(Hoster): self.multi_dl = True self.req.canContinue = True else: - self.config['premium'] = False + self.usePremium = False self.start_dl = False @@ -41,7 +42,6 @@ class UploadedTo(Hoster): tries = 0 while not self.pyfile.status.url: - #self.req.clear_cookies() self.download_html() self.pyfile.status.exists = self.file_exists() @@ -53,9 +53,15 @@ class UploadedTo(Hoster): self.pyfile.status.filename = self.get_file_name() - if self.config['premium']: - self.pyfile.status.url = self.parent.url - return True + 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"]/1024/1024)) + if self.api_data["size"] > 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 self.get_waiting_time() @@ -82,7 +88,7 @@ class UploadedTo(Hoster): self.api_data = {} lines = src.splitlines() self.api_data["filename"] = lines[0] - self.api_data["size"] = lines[1] # in kbytes + self.api_data["size"] = int(lines[1]) # in kbytes self.api_data["checksum"] = lines[2] #sha1 def download_html(self): @@ -99,7 +105,7 @@ class UploadedTo(Hoster): self.time_plus_wait = 0 def get_file_url(self): - if self.config['premium']: + if self.usePremium: self.start_dl = True return self.parent.url try: @@ -134,7 +140,7 @@ class UploadedTo(Hoster): return url def proceed(self, url, location): - if self.config['premium']: + if self.usePremium: self.load(url, cookies=True, just_header=True) if self.cleanUrl(self.req.lastEffectiveURL) == self.cleanUrl(url): self.logger.info(_("UploadedTo indirect download")) |