mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
remove dups from get_tracks_by_albumhash
This commit is contained in:
+25
-25
@@ -279,28 +279,28 @@ def get_all_artist_tracks(artisthash: str):
|
||||
|
||||
return {"tracks": tracks}
|
||||
|
||||
|
||||
@api.route("/artist/<artisthash>/similar", methods=["GET"])
|
||||
def get_similar_artists(artisthash: str):
|
||||
"""
|
||||
Returns similar artists.
|
||||
"""
|
||||
limit = request.args.get("limit")
|
||||
|
||||
if limit is None:
|
||||
limit = 6
|
||||
|
||||
limit = int(limit)
|
||||
|
||||
artist = ArtistStore.get_artist_by_hash(artisthash)
|
||||
|
||||
if artist is None:
|
||||
return {"error": "Artist not found"}, 404
|
||||
|
||||
similar_hashes = fetch_similar_artists(artist.name)
|
||||
similar = ArtistStore.get_artists_by_hashes(similar_hashes)
|
||||
|
||||
if len(similar) > limit:
|
||||
similar = random.sample(similar, limit)
|
||||
|
||||
return {"similar": similar[:limit]}
|
||||
#
|
||||
# @api.route("/artist/<artisthash>/similar", methods=["GET"])
|
||||
# def get_similar_artists(artisthash: str):
|
||||
# """
|
||||
# Returns similar artists.
|
||||
# """
|
||||
# limit = request.args.get("limit")
|
||||
#
|
||||
# if limit is None:
|
||||
# limit = 6
|
||||
#
|
||||
# limit = int(limit)
|
||||
#
|
||||
# artist = ArtistStore.get_artist_by_hash(artisthash)
|
||||
#
|
||||
# if artist is None:
|
||||
# return {"error": "Artist not found"}, 404
|
||||
#
|
||||
# similar_hashes = fetch_similar_artists(artist.name)
|
||||
# similar = ArtistStore.get_artists_by_hashes(similar_hashes)
|
||||
#
|
||||
# if len(similar) > limit:
|
||||
# similar = random.sample(similar, limit)
|
||||
#
|
||||
# return {"similar": similar[:limit]}
|
||||
|
||||
+2
-1
@@ -123,7 +123,8 @@ class TrackStore:
|
||||
"""
|
||||
Returns all tracks matching the given album hash.
|
||||
"""
|
||||
return [t for t in cls.tracks if t.albumhash == album_hash]
|
||||
tracks = [t for t in cls.tracks if t.albumhash == album_hash]
|
||||
return remove_duplicates(tracks)
|
||||
|
||||
@classmethod
|
||||
def get_tracks_by_artist(cls, artisthash: str) -> list[Track]:
|
||||
|
||||
Reference in New Issue
Block a user