diff --git a/server/app/api.py b/server/app/api.py index d0b5eee..fc0fbea 100644 --- a/server/app/api.py +++ b/server/app/api.py @@ -351,12 +351,16 @@ def getAlbums(): return {'albums': albums} -@bp.route('/albums/') -def getAlbumSongs(album: str): - album = urllib.parse.unquote(album) - songs = all_songs_instance.find_songs_by_album(album) +@bp.route('/albums/') +def getAlbumSongs(query: str): + album = query.split('::')[0] + artist = query.split('::')[1] + + songs = all_songs_instance.find_songs_by_album(album, artist) songs_array = convert_to_json(songs) + print(artist) + for song in songs_array: song['artists'] = song['artists'].split(', ') song['filepath'] = song['filepath'].replace(home_dir, '') diff --git a/server/app/models.py b/server/app/models.py index c17d94a..36e4c52 100644 --- a/server/app/models.py +++ b/server/app/models.py @@ -46,8 +46,8 @@ class AllSongs(Mongo): self.collection.create_index([('title', pymongo.TEXT)]) return self.collection.find({'title': {'$regex': query, '$options': 'i'}}) - def find_songs_by_album(self, query): - return self.collection.find({'album': query}) + def find_songs_by_album(self, name, artist): + return self.collection.find({'album': name, 'album_artist': artist}) def get_all_songs(self): return self.collection.find().limit(25) diff --git a/src/components/FolderView/SongList.vue b/src/components/FolderView/SongList.vue index 1fd9f8d..e0bdd3f 100644 --- a/src/components/FolderView/SongList.vue +++ b/src/components/FolderView/SongList.vue @@ -32,7 +32,7 @@ -
+
{{ artist }}
+
+ {{ song.album_artist }} +
{{ song.album }} @@ -80,6 +86,7 @@ export default { const putCommas = perks.putCommas; const updateQueue = async (song) => { + console.log(song.artists.length); if (perks.queue.value[0]._id.$oid !== song_list.value[0]._id.$oid) { const queue = song_list.value; localStorage.setItem("queue", JSON.stringify(queue)); diff --git a/src/components/RightSideBar/NowPlaying.vue b/src/components/RightSideBar/NowPlaying.vue index 2146984..50a3f5f 100644 --- a/src/components/RightSideBar/NowPlaying.vue +++ b/src/components/RightSideBar/NowPlaying.vue @@ -10,11 +10,14 @@

{{ current.title }}


-
+
{{ artist }}
+
+ {{ current.album_artist }} +
diff --git a/src/composables/getAlbum.js b/src/composables/getAlbum.js index be3de2d..6a8d272 100644 --- a/src/composables/getAlbum.js +++ b/src/composables/getAlbum.js @@ -1,7 +1,7 @@ let base_uri = "http://127.0.0.1:9876"; -const getAlbum = async (name) => { - const res = await fetch(base_uri + "/albums/" + name); +const getAlbum = async (name, artist) => { + const res = await fetch(base_uri + "/albums/" + name + "::" + artist); if (!res.ok) { const message = `An error has occured: ${res.status}`; diff --git a/src/router/index.js b/src/router/index.js index 832d60a..31f420f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -34,7 +34,7 @@ const routes = [ component: AlbumsExplorer, }, { - path: "/albums/:album", + path: "/albums/:album/:artist", name: "AlbumView", component: AlbumView, }, diff --git a/src/views/AlbumView.vue b/src/views/AlbumView.vue index 2ecd373..9bfc3e2 100644 --- a/src/views/AlbumView.vue +++ b/src/views/AlbumView.vue @@ -40,11 +40,12 @@ export default { setup() { const route = useRoute(); const album_name = route.params.album; + const album_artists = route.params.artist; const album_songs = ref([]); const album_info = ref({}); onMounted(() => { - getAlbum(album_name).then((data) => { + getAlbum(album_name, album_artists).then((data) => { album_songs.value = data.songs; album_info.value = data.info; });