feat: add album dates to artist albums

This commit is contained in:
geoffrey45 2023-02-09 21:15:07 +03:00
parent 1be60f73e4
commit 97e29c3254
3 changed files with 16 additions and 7 deletions

View File

@ -61,11 +61,7 @@ def get_album():
tracks = utils.remove_duplicates(tracks) tracks = utils.remove_duplicates(tracks)
album.count = len(tracks) album.count = len(tracks)
album.get_date_from_tracks(tracks)
for track in tracks:
if track.date != "Unknown":
album.date = track.date
break
try: try:
album.duration = sum((t.duration for t in tracks)) album.duration = sum((t.duration for t in tracks))

View File

@ -39,7 +39,7 @@ class ArtistsCache:
Holds artist page cache. Holds artist page cache.
""" """
artists: deque[CacheEntry] = deque(maxlen=6) artists: deque[CacheEntry] = deque(maxlen=1)
@classmethod @classmethod
def get_albums_by_artisthash(cls, artisthash: str): 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 = Store.get_tracks_by_albumhash(album.albumhash)
album_tracks = remove_duplicates(album_tracks) album_tracks = remove_duplicates(album_tracks)
album.get_date_from_tracks(album_tracks)
album.check_is_single(album_tracks) album.check_is_single(album_tracks)
entry.type_checked = True entry.type_checked = True
@ -241,6 +242,10 @@ def get_artist_albums(artisthash: str):
albums = list(albums) albums = list(albums)
albums = remove_EPs_and_singles(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 = filter(lambda a: artisthash not in a.albumartisthash, all_albums)
appearances = list(appearances) appearances = list(appearances)
@ -257,6 +262,7 @@ def get_artist_albums(artisthash: str):
"singles": singles[:limit], "singles": singles[:limit],
"eps": eps[:limit], "eps": eps[:limit],
"appearances": appearances[:limit], "appearances": appearances[:limit],
"compilations": compilations[:limit]
} }

View File

@ -159,7 +159,8 @@ class Album:
if "various artists" in artists: if "various artists" in artists:
return True 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: for substring in substrings:
if substring in self.title.lower(): if substring in self.title.lower():
@ -198,6 +199,12 @@ class Album:
): ):
self.is_single = True 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 @dataclass
class Playlist: class Playlist: