Make bitrate a real attribute instead of calculating in jinja

This commit is contained in:
voussoir 2017-05-11 22:34:19 -07:00
parent a5924b4642
commit a485be3c64
2 changed files with 3 additions and 1 deletions

View file

@ -499,6 +499,8 @@ class Photo(ObjectBase):
self.ratio = db_row['ratio'] self.ratio = db_row['ratio']
self.thumbnail = db_row['thumbnail'] self.thumbnail = db_row['thumbnail']
if self.duration:
self.bitrate = (self.bytes / 128) / self.duration
self.mimetype = helpers.get_mimetype(self.real_filepath) self.mimetype = helpers.get_mimetype(self.real_filepath)
if self.mimetype is None: if self.mimetype is None:
self.simple_mimetype = None self.simple_mimetype = None

View file

@ -183,7 +183,7 @@
<li>Size: {{photo.bytestring()}}</li> <li>Size: {{photo.bytestring()}}</li>
{% if photo.duration %} {% if photo.duration %}
<li>Duration: {{photo.duration_string}}</li> <li>Duration: {{photo.duration_string}}</li>
<li>Overall Bitrate: {{((photo.bytes / 128) / photo.duration)|int}} kbps</li> <li>Overall Bitrate: {{photo.bitrate|int}} kbps</li>
{% endif %} {% endif %}
<li><a href="/file/{{photo.id}}{{photo.dot_extension}}?download=true&original_filename=true">Download as original filename</a></li> <li><a href="/file/{{photo.id}}{{photo.dot_extension}}?download=true&original_filename=true">Download as original filename</a></li>
<li><a href="/file/{{photo.id}}{{photo.dot_extension}}?download=true">Download as {{photo.id}}.{{photo.extension}}</a></li> <li><a href="/file/{{photo.id}}{{photo.dot_extension}}?download=true">Download as {{photo.id}}.{{photo.extension}}</a></li>