# -*- coding: utf-8 -*- import re from time import time from module.plugins.Hoster import Hoster import hashlib class UploadedTo(Hoster): __name__ = "UploadedTo" __type__ = "hoster" __pattern__ = r"http://(?:www\.)?u(?:p)?l(?:oaded)?\.to/(?:file/|\?id=)?(.+)" __version__ = "0.4" __description__ = """Uploaded.to Download Hoster""" __author_name__ = ("spoob", "mkaay") __author_mail__ = ("spoob@pyload.org", "mkaay@mkaay.de") def setup(self): self.html = None self.api_data = None self.multiDL = False # self.usePremium = self.config['premium'] # if self.usePremium: # self.account = self.parent.core.pluginManager.getAccountPlugin(self.__name__) # req = self.account.getAccountRequest(self) # if req: # self.req = req # self.multi_dl = True # self.req.canContinue = True # else: # self.usePremium = False def process(self, pyfile): self.url = False self.pyfile = pyfile self.prepare() self.proceed() def prepare(self): tries = 0 while not self.url: self.download_html() if not self.file_exists(): self.offline() self.download_api_data() # self.pyfile.name = self.get_file_name() # if self.usePremium: # info = self.account.getAccountInfo(self.account.getAccountData(self)[0]) # self.logger.info(_("%s: Use Premium Account (%sGB left)") % (self.__name__, info["trafficleft"]/1024/1024)) # if self.api_data["size"]/1024 > info["trafficleft"]: # self.logger.info(_("%s: Not enough traffic left" % self.__name__)) # self.usePremium = False # else: # self.pyfile.status.url = self.parent.url # return True self.url = self.get_file_url() self.setWait(self.get_waiting_time()) self.wait() self.pyfile.name = self.get_file_name() tries += 1 if tries > 5: self.fail("Error while preparing DL") return True def download_api_data(self): match = re.compile(self.__pattern__).search(self.pyfile.url) if match: src = self.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"] = int(lines[1]) # in bytes self.api_data["checksum"] = lines[2] #sha1 def download_html(self): self.html = self.load(self.pyfile.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.wantReconnect = True return 60 * int(wait_minutes) except: return 0 def get_file_url(self): # if self.usePremium: # self.start_dl = True # return self.url try: file_url_pattern = r".*