def _album_params(album): items = album.items if not items: abort(404) files = objects[Album](album)['files'] types = set([f.processor for f in items]) filename = album.hash subtitles = False for f in items: metadata = {} if f.metadata and f.metadata != 'null': try: metadata = json.loads(f.metadata) except: pass if 'has_subtitles' in metadata: subtitles = metadata['has_subtitles'] can_delete = None try: if request.cookies.get('hist-opt-out', '0') == '1': can_delete = check_password_hash(f.ip, get_ip()) except: pass if album.description: album.description = slimdown.convert(album.description) return vars()
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, }
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, }