mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
server: 😜 fix remove dups
This commit is contained in:
+4
-2
@@ -51,7 +51,7 @@ def search_by_title():
|
|||||||
songs = all_songs_instance.find_song_by_title(query)
|
songs = all_songs_instance.find_song_by_title(query)
|
||||||
all_songs.append(convert_to_json(songs))
|
all_songs.append(convert_to_json(songs))
|
||||||
|
|
||||||
songs_by_albums = all_songs_instance.find_songs_by_album(query)
|
songs_by_albums = all_songs_instance.get_songs_by_album(query)
|
||||||
all_songs.append(convert_to_json(songs_by_albums))
|
all_songs.append(convert_to_json(songs_by_albums))
|
||||||
|
|
||||||
songs_by_artists = all_songs_instance.find_songs_by_artist(query)
|
songs_by_artists = all_songs_instance.find_songs_by_artist(query)
|
||||||
@@ -277,7 +277,9 @@ def getFolderTree(folder: str = None):
|
|||||||
|
|
||||||
songs_array = all_songs_instance.find_songs_by_folder(
|
songs_array = all_songs_instance.find_songs_by_folder(
|
||||||
req_dir)
|
req_dir)
|
||||||
|
|
||||||
songs = convert_to_json(songs_array)
|
songs = convert_to_json(songs_array)
|
||||||
|
|
||||||
for song in songs:
|
for song in songs:
|
||||||
song['artists'] = song['artists'].split(', ')
|
song['artists'] = song['artists'].split(', ')
|
||||||
song['filepath'] = song['filepath'].replace(home_dir, '')
|
song['filepath'] = song['filepath'].replace(home_dir, '')
|
||||||
@@ -286,7 +288,7 @@ def getFolderTree(folder: str = None):
|
|||||||
song['type']['name'] = "folder"
|
song['type']['name'] = "folder"
|
||||||
song['type']['id'] = req_dir
|
song['type']['id'] = req_dir
|
||||||
|
|
||||||
return {"files": songs, "folders": sorted(folders, key= lambda i: i['name'])}
|
return {"files": remove_duplicates(songs), "folders": sorted(folders, key= lambda i: i['name'])}
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/get/queue', methods=['POST'])
|
@bp.route('/get/queue', methods=['POST'])
|
||||||
|
|||||||
+11
-2
@@ -94,13 +94,13 @@ def getTags(full_path):
|
|||||||
try:
|
try:
|
||||||
audio = FLAC(full_path)
|
audio = FLAC(full_path)
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
elif full_path.endswith('.mp3'):
|
elif full_path.endswith('.mp3'):
|
||||||
try:
|
try:
|
||||||
audio = MP3(full_path)
|
audio = MP3(full_path)
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
artists = audio['artist'][0]
|
artists = audio['artist'][0]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -202,6 +202,15 @@ def get_folders():
|
|||||||
|
|
||||||
|
|
||||||
def remove_duplicates(array):
|
def remove_duplicates(array):
|
||||||
|
song_num = 0
|
||||||
|
|
||||||
|
while song_num < len(array):
|
||||||
|
for index, song in enumerate(array):
|
||||||
|
if array[song_num]["title"] == song["title"] and array[song_num]["album"] == song["album"] and array[song_num]["artists"] == song["artists"] and index != song_num:
|
||||||
|
array.remove(song)
|
||||||
|
|
||||||
|
song_num += 1
|
||||||
|
|
||||||
return array
|
return array
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ class AllSongs(Mongo):
|
|||||||
|
|
||||||
def find_songs_by_album(self, name, artist):
|
def find_songs_by_album(self, name, artist):
|
||||||
return self.collection.find({'album': name, 'album_artist': artist})
|
return self.collection.find({'album': name, 'album_artist': artist})
|
||||||
|
|
||||||
|
def get_songs_by_album(self, query):
|
||||||
|
return self.collection.find({'album': query})
|
||||||
|
|
||||||
def get_all_songs(self):
|
def get_all_songs(self):
|
||||||
return self.collection.find().limit(25)
|
return self.collection.find().limit(25)
|
||||||
|
|||||||
Reference in New Issue
Block a user