mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-08 04:05:35 +00:00
fix incorrect album fetching
This commit is contained in:
parent
49947a22b2
commit
c49e1e48f1
@ -351,12 +351,16 @@ def getAlbums():
|
|||||||
|
|
||||||
return {'albums': albums}
|
return {'albums': albums}
|
||||||
|
|
||||||
@bp.route('/albums/<album>')
|
@bp.route('/albums/<query>')
|
||||||
def getAlbumSongs(album: str):
|
def getAlbumSongs(query: str):
|
||||||
album = urllib.parse.unquote(album)
|
album = query.split('::')[0]
|
||||||
songs = all_songs_instance.find_songs_by_album(album)
|
artist = query.split('::')[1]
|
||||||
|
|
||||||
|
songs = all_songs_instance.find_songs_by_album(album, artist)
|
||||||
songs_array = convert_to_json(songs)
|
songs_array = convert_to_json(songs)
|
||||||
|
|
||||||
|
print(artist)
|
||||||
|
|
||||||
for song in songs_array:
|
for song in songs_array:
|
||||||
song['artists'] = song['artists'].split(', ')
|
song['artists'] = song['artists'].split(', ')
|
||||||
song['filepath'] = song['filepath'].replace(home_dir, '')
|
song['filepath'] = song['filepath'].replace(home_dir, '')
|
||||||
|
@ -46,8 +46,8 @@ class AllSongs(Mongo):
|
|||||||
self.collection.create_index([('title', pymongo.TEXT)])
|
self.collection.create_index([('title', pymongo.TEXT)])
|
||||||
return self.collection.find({'title': {'$regex': query, '$options': 'i'}})
|
return self.collection.find({'title': {'$regex': query, '$options': 'i'}})
|
||||||
|
|
||||||
def find_songs_by_album(self, query):
|
def find_songs_by_album(self, name, artist):
|
||||||
return self.collection.find({'album': query})
|
return self.collection.find({'album': name, 'album_artist': artist})
|
||||||
|
|
||||||
def get_all_songs(self):
|
def get_all_songs(self):
|
||||||
return self.collection.find().limit(25)
|
return self.collection.find().limit(25)
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td :style="{ width: songTitleWidth + 'px' }">
|
<td :style="{ width: songTitleWidth + 'px' }">
|
||||||
<div class="ellip">
|
<div class="ellip" v-if="song.artists[0] != ''">
|
||||||
<span
|
<span
|
||||||
class="artist"
|
class="artist"
|
||||||
v-for="artist in putCommas(song.artists)"
|
v-for="artist in putCommas(song.artists)"
|
||||||
@ -40,11 +40,17 @@
|
|||||||
>{{ artist }}</span
|
>{{ artist }}</span
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="ellip" v-else>
|
||||||
|
<span class="artist">{{ song.album_artist }}</span>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td :style="{ width: songTitleWidth + 'px' }">
|
<td :style="{ width: songTitleWidth + 'px' }">
|
||||||
<router-link
|
<router-link
|
||||||
class="ellip"
|
class="ellip"
|
||||||
:to="{ name: 'AlbumView', params: { album: song.album } }"
|
:to="{
|
||||||
|
name: 'AlbumView',
|
||||||
|
params: { album: song.album, artist: song.album_artist },
|
||||||
|
}"
|
||||||
>{{ song.album }}</router-link
|
>{{ song.album }}</router-link
|
||||||
>
|
>
|
||||||
</td>
|
</td>
|
||||||
@ -80,6 +86,7 @@ export default {
|
|||||||
const putCommas = perks.putCommas;
|
const putCommas = perks.putCommas;
|
||||||
|
|
||||||
const updateQueue = async (song) => {
|
const updateQueue = async (song) => {
|
||||||
|
console.log(song.artists.length);
|
||||||
if (perks.queue.value[0]._id.$oid !== song_list.value[0]._id.$oid) {
|
if (perks.queue.value[0]._id.$oid !== song_list.value[0]._id.$oid) {
|
||||||
const queue = song_list.value;
|
const queue = song_list.value;
|
||||||
localStorage.setItem("queue", JSON.stringify(queue));
|
localStorage.setItem("queue", JSON.stringify(queue));
|
||||||
|
@ -10,11 +10,14 @@
|
|||||||
<div>
|
<div>
|
||||||
<p id="title" class="ellipsis">{{ current.title }}</p>
|
<p id="title" class="ellipsis">{{ current.title }}</p>
|
||||||
<hr />
|
<hr />
|
||||||
<div id="artist">
|
<div id="artist" v-if="current.artists[0] != ''">
|
||||||
<span v-for="artist in putCommas(current.artists)" :key="artist">{{
|
<span v-for="artist in putCommas(current.artists)" :key="artist">{{
|
||||||
artist
|
artist
|
||||||
}}</span>
|
}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="artist" v-else>
|
||||||
|
<span>{{ current.album_artist }}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="progress">
|
<div class="progress">
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
let base_uri = "http://127.0.0.1:9876";
|
let base_uri = "http://127.0.0.1:9876";
|
||||||
|
|
||||||
const getAlbum = async (name) => {
|
const getAlbum = async (name, artist) => {
|
||||||
const res = await fetch(base_uri + "/albums/" + name);
|
const res = await fetch(base_uri + "/albums/" + name + "::" + artist);
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
const message = `An error has occured: ${res.status}`;
|
const message = `An error has occured: ${res.status}`;
|
||||||
|
@ -34,7 +34,7 @@ const routes = [
|
|||||||
component: AlbumsExplorer,
|
component: AlbumsExplorer,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/albums/:album",
|
path: "/albums/:album/:artist",
|
||||||
name: "AlbumView",
|
name: "AlbumView",
|
||||||
component: AlbumView,
|
component: AlbumView,
|
||||||
},
|
},
|
||||||
|
@ -40,11 +40,12 @@ export default {
|
|||||||
setup() {
|
setup() {
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const album_name = route.params.album;
|
const album_name = route.params.album;
|
||||||
|
const album_artists = route.params.artist;
|
||||||
const album_songs = ref([]);
|
const album_songs = ref([]);
|
||||||
const album_info = ref({});
|
const album_info = ref({});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getAlbum(album_name).then((data) => {
|
getAlbum(album_name, album_artists).then((data) => {
|
||||||
album_songs.value = data.songs;
|
album_songs.value = data.songs;
|
||||||
album_info.value = data.info;
|
album_info.value = data.info;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user