diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-16 17:01:39 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-16 17:01:39 +0200 |
commit | 84169f4862fa257e0a8a47e5f3578e9ec97ccf4f (patch) | |
tree | dd18f97f02637f667b803796f2b456836204a5d5 | |
parent | Merge branch 'stable' into 0.4.10 (diff) | |
download | pyload-84169f4862fa257e0a8a47e5f3578e9ec97ccf4f.tar.xz |
Plugins cleanup
27 files changed, 37 insertions, 66 deletions
diff --git a/pyload/plugin/Crypter.py b/pyload/plugin/Crypter.py index aa9966ab4..bfb558abd 100644 --- a/pyload/plugin/Crypter.py +++ b/pyload/plugin/Crypter.py @@ -42,7 +42,7 @@ class Crypter(Plugin): self.generatePackages() elif not self.packages: - self.error(_("No link extracted"), "decrypt") + self.error(_("No link grabbed"), "decrypt") self.createPackages() diff --git a/pyload/plugin/account/FastixRu.py b/pyload/plugin/account/FastixRu.py index fbb635437..ead4e63aa 100644 --- a/pyload/plugin/account/FastixRu.py +++ b/pyload/plugin/account/FastixRu.py @@ -18,13 +18,14 @@ class FastixRu(Account): data = self.getAccountData(user) html = json_loads(req.load("http://fastix.ru/api_v2/", get={'apikey': data['api'], 'sub': "getaccountdetails"})) - points = html['points'] - kb = float(points) * 1024 ** 2 / 1000 + points = html['points'] + trafficleft = float(points) * 1024 ** 2 / 1000 if points > 0: - account_info = {"validuntil": -1, "trafficleft": kb} + account_info = {"validuntil": -1, "trafficleft": trafficleft} else: account_info = {"validuntil": None, "trafficleft": None, "premium": False} + return account_info diff --git a/pyload/plugin/account/NoPremiumPl.py b/pyload/plugin/account/NoPremiumPl.py index ac0e64cd4..d825b38ed 100644 --- a/pyload/plugin/account/NoPremiumPl.py +++ b/pyload/plugin/account/NoPremiumPl.py @@ -46,7 +46,7 @@ class NoPremiumPl(Account): if "expire" in result.keys() and result["expire"]: premium = True valid_untill = time.mktime(datetime.datetime.fromtimestamp(int(result["expire"])).timetuple()) - traffic_left = result["balance"] * 1024 + traffic_left = result["balance"] * 2 ** 20 return ({ "validuntil": valid_untill, diff --git a/pyload/plugin/account/OboomCom.py b/pyload/plugin/account/OboomCom.py index 17d81428c..68e083d75 100644 --- a/pyload/plugin/account/OboomCom.py +++ b/pyload/plugin/account/OboomCom.py @@ -64,8 +64,8 @@ class OboomCom(Account): traffic = userData['traffic'] - trafficLeft = traffic['current'] / 1024 #@TODO: Remove `/ 1024` in 0.4.10 - maxTraffic = traffic['max'] / 1024 #@TODO: Remove `/ 1024` in 0.4.10 + trafficLeft = traffic['current'] + maxTraffic = traffic['max'] session = accountData['session'] diff --git a/pyload/plugin/account/PremiumTo.py b/pyload/plugin/account/PremiumTo.py index fcd856ea7..586ddf635 100644 --- a/pyload/plugin/account/PremiumTo.py +++ b/pyload/plugin/account/PremiumTo.py @@ -20,7 +20,7 @@ class PremiumTo(Account): get={'username': self.username, 'password': self.password}) if "wrong username" not in traffic: - trafficleft = sum(map(float, traffic.split(';'))) / 1024 #@TODO: Remove `/ 1024` in 0.4.10 + trafficleft = sum(map(float, traffic.split(';'))) return {'premium': True, 'trafficleft': trafficleft, 'validuntil': -1} else: return {'premium': False, 'trafficleft': None, 'validuntil': None} diff --git a/pyload/plugin/account/PremiumizeMe.py b/pyload/plugin/account/PremiumizeMe.py index 7a701d03b..06e6ffb98 100644 --- a/pyload/plugin/account/PremiumizeMe.py +++ b/pyload/plugin/account/PremiumizeMe.py @@ -22,7 +22,7 @@ class PremiumizeMe(Account): # Parse account info account_info = {"validuntil": float(status['result']['expires']), - "trafficleft": max(0, status['result']['trafficleft_bytes'] / 1024)} #@TODO: Remove `/ 1024` in 0.4.10 + "trafficleft": max(0, status['result']['trafficleft_bytes'])} if status['result']['type'] == 'free': account_info['premium'] = False diff --git a/pyload/plugin/account/RapidgatorNet.py b/pyload/plugin/account/RapidgatorNet.py index 17b615a0b..729635037 100644 --- a/pyload/plugin/account/RapidgatorNet.py +++ b/pyload/plugin/account/RapidgatorNet.py @@ -38,7 +38,7 @@ class RapidgatorNet(Account): self.scheduleRefresh(user, json['response']['reset_in']) validuntil = json['response']['expire_date'] - trafficleft = float(json['response']['traffic_left']) / 1024 #@TODO: Remove `/ 1024` in 0.4.10 + trafficleft = float(json['response']['traffic_left']) premium = True else: self.logError(json['response_details']) diff --git a/pyload/plugin/account/ShareonlineBiz.py b/pyload/plugin/account/ShareonlineBiz.py index a27d52736..06b2818c9 100644 --- a/pyload/plugin/account/ShareonlineBiz.py +++ b/pyload/plugin/account/ShareonlineBiz.py @@ -27,7 +27,7 @@ class ShareonlineBiz(Account): premium = False validuntil = None trafficleft = -1 - maxtraffic = 100 * 1024 * 1024 * 1024 #: 100 GB + maxtraffic = 100 * 2 ** 30 #: 100 GB api = {} for line in self.api_response(user, req).splitlines(): @@ -48,9 +48,6 @@ class ShareonlineBiz(Account): maxtraffic = max(maxtraffic, traffic) trafficleft = maxtraffic - traffic - maxtraffic /= 1024 #@TODO: Remove `/ 1024` in 0.4.10 - trafficleft /= 1024 #@TODO: Remove `/ 1024` in 0.4.10 - return {'premium' : premium, 'validuntil' : validuntil, 'trafficleft': trafficleft, diff --git a/pyload/plugin/account/SimplyPremiumCom.py b/pyload/plugin/account/SimplyPremiumCom.py index 92e4edbb9..2547dad56 100644 --- a/pyload/plugin/account/SimplyPremiumCom.py +++ b/pyload/plugin/account/SimplyPremiumCom.py @@ -32,7 +32,7 @@ class SimplyPremiumCom(Account): validuntil = float(json_data['result']['timeend']) if 'remain_traffic' in json_data['result'] and json_data['result']['remain_traffic']: - trafficleft = float(json_data['result']['remain_traffic']) / 1024 #@TODO: Remove `/ 1024` in 0.4.10 + trafficleft = float(json_data['result']['remain_traffic']) return {"premium": premium, "validuntil": validuntil, "trafficleft": trafficleft} diff --git a/pyload/plugin/account/UnrestrictLi.py b/pyload/plugin/account/UnrestrictLi.py index 8d3071580..d57b998ca 100644 --- a/pyload/plugin/account/UnrestrictLi.py +++ b/pyload/plugin/account/UnrestrictLi.py @@ -23,7 +23,7 @@ class UnrestrictLi(Account): return {"premium": False} validuntil = json_data['result']['expires'] - trafficleft = float(json_data['result']['traffic'] / 1024) #@TODO: Remove `/ 1024` in 0.4.10 + trafficleft = float(json_data['result']['traffic']) return {"premium": True, "validuntil": validuntil, "trafficleft": trafficleft} diff --git a/pyload/plugin/account/UploadedTo.py b/pyload/plugin/account/UploadedTo.py index 13b0f3112..61765faf8 100644 --- a/pyload/plugin/account/UploadedTo.py +++ b/pyload/plugin/account/UploadedTo.py @@ -49,11 +49,7 @@ class UploadedTo(Account): size = traffic['S'].replace('.', '') unit = traffic['U'].lower() - if unit.startswith('t'): #@NOTE: Remove in 0.4.10 - trafficleft = float(size.replace(',', '.')) / 1024 - trafficleft *= 1 << 40 - else: - trafficleft = self.parseTraffic(size + unit) + trafficleft = self.parseTraffic(size + unit) return {'validuntil' : validuntil, 'trafficleft': trafficleft, diff --git a/pyload/plugin/account/ZeveraCom.py b/pyload/plugin/account/ZeveraCom.py index 9be032ca1..25c2c5512 100644 --- a/pyload/plugin/account/ZeveraCom.py +++ b/pyload/plugin/account/ZeveraCom.py @@ -41,7 +41,7 @@ class ZeveraCom(Account): if "No trafic" not in api and api['endsubscriptiondate'] != "Expired!": validuntil = time.mktime(time.strptime(api['endsubscriptiondate'], "%Y/%m/%d %H:%M:%S")) - trafficleft = float(api['availabletodaytraffic']) * 1024 if api['orondaytrafficlimit'] != '0' else -1 + trafficleft = float(api['availabletodaytraffic']) * 2 ** 20 if api['orondaytrafficlimit'] != '0' else -1 premium = True return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} diff --git a/pyload/plugin/addon/AntiVirus.py b/pyload/plugin/addon/AntiVirus.py index 3866014ee..87780e337 100644 --- a/pyload/plugin/addon/AntiVirus.py +++ b/pyload/plugin/addon/AntiVirus.py @@ -28,8 +28,6 @@ class AntiVirus(Addon): def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - try: import send2trash diff --git a/pyload/plugin/addon/ExternalScripts.py b/pyload/plugin/addon/ExternalScripts.py index 75c9ae810..19d5202fd 100644 --- a/pyload/plugin/addon/ExternalScripts.py +++ b/pyload/plugin/addon/ExternalScripts.py @@ -30,7 +30,7 @@ class ExternalScripts(Addon): def setup(self): - self.info = {'oldip': None} + self.info['oldip'] = None self.scripts = {} folders = ["pyload_start", "pyload_restart", "pyload_stop", @@ -38,7 +38,7 @@ class ExternalScripts(Addon): "download_preparing", "download_failed", "download_finished", "archive_extract_failed", "archive_extracted", "package_finished", "package_deleted", "package_extract_failed", "package_extracted", - "all_downloads_processed", "all_downloads_finished", # @TODO: Invert `all_downloads_processed`, `all_downloads_finished` order in 0.4.10 + "all_downloads_processed", "all_downloads_finished", #@TODO: Invert `all_downloads_processed`, `all_downloads_finished` order in 0.4.10 "all_archives_extracted", "all_archives_processed"] for folder in folders: @@ -84,7 +84,7 @@ class ExternalScripts(Addon): self.logDebug("Executing: %s" % os.path.abspath(script), "Args: " + ' '.join(cmd_args)) - p = subprocess.Popen(cmd, bufsize=-1) # @NOTE: output goes to pyload + p = subprocess.Popen(cmd, bufsize=-1) #@NOTE: output goes to pyload if self.getConfig('waitend'): p.communicate() @@ -113,7 +113,7 @@ class ExternalScripts(Addon): def afterReconnecting(self, ip): for script in self.scripts['after_reconnect']: - self.callScript(script, ip, self.info['oldip']) # @TODO: Use built-in oldip in 0.4.10 + self.callScript(script, ip, self.info['oldip']) #@TODO: Use built-in oldip in 0.4.10 def downloadPreparing(self, pyfile): diff --git a/pyload/plugin/addon/ExtractArchive.py b/pyload/plugin/addon/ExtractArchive.py index ce67cbcaf..a4a28ab32 100644 --- a/pyload/plugin/addon/ExtractArchive.py +++ b/pyload/plugin/addon/ExtractArchive.py @@ -198,11 +198,11 @@ class ExtractArchive(Addon): while packages: if self.lastPackage: #: called from allDownloadsProcessed self.lastPackage = False - if self.extract(packages, thread): # @NOTE: check only if all gone fine, no failed reporting for now + if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now self.manager.dispatchEvent("all_archives_extracted") self.manager.dispatchEvent("all_archives_processed") else: - if self.extract(packages, thread): # @NOTE: check only if all gone fine, no failed reporting for now + if self.extract(packages, thread): #@NOTE: check only if all gone fine, no failed reporting for now pass packages = self.queue.get() #: check for packages added during extraction @@ -234,7 +234,7 @@ class ExtractArchive(Addon): @Expose - def extract(self, ids, thread=None): # @TODO: Use pypack, not pid to improve method usability + def extract(self, ids, thread=None): #@TODO: Use pypack, not pid to improve method usability if not ids: return False @@ -295,7 +295,7 @@ class ExtractArchive(Addon): new_files_ids = [] if extensions: - files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids + files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids if filter(lambda ext: fname.lower().endswith(ext), extensions)] for Extractor in self.extractors: @@ -341,7 +341,7 @@ class ExtractArchive(Addon): continue # remove processed file and related multiparts from list - files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids + files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids if fname not in archive.getDeleteFiles()] self.logDebug("Extracted files: %s" % new_files) self.setPermissions(new_files) diff --git a/pyload/plugin/addon/UpdateManager.py b/pyload/plugin/addon/UpdateManager.py index 57498d512..cf8349e79 100644 --- a/pyload/plugin/addon/UpdateManager.py +++ b/pyload/plugin/addon/UpdateManager.py @@ -222,7 +222,7 @@ class UpdateManager(Addon): for plugin in sorted(updatelist, key=itemgetter("type", "name")): filename = plugin['name'] - prefix = plugin['type'] + type = plugin['type'] version = plugin['version'] if filename.endswith(".pyc"): @@ -230,12 +230,6 @@ class UpdateManager(Addon): else: name = filename.replace(".py", "") - #@TODO: Remove in 0.4.10 - if prefix.endswith("s"): - type = prefix[:-1] - else: - type = prefix - plugins = getattr(self.core.pluginManager, "%sPlugins" % type) oldver = float(plugins[name]['version']) if name in plugins else None diff --git a/pyload/plugin/addon/UserAgentSwitcher.py b/pyload/plugin/addon/UserAgentSwitcher.py index ec1640e63..31a2b763b 100644 --- a/pyload/plugin/addon/UserAgentSwitcher.py +++ b/pyload/plugin/addon/UserAgentSwitcher.py @@ -25,10 +25,6 @@ class UserAgentSwitcher(Addon): __authors = [("Walter Purcaro", "vuolter@gmail.com")] - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - - def downloadPreparing(self, pyfile): uar = self.getConfig('uar') uaf = fs_encode(self.getConfig('uaf')) diff --git a/pyload/plugin/crypter/MegaCoNz.py b/pyload/plugin/crypter/MegaCoNz.py index 2ab7ec55c..c66b3f112 100644 --- a/pyload/plugin/crypter/MegaCoNz.py +++ b/pyload/plugin/crypter/MegaCoNz.py @@ -27,6 +27,3 @@ class MegaCoNz(Crypter): url = "https://mega.co.nz/#F!%s!%s" % re.match(self.__pattern, pyfile.url).groups() self.html = self.load("http://rapidgen.org/linkfinder", post={'linklisturl': url}) self.urls = re.findall(r'(https://mega.co.nz/#N!.+?)<', self.html) - - if not self.urls: #@TODO: Remove in 0.4.10 - self.fail(_("No link grabbed")) diff --git a/pyload/plugin/hoster/FilerNet.py b/pyload/plugin/hoster/FilerNet.py index f9b38e8cb..86a5809da 100644 --- a/pyload/plugin/hoster/FilerNet.py +++ b/pyload/plugin/hoster/FilerNet.py @@ -48,13 +48,9 @@ class FilerNet(SimpleHoster): recaptcha = ReCaptcha(self) response, challenge = recaptcha.challenge() - #@NOTE: Work-around for v0.4.9 just_header issue - #@TODO: Check for v0.4.10 - self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 0) self.load(pyfile.url, post={'recaptcha_challenge_field': challenge, 'recaptcha_response_field': response, - 'hash': inputs['hash']}) - self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 1) + 'hash': inputs['hash']}, follow_location=False) if 'location' in self.req.http.header.lower(): self.link = re.search(r'location: (\S+)', self.req.http.header, re.I).group(1) diff --git a/pyload/plugin/hoster/FreakshareCom.py b/pyload/plugin/hoster/FreakshareCom.py index c5315cdc8..64d8f8308 100644 --- a/pyload/plugin/hoster/FreakshareCom.py +++ b/pyload/plugin/hoster/FreakshareCom.py @@ -130,7 +130,7 @@ class FreakshareCom(Hoster): if m: units = float(m.group(1).replace(",", "")) pow = {'KB': 1, 'MB': 2, 'GB': 3}[m.group(2)] - size = int(units * 1024 ** pow) + size = int(units * (2 ** 20) ** pow) return size diff --git a/pyload/plugin/hoster/GigapetaCom.py b/pyload/plugin/hoster/GigapetaCom.py index adbdc2396..c524a0a7c 100644 --- a/pyload/plugin/hoster/GigapetaCom.py +++ b/pyload/plugin/hoster/GigapetaCom.py @@ -43,7 +43,7 @@ class GigapetaCom(SimpleHoster): m = re.search(r'Location\s*:\s*(.+)', self.req.http.header, re.I) if m: - self.link = m.group(1).rstrip() #@TODO: Remove .rstrip() in 0.4.10 + self.link = m.group(1) break elif "Entered figures don`t coincide with the picture" in self.html: self.invalidCaptcha() diff --git a/pyload/plugin/hoster/MegasharesCom.py b/pyload/plugin/hoster/MegasharesCom.py index 184be2fd6..ac7a81313 100644 --- a/pyload/plugin/hoster/MegasharesCom.py +++ b/pyload/plugin/hoster/MegasharesCom.py @@ -89,7 +89,7 @@ class MegasharesCom(SimpleHoster): self.fail(_("Passport not found")) self.logInfo(_("Download passport: %s") % m.group(1)) - data_left = float(m.group(2)) * 1024 ** {'B': 0, 'KB': 1, 'MB': 2, 'GB': 3}[m.group(3)] + data_left = float(m.group(2)) * (2 ** 20) ** {'B': 0, 'KB': 1, 'MB': 2, 'GB': 3}[m.group(3)] self.logInfo(_("Data left: %s %s (%d MB needed)") % (m.group(2), m.group(3), self.pyfile.size / 1048576)) if not data_left: diff --git a/pyload/plugin/hoster/QuickshareCz.py b/pyload/plugin/hoster/QuickshareCz.py index 6d6f21c71..3dd11f04a 100644 --- a/pyload/plugin/hoster/QuickshareCz.py +++ b/pyload/plugin/hoster/QuickshareCz.py @@ -65,7 +65,7 @@ class QuickshareCz(SimpleHoster): if m is None: self.fail(_("File not found")) - self.link = m.group(1).rstrip() #@TODO: Remove .rstrip() in 0.4.10 + self.link = m.group(1) self.logDebug("FREE URL2:" + self.link) # check errors diff --git a/pyload/plugin/hoster/XdadevelopersCom.py b/pyload/plugin/hoster/XdadevelopersCom.py index 488d29c44..0fe9197aa 100644 --- a/pyload/plugin/hoster/XdadevelopersCom.py +++ b/pyload/plugin/hoster/XdadevelopersCom.py @@ -33,4 +33,5 @@ class XdadevelopersCom(SimpleHoster): def handleFree(self, pyfile): - self.link = pyfile.url + "&task=get" #@TODO: Revert to `get={'task': "get"}` in 0.4.10 + self.download(pyfile.url, + get={'task': "get"}) diff --git a/pyload/plugin/internal/SimpleDereferer.py b/pyload/plugin/internal/SimpleDereferer.py index f3596b32c..c82afe0b4 100644 --- a/pyload/plugin/internal/SimpleDereferer.py +++ b/pyload/plugin/internal/SimpleDereferer.py @@ -59,10 +59,7 @@ class SimpleDereferer(Crypter): link = self.getLink() if link.strip(): - self.urls = [link.strip()] #@TODO: Remove `.strip()` in 0.4.10 - - elif not self.urls and not self.packages: #@TODO: Remove in 0.4.10 - self.fail(_("No link grabbed")) + self.urls = [link] def prepare(self): diff --git a/pyload/plugin/internal/SimpleHoster.py b/pyload/plugin/internal/SimpleHoster.py index a215e6886..add54786f 100644 --- a/pyload/plugin/internal/SimpleHoster.py +++ b/pyload/plugin/internal/SimpleHoster.py @@ -728,8 +728,8 @@ class SimpleHoster(Hoster): elif traffic == -1: return True else: - size = self.pyfile.size / 1024 - self.logInfo(_("Filesize: %i KiB, Traffic left for user %s: %i KiB") % (size, self.user, traffic)) + size = self.pyfile.size + self.logInfo(_("Filesize: %i KiB, Traffic left for user %s: %i KiB") % (size / 1024, self.user, traffic / 1024)) return size <= traffic @@ -751,8 +751,6 @@ class SimpleHoster(Hoster): self.retries = 0 raise Retry(_("Fallback to free download")) - #@TODO: Remove in 0.4.10 - def wait(self, seconds=0, reconnect=None): return _wait(self, seconds, reconnect) diff --git a/pyload/plugin/internal/XFSHoster.py b/pyload/plugin/internal/XFSHoster.py index 92ec020a6..7b8149bc3 100644 --- a/pyload/plugin/internal/XFSHoster.py +++ b/pyload/plugin/internal/XFSHoster.py @@ -113,7 +113,7 @@ class XFSHoster(SimpleHoster): self.logError(data['op'] if 'op' in data else _("UNKNOWN")) return "" - self.link = m.group(1).strip() #@TODO: Remove .strip() in 0.4.10 + self.link = m.group(1) def handlePremium(self, pyfile): |