def __init__(self, manager, fid, name, size, filestatus, media, added, fileorder, url, pluginname, hash, status, error, package, owner): self.manager = manager self.fid = int(fid) self._name = format.name(name) self._size = size self.filestatus = filestatus self.media = media self.added = added self.fileorder = fileorder self.url = url self.pluginname = pluginname self.hash = hash self.status = status self.error = error self.owner = owner self.packageid = package # database information ends here self.lock = ReadWriteLock() self.plugin = None self.wait_until = 0 #: time.time() + time to wait # status attributes self.abort = False self.reconnected = False self.statusname = None
def url_to_name(url, strict=False): url = format.url(url) url_p = urllib.parse.urlparse(url) name = url_p.path.split('/')[-1] if not name: name = url_p.query.split('=', 1)[::-1][0].split('&', 1)[0] if not name: name = url_p.netloc.split('.', 1)[0] return name.strip() if strict else format.name(name)
def set_name(self, name): """ Only set unicode or utf8 strings as name. """ name = format.name(name) # media type is updated if needed if self._name != name: self.media = guess_type(name) self._name = name
def addcrypted(): package = request.forms.get('referer', 'ClickAndLoad Package') dlc = request.forms['crypted'].replace(" ", "+") dlc_path = os.path.join(DL_ROOT, format.name(package) + ".dlc") with io.open(dlc_path, mode='wb') as fp: fp.write(dlc) try: API.add_package(package, [dlc_path], paused=True) except Exception: return HTTPError() else: return "success\r\n"
def parse_header(self): """ Parse data from received header. """ for orgline in self.decode_response(self.header).splitlines(): line = orgline.strip().lower() if line.startswith("accept-ranges") and "bytes" in line: self.p.chunk_support = True if 'content-disposition' in line: m = self._re_filename.search(orgline.strip()) if m: name = format.name(m.groupdict()['name']) self.p._name = name self.log.debug("Content-Disposition: {0}".format(name)) if not self.resume and line.startswith('content-length'): self.p._size = int(line.split(":")[1]) self.header_parsed = True
def parse_header(self): """ Parse data from received header. """ for orgline in self.decode_response(self.header).splitlines(): line = orgline.strip().lower() if line.startswith("accept-ranges") and "bytes" in line: self.p.chunk_support = True if "content-disposition" in line: m = _re_filename.search(orgline.strip()) if m: name = format.name(m.groupdict()['name']) self.p._name = name self.log.debug("Content-Disposition: {0}".format(name)) if not self.resume and line.startswith("content-length"): self.p._size = int(line.split(":")[1]) self.header_parsed = True
def alias(value): chunks = _re_alias.split(format.name(value)) return ''.join(word.capitalize() for word in chunks if word)