fix duplicate albums with date = 0

This commit is contained in:
mungai-njoroge 2023-06-26 13:17:24 +03:00
parent dbfa395207
commit 1cf5d38a96
3 changed files with 11 additions and 5 deletions

View File

@ -262,6 +262,9 @@ def get_artist_albums(artisthash: str):
artist = ArtistStore.get_artist_by_hash(artisthash)
if artist is None:
return {"error": "Artist not found"}, 404
if return_all is not None:
limit = len(all_albums)

View File

@ -129,13 +129,13 @@ def add_track(filepath: str) -> None:
Then creates the folder, album and artist objects for the added track and adds them to the store.
"""
# remove the track if it already exists
TrackStore.remove_track_by_filepath(filepath)
# add the track to the database and store.
tags = get_tags(filepath)
if tags is None:
# if the track is somehow invalid, return
if tags is None or tags["bitrate"] == 0 or tags["duration"] == 0:
return
with SQLiteManager() as cur:

View File

@ -61,8 +61,11 @@ class ArtistStore:
Returns an artist by its hash.P
"""
artists = sorted(cls.artists, key=lambda x: x.artisthash)
artist = UseBisection(artists, "artisthash", [artisthash])()[0]
return artist
try:
artist = UseBisection(artists, "artisthash", [artisthash])()[0]
return artist
except IndexError:
return None
@classmethod
def get_artists_by_hashes(cls, artisthashes: list[str]) -> list[Artist]: