mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-07-28 21:51:41 +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
|
||||
|
||||
|
||||
@bp.route("/file/<track_id>")
|
||||
def send_track_file(track_id):
|
||||
@bp.route("/file/<trackid>")
|
||||
def send_track_file(trackid):
|
||||
"""
|
||||
Returns an audio file that matches the passed id to the client.
|
||||
"""
|
||||
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")
|
||||
except FileNotFoundError:
|
||||
return "File not found", 404
|
||||
|
@ -207,7 +207,7 @@ class Track:
|
||||
Track class
|
||||
"""
|
||||
|
||||
track_id: str
|
||||
trackid: str
|
||||
title: str
|
||||
artists: str
|
||||
albumartist: str
|
||||
|
@ -49,11 +49,11 @@ def remove_track(filepath: str) -> None:
|
||||
"""
|
||||
Removes a track from the music dict.
|
||||
"""
|
||||
track_id = instances.songs_instance.get_song_by_path(filepath)["_id"]["$oid"]
|
||||
instances.songs_instance.remove_song_by_id(track_id)
|
||||
trackid = instances.songs_instance.get_song_by_path(filepath)["_id"]["$oid"]
|
||||
instances.songs_instance.remove_song_by_id(trackid)
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<tbody>
|
||||
<TrackItem
|
||||
v-for="track in props.tracks"
|
||||
:key="track.track_id"
|
||||
:key="track.trackid"
|
||||
:track="track"
|
||||
/>
|
||||
</tbody>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<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="flex" @click="emitUpdate(song)">
|
||||
<div
|
||||
@ -8,7 +8,7 @@
|
||||
>
|
||||
<div
|
||||
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 }"
|
||||
></div>
|
||||
</div>
|
||||
|
@ -3,7 +3,7 @@
|
||||
class="track-item h-1"
|
||||
@click="playThis(props.track)"
|
||||
:class="{
|
||||
currentInQueue: current.track_id === props.track.track_id,
|
||||
currentInQueue: current.trackid === props.track.trackid,
|
||||
}"
|
||||
>
|
||||
<div
|
||||
@ -14,7 +14,7 @@
|
||||
>
|
||||
<div
|
||||
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 }"
|
||||
></div>
|
||||
</div>
|
||||
@ -44,7 +44,7 @@ const putCommas = perks.putCommas;
|
||||
const is_playing = ref(playAudio.playing);
|
||||
|
||||
const playThis = (song) => {
|
||||
playAudio.playAudio(song.track_id);
|
||||
playAudio.playAudio(song.trackid);
|
||||
perks.current.value = song;
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,7 @@ const putCommas = (artists) => {
|
||||
|
||||
function updateNext(song_) {
|
||||
const index = state.queue.value.findIndex(
|
||||
(item) => item.track_id === song_.track_id
|
||||
(item) => item.trackid === song_.trackid
|
||||
);
|
||||
|
||||
if (index === queue.value.length - 1) {
|
||||
@ -52,7 +52,7 @@ function updateNext(song_) {
|
||||
|
||||
function updatePrev(song) {
|
||||
const index = state.queue.value.findIndex(
|
||||
(item) => item.track_id === song.track_id
|
||||
(item) => item.trackid === song.trackid
|
||||
);
|
||||
|
||||
if (index === 0) {
|
||||
@ -81,7 +81,7 @@ const readQueue = () => {
|
||||
};
|
||||
|
||||
const updateQueue = async (song, type) => {
|
||||
playAudio.playAudio(song.track_id);
|
||||
playAudio.playAudio(song.trackid);
|
||||
let list;
|
||||
|
||||
switch (type) {
|
||||
@ -93,7 +93,7 @@ const updateQueue = async (song, type) => {
|
||||
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;
|
||||
localStorage.setItem("queue", JSON.stringify(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 playAudio = (track_id) => {
|
||||
const playAudio = (trackid) => {
|
||||
const elem = document.getElementsByClassName('progress-bar')[0];
|
||||
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) => {
|
||||
audio.src = full_path;
|
||||
@ -43,13 +43,13 @@ const playAudio = (track_id) => {
|
||||
};
|
||||
|
||||
function playNext() {
|
||||
playAudio(perks.next.value.track_id);
|
||||
playAudio(perks.next.value.trackid);
|
||||
perks.current.value = perks.next.value;
|
||||
media.showMediaNotif();
|
||||
}
|
||||
|
||||
function playPrev() {
|
||||
playAudio(state.prev.value.track_id);
|
||||
playAudio(state.prev.value.trackid);
|
||||
perks.current.value = perks.prev.value;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ function seek(position) {
|
||||
|
||||
function playPause() {
|
||||
if (audio.src === "") {
|
||||
playAudio(perks.current.value.filepath);
|
||||
playAudio(perks.current.value.trackid);
|
||||
}
|
||||
|
||||
if (audio.paused) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user