Commit 6bee38bb authored by Michael Murtaugh's avatar Michael Murtaugh
Browse files

mediatype in info + template

parent 14dcfeed
......@@ -82,11 +82,13 @@
<td class="name">
<a {% if f.play %}property="hasPlay dcterms:hasFormat" href="{{f.play|urlencode}}"{%else%}href="{{f.id}}"{% endif %}><span property="dcterms:title" content="{%if f.title%}{{f.title}}{% else %}{{f.filename|filename2title}}{% endif %}">{{f.filename|wbr_}}</span></a>
{% if f.play %}<a class="original" href="{{f.id}}">&crarr;</a>{% endif %}
{% if f.ext == "pdf" %}
{% if f.mediatype == "pdf" %}
<span property="mediatype" content="pdf"></span>
{% elif f.ext.startswith("audio/") or f.ext.startswith("video/") %}
{% if f.video %}<span property="mediatype" content="video"></span>{%else%}<span property="mediatype" content="audio"></span>{%endif%}
{% elif f.ext.startswith("image/") %}
{% elif f.mediatype == "video" %}
<span property="mediatype" content="video"></span>
{% elif f.mediatype == "audio" %}
<span property="mediatype" content="audio"></span>
{% elif f.mediatype == "image" %}
<span property="mediatype" content="image"></span>
{% endif %}
{% if f.ext %}<span property="dcterms:format" content="{{f.ext}}"></span>{% endif %}
......
......@@ -45,6 +45,7 @@ def get_info(url, data=None):
o = popen.communicate()[1].decode("utf-8")
if data == None:
data = {}
data['mediatype'] = "video"
dur = extract_duration(o)
if dur and dur >= 0.05:
data['duration'] = dur
......@@ -54,10 +55,13 @@ def get_info(url, data=None):
data['width'] = size[0]
data['height'] = size[1]
for audio in extract_audio_streams(o):
data['audio'] = audio['description']
for video in extract_video_streams(o):
data['video'] = video['description']
data['mediatype'] = "video"
for audio in extract_audio_streams(o):
data['audio'] = audio['description']
if 'mediatype' not in data:
data['mediatype'] = "audio"
# data['metadata'] = extract_metadata(o)
return data
......
......@@ -20,6 +20,7 @@ def get_info(path, data=None):
o = p.stdout.decode("utf-8")
if data == None:
data = {}
data['mediatype'] = "image"
d = extract(o)
if d:
data['image_format'] = d['format']
......
......@@ -38,10 +38,12 @@ async def pdf_info_from_data (data):
d[name] = value
return d
def get_info(url, data=None):
def get_info(url, d=None):
popen = subprocess.Popen(["pdfinfo", url], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
o = popen.communicate()[0].decode("utf-8")
d = {}
if d is None:
d = {}
d['mediatype'] = "pdf"
for line in o.splitlines():
if ":" in line:
name, value = line.split(":", 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment