def _file_object(f): mimetype = f.mimetype processor = get_processor(f.processor) metadata = {} if f.metadata and f.metadata != 'None': metadata = json.loads(f.metadata) ret = { 'original': media_url(f.original, absolute=False), 'type': mimetype, 'blob_type': normalise_processor(f.processor), 'hash': f.hash, 'files': [], 'extras': [], 'metadata': metadata, 'flags': f.flags.as_dict(), 'title': f.title, 'description': f.description, } if f.compression: ret['compression'] = float(f.compression) ret['files'].append(_file_entry(f.original, mimetype=f.mimetype)) for f_ext in processor.outputs: name = "%s.%s" % (f.hash, f_ext) if name == f.original: continue ret['files'].append(_file_entry(name)) for f_ext in processor.extras: ret['extras'].append(_file_entry("%s.%s" % (f.hash, f_ext))) return ret
def _file_object(f): mimetype = f.mimetype processor = get_processor(f.processor) ret = { 'original': media_url(f.original), 'type': mimetype, 'blob_type': normalise_processor(f.processor), 'hash': f.hash, 'files': [], 'extras': [], 'flags': f.flags.as_dict(), } if f.compression: ret['compression'] = float(f.compression) ret['files'].append(_file_entry(f.original, mimetype=f.mimetype)) for f_ext in processor.outputs: name = "%s.%s" % (f.hash, f_ext) if name == f.original: continue ret['files'].append(_file_entry(name)) for f_ext in processor.extras: ret['extras'].append(_file_entry("%s.%s" % (f.hash, f_ext))) return ret
def _file_object(f): mimetype = f.mimetype processor = get_processor(f.processor) metadata = {} if f.metadata and f.metadata != "None": metadata = json.loads(f.metadata) ret = { "original": media_url(f.original, absolute=False), "type": mimetype, "blob_type": normalise_processor(f.processor), "hash": f.hash, "files": [], "extras": [], "metadata": metadata, "flags": f.flags.as_dict(), "title": f.title, "description": f.description, } if f.compression: ret["compression"] = float(f.compression) ret["files"].append(_file_entry(f.original, mimetype=f.mimetype)) for f_ext in processor.outputs: name = "%s.%s" % (f.hash, f_ext) if name == f.original: continue ret["files"].append(_file_entry(name)) for f_ext in processor.extras: ret["extras"].append(_file_entry("%s.%s" % (f.hash, f_ext))) return ret
def fragment(processor): np = normalise_processor(processor) if np == 'video' and g.mobile: return 'mobilevideo' else: return np
def _template_params(f): if f.compression: compression = int(float(f.compression) * 100) if compression == 100 or f.status != "done": compression = None can_delete = None try: if request.cookies.get('hist-opt-out', '0') == '1': can_delete = check_password_hash(f.ip, get_ip()) except: pass mimetype = f.mimetype processor = get_processor(f.processor) types = [mimetype] for f_ext in processor.outputs: types.append(get_mimetype(f_ext)) if 'do-not-send' in request.cookies: try: blacklist = json.loads(request.cookies['do-not-send']) for t in blacklist: if t in types: types.remove(t) except: pass metadata = {} if f.metadata and f.metadata != 'null': metadata = json.loads(f.metadata) subtitles = None if 'subtitles' in metadata and 'streams' in metadata['subtitles']: for stream in metadata['subtitles']['streams']: if stream['type'] == 'subtitle': subtitles = stream if subtitles['info']['codec_name'] == 'ssa': subtitles['info']['codec_name'] = 'ass' subtitles['url'] = '/' + f.hash + '.' + subtitles['info']['codec_name'] break return { 'filename': f.hash, 'original': f.original, 'video': normalise_processor(f.processor) == 'video', 'flags': f.flags.as_dict(), 'metadata': metadata, 'subtitles': subtitles, 'has_subtitles': subtitles != None, 'compression': compression, 'mimetype': mimetype, 'can_delete': can_delete if can_delete is not None else 'check', 'fragment': 'fragments/' + fragment(f.processor) + '.html', 'types': types, 'processor': f.processor, 'protocol': _cfg("protocol"), 'domain': _cfg("domain"), }
def _template_params(f): if f.compression: compression = int(float(f.compression) * 100) if compression == 100 or f.status != "done": compression = None can_delete = None try: if request.cookies.get("hist-opt-out", "0") == "1": can_delete = check_password_hash(f.ip, get_ip()) except: pass mimetype = f.mimetype processor = get_processor(f.processor) types = [mimetype] for f_ext in processor.outputs: types.append(get_mimetype(f_ext)) if "do-not-send" in request.cookies: try: blacklist = json.loads(request.cookies["do-not-send"]) for t in blacklist: if t in types: types.remove(t) except: pass metadata = {} if f.metadata and f.metadata != "null": metadata = json.loads(f.metadata) subtitles = None if "subtitles" in metadata and "streams" in metadata["subtitles"]: for stream in metadata["subtitles"]["streams"]: if stream["type"] == "subtitle": subtitles = stream if subtitles["info"]["codec_name"] == "ssa": subtitles["info"]["codec_name"] = "ass" subtitles["url"] = "/" + f.hash + "." + subtitles["info"]["codec_name"] break return { "filename": f.hash, "original": f.original, "video": normalise_processor(f.processor) == "video", "flags": f.flags.as_dict(), "metadata": metadata, "subtitles": subtitles, "has_subtitles": subtitles != None, "compression": compression, "mimetype": mimetype, "can_delete": can_delete if can_delete is not None else "check", "fragment": "fragments/" + fragment(f.processor) + ".html", "types": types, "processor": f.processor, "protocol": _cfg("protocol"), "domain": _cfg("domain"), }
def fragment(processor): np = normalise_processor(processor) if np == "video" and g.mobile: return "mobilevideo" elif np == "audio" and g.mobile: return "mobileaudio" else: return np
def fragment(processor): np = normalise_processor(processor) if np == 'video' and g.mobile: return 'mobilevideo' elif np == 'audio' and g.mobile: return 'mobileaudio' else: return np
def _template_params(f): if f.compression: compression = int(float(f.compression) * 100) if compression == 100 or f.status != "done": compression = None can_delete = None try: if request.cookies.get('hist-opt-out', '0') == '1': can_delete = check_password_hash(f.ip, get_ip()) except: pass mimetype = f.mimetype processor = get_processor(f.processor) types = [mimetype] for f_ext in processor.outputs: types.append(get_mimetype(f_ext)) if 'do-not-send' in request.cookies: try: blacklist = json.loads(request.cookies['do-not-send']) for t in blacklist: if t in types: types.remove(t) except: pass metadata = {} if f.metadata and f.metadata != 'None': metadata = json.loads(f.metadata) return { 'filename': f.hash, 'original': f.original, 'video': normalise_processor(f.processor) == 'video', 'flags': f.flags.as_dict(), 'metadata': metadata, 'compression': compression, 'mimetype': mimetype, 'can_delete': can_delete if can_delete is not None else 'check', 'fragment': 'fragments/' + fragment(f.processor) + '.html', 'types': types, 'processor': f.processor, 'protocol': _cfg("protocol"), 'domain': _cfg("domain"), }
def _template_params(f): if f.compression: compression = int(float(f.compression) * 100) if compression == 100 or f.status != "done": compression = None can_delete = None try: if request.cookies.get('hist-opt-out', '0') == '1': can_delete = check_password_hash(f.ip, get_ip()) except: pass mimetype = f.mimetype processor = get_processor(f.processor) types = [mimetype] for f_ext in processor.outputs: types.append(get_mimetype(f_ext)) if 'do-not-send' in request.cookies: try: blacklist = json.loads(request.cookies['do-not-send']) for t in blacklist: if t in types: types.remove(t) except: pass return { 'filename': f.hash, 'original': f.original, 'video': normalise_processor(f.processor) == 'video', 'flags': f.flags.as_dict(), 'compression': compression, 'mimetype': mimetype, 'can_delete': can_delete if can_delete is not None else 'check', 'fragment': 'fragments/' + fragment(f.processor) + '.html', 'types': types, 'processor': f.processor, 'protocol': _cfg("protocol"), 'domain': _cfg("domain"), }
def processor(self, v): self._processor = v # When the processor is changed, so is the interpretation of the flags. options = flags_per_processor.get(normalise_processor(v), []) self.flags = BitVector(options)
def processor(self, v): self._processor = v # When the processor is changed, so is the interpretation of the flags. options = flags_per_processor.get(normalise_processor(v), []) self.flags = BitVector(options, iv=self._configvector)
def _template_params(f): if f.compression: compression = int(float(f.compression) * 100) if compression == 100 or f.status != "done": compression = None can_delete = None try: if request.cookies.get('hist-opt-out', '0') == '1': can_delete = check_password_hash(f.ip, get_ip()) except: pass mimetype = f.mimetype processor = get_processor(f.processor) types = [mimetype] for f_ext in processor.outputs: types.append(get_mimetype(f_ext)) if 'do-not-send' in request.cookies: try: blacklist = json.loads(request.cookies['do-not-send']) for t in blacklist: if t in types: types.remove(t) except: pass metadata = {} if f.metadata and f.metadata != 'null': try: metadata = json.loads(f.metadata) except: pass subtitles = None if 'subtitles' in metadata and 'streams' in metadata['subtitles']: for stream in metadata['subtitles']['streams']: if stream['type'] == 'subtitle': subtitles = stream if subtitles['info']['codec_name'] == 'ssa': subtitles['info']['codec_name'] = 'ass' subtitles['url'] = '/' + f.hash + '.' + subtitles['info']['codec_name'] break if f.description: f.description = slimdown.convert(f.description) return { 'filename': f.hash, 'original': f.original, 'video': normalise_processor(f.processor) == 'video', 'flags': f.flags.as_dict(), 'metadata': metadata, 'subtitles': subtitles, 'has_subtitles': subtitles != None, 'compression': compression, 'mimetype': mimetype, 'can_delete': can_delete if can_delete is not None else 'check', 'fragment': 'fragments/' + fragment(f.processor) + '.html', 'types': types, 'processor': f.processor, 'protocol': _cfg("protocol"), 'domain': _cfg("domain"), 'file': f }
def _template_params(f): if f.compression: compression = int(float(f.compression) * 100) if compression == 100 or f.status != "done": compression = None can_delete = None try: if request.cookies.get("hist-opt-out", "0") == "1": can_delete = check_password_hash(f.ip, get_ip()) except: pass mimetype = f.mimetype processor = get_processor(f.processor) types = [mimetype] for f_ext in processor.outputs: types.append(get_mimetype(f_ext)) if "do-not-send" in request.cookies: try: blacklist = json.loads(request.cookies["do-not-send"]) for t in blacklist: if t in types: types.remove(t) except: pass metadata = {} if f.metadata and f.metadata != "null": try: metadata = json.loads(f.metadata) except: pass subtitles = None if "subtitles" in metadata and "streams" in metadata["subtitles"]: for stream in metadata["subtitles"]["streams"]: if stream["type"] == "subtitle": subtitles = stream if subtitles["info"]["codec_name"] == "ssa": subtitles["info"]["codec_name"] = "ass" subtitles["url"] = "/" + f.hash + "." + subtitles["info"][ "codec_name"] break if f.description: f.description = slimdown.convert(f.description) return { "filename": f.hash, "original": f.original, "video": normalise_processor(f.processor) == "video", "flags": f.flags.as_dict(), "metadata": metadata, "subtitles": subtitles, "has_subtitles": subtitles != None, "compression": compression, "mimetype": mimetype, "can_delete": can_delete if can_delete is not None else "check", "fragment": "fragments/" + fragment(f.processor) + ".html", "types": types, "processor": f.processor, "protocol": _cfg("protocol"), "domain": _cfg("domain"), "file": f, }