mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
fix removing duplicate tracks
- add uniq_hash prop to Track class
This commit is contained in:
@@ -45,6 +45,7 @@ def get_album():
|
||||
|
||||
tracks = instances.tracks_instance.find_tracks_by_hash(albumhash)
|
||||
tracks = [models.Track(t) for t in tracks]
|
||||
tracks = helpers.RemoveDuplicates(tracks)()
|
||||
|
||||
album = instances.album_instance.find_album_by_hash(albumhash)
|
||||
|
||||
|
||||
+33
-33
@@ -11,48 +11,48 @@ from flask import Blueprint
|
||||
artist_bp = Blueprint("artist", __name__, url_prefix="/")
|
||||
|
||||
|
||||
@artist_bp.route("/artist/<artist>")
|
||||
@cache.cached()
|
||||
def get_artist_data(artist: str):
|
||||
"""Returns the artist's data, tracks and albums"""
|
||||
artist = urllib.parse.unquote(artist)
|
||||
artist_obj = instances.artist_instance.get_artists_by_name(artist)
|
||||
# @artist_bp.route("/artist/<artist>")
|
||||
# @cache.cached()
|
||||
# def get_artist_data(artist: str):
|
||||
# """Returns the artist's data, tracks and albums"""
|
||||
# artist = urllib.parse.unquote(artist)
|
||||
# artist_obj = instances.artist_instance.get_artists_by_name(artist)
|
||||
|
||||
def get_artist_tracks():
|
||||
songs = instances.tracks_instance.find_songs_by_artist(artist)
|
||||
# def get_artist_tracks():
|
||||
# songs = instances.tracks_instance.find_songs_by_artist(artist)
|
||||
|
||||
return songs
|
||||
# return songs
|
||||
|
||||
artist_songs = get_artist_tracks()
|
||||
songs = helpers.remove_duplicates(artist_songs)
|
||||
# artist_songs = get_artist_tracks()
|
||||
# songs = helpers.remove_duplicates(artist_songs)
|
||||
|
||||
def get_artist_albums():
|
||||
artist_albums = []
|
||||
albums_with_count = []
|
||||
# def get_artist_albums():
|
||||
# artist_albums = []
|
||||
# albums_with_count = []
|
||||
|
||||
albums = instances.tracks_instance.find_songs_by_albumartist(artist)
|
||||
# albums = instances.tracks_instance.find_songs_by_albumartist(artist)
|
||||
|
||||
for song in albums:
|
||||
if song["album"] not in artist_albums:
|
||||
artist_albums.append(song["album"])
|
||||
# for song in albums:
|
||||
# if song["album"] not in artist_albums:
|
||||
# artist_albums.append(song["album"])
|
||||
|
||||
for album in artist_albums:
|
||||
count = 0
|
||||
length = 0
|
||||
# for album in artist_albums:
|
||||
# count = 0
|
||||
# length = 0
|
||||
|
||||
for song in artist_songs:
|
||||
if song["album"] == album:
|
||||
count = count + 1
|
||||
length = length + song["length"]
|
||||
# for song in artist_songs:
|
||||
# if song["album"] == album:
|
||||
# count = count + 1
|
||||
# length = length + song["length"]
|
||||
|
||||
album_ = {"title": album, "count": count, "length": length}
|
||||
# album_ = {"title": album, "count": count, "length": length}
|
||||
|
||||
albums_with_count.append(album_)
|
||||
# albums_with_count.append(album_)
|
||||
|
||||
return albums_with_count
|
||||
# return albums_with_count
|
||||
|
||||
return {
|
||||
"artist": artist_obj,
|
||||
"songs": songs,
|
||||
"albums": get_artist_albums()
|
||||
}
|
||||
# return {
|
||||
# "artist": artist_obj,
|
||||
# "songs": songs,
|
||||
# "albums": get_artist_albums()
|
||||
# }
|
||||
|
||||
@@ -48,6 +48,7 @@ class DoSearch:
|
||||
"""
|
||||
self.tracks = helpers.Get.get_all_tracks()
|
||||
tracks = searchlib.SearchTracks(self.tracks, self.query)()
|
||||
tracks = helpers.RemoveDuplicates(tracks)()
|
||||
SearchResults.tracks = tracks
|
||||
|
||||
return tracks
|
||||
|
||||
Reference in New Issue
Block a user