calculate playlist duration

- use python's `sum()` method to add durations instead of for loop
This commit is contained in:
geoffrey45
2022-07-02 13:19:09 +03:00
committed by Mungai Geoffrey
parent 5bc0eaf8e6
commit b318c0d324
7 changed files with 27 additions and 25 deletions
+5 -5
View File
@@ -59,10 +59,9 @@ class Playlist:
lastUpdated: int
description: str
count: int = 0
duration: int = 0
def __init__(self,
p: models.Playlist,
construct_last_updated: bool = True) -> None:
def __init__(self, p: models.Playlist, construct_last_updated: bool = True) -> None:
self.playlistid = p.playlistid
self.name = p.name
self.image = p.image
@@ -72,7 +71,8 @@ class Playlist:
self.count = p.count
if construct_last_updated:
self.lastUpdated = self.l_updated(p.lastUpdated)
self.lastUpdated = self.get_l_updated(p.lastUpdated)
def l_updated(self, date: str) -> str:
@staticmethod
def get_l_updated(date: str) -> str:
return date_string_to_time_passed(date)