From 8e87787753b2e049917a5491727d285b1c5a7095 Mon Sep 17 00:00:00 2001 From: mkaay Date: Sun, 27 Dec 2009 00:20:21 +0100 Subject: closes #13 --- module/plugins/hoster/RapidshareCom.py | 191 +++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) create 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 new file mode 100644 index 000000000..973e28470 --- /dev/null +++ b/module/plugins/hoster/RapidshareCom.py @@ -0,0 +1,191 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +from time import time + +from module.Plugin import Plugin +import hashlib + +class RapidshareCom(Plugin): + + def __init__(self, parent): + Plugin.__init__(self, parent) + props = {} + props['name'] = "RapidshareCom" + props['type'] = "hoster" + props['pattern'] = r"http://[\w\.]*?rapidshare.com/files/(\d*?)/(.*)" + props['version'] = "1.0" + props['description'] = """Rapidshare.com Download Plugin""" + props['author_name'] = ("spoob", "RaNaN", "mkaay") + props['author_mail'] = ("spoob@pyload.org", "ranan@pyload.org", "mkaay@mkaay.de") + self.props = props + self.parent = parent + self.html = [None, None] + self.html_old = None #time() where loaded the HTML + self.time_plus_wait = None #time() + wait in seconds + self.want_reconnect = False + self.no_slots = True + self.api_data = None + self.url = self.parent.url + self.read_config() + if self.config['premium']: + self.multi_dl = True + else: + self.multi_dl = False + + self.start_dl = False + + def prepare(self, thread): + pyfile = self.parent + self.req.clear_cookies() + + self.download_api_data() + if self.api_data["status"] == "1": + pyfile.status.filename = self.get_file_name() + + if self.config["premium"]: + self.logger.info("Rapidshare: Use Premium Account (%sGB left)" % (self.props["premkbleft"]/1000000)) + pyfile.status.url = self.parent.url + return True + + self.download_html() + while self.no_slots: + self.get_wait_time() + pyfile.status.waituntil = self.time_plus_wait + pyfile.status.want_reconnect = self.want_reconnect + thread.wait(pyfile) + + pyfile.status.url = self.get_file_url() + + return True + elif self.api_data["status"] == "2": + self.logger.info("Rapidshare: Traffic Share (direct download)") + pyfile.status.filename = self.get_file_name() + pyfile.status.url = self.parent.url + return True + else: + raise Exception, "The file was not found on the server." + + def download_api_data(self): + """ + http://images.rapidshare.com/apidoc.txt + """ + api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi" + api_param_file = {"sub": "checkfiles_v1", "files": "", "filenames": "", "incmd5": "1"} + m = re.compile(self.props['pattern']).search(self.url) + if m: + api_param_file["files"] = m.group(1) + api_param_file["filenames"] = m.group(2) + src = self.req.load(api_url_base, cookies=False, get=api_param_file) + if src.startswith("ERROR"): + return + fields = src.split(",") + self.api_data = {} + self.api_data["fileid"] = fields[0] + self.api_data["filename"] = fields[1] + self.api_data["size"] = fields[2] # in bytes + self.api_data["serverid"] = fields[3] + self.api_data["status"] = fields[4] + """ + status codes: + 0=File not found + 1=File OK (Downloading possible without any logging) + 2=File OK (TrafficShare direct download without any logging) + 3=Server down + 4=File marked as illegal + 5=Anonymous file locked, because it has more than 10 downloads already + 6=File OK (TrafficShare direct download with enabled logging) + """ + self.api_data["shorthost"] = fields[5] + self.api_data["checksum"] = fields[6].strip().lower() # md5 + + self.api_data["mirror"] = "http://rs%(serverid)s%(shorthost)s.rapidshare.com/files/%(fileid)s/%(filename)s" % self.api_data + + if self.config["premium"]: + api_param_prem = {"sub": "getaccountdetails_v1", "type": "prem", \ + "login": self.config['username'], "password": self.config['password']} + src = self.req.load(api_url_base, cookies=False, get=api_param_prem) + if src.startswith("ERROR"): + self.config["premium"] = False + self.logger.info("Rapidshare: Login faild") + return + fields = src.split("\n") + premkbleft = int(fields[19].split("=")[1]) + if premkbleft < int(self.api_data["size"][0:-3]): + self.logger.info("Rapidshare: Not enough traffic left") + self.config["premium"] = False + else: + self.props["premkbleft"] = premkbleft + + def download_html(self): + """ gets the url from self.parent.url saves html in self.html and parses + """ + self.html[0] = self.req.load(self.url, cookies=True) + self.html_old = time() + + def get_wait_time(self): + """downloads html with the important informations + """ + file_server_url = re.search(r"
%s
' % self.config['server'] + + return re.search(file_url_pattern, self.html[1]).group(1) + + def get_file_name(self): + if self.api_data["filename"]: + return self.api_data["filename"] + elif self.html[0]: + file_name_pattern = r"

.+/(.+) Date: Sun, 27 Dec 2009 23:29:51 +0100 Subject: Fixed Reconnect in Netload and Rapidshare --- 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 973e28470..5da9996fd 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -39,6 +39,7 @@ class RapidshareCom(Plugin): def prepare(self, thread): pyfile = self.parent self.req.clear_cookies() + self.want_reconnect = False self.download_api_data() if self.api_data["status"] == "1": -- cgit v1.2.3 From ce2a8294b5aefe4497c88f24c817084868b8b1eb Mon Sep 17 00:00:00 2001 From: mkaay Date: Mon, 28 Dec 2009 15:32:06 +0100 Subject: gui now stable --- 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 5da9996fd..754c885ef 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -109,7 +109,7 @@ class RapidshareCom(Plugin): src = self.req.load(api_url_base, cookies=False, get=api_param_prem) if src.startswith("ERROR"): self.config["premium"] = False - self.logger.info("Rapidshare: Login faild") + self.logger.info("Rapidshare: Login failed") return fields = src.split("\n") premkbleft = int(fields[19].split("=")[1]) -- cgit v1.2.3 From 8e9353a2e42a2e98d93618af1b6435568c44fa0f Mon Sep 17 00:00:00 2001 From: spoob Date: Tue, 5 Jan 2010 23:18:53 +0100 Subject: fixed rapidshare slot wait --- 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 754c885ef..677916dcf 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -143,7 +143,7 @@ class RapidshareCom(Plugin): self.time_plus_wait = time() + 60 * int(wait_minutes) self.want_reconnect = True except: - if re.search(r"(Currently a lot of users|There are no more download slots)", self.html[1], re.I) != None: + if re.search(r"(currently a lot of users|no more download slots)", self.html[1], re.I) != None: self.time_plus_wait = time() + 130 self.logger.info("Rapidshare: No free slots!") self.no_slots = True -- cgit v1.2.3 From 1896a9faec5871f8051a8dfa407883cef46bb6df Mon Sep 17 00:00:00 2001 From: spoob Date: Thu, 7 Jan 2010 15:59:23 +0100 Subject: Better Rapidshare Slot Check thanks #66 --- 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 677916dcf..10654e5c8 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -143,7 +143,7 @@ class RapidshareCom(Plugin): self.time_plus_wait = time() + 60 * int(wait_minutes) self.want_reconnect = True except: - if re.search(r"(currently a lot of users|no more download slots)", self.html[1], re.I) != None: + if re.search(r"(Currently a lot of users|no more download slots|servers are overloaded)", self.html[1], re.I) != None: self.time_plus_wait = time() + 130 self.logger.info("Rapidshare: No free slots!") self.no_slots = True -- cgit v1.2.3