Add method to format media duration in human format
@@ -189,6 +189,13 @@ def guids(self):
ordered = sorted(guids, key=lambda guid: sort_order[guid.provider])
return ordered
+ @cached_property
+ def duration(self):
+ hours, remainder = divmod(self.item.duration / 1000, 3600)
+ minutes, seconds = divmod(remainder, 60)
+
+ return '{:02}:{:02}:{:02}'.format(int(hours), int(minutes), int(seconds))
+
@cached_property
def media_type(self):
return f"{self.type}s"
