From a78e7b73331f34875b51ec145553d7434f286cec Mon Sep 17 00:00:00 2001 From: sebnapi Date: Sun, 10 May 2009 18:41:41 +0000 Subject: new plugin-sys --- Plugins/RapidshareCom.py | 120 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 90 insertions(+), 30 deletions(-) mode change 100755 => 100644 Plugins/RapidshareCom.py (limited to 'Plugins/RapidshareCom.py') diff --git a/Plugins/RapidshareCom.py b/Plugins/RapidshareCom.py old mode 100755 new mode 100644 index a3ca09e87..69a8cf933 --- a/Plugins/RapidshareCom.py +++ b/Plugins/RapidshareCom.py @@ -1,37 +1,97 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + import urllib2 import urllib import re import time -plugin_name = "Rapidshare.com" -plugin_type = "hoster" -plugin_pattern = r"http://(?:www.)?rapidshare.com/files/" - -def get_file_url(url): - root_url = urllib2.urlopen(url).read() +from Plugin import Plugin +from time import time - if re.search(r".*The File could not be found.*", root_url) != None or re.search(r"(

This limit is reached.

)", root_url) or re.search(r"(.*is momentarily not available.*)", root_url): - return ("missing", url) - else: - last_url = urllib2.urlopen(re.search(r"
This limit is reached.

)", self.html) or \ + re.search(r"(.*is momentarily not available.*)", self.html): + return False else: - try: - wait_minutes = re.search(r"Or try again in about (\d+) minute", last_url).group(1) - return ('wait', wait_minutes) - - except: - if re.search(r".*Currently a lot of users.*", last_url) != None: - return ('wait', 2) - else: - wait_seconds = re.search(r"var c=(.*);.*", last_url).group(1) - file_url = re.search(r".*name=\"dlf\" action=\"(.*)\" method=.*", last_url).group(1) - file_name = file_url.split('/')[-1] - - for second in range(1, int(wait_seconds) + 1): - print "Noch " + str(int(wait_seconds) + 1 - second - 1) + " Sekunden zum Download von " + file_name - time.sleep(1) - - return ("download", (file_url, file_name)) + return True + + def get_file_url(self): + """ returns the absolute downloadable filepath + """ + if self.html == None: + self.download_html() + if (self.html_old + 5*60) > time(): # nach einiger zeit ist die file_url nicht mehr aktuell + self.download_html() + file_url_pattern = r".*name=\"dlf\" action=\"(.*)\" method=.*" + return re.search(file_url_pattern, self.html).group(1) + + def get_file_name(self): + if self.html == None: + self.download_html() + file_name_pattern = r".*name=\"dlf\" action=\"(.*)\" method=.*" + return re.search(file_name_pattern, self.html).group(1).split('/')[-1] + + def wait_until(self): + if self.html == None: + self.download_html() + return self.time_plus_wait + + + def __call__(self): + return self.plugin_name -- cgit v1.2.3