def _file_entry(f, mimetype=None): return { 'type': mimetype if mimetype else get_mimetype(f), 'file': media_url(f, absolute=False), # This silliness will be fixed in API 2 'url': media_url(f) }
def _file_entry(f, mimetype=None): return { "type": mimetype if mimetype else get_mimetype(f), "file": media_url(f, absolute=False), # This silliness will be fixed in API 2 "url": media_url(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': 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 _send_file(self, id, base=_cfg("storage_folder"), as_attachment=False): if ".." in id or id.startswith("/"): abort(403) if "." in id: path = os.path.join(base, id) if os.path.exists(path): return send_file(path, as_attachment=as_attachment, mimetype=get_mimetype(path)) else: return abort(404) return False
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': mimetype in VIDEO_FORMATS, 'loop': mimetype in LOOP_FORMATS, 'autoplay': mimetype in AUTOPLAY_FORMATS, '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 _file_entry(f, mimetype=None): return { 'type': mimetype if mimetype else get_mimetype(f), 'file': media_url(f), }
def test_get_mimetype(self): self.assertEqual(get_mimetype("blah.mp4"), "video/mp4")
def _file_entry(f, mimetype=None): return { 'type': mimetype if mimetype else get_mimetype(f), 'file': media_url(f), 'url': _cfg("cdn") + media_url(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, }