From a485be3c641d3227261ce91552aea1160b4aeea2 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 11 May 2017 22:34:19 -0700 Subject: [PATCH] Make bitrate a real attribute instead of calculating in jinja --- etiquette/objects.py | 2 ++ frontends/etiquette_flask/templates/photo.html | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/etiquette/objects.py b/etiquette/objects.py index 07fc809..e4868d5 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -499,6 +499,8 @@ class Photo(ObjectBase): self.ratio = db_row['ratio'] self.thumbnail = db_row['thumbnail'] + if self.duration: + self.bitrate = (self.bytes / 128) / self.duration self.mimetype = helpers.get_mimetype(self.real_filepath) if self.mimetype is None: self.simple_mimetype = None diff --git a/frontends/etiquette_flask/templates/photo.html b/frontends/etiquette_flask/templates/photo.html index f22bdd6..8d50d16 100644 --- a/frontends/etiquette_flask/templates/photo.html +++ b/frontends/etiquette_flask/templates/photo.html @@ -183,7 +183,7 @@
  • Size: {{photo.bytestring()}}
  • {% if photo.duration %}
  • Duration: {{photo.duration_string}}
  • -
  • Overall Bitrate: {{((photo.bytes / 128) / photo.duration)|int}} kbps
  • +
  • Overall Bitrate: {{photo.bitrate|int}} kbps
  • {% endif %}
  • Download as original filename
  • Download as {{photo.id}}.{{photo.extension}}