summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar spoob <spoob@gmx.de> 2009-12-15 23:19:06 +0100
committerGravatar spoob <spoob@gmx.de> 2009-12-15 23:19:06 +0100
commit607171fa1355a6a2e59320665887769fcd741191 (patch)
treecc89eea5cba48a112fa02fd8161530763f608b53 /module
parentFixed web/init, download script (diff)
downloadpyload-607171fa1355a6a2e59320665887769fcd741191.tar.xz
RS fixedhg
Diffstat (limited to 'module')
-rw-r--r--module/plugins/RapidshareCom.py104
-rw-r--r--module/web/__init__.py (renamed from module/web/_init_.py)0
2 files changed, 26 insertions, 78 deletions
diff --git a/module/plugins/RapidshareCom.py b/module/plugins/RapidshareCom.py
index 778383338..2fd65c706 100644
--- a/module/plugins/RapidshareCom.py
+++ b/module/plugins/RapidshareCom.py
@@ -15,7 +15,7 @@ class RapidshareCom(Plugin):
props['name'] = "RapidshareCom"
props['type'] = "hoster"
props['pattern'] = r"http://[\w\.]*?rapidshare.com/files/(\d*?)/(.*)"
- props['version'] = "0.5"
+ props['version'] = "0.9"
props['description'] = """Rapidshare.com Download Plugin"""
props['author_name'] = ("spoob", "RaNaN", "mkaay")
props['author_mail'] = ("spoob@pyload.org", "ranan@pyload.org", "mkaay@mkaay.de")
@@ -27,7 +27,7 @@ class RapidshareCom(Plugin):
self.want_reconnect = False
self.no_slots = True
self.api_data = None
- #~ self.logger = logging.getLogger("log")
+ self.url = self.parent.url
self.read_config()
if self.config['premium']:
self.multi_dl = True
@@ -41,53 +41,34 @@ class RapidshareCom(Plugin):
self.want_reconnect = False
- tries = 0
-
- while not self.start_dl or not pyfile.status.url:
-
- self.req.clear_cookies()
-
- self.download_html()
-
- pyfile.status.exists = self.file_exists()
-
- if not pyfile.status.exists:
- raise Exception, "The file was not found on the server."
-
- self.download_api_data()
-
- pyfile.status.filename = self.get_file_name()
-
- if self.config['premium']:
+ self.download_api_data()
+ if self.api_data["status"] == "1":
+ pyfile.status.exists = self.get_file_name()
+ if self.config["premium"]:
pyfile.status.url = self.parent.url
return True
+ self.download_html()
while self.no_slots:
self.download_serverhtml()
pyfile.status.waituntil = self.time_plus_wait
pyfile.status.want_reconnect = self.want_reconnect
-
thread.wait(pyfile)
pyfile.status.url = self.get_file_url()
-
- if self.no_slots:
- raise Exception, "No free slots!"
+ self.logger.info("Rapidshare: Download starts!")
- tries += 1
- if tries > 5:
- raise Exception, "Error while preparing, HTML dump:"+ str(self.html[0]) + str(self.html[1])
-
- return True
+ return True
+ else:
+ raise Exception, "The file was not found on the server."
def download_api_data(self):
"""
http://images.rapidshare.com/apidoc.txt
"""
- url = self.parent.url
api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi"
api_param = {"sub": "checkfiles_v1", "files": "", "filenames": "", "incmd5": "1"}
- m = re.compile(self.props['pattern']).search(url)
+ m = re.compile(self.props['pattern']).search(self.url)
if m:
api_param["files"] = m.group(1)
api_param["filenames"] = m.group(2)
@@ -119,8 +100,7 @@ class RapidshareCom(Plugin):
def download_html(self):
""" gets the url from self.parent.url saves html in self.html and parses
"""
- url = self.parent.url
- self.html[0] = self.req.load(url, cookies=True)
+ self.html[0] = self.req.load(self.url, cookies=True)
self.html_old = time()
def download_serverhtml(self):
@@ -130,9 +110,7 @@ class RapidshareCom(Plugin):
self.html[1] = self.req.load(file_server_url, cookies=True, post={"dl.start": "Free"})
self.html_old = time()
- self.get_wait_time()
- def get_wait_time(self):
if re.search(r"is already downloading", self.html[1]) != None:
self.time_plus_wait = time() + 10 * 60
self.no_slots = False
@@ -150,56 +128,26 @@ class RapidshareCom(Plugin):
wait_seconds = re.search(r"var c=(.*);.*", self.html[1]).group(1)
self.time_plus_wait = time() + int(wait_seconds) + 5
- def file_exists(self):
- """ returns True or False
- """
- if self.html[0] == None:
- self.download_html()
- if re.search("The file could not be found|This limit is reached| \
- is momentarily not available|removed this file| \
- contain illegal content", self.html[0], re.I) != None:
- return False
- else:
- return True
-
def get_file_url(self):
""" returns the absolute downloadable filepath
"""
- if self.config['premium']:
- self.start_dl = True
- if self.api_data and self.api_data["mirror"]:
- return self.api_data["mirror"]
- return self.parent.url
-
- #if (self.html_old + 5 * 60) < time(): # nach einiger zeit ist die file_url nicht mehr aktuell
- # self.download_serverhtml()
-
- try:
- if self.no_slots:
- self.start_dl = False
- return False
- if self.config['server'] == "":
- file_url_pattern = r".*name=\"dlf\" action=\"(.*)\" method=.*"
- else:
- file_url_pattern = '(http://rs.*)\';" /> %s<br />' % self.config['server']
+ if self.config['server'] == "":
+ file_url_pattern = r".*name=\"dlf\" action=\"(.*)\" method=.*"
+ else:
+ file_url_pattern = '(http://rs.*)\';" /> %s<br />' % self.config['server']
- self.start_dl = True
- return re.search(file_url_pattern, self.html[1]).group(1)
- except Exception, e:
- self.start_dl = False
- return False
- #print self.html[1] #test print
- #raise Exception, "Error when retrieving download url"
+ return re.search(file_url_pattern, self.html[1]).group(1)
def get_file_name(self):
- if self.html[0] == None:
- self.download_html()
- if self.api_data == None:
- self.download_api_data()
if self.api_data and self.api_data["filename"]:
return self.api_data["filename"]
- file_name_pattern = r"<p class=\"downloadlink\">.+/(.+) <font"
- return re.findall(file_name_pattern, self.html[0])[0]
+ elif self.html:
+ file_name_pattern = "<p class=\"downloadlink\">.+/(.+) <font"
+ file_name_search = re.search(file_name_pattern, self.html):
+ if file_name_search:
+ return file_name_search.group(1)
+ else:
+ return self.url.split("/")[-1]
def proceed(self, url, location):
if self.config['premium']:
@@ -218,4 +166,4 @@ class RapidshareCom(Plugin):
else:
return (False, 1)
else:
- return (True, 5)
+ return (True, 5)
diff --git a/module/web/_init_.py b/module/web/__init__.py
index e69de29bb..e69de29bb 100644
--- a/module/web/_init_.py
+++ b/module/web/__init__.py