Added some Information for audio userview, stringtools integrated
This commit is contained in:
parent
78df2b0459
commit
f88baa3e29
@ -13,11 +13,21 @@
|
|||||||
<div id="openModal" class="image">
|
<div id="openModal" class="image">
|
||||||
{% with bar=item.tagbar slim=True %}{% include 'themes/'|add:settings.page_theme|add:'/menubar.html' %}{% endwith %}
|
{% with bar=item.tagbar slim=True %}{% include 'themes/'|add:settings.page_theme|add:'/menubar.html' %}{% endwith %}
|
||||||
<div class="image_bg">
|
<div class="image_bg">
|
||||||
<h1>{{ item.heading }}</h1>
|
<h1>{{ item.heading }}</h1>
|
||||||
<audio controls preload{% if item.is_repeatview %} autoplay{% endif %} controlsList="nodownload">
|
<audio controls preload{% if item.is_repeatview %} autoplay{% endif %} controlsList="nodownload">
|
||||||
<source src="{{ item.url_item|safe }}" type="{{ item.mime_type }}">
|
<source src="{{ item.url_item|safe }}" type="{{ item.mime_type }}">
|
||||||
Your browser does not support the audio element.
|
Your browser does not support the audio element.
|
||||||
</audio>
|
</audio>
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
{% for line in item.audio_information %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ line.description }}:</td>
|
||||||
|
<td style="text-align:right;">{{ line.data }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{% if item.item_information|length > 0 %}
|
||||||
<h1>{{ heading.information }}</h1>
|
<h1>{{ heading.information }}</h1>
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -23,6 +24,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{% endif %}
|
||||||
{% if item.database_information|length > 0 %}
|
{% if item.database_information|length > 0 %}
|
||||||
<h1>{{ heading.database }}</h1>
|
<h1>{{ heading.database }}</h1>
|
||||||
<table>
|
<table>
|
||||||
|
@ -106,6 +106,8 @@ def pygal_download(request, datatype, rel_path):
|
|||||||
# Create the Archive from fp_list
|
# Create the Archive from fp_list
|
||||||
#
|
#
|
||||||
flat = pygal.is_flat(request)
|
flat = pygal.is_flat(request)
|
||||||
|
if not os.path.exists(settings.TEMP_ROOT):
|
||||||
|
fstools.mkdir(settings.TEMP_ROOT)
|
||||||
temp = tempfile.TemporaryFile(dir=settings.TEMP_ROOT)
|
temp = tempfile.TemporaryFile(dir=settings.TEMP_ROOT)
|
||||||
archive = zipfile.ZipFile(temp, 'w', zipfile.ZIP_STORED)
|
archive = zipfile.ZipFile(temp, 'w', zipfile.ZIP_STORED)
|
||||||
for fp in fp_list:
|
for fp in fp_list:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
import fractions
|
|
||||||
import geo
|
import geo
|
||||||
from ..models import get_item_type, TYPE_AUDIO, TYPE_FOLDER, TYPE_IMAGE, TYPE_VIDEO
|
from ..models import get_item_type, TYPE_AUDIO, TYPE_FOLDER, TYPE_IMAGE, TYPE_VIDEO
|
||||||
|
import stringtools
|
||||||
from .userviews import base_view as base_userview
|
from .userviews import base_view as base_userview
|
||||||
|
|
||||||
|
|
||||||
@ -82,8 +82,7 @@ class image_view(base_view):
|
|||||||
c = geo.gps.coordinate(**gps_data)
|
c = geo.gps.coordinate(**gps_data)
|
||||||
rv.append({'description': _('GPS'), 'data': str(c), 'url': geo.osm.landmark_link(c)})
|
rv.append({'description': _('GPS'), 'data': str(c), 'url': geo.osm.landmark_link(c)})
|
||||||
rv.append({'description': _('Exposure Program'), 'data': self.item.item_data.exposure_program, 'url': None})
|
rv.append({'description': _('Exposure Program'), 'data': self.item.item_data.exposure_program, 'url': None})
|
||||||
f = fractions.Fraction(self.item.item_data.exposure_time).limit_denominator()
|
rv.append({'description': _('Exposure Time'), 'data': '%ss' % (stringtools.frac_repr(self.item.item_data.exposure_time)), 'url': None})
|
||||||
rv.append({'description': _('Exposure Time'), 'data': '%d/%d s' % (f.numerator, f.denominator), 'url': None})
|
|
||||||
rv.append({'description': _('ISO'), 'data': self.item.item_data.iso, 'url': None})
|
rv.append({'description': _('ISO'), 'data': self.item.item_data.iso, 'url': None})
|
||||||
rv.append({'description': _('Focal Length'), 'data': self.item.item_data.focal_length, 'url': None})
|
rv.append({'description': _('Focal Length'), 'data': self.item.item_data.focal_length, 'url': None})
|
||||||
rv.append({'description': _('Apeture'), 'data': self.item.item_data.f_number, 'url': None})
|
rv.append({'description': _('Apeture'), 'data': self.item.item_data.f_number, 'url': None})
|
||||||
@ -117,7 +116,7 @@ class audio_view(base_view):
|
|||||||
rv.append({'description': _('Year'), 'data': self.item.item_data.year, 'url': None})
|
rv.append({'description': _('Year'), 'data': self.item.item_data.year, 'url': None})
|
||||||
rv.append({'description': _('Title'), 'data': self.item.item_data.title, 'url': None})
|
rv.append({'description': _('Title'), 'data': self.item.item_data.title, 'url': None})
|
||||||
rv.append({'description': _('Track'), 'data': self.item.item_data.track, 'url': None})
|
rv.append({'description': _('Track'), 'data': self.item.item_data.track, 'url': None})
|
||||||
rv.append({'description': _('Duration'), 'data': self.__duration_txt__(self.item.item_data.duration), 'url': None})
|
rv.append({'description': _('Duration'), 'data': stringtools.time_repr(self.item.item_data.duration), 'url': None})
|
||||||
rv.append({'description': _('Genre'), 'data': self.item.item_data.genre, 'url': None})
|
rv.append({'description': _('Genre'), 'data': self.item.item_data.genre, 'url': None})
|
||||||
rv.append({'description': _('Bitrate'), 'data': self.__size_txt__(self.item.item_data.bitrate), 'url': None})
|
rv.append({'description': _('Bitrate'), 'data': stringtools.physical_value_repr(self.item.item_data.bitrate), 'url': None})
|
||||||
return rv
|
return rv
|
||||||
|
@ -7,8 +7,8 @@ import os
|
|||||||
import pygal
|
import pygal
|
||||||
from ..queries import search_result_query
|
from ..queries import search_result_query
|
||||||
import random
|
import random
|
||||||
|
import stringtools
|
||||||
import themes
|
import themes
|
||||||
import time
|
|
||||||
|
|
||||||
ADDTAG_ENTRY = 'addtag-main'
|
ADDTAG_ENTRY = 'addtag-main'
|
||||||
INFOVIEW_ENTRY = 'infoview-main'
|
INFOVIEW_ENTRY = 'infoview-main'
|
||||||
@ -85,7 +85,7 @@ class base_view(object):
|
|||||||
rv.append({'description': _('Name'), 'data': os.path.basename(full_path), 'url': None})
|
rv.append({'description': _('Name'), 'data': os.path.basename(full_path), 'url': None})
|
||||||
rv.append({'description': _('Creation Time'), 'data': self.item.item_data.formatted_datetime, 'url': None})
|
rv.append({'description': _('Creation Time'), 'data': self.item.item_data.formatted_datetime, 'url': None})
|
||||||
rv.append({'description': _('Path'), 'data': os.path.dirname(full_path), 'url': None})
|
rv.append({'description': _('Path'), 'data': os.path.dirname(full_path), 'url': None})
|
||||||
rv.append({'description': _('Size'), 'data': self.__size_txt__(self.item.item_data.size) + 'B', 'url': None})
|
rv.append({'description': _('Size'), 'data': stringtools.physical_value_repr(self.item.item_data.size, 'B'), 'url': None})
|
||||||
rv.append({'description': _('UID'), 'data': self.item.current_uid(), 'url': None})
|
rv.append({'description': _('UID'), 'data': self.item.current_uid(), 'url': None})
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
@ -241,29 +241,6 @@ class base_view(object):
|
|||||||
def date_txt(self):
|
def date_txt(self):
|
||||||
return self.item.item_data.formatted_datetime
|
return self.item.item_data.formatted_datetime
|
||||||
|
|
||||||
def __size_txt__(self, size):
|
|
||||||
unit = {
|
|
||||||
0: '',
|
|
||||||
1: 'k',
|
|
||||||
2: 'M',
|
|
||||||
3: 'G',
|
|
||||||
4: 'T',
|
|
||||||
}
|
|
||||||
u = 0
|
|
||||||
while u < 4 and size > 1000.:
|
|
||||||
u += 1
|
|
||||||
size /= 1000.
|
|
||||||
if size < 100.:
|
|
||||||
return '%.2f %s' % (size, unit.get(u, '?'))
|
|
||||||
else:
|
|
||||||
return '%.1f %s' % (size, unit.get(u, '?'))
|
|
||||||
|
|
||||||
def __duration_txt__(self, duration):
|
|
||||||
if duration >= 3600:
|
|
||||||
return time.strftime('%H:%M:%S', time.gmtime(duration))
|
|
||||||
else:
|
|
||||||
return time.strftime('%M:%S', time.gmtime(duration))
|
|
||||||
|
|
||||||
def __parent__(self):
|
def __parent__(self):
|
||||||
if pygal.is_searchview(self.request):
|
if pygal.is_searchview(self.request):
|
||||||
return query_view(self.request, search_result_query(self.request))
|
return query_view(self.request, search_result_query(self.request))
|
||||||
@ -528,6 +505,21 @@ class audio_view(base_view):
|
|||||||
def heading(self):
|
def heading(self):
|
||||||
return '%02d - %s' % (self.item.item_data.track, self.item.item_data.title)
|
return '%02d - %s' % (self.item.item_data.track, self.item.item_data.title)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def audio_information(self):
|
||||||
|
rv = []
|
||||||
|
entries = (
|
||||||
|
(_('Artist'), self.item.artist_c),
|
||||||
|
(_('Album'), self.item.album_c),
|
||||||
|
(_('Year'), self.item.year_c),
|
||||||
|
(_('Title'), self.item.title_c),
|
||||||
|
(_('Duration'), stringtools.time_repr(self.item.duration_c)),
|
||||||
|
)
|
||||||
|
for description, data in entries:
|
||||||
|
if data is not None:
|
||||||
|
rv.append({'description': description, 'data': data, 'url': None})
|
||||||
|
return rv
|
||||||
|
|
||||||
|
|
||||||
class other_view(base_view):
|
class other_view(base_view):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user