diff --git a/server/app/models.py b/server/app/models.py index 1996c92f..fc15bbd0 100644 --- a/server/app/models.py +++ b/server/app/models.py @@ -86,25 +86,41 @@ class Album: hash: str count: int = 0 duration: int = 0 + is_soundtrack: bool = False + is_compilation: bool = False def __init__(self, tags): self.title = tags["title"] self.artist = tags["artist"] self.date = tags["date"] self.image = tags["image"] - self.hash = helpers.create_album_hash(self.title, self.artist) try: self.hash = tags["albumhash"] except KeyError: self.hash = helpers.create_album_hash(self.title, self.artist) + @property + def is_soundtrack(self) -> bool: + keywords = ["motion picture", "soundtrack"] + for keyword in keywords: + if keyword in self.title.lower(): + return True + + return False + + @property + def is_compilation(self) -> bool: + return self.artist.lower() == "various artists" + def get_p_track(ptrack): for track in api.TRACKS: - if (track.title == ptrack["title"] - and track.artists == ptrack["artists"] - and ptrack["album"] == track.album): + if ( + track.title == ptrack["title"] + and track.artists == ptrack["artists"] + and ptrack["album"] == track.album + ): return track diff --git a/src/interfaces.ts b/src/interfaces.ts index 95d76c42..5f5269ee 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -31,6 +31,8 @@ interface AlbumInfo { duration: number; date: string; image: string; + is_compilation: boolean; + is_soundtrack: boolean; } interface Artist {