|
@@ -7,8 +7,8 @@ import os
|
7
|
7
|
import pygal
|
8
|
8
|
from ..queries import search_result_query
|
9
|
9
|
import random
|
|
10
|
+import stringtools
|
10
|
11
|
import themes
|
11
|
|
-import time
|
12
|
12
|
|
13
|
13
|
ADDTAG_ENTRY = 'addtag-main'
|
14
|
14
|
INFOVIEW_ENTRY = 'infoview-main'
|
|
@@ -85,7 +85,7 @@ class base_view(object):
|
85
|
85
|
rv.append({'description': _('Name'), 'data': os.path.basename(full_path), 'url': None})
|
86
|
86
|
rv.append({'description': _('Creation Time'), 'data': self.item.item_data.formatted_datetime, 'url': None})
|
87
|
87
|
rv.append({'description': _('Path'), 'data': os.path.dirname(full_path), 'url': None})
|
88
|
|
- rv.append({'description': _('Size'), 'data': self.__size_txt__(self.item.item_data.size) + 'B', 'url': None})
|
|
88
|
+ rv.append({'description': _('Size'), 'data': stringtools.physical_value_repr(self.item.item_data.size, 'B'), 'url': None})
|
89
|
89
|
rv.append({'description': _('UID'), 'data': self.item.current_uid(), 'url': None})
|
90
|
90
|
return rv
|
91
|
91
|
|
|
@@ -241,29 +241,6 @@ class base_view(object):
|
241
|
241
|
def date_txt(self):
|
242
|
242
|
return self.item.item_data.formatted_datetime
|
243
|
243
|
|
244
|
|
- def __size_txt__(self, size):
|
245
|
|
- unit = {
|
246
|
|
- 0: '',
|
247
|
|
- 1: 'k',
|
248
|
|
- 2: 'M',
|
249
|
|
- 3: 'G',
|
250
|
|
- 4: 'T',
|
251
|
|
- }
|
252
|
|
- u = 0
|
253
|
|
- while u < 4 and size > 1000.:
|
254
|
|
- u += 1
|
255
|
|
- size /= 1000.
|
256
|
|
- if size < 100.:
|
257
|
|
- return '%.2f %s' % (size, unit.get(u, '?'))
|
258
|
|
- else:
|
259
|
|
- return '%.1f %s' % (size, unit.get(u, '?'))
|
260
|
|
-
|
261
|
|
- def __duration_txt__(self, duration):
|
262
|
|
- if duration >= 3600:
|
263
|
|
- return time.strftime('%H:%M:%S', time.gmtime(duration))
|
264
|
|
- else:
|
265
|
|
- return time.strftime('%M:%S', time.gmtime(duration))
|
266
|
|
-
|
267
|
244
|
def __parent__(self):
|
268
|
245
|
if pygal.is_searchview(self.request):
|
269
|
246
|
return query_view(self.request, search_result_query(self.request))
|
|
@@ -528,6 +505,21 @@ class audio_view(base_view):
|
528
|
505
|
def heading(self):
|
529
|
506
|
return '%02d - %s' % (self.item.item_data.track, self.item.item_data.title)
|
530
|
507
|
|
|
508
|
+ @property
|
|
509
|
+ def audio_information(self):
|
|
510
|
+ rv = []
|
|
511
|
+ entries = (
|
|
512
|
+ (_('Artist'), self.item.artist_c),
|
|
513
|
+ (_('Album'), self.item.album_c),
|
|
514
|
+ (_('Year'), self.item.year_c),
|
|
515
|
+ (_('Title'), self.item.title_c),
|
|
516
|
+ (_('Duration'), stringtools.time_repr(self.item.duration_c)),
|
|
517
|
+ )
|
|
518
|
+ for description, data in entries:
|
|
519
|
+ if data is not None:
|
|
520
|
+ rv.append({'description': description, 'data': data, 'url': None})
|
|
521
|
+ return rv
|
|
522
|
+
|
531
|
523
|
|
532
|
524
|
class other_view(base_view):
|
533
|
525
|
def __init__(self, *args, **kwargs):
|