diff --git a/app/api/album.py b/app/api/album.py index 01c0f9a..4b0e826 100644 --- a/app/api/album.py +++ b/app/api/album.py @@ -61,11 +61,7 @@ def get_album(): tracks = utils.remove_duplicates(tracks) album.count = len(tracks) - - for track in tracks: - if track.date != "Unknown": - album.date = track.date - break + album.get_date_from_tracks(tracks) try: album.duration = sum((t.duration for t in tracks)) diff --git a/app/api/artist.py b/app/api/artist.py index 4106c05..486c044 100644 --- a/app/api/artist.py +++ b/app/api/artist.py @@ -39,7 +39,7 @@ class ArtistsCache: Holds artist page cache. """ - artists: deque[CacheEntry] = deque(maxlen=6) + artists: deque[CacheEntry] = deque(maxlen=1) @classmethod def get_albums_by_artisthash(cls, artisthash: str): @@ -131,6 +131,7 @@ class ArtistsCache: album_tracks = Store.get_tracks_by_albumhash(album.albumhash) album_tracks = remove_duplicates(album_tracks) + album.get_date_from_tracks(album_tracks) album.check_is_single(album_tracks) entry.type_checked = True @@ -241,6 +242,10 @@ def get_artist_albums(artisthash: str): albums = list(albums) albums = remove_EPs_and_singles(albums) + compilations = [a for a in albums if a.is_compilation] + for c in compilations: + albums.remove(c) + appearances = filter(lambda a: artisthash not in a.albumartisthash, all_albums) appearances = list(appearances) @@ -257,6 +262,7 @@ def get_artist_albums(artisthash: str): "singles": singles[:limit], "eps": eps[:limit], "appearances": appearances[:limit], + "compilations": compilations[:limit] } diff --git a/app/models.py b/app/models.py index bce545d..8297e1d 100644 --- a/app/models.py +++ b/app/models.py @@ -159,7 +159,8 @@ class Album: if "various artists" in artists: return True - substrings = ["the essential", "best of", "greatest hits", "#1 hits", "number ones", "super hits"] + substrings = ["the essential", "best of", "greatest hits", "#1 hits", "number ones", "super hits", + "ultimate collection"] for substring in substrings: if substring in self.title.lower(): @@ -198,6 +199,12 @@ class Album: ): self.is_single = True + def get_date_from_tracks(self, tracks: list[Track]): + for track in tracks: + if track.date != "Unknown": + self.date = track.date + break + @dataclass class Playlist: