mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-07-29 06:02:06 +00:00
convert track_id --> trackid
This commit is contained in:
parent
2e699f7be7
commit
fe07961757
@ -286,13 +286,13 @@ def get_album_bio(title, artist):
|
|||||||
return {"bio": bio}, 200
|
return {"bio": bio}, 200
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/file/<track_id>")
|
@bp.route("/file/<trackid>")
|
||||||
def send_track_file(track_id):
|
def send_track_file(trackid):
|
||||||
"""
|
"""
|
||||||
Returns an audio file that matches the passed id to the client.
|
Returns an audio file that matches the passed id to the client.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
filepath = instances.songs_instance.get_song_by_id(track_id)['filepath']
|
filepath = instances.songs_instance.get_song_by_id(trackid)['filepath']
|
||||||
return send_file(filepath, mimetype="audio/mp3")
|
return send_file(filepath, mimetype="audio/mp3")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return "File not found", 404
|
return "File not found", 404
|
||||||
|
@ -207,7 +207,7 @@ class Track:
|
|||||||
Track class
|
Track class
|
||||||
"""
|
"""
|
||||||
|
|
||||||
track_id: str
|
trackid: str
|
||||||
title: str
|
title: str
|
||||||
artists: str
|
artists: str
|
||||||
albumartist: str
|
albumartist: str
|
||||||
|
@ -49,11 +49,11 @@ def remove_track(filepath: str) -> None:
|
|||||||
"""
|
"""
|
||||||
Removes a track from the music dict.
|
Removes a track from the music dict.
|
||||||
"""
|
"""
|
||||||
track_id = instances.songs_instance.get_song_by_path(filepath)["_id"]["$oid"]
|
trackid = instances.songs_instance.get_song_by_path(filepath)["_id"]["$oid"]
|
||||||
instances.songs_instance.remove_song_by_id(track_id)
|
instances.songs_instance.remove_song_by_id(trackid)
|
||||||
|
|
||||||
for track in api.all_the_f_music:
|
for track in api.all_the_f_music:
|
||||||
if track.track_id == track_id:
|
if track.trackid == trackid:
|
||||||
api.all_the_f_music.remove(track)
|
api.all_the_f_music.remove(track)
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="scrollable-r border rounded">
|
<div class="scrollable-r border rounded">
|
||||||
<TrackItem v-for="song in queue" :key="song.track_id" :track="song" />
|
<TrackItem v-for="song in queue" :key="song.trackid" :track="song" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<TrackItem
|
<TrackItem
|
||||||
v-for="track in props.tracks"
|
v-for="track in props.tracks"
|
||||||
:key="track.track_id"
|
:key="track.trackid"
|
||||||
:track="track"
|
:track="track"
|
||||||
/>
|
/>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<tr class="songlist-item" :class="{ current: current.track_id === song.track_id }">
|
<tr class="songlist-item" :class="{ current: current.trackid === song.trackid }">
|
||||||
<td class="index">{{ index }}</td>
|
<td class="index">{{ index }}</td>
|
||||||
<td class="flex" @click="emitUpdate(song)">
|
<td class="flex" @click="emitUpdate(song)">
|
||||||
<div
|
<div
|
||||||
@ -8,7 +8,7 @@
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="now-playing-track image"
|
class="now-playing-track image"
|
||||||
v-if="current.track_id === song.track_id"
|
v-if="current.trackid === song.trackid"
|
||||||
:class="{ active: is_playing, not_active: !is_playing }"
|
:class="{ active: is_playing, not_active: !is_playing }"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class="track-item h-1"
|
class="track-item h-1"
|
||||||
@click="playThis(props.track)"
|
@click="playThis(props.track)"
|
||||||
:class="{
|
:class="{
|
||||||
currentInQueue: current.track_id === props.track.track_id,
|
currentInQueue: current.trackid === props.track.trackid,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@ -14,7 +14,7 @@
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="now-playing-track image"
|
class="now-playing-track image"
|
||||||
v-if="current.track_id === props.track.track_id"
|
v-if="current.trackid === props.track.trackid"
|
||||||
:class="{ active: is_playing, not_active: !is_playing }"
|
:class="{ active: is_playing, not_active: !is_playing }"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
@ -44,7 +44,7 @@ const putCommas = perks.putCommas;
|
|||||||
const is_playing = ref(playAudio.playing);
|
const is_playing = ref(playAudio.playing);
|
||||||
|
|
||||||
const playThis = (song) => {
|
const playThis = (song) => {
|
||||||
playAudio.playAudio(song.track_id);
|
playAudio.playAudio(song.trackid);
|
||||||
perks.current.value = song;
|
perks.current.value = song;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ const putCommas = (artists) => {
|
|||||||
|
|
||||||
function updateNext(song_) {
|
function updateNext(song_) {
|
||||||
const index = state.queue.value.findIndex(
|
const index = state.queue.value.findIndex(
|
||||||
(item) => item.track_id === song_.track_id
|
(item) => item.trackid === song_.trackid
|
||||||
);
|
);
|
||||||
|
|
||||||
if (index === queue.value.length - 1) {
|
if (index === queue.value.length - 1) {
|
||||||
@ -52,7 +52,7 @@ function updateNext(song_) {
|
|||||||
|
|
||||||
function updatePrev(song) {
|
function updatePrev(song) {
|
||||||
const index = state.queue.value.findIndex(
|
const index = state.queue.value.findIndex(
|
||||||
(item) => item.track_id === song.track_id
|
(item) => item.trackid === song.trackid
|
||||||
);
|
);
|
||||||
|
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
@ -81,7 +81,7 @@ const readQueue = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateQueue = async (song, type) => {
|
const updateQueue = async (song, type) => {
|
||||||
playAudio.playAudio(song.track_id);
|
playAudio.playAudio(song.trackid);
|
||||||
let list;
|
let list;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -93,7 +93,7 @@ const updateQueue = async (song, type) => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.queue.value[0].track_id !== list[0].track_id) {
|
if (state.queue.value[0].trackid !== list[0].trackid) {
|
||||||
const new_queue = list;
|
const new_queue = list;
|
||||||
localStorage.setItem("queue", JSON.stringify(new_queue));
|
localStorage.setItem("queue", JSON.stringify(new_queue));
|
||||||
state.queue.value = new_queue;
|
state.queue.value = new_queue;
|
||||||
|
@ -13,11 +13,11 @@ const playing = ref(state.is_playing);
|
|||||||
|
|
||||||
const url = "http://0.0.0.0:9876/file/";
|
const url = "http://0.0.0.0:9876/file/";
|
||||||
|
|
||||||
const playAudio = (track_id) => {
|
const playAudio = (trackid) => {
|
||||||
const elem = document.getElementsByClassName('progress-bar')[0];
|
const elem = document.getElementsByClassName('progress-bar')[0];
|
||||||
const bottom_elem = document.getElementsByClassName('progress-bar')[1];
|
const bottom_elem = document.getElementsByClassName('progress-bar')[1];
|
||||||
|
|
||||||
const full_path = url + encodeURIComponent(track_id);
|
const full_path = url + encodeURIComponent(trackid);
|
||||||
|
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
audio.src = full_path;
|
audio.src = full_path;
|
||||||
@ -43,13 +43,13 @@ const playAudio = (track_id) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function playNext() {
|
function playNext() {
|
||||||
playAudio(perks.next.value.track_id);
|
playAudio(perks.next.value.trackid);
|
||||||
perks.current.value = perks.next.value;
|
perks.current.value = perks.next.value;
|
||||||
media.showMediaNotif();
|
media.showMediaNotif();
|
||||||
}
|
}
|
||||||
|
|
||||||
function playPrev() {
|
function playPrev() {
|
||||||
playAudio(state.prev.value.track_id);
|
playAudio(state.prev.value.trackid);
|
||||||
perks.current.value = perks.prev.value;
|
perks.current.value = perks.prev.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ function seek(position) {
|
|||||||
|
|
||||||
function playPause() {
|
function playPause() {
|
||||||
if (audio.src === "") {
|
if (audio.src === "") {
|
||||||
playAudio(perks.current.value.filepath);
|
playAudio(perks.current.value.trackid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audio.paused) {
|
if (audio.paused) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user