#!/usr/bin/env python # -*- coding: utf-8 -*- import re from time import time from module.Plugin import Plugin import hashlib class UploadedTo(Plugin): def __init__(self, parent): Plugin.__init__(self, parent) props = {} props['name'] = "UploadedTo" props['type'] = "hoster" props['pattern'] = r"http://(?:www\.)?u(?:p)?l(?:oaded)?\.to/(?:file/)?(.*)" props['version'] = "0.3" props['description'] = """Uploaded.to Download Plugin""" props['author_name'] = ("spoob", "mkaay") props['author_mail'] = ("spoob@pyload.org", "mkaay@mkaay.de") self.props = props self.parent = parent self.html = None self.time_plus_wait = None #time() + wait in seconds self.api_data = None self.want_reconnect = False 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.want_reconnect = False tries = 0 while 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']: pyfile.status.url = self.parent.url return True self.get_waiting_time() pyfile.status.waituntil = self.time_plus_wait pyfile.status.url = self.get_file_url() pyfile.status.want_reconnect = self.want_reconnect thread.wait(self.parent) pyfile.status.filename = self.get_file_name() tries += 1 if tries > 5: raise Exception, "Error while preparing DL" return True def download_api_data(self): url = self.parent.url match = re.compile(self.props['pattern']).search(url) if match: src = self.req.load("http://uploaded.to/api/file", cookies=False, get={"id": match.group(1).split("/")[0]}) if not src.find("404 Not Found"): return self.api_data = {} lines = src.splitlines() self.api_data["filename"] = lines[0] self.api_data["size"] = lines[1] # in kbytes self.api_data["checksum"] = lines[2] #sha1 def download_html(self): url = self.parent.url self.html = self.req.load(url, cookies=False) def get_waiting_time(self): try: wait_minutes = re.search(r"Or wait ([\d\-]+) minutes", self.html).group(1) if int(wait_minutes) < 0: wait_minutes = 1 self.time_plus_wait = time() + 60 * int(wait_minutes) self.want_reconnect = True except: self.time_plus_wait = 0 def get_file_url(self): """ returns the absolute downloadable filepath """ if self.config['premium']: self.start_dl = True return self.parent.url try: file_url_pattern = r".*