mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
fix playlist image being lost on title edit
This commit is contained in:
@@ -21,8 +21,7 @@ TrackExistsInPlaylist = exceptions.TrackExistsInPlaylist
|
|||||||
@playlist_bp.route("/playlists", methods=["GET"])
|
@playlist_bp.route("/playlists", methods=["GET"])
|
||||||
def get_all_playlists():
|
def get_all_playlists():
|
||||||
playlists = [
|
playlists = [
|
||||||
serializer.Playlist(p, construct_last_updated=False)
|
serializer.Playlist(p, construct_last_updated=False) for p in api.PLAYLISTS
|
||||||
for p in api.PLAYLISTS
|
|
||||||
]
|
]
|
||||||
playlists.sort(
|
playlists.sort(
|
||||||
key=lambda p: datetime.strptime(p.lastUpdated, "%Y-%m-%d %H:%M:%S"),
|
key=lambda p: datetime.strptime(p.lastUpdated, "%Y-%m-%d %H:%M:%S"),
|
||||||
@@ -69,7 +68,7 @@ def add_track_to_playlist(playlist_id: str):
|
|||||||
try:
|
try:
|
||||||
playlistlib.add_track(playlist_id, trackid)
|
playlistlib.add_track(playlist_id, trackid)
|
||||||
except TrackExistsInPlaylist as e:
|
except TrackExistsInPlaylist as e:
|
||||||
return {"error": str(e)}, 409
|
return {"error": "Track already exists in playlist"}, 409
|
||||||
|
|
||||||
return {"msg": "I think It's done"}, 200
|
return {"msg": "I think It's done"}, 200
|
||||||
|
|
||||||
@@ -103,11 +102,14 @@ def update_playlist(playlistid: str):
|
|||||||
"image": None,
|
"image": None,
|
||||||
}
|
}
|
||||||
|
|
||||||
if image:
|
|
||||||
playlist["image"] = playlistlib.save_p_image(image, playlistid)
|
|
||||||
|
|
||||||
for p in api.PLAYLISTS:
|
for p in api.PLAYLISTS:
|
||||||
if p.playlistid == playlistid:
|
if p.playlistid == playlistid:
|
||||||
|
|
||||||
|
if image:
|
||||||
|
playlist["image"] = playlistlib.save_p_image(image, playlistid)
|
||||||
|
else:
|
||||||
|
playlist["image"] = p.image.split("/")[-1]
|
||||||
|
|
||||||
p.update_playlist(playlist)
|
p.update_playlist(playlist)
|
||||||
instances.playlist_instance.update_playlist(playlistid, playlist)
|
instances.playlist_instance.update_playlist(playlistid, playlist)
|
||||||
|
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ def add_track(playlistid: str, trackid: str):
|
|||||||
instances.playlist_instance.add_track_to_playlist(
|
instances.playlist_instance.add_track_to_playlist(
|
||||||
playlistid, track)
|
playlistid, track)
|
||||||
return
|
return
|
||||||
except TrackExistsInPlaylist as e:
|
except TrackExistsInPlaylist as error:
|
||||||
return {"error": str(e)}, 409
|
raise error
|
||||||
|
|
||||||
|
|
||||||
def get_playlist_tracks(pid: str):
|
def get_playlist_tracks(pid: str):
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class Playlist:
|
|||||||
if image:
|
if image:
|
||||||
return settings.IMG_PLAYLIST_URI + image
|
return settings.IMG_PLAYLIST_URI + image
|
||||||
|
|
||||||
return settings.IMG_PLAYLIST_URI + ""
|
return settings.IMG_PLAYLIST_URI + "default.webp"
|
||||||
|
|
||||||
def update_count(self):
|
def update_count(self):
|
||||||
self.count = len(self._pre_tracks)
|
self.count = len(self._pre_tracks)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
v-if="search.query.trim().length === 0"
|
v-if="search.query.trim().length === 0"
|
||||||
class="no-res border rounded"
|
class="no-res border rounded"
|
||||||
>
|
>
|
||||||
<div class="no-res-text">👻 Find your music</div>
|
<div class="no-res-text">🦋 Find your music</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-else-if="
|
v-else-if="
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import axios from "axios";
|
import axios, { AxiosError } from "axios";
|
||||||
import state from "./state";
|
import state from "./state";
|
||||||
import { AlbumInfo, Track } from "../interfaces";
|
import { AlbumInfo, Track } from "../interfaces";
|
||||||
|
|
||||||
@@ -17,14 +17,14 @@ const getAlbumTracks = async (album: string, artist: string) => {
|
|||||||
data.info = res.data.info;
|
data.info = res.data.info;
|
||||||
data.tracks = res.data.songs;
|
data.tracks = res.data.songs;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err: AxiosError) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getAlbumArtists = async (album, artist) => {
|
const getAlbumArtists = async (album:string, artist:string) => {
|
||||||
let artists = [];
|
let artists = [];
|
||||||
|
|
||||||
await axios
|
await axios
|
||||||
@@ -35,7 +35,7 @@ const getAlbumArtists = async (album, artist) => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
artists = res.data.artists;
|
artists = res.data.artists;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err: AxiosError) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ const getAlbumBio = async (album: string, albumartist: string) => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
bio = res.data.bio;
|
bio = res.data.bio;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err: AxiosError) => {
|
||||||
if (err.response.status === 404) {
|
if (err.response.status === 404) {
|
||||||
bio = null;
|
bio = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user