#!/usr/bin/python # -*- coding: utf-8 -*- import urllib2 import urllib import re import time from Plugin import Plugin from time import time class RapidshareCom(Plugin): def __init__(self, parent): self.plugin_name = "Rapidshare.com" self.plugin_pattern = r"http://(?:www.)?rapidshare.com/files/" self.plugin_type = "hoster" self.plugin_config = {} pluginProp = {} pluginProp ['name'] = "RapidshareCom" pluginProp ['version'] = "0.1" pluginProp ['format'] = "*.py" pluginProp ['description'] = """Rapidshare Plugin""" pluginProp ['author'] = "spoob" pluginProp ['author_email'] = "nn@nn.de" self.pluginProp = pluginProp self.parent = parent self.html = None self.html_old = None #time() where loaded the HTML self.time_plus_wait = None #time() + wait in seconds def set_parent_status(self): """ sets all available Statusinfos about a File in self.parent.status """ if self.html == None: self.download_html() self.parent.status.filename = self.get_file_name() self.parent.status.url = self.get_file_url() self.parent.status.wait = self.wait_until() def download_html(self): """ gets the url from self.parent.url saves html in self.html and parses """ url = self.parent.url html = urllib2.urlopen(url).read() self.html = html self.html_old = time() file_server_url = re.search(r"
This limit is reached.

)", self.html) or \ re.search(r"(.*is momentarily not available.*)", self.html): return False else: return True #The uploader has removed this file from the server. 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