From 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 15 Jul 2014 16:25:41 +0200 Subject: Fix code indentation, some bad whitespaces and missing authors + use 'not' instead 'is None' + replace __pattern__'s r" with r' + other minor cosmetics --- module/plugins/hoster/RapidshareCom.py | 1 - 1 file changed, 1 deletion(-) (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index e5ab6b445..4ecd3c841 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -109,7 +109,6 @@ class RapidshareCom(Hoster): self.fail("Unknown response code.") def handleFree(self): - while self.no_download: self.dl_dict = self.freeWait() -- cgit v1.2.3 From 7b8c458cca7d21a029620f98e453f746fce69cd1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 16:10:01 +0200 Subject: Prefer single quote for dict key name --- module/plugins/hoster/RapidshareCom.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 4ecd3c841..b50f1c568 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -87,7 +87,7 @@ class RapidshareCom(Hoster): self.name = m.group("name_new") self.download_api_data() - if self.api_data["status"] == "1": + if self.api_data['status'] == "1": self.pyfile.name = self.get_file_name() if self.premium: @@ -95,15 +95,15 @@ class RapidshareCom(Hoster): else: self.handleFree() - elif self.api_data["status"] == "2": + elif self.api_data['status'] == "2": self.logInfo(_("Rapidshare: Traffic Share (direct download)")) self.pyfile.name = self.get_file_name() self.download(self.pyfile.url, get={"directstart": 1}) - elif self.api_data["status"] in ("0", "4", "5"): + elif self.api_data['status'] in ("0", "4", "5"): self.offline() - elif self.api_data["status"] == "3": + elif self.api_data['status'] == "3": self.tempOffline() else: self.fail("Unknown response code.") @@ -133,7 +133,7 @@ class RapidshareCom(Hoster): def handlePremium(self): info = self.account.getAccountInfo(self.user, True) self.logDebug("%s: Use Premium Account" % self.__name__) - url = self.api_data["mirror"] + url = self.api_data['mirror'] self.download(url, get={"directstart": 1}) def download_api_data(self, force=False): @@ -163,12 +163,12 @@ class RapidshareCom(Hoster): self.api_data = {"fileid": fields[0], "filename": fields[1], "size": int(fields[2]), "serverid": fields[3], "status": fields[4], "shorthost": fields[5], "checksum": fields[6].strip().lower()} - if int(self.api_data["status"]) > 100: - self.api_data["status"] = str(int(self.api_data["status"]) - 100) - elif int(self.api_data["status"]) > 50: - self.api_data["status"] = str(int(self.api_data["status"]) - 50) + if int(self.api_data['status']) > 100: + self.api_data['status'] = str(int(self.api_data['status']) - 100) + elif int(self.api_data['status']) > 50: + self.api_data['status'] = str(int(self.api_data['status']) - 50) - self.api_data["mirror"] = "http://rs%(serverid)s%(shorthost)s.rapidshare.com/files/%(fileid)s/%(filename)s" % self.api_data + self.api_data['mirror'] = "http://rs%(serverid)s%(shorthost)s.rapidshare.com/files/%(fileid)s/%(filename)s" % self.api_data def freeWait(self): """downloads html with the important information @@ -214,14 +214,14 @@ class RapidshareCom(Hoster): "name": name, "host": data[0], "auth": data[1], - "server": self.api_data["serverid"], - "size": self.api_data["size"]} + "server": self.api_data['serverid'], + "size": self.api_data['size']} self.setWait(int(data[2]) + 2 + self.offset) self.wait() return dl_dict def get_file_name(self): - if self.api_data["filename"]: - return self.api_data["filename"] + if self.api_data['filename']: + return self.api_data['filename'] return self.url.split("/")[-1] -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/hoster/RapidshareCom.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index b50f1c568..19d6cf772 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -1,12 +1,5 @@ # -*- coding: utf-8 -*- -# v1.36 -# * fixed call checkfiles subroutine -# v1.35 -# * fixed rs-urls in handleFree(..) and freeWait(..) -# * removed getInfo(..) function as it was not used anywhere (in this file) -# * removed some (old?) comment blocks - import re from module.network.RequestFactory import getURL @@ -51,15 +44,18 @@ def getInfo(urls): class RapidshareCom(Hoster): __name__ = "RapidshareCom" __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?rapidshare.com/(?:files/(?P\d*?)/(?P[^?]+)|#!download\|(?:\w+)\|(?P\d+)\|(?P[^|]+))' __version__ = "1.39" - __description__ = """Rapidshare.com hoster plugin""" + + __pattern__ = r'https?://(?:www\.)?rapidshare.com/(?:files/(?P\d*?)/(?P[^?]+)|#!download\|(?:\w+)\|(?P\d+)\|(?P[^|]+))' __config__ = [("server", "Cogent;Deutsche Telekom;Level(3);Level(3) #2;GlobalCrossing;Level(3) #3;Teleglobe;GlobalCrossing #2;TeliaSonera #2;Teleglobe #2;TeliaSonera #3;TeliaSonera", "Preferred Server", "None")] + + __description__ = """Rapidshare.com hoster plugin""" __author_name__ = ("spoob", "RaNaN", "mkaay") __author_mail__ = ("spoob@pyload.org", "ranan@pyload.org", "mkaay@mkaay.de") + def setup(self): self.no_download = True self.api_data = None -- cgit v1.2.3 From b0868ae6446078bacf1635dde5e4ab316b4a94cb Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Oct 2014 18:57:59 +0200 Subject: New __authors__ key replaces __author_name__ and __author_mail__ + Whitespaces and EOF fixup --- module/plugins/hoster/RapidshareCom.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 19d6cf772..7ece1ffee 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -52,8 +52,9 @@ class RapidshareCom(Hoster): "Preferred Server", "None")] __description__ = """Rapidshare.com hoster plugin""" - __author_name__ = ("spoob", "RaNaN", "mkaay") - __author_mail__ = ("spoob@pyload.org", "ranan@pyload.org", "mkaay@mkaay.de") + __authors__ = [("spoob", "spoob@pyload.org"), + ("RaNaN", "ranan@pyload.org"), + ("mkaay", "mkaay@mkaay.de")] def setup(self): -- cgit v1.2.3 From ae7a7e66981456e5bbe2b54006d79b6f907be7a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 8 Oct 2014 20:18:13 +0200 Subject: Add __license__ key attribute to plugins --- module/plugins/hoster/RapidshareCom.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 7ece1ffee..22887e7cc 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -52,6 +52,7 @@ class RapidshareCom(Hoster): "Preferred Server", "None")] __description__ = """Rapidshare.com hoster plugin""" + __license__ = "GPLv3" __authors__ = [("spoob", "spoob@pyload.org"), ("RaNaN", "ranan@pyload.org"), ("mkaay", "mkaay@mkaay.de")] -- cgit v1.2.3 From f76e5c2336718dca9da8033ba22cd83c72c7b3b3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 11 Oct 2014 15:14:28 +0200 Subject: Pattern update 1 --- module/plugins/hoster/RapidshareCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 22887e7cc..88154b5e9 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -46,7 +46,7 @@ class RapidshareCom(Hoster): __type__ = "hoster" __version__ = "1.39" - __pattern__ = r'https?://(?:www\.)?rapidshare.com/(?:files/(?P\d*?)/(?P[^?]+)|#!download\|(?:\w+)\|(?P\d+)\|(?P[^|]+))' + __pattern__ = r'https?://(?:www\.)?rapidshare.com/(?:files/(?P\d+)/(?P[^?]+)|#!download\|(?:\w+)\|(?P\d+)\|(?P[^|]+))' __config__ = [("server", "Cogent;Deutsche Telekom;Level(3);Level(3) #2;GlobalCrossing;Level(3) #3;Teleglobe;GlobalCrossing #2;TeliaSonera #2;Teleglobe #2;TeliaSonera #3;TeliaSonera", "Preferred Server", "None")] -- cgit v1.2.3 From c5d1a4fd8943877c6d2eb3843e0de725dba5191e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 11 Oct 2014 15:09:53 +0200 Subject: Pattern update 2 --- module/plugins/hoster/RapidshareCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 88154b5e9..befbbb123 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -46,7 +46,7 @@ class RapidshareCom(Hoster): __type__ = "hoster" __version__ = "1.39" - __pattern__ = r'https?://(?:www\.)?rapidshare.com/(?:files/(?P\d+)/(?P[^?]+)|#!download\|(?:\w+)\|(?P\d+)\|(?P[^|]+))' + __pattern__ = r'https?://(?:www\.)?rapidshare\.com/(?:files/(?P\d+)/(?P[^?]+)|#!download\|(?:\w+)\|(?P\d+)\|(?P[^|]+))' __config__ = [("server", "Cogent;Deutsche Telekom;Level(3);Level(3) #2;GlobalCrossing;Level(3) #3;Teleglobe;GlobalCrossing #2;TeliaSonera #2;Teleglobe #2;TeliaSonera #3;TeliaSonera", "Preferred Server", "None")] -- cgit v1.2.3 From 0eb6e7ec4a1144dcca824d8add049787d3da1762 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 19:44:59 +0200 Subject: Two space before function declaration --- module/plugins/hoster/RapidshareCom.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index befbbb123..2dd36b84e 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -70,10 +70,12 @@ class RapidshareCom(Hoster): self.chunkLimit = -1 if self.premium else 1 self.multiDL = self.resumeDownload = self.premium + def process(self, pyfile): self.url = pyfile.url self.prepare() + def prepare(self): m = re.match(self.__pattern__, self.url) @@ -106,6 +108,7 @@ class RapidshareCom(Hoster): else: self.fail("Unknown response code.") + def handleFree(self): while self.no_download: self.dl_dict = self.freeWait() @@ -128,12 +131,14 @@ class RapidshareCom(Hoster): self.offset += 5 self.handleFree() + def handlePremium(self): info = self.account.getAccountInfo(self.user, True) self.logDebug("%s: Use Premium Account" % self.__name__) url = self.api_data['mirror'] self.download(url, get={"directstart": 1}) + def download_api_data(self, force=False): """ http://images.rapidshare.com/apidoc.txt @@ -168,6 +173,7 @@ class RapidshareCom(Hoster): self.api_data['mirror'] = "http://rs%(serverid)s%(shorthost)s.rapidshare.com/files/%(fileid)s/%(filename)s" % self.api_data + def freeWait(self): """downloads html with the important information """ @@ -219,6 +225,7 @@ class RapidshareCom(Hoster): return dl_dict + def get_file_name(self): if self.api_data['filename']: return self.api_data['filename'] -- cgit v1.2.3 From 8cde8385b0224f8fa26758f6c2b6b782e5fb3663 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 23 Oct 2014 22:34:36 +0200 Subject: Call error instead fail in some plugins --- module/plugins/hoster/RapidshareCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 2dd36b84e..b0462e82c 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -106,7 +106,7 @@ class RapidshareCom(Hoster): elif self.api_data['status'] == "3": self.tempOffline() else: - self.fail("Unknown response code.") + self.error("Unknown response code.") def handleFree(self): -- cgit v1.2.3 From 9f2ebe486a3e155fb6a60e07cccb77ab6a772eb2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 26 Oct 2014 02:31:54 +0200 Subject: Extend translation support in plugins + a lot of code cosmetics and typo fixes --- module/plugins/hoster/RapidshareCom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index b0462e82c..1b8967108 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -106,7 +106,7 @@ class RapidshareCom(Hoster): elif self.api_data['status'] == "3": self.tempOffline() else: - self.error("Unknown response code.") + self.error(_("Unknown response code")) def handleFree(self): @@ -134,7 +134,7 @@ class RapidshareCom(Hoster): def handlePremium(self): info = self.account.getAccountInfo(self.user, True) - self.logDebug("%s: Use Premium Account" % self.__name__) + self.logDebug("Use Premium Account") url = self.api_data['mirror'] self.download(url, get={"directstart": 1}) -- cgit v1.2.3 From 8b3589dd394d81177bf4680dddb5bdb9506b89ea Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 16:04:10 +0100 Subject: Update plugins to last changes --- module/plugins/hoster/RapidshareCom.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 1b8967108..24e39f8f8 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -205,8 +205,7 @@ class RapidshareCom(Hoster): elif "Filename invalid." in result: self.fail(_("Filename reported invalid")) elif between_wait: - self.setWait(int(between_wait.group(1))) - self.wantReconnect = True + self.setWait(int(between_wait.group(1)), True) self.wait() else: self.no_download = False -- cgit v1.2.3 From 34984dae733c3f3d47b41a0acfba3724d53c65a1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 16:52:10 +0100 Subject: Code cosmetics: plugin class attributes --- module/plugins/hoster/RapidshareCom.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 24e39f8f8..30abd7c7f 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -42,8 +42,8 @@ def getInfo(urls): class RapidshareCom(Hoster): - __name__ = "RapidshareCom" - __type__ = "hoster" + __name__ = "RapidshareCom" + __type__ = "hoster" __version__ = "1.39" __pattern__ = r'https?://(?:www\.)?rapidshare\.com/(?:files/(?P\d+)/(?P[^?]+)|#!download\|(?:\w+)\|(?P\d+)\|(?P[^|]+))' @@ -52,10 +52,10 @@ class RapidshareCom(Hoster): "Preferred Server", "None")] __description__ = """Rapidshare.com hoster plugin""" - __license__ = "GPLv3" - __authors__ = [("spoob", "spoob@pyload.org"), - ("RaNaN", "ranan@pyload.org"), - ("mkaay", "mkaay@mkaay.de")] + __license__ = "GPLv3" + __authors__ = [("spoob", "spoob@pyload.org"), + ("RaNaN", "ranan@pyload.org"), + ("mkaay", "mkaay@mkaay.de")] def setup(self): -- cgit v1.2.3 From 12bf6e492c980814646c6bc6e88a2ed759f5acbc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 9 Nov 2014 16:52:01 +0100 Subject: [PluginManager] Improve error handling for parse method --- module/plugins/hoster/RapidshareCom.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 30abd7c7f..2a81108cd 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -44,12 +44,9 @@ def getInfo(urls): class RapidshareCom(Hoster): __name__ = "RapidshareCom" __type__ = "hoster" - __version__ = "1.39" + __version__ = "1.40" __pattern__ = r'https?://(?:www\.)?rapidshare\.com/(?:files/(?P\d+)/(?P[^?]+)|#!download\|(?:\w+)\|(?P\d+)\|(?P[^|]+))' - __config__ = [("server", - "Cogent;Deutsche Telekom;Level(3);Level(3) #2;GlobalCrossing;Level(3) #3;Teleglobe;GlobalCrossing #2;TeliaSonera #2;Teleglobe #2;TeliaSonera #3;TeliaSonera", - "Preferred Server", "None")] __description__ = """Rapidshare.com hoster plugin""" __license__ = "GPLv3" -- cgit v1.2.3 From c9e31d875d32de31e54959b82bc35eff2b3e0f3f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 10 Nov 2014 00:19:51 +0100 Subject: Code cosmetics --- module/plugins/hoster/RapidshareCom.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 2a81108cd..4ec5af67a 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -144,11 +144,11 @@ class RapidshareCom(Hoster): return api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi" api_param_file = {"sub": "checkfiles", "incmd5": "1", "files": self.id, "filenames": self.name} - src = self.load(api_url_base, cookies=False, get=api_param_file).strip() - self.logDebug("RS INFO API: %s" % src) - if src.startswith("ERROR"): + html = self.load(api_url_base, cookies=False, get=api_param_file).strip() + self.logDebug("RS INFO API: %s" % html) + if html.startswith("ERROR"): return - fields = src.split(",") + fields = html.split(",") # status codes: # 0=File not found -- cgit v1.2.3 From 67587fbe0335cacfde28a86ba729b9d567ce1da7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 7 Dec 2014 00:27:18 +0100 Subject: Plugin code cosmetics (3) --- module/plugins/hoster/RapidshareCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 4ec5af67a..5ec837c58 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -65,7 +65,7 @@ class RapidshareCom(Hoster): self.name = None self.chunkLimit = -1 if self.premium else 1 - self.multiDL = self.resumeDownload = self.premium + self.multiDL = self.resumeDownload = self.premium def process(self, pyfile): -- cgit v1.2.3 From cf91e7fd171417f2a35d1149c4efff9a66beaab7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 7 Dec 2014 00:28:34 +0100 Subject: [RapidshareCom] Remove (very) old plugin --- module/plugins/hoster/RapidshareCom.py | 228 --------------------------------- 1 file changed, 228 deletions(-) delete mode 100644 module/plugins/hoster/RapidshareCom.py (limited to 'module/plugins/hoster/RapidshareCom.py') diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py deleted file mode 100644 index 5ec837c58..000000000 --- a/module/plugins/hoster/RapidshareCom.py +++ /dev/null @@ -1,228 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from module.network.RequestFactory import getURL -from module.plugins.Hoster import Hoster - - -def getInfo(urls): - ids = "" - names = "" - - p = re.compile(RapidshareCom.__pattern__) - - for url in urls: - r = p.search(url) - if r.group("name"): - ids += "," + r.group("id") - names += "," + r.group("name") - elif r.group("name_new"): - ids += "," + r.group("id_new") - names += "," + r.group("name_new") - - url = "http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles&files=%s&filenames=%s" % (ids[1:], names[1:]) - - api = getURL(url) - result = [] - i = 0 - for res in api.split(): - tmp = res.split(",") - if tmp[4] in ("0", "4", "5"): - status = 1 - elif tmp[4] == "1": - status = 2 - else: - status = 3 - - result.append((tmp[1], tmp[2], status, urls[i])) - i += 1 - - yield result - - -class RapidshareCom(Hoster): - __name__ = "RapidshareCom" - __type__ = "hoster" - __version__ = "1.40" - - __pattern__ = r'https?://(?:www\.)?rapidshare\.com/(?:files/(?P\d+)/(?P[^?]+)|#!download\|(?:\w+)\|(?P\d+)\|(?P[^|]+))' - - __description__ = """Rapidshare.com hoster plugin""" - __license__ = "GPLv3" - __authors__ = [("spoob", "spoob@pyload.org"), - ("RaNaN", "ranan@pyload.org"), - ("mkaay", "mkaay@mkaay.de")] - - - def setup(self): - self.no_download = True - self.api_data = None - self.offset = 0 - self.dl_dict = {} - - self.id = None - self.name = None - - self.chunkLimit = -1 if self.premium else 1 - self.multiDL = self.resumeDownload = self.premium - - - def process(self, pyfile): - self.url = pyfile.url - self.prepare() - - - def prepare(self): - m = re.match(self.__pattern__, self.url) - - if m.group("name"): - self.id = m.group("id") - self.name = m.group("name") - else: - self.id = m.group("id_new") - self.name = m.group("name_new") - - self.download_api_data() - if self.api_data['status'] == "1": - self.pyfile.name = self.get_file_name() - - if self.premium: - self.handlePremium() - else: - self.handleFree() - - elif self.api_data['status'] == "2": - self.logInfo(_("Rapidshare: Traffic Share (direct download)")) - self.pyfile.name = self.get_file_name() - - self.download(self.pyfile.url, get={"directstart": 1}) - - elif self.api_data['status'] in ("0", "4", "5"): - self.offline() - elif self.api_data['status'] == "3": - self.tempOffline() - else: - self.error(_("Unknown response code")) - - - def handleFree(self): - while self.no_download: - self.dl_dict = self.freeWait() - - #tmp = "#!download|%(server)s|%(id)s|%(name)s|%(size)s" - download = "http://%(host)s/cgi-bin/rsapi.cgi?sub=download&editparentlocation=0&bin=1&fileid=%(id)s&filename=%(name)s&dlauth=%(auth)s" % self.dl_dict - - self.logDebug("RS API Request: %s" % download) - self.download(download, ref=False) - - check = self.checkDownload({"ip": "You need RapidPro to download more files from your IP address", - "auth": "Download auth invalid"}) - if check == "ip": - self.setWait(60) - self.logInfo(_("Already downloading from this ip address, waiting 60 seconds")) - self.wait() - self.handleFree() - elif check == "auth": - self.logInfo(_("Invalid Auth Code, download will be restarted")) - self.offset += 5 - self.handleFree() - - - def handlePremium(self): - info = self.account.getAccountInfo(self.user, True) - self.logDebug("Use Premium Account") - url = self.api_data['mirror'] - self.download(url, get={"directstart": 1}) - - - def download_api_data(self, force=False): - """ - http://images.rapidshare.com/apidoc.txt - """ - if self.api_data and not force: - return - api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi" - api_param_file = {"sub": "checkfiles", "incmd5": "1", "files": self.id, "filenames": self.name} - html = self.load(api_url_base, cookies=False, get=api_param_file).strip() - self.logDebug("RS INFO API: %s" % html) - if html.startswith("ERROR"): - return - fields = html.split(",") - - # status codes: - # 0=File not found - # 1=File OK (Anonymous downloading) - # 3=Server down - # 4=File marked as illegal - # 5=Anonymous file locked, because it has more than 10 downloads already - # 50+n=File OK (TrafficShare direct download type "n" without any logging.) - # 100+n=File OK (TrafficShare direct download type "n" with logging. - # Read our privacy policy to see what is logged.) - - self.api_data = {"fileid": fields[0], "filename": fields[1], "size": int(fields[2]), "serverid": fields[3], - "status": fields[4], "shorthost": fields[5], "checksum": fields[6].strip().lower()} - - if int(self.api_data['status']) > 100: - self.api_data['status'] = str(int(self.api_data['status']) - 100) - elif int(self.api_data['status']) > 50: - self.api_data['status'] = str(int(self.api_data['status']) - 50) - - self.api_data['mirror'] = "http://rs%(serverid)s%(shorthost)s.rapidshare.com/files/%(fileid)s/%(filename)s" % self.api_data - - - def freeWait(self): - """downloads html with the important information - """ - self.no_download = True - - id = self.id - name = self.name - - prepare = "https://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=%(id)s&filename=%(name)s&try=1&cbf=RSAPIDispatcher&cbid=1" % { - "name": name, "id": id} - - self.logDebug("RS API Request: %s" % prepare) - result = self.load(prepare, ref=False) - self.logDebug("RS API Result: %s" % result) - - between_wait = re.search("You need to wait (\d+) seconds", result) - - if "You need RapidPro to download more files from your IP address" in result: - self.setWait(60) - self.logInfo(_("Already downloading from this ip address, waiting 60 seconds")) - self.wait() - elif ("Too many users downloading from this server right now" in result or - "All free download slots are full" in result): - self.setWait(120) - self.logInfo(_("RapidShareCom: No free slots")) - self.wait() - elif "This file is too big to download it for free" in result: - self.fail(_("You need a premium account for this file")) - elif "Filename invalid." in result: - self.fail(_("Filename reported invalid")) - elif between_wait: - self.setWait(int(between_wait.group(1)), True) - self.wait() - else: - self.no_download = False - - tmp, info = result.split(":") - data = info.split(",") - - dl_dict = {"id": id, - "name": name, - "host": data[0], - "auth": data[1], - "server": self.api_data['serverid'], - "size": self.api_data['size']} - self.setWait(int(data[2]) + 2 + self.offset) - self.wait() - - return dl_dict - - - def get_file_name(self): - if self.api_data['filename']: - return self.api_data['filename'] - return self.url.split("/")[-1] -- cgit v1.2.3