mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
fix playlist image being lost on title edit (#29)
This commit is contained in:
@@ -21,8 +21,7 @@ TrackExistsInPlaylist = exceptions.TrackExistsInPlaylist
|
||||
@playlist_bp.route("/playlists", methods=["GET"])
|
||||
def get_all_playlists():
|
||||
playlists = [
|
||||
serializer.Playlist(p, construct_last_updated=False)
|
||||
for p in api.PLAYLISTS
|
||||
serializer.Playlist(p, construct_last_updated=False) for p in api.PLAYLISTS
|
||||
]
|
||||
playlists.sort(
|
||||
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:
|
||||
playlistlib.add_track(playlist_id, trackid)
|
||||
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
|
||||
|
||||
@@ -103,11 +102,14 @@ def update_playlist(playlistid: str):
|
||||
"image": None,
|
||||
}
|
||||
|
||||
if image:
|
||||
playlist["image"] = playlistlib.save_p_image(image, playlistid)
|
||||
|
||||
for p in api.PLAYLISTS:
|
||||
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)
|
||||
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(
|
||||
playlistid, track)
|
||||
return
|
||||
except TrackExistsInPlaylist as e:
|
||||
return {"error": str(e)}, 409
|
||||
except TrackExistsInPlaylist as error:
|
||||
raise error
|
||||
|
||||
|
||||
def get_playlist_tracks(pid: str):
|
||||
|
||||
@@ -127,7 +127,7 @@ class Playlist:
|
||||
if image:
|
||||
return settings.IMG_PLAYLIST_URI + image
|
||||
|
||||
return settings.IMG_PLAYLIST_URI + ""
|
||||
return settings.IMG_PLAYLIST_URI + "default.webp"
|
||||
|
||||
def update_count(self):
|
||||
self.count = len(self._pre_tracks)
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
v-if="search.query.trim().length === 0"
|
||||
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
|
||||
v-else-if="
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import axios from "axios";
|
||||
import axios, { AxiosError } from "axios";
|
||||
import state from "./state";
|
||||
import { AlbumInfo, Track } from "../interfaces";
|
||||
|
||||
@@ -17,14 +17,14 @@ const getAlbumTracks = async (album: string, artist: string) => {
|
||||
data.info = res.data.info;
|
||||
data.tracks = res.data.songs;
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch((err: AxiosError) => {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
const getAlbumArtists = async (album, artist) => {
|
||||
const getAlbumArtists = async (album:string, artist:string) => {
|
||||
let artists = [];
|
||||
|
||||
await axios
|
||||
@@ -35,7 +35,7 @@ const getAlbumArtists = async (album, artist) => {
|
||||
.then((res) => {
|
||||
artists = res.data.artists;
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch((err: AxiosError) => {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ const getAlbumBio = async (album: string, albumartist: string) => {
|
||||
.then((res) => {
|
||||
bio = res.data.bio;
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch((err: AxiosError) => {
|
||||
if (err.response.status === 404) {
|
||||
bio = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user