From 73891aa5cf6ac62dedf245384031f520378158f8 Mon Sep 17 00:00:00 2001 From: "restyled-io[bot]" <32688539+restyled-io[bot]@users.noreply.github.com> Date: Wed, 6 Jul 2022 17:38:11 +0300 Subject: [PATCH] Restyle New album page design (#77) --- server/app/api/album.py | 8 ++------ server/app/api/playlist.py | 8 +++++--- server/app/api/track.py | 8 +++----- server/app/functions.py | 16 +++++++--------- server/app/lib/albumslib.py | 9 +++++++-- server/app/lib/watchdoge.py | 2 +- server/app/serializer.py | 4 +++- src/composables/searchMusic.ts | 2 +- 8 files changed, 29 insertions(+), 28 deletions(-) diff --git a/server/app/api/album.py b/server/app/api/album.py index 0b00fe63..2f22f702 100644 --- a/server/app/api/album.py +++ b/server/app/api/album.py @@ -64,12 +64,8 @@ def get_album(): except AttributeError: album.duration = 0 - if ( - album.count == 1 - and tracks[0].title == album.title - and tracks[0].tracknumber == 1 - and tracks[0].disknumber == 1 - ): + if (album.count == 1 and tracks[0].title == album.title + and tracks[0].tracknumber == 1 and tracks[0].disknumber == 1): album.is_single = True return {"tracks": tracks, "info": album} diff --git a/server/app/api/playlist.py b/server/app/api/playlist.py index f7d5a0a1..c26eb0df 100644 --- a/server/app/api/playlist.py +++ b/server/app/api/playlist.py @@ -8,12 +8,13 @@ from app import exceptions from app import instances from app import models from app import serializer +from app.helpers import create_new_date +from app.helpers import Get +from app.helpers import UseBisection from app.lib import playlistlib from flask import Blueprint from flask import request -from app.helpers import Get, UseBisection, create_new_date - playlist_bp = Blueprint("playlist", __name__, url_prefix="/") PlaylistExists = exceptions.PlaylistExists @@ -27,7 +28,8 @@ def get_all_playlists(): dbplaylists = [models.Playlist(p) for p in dbplaylists] playlists = [ - serializer.Playlist(p, construct_last_updated=False) for p in dbplaylists + serializer.Playlist(p, construct_last_updated=False) + for p in dbplaylists ] playlists.sort( key=lambda p: datetime.strptime(p.lastUpdated, "%Y-%m-%d %H:%M:%S"), diff --git a/server/app/api/track.py b/server/app/api/track.py index 08ca78e6..924f6aa1 100644 --- a/server/app/api/track.py +++ b/server/app/api/track.py @@ -3,11 +3,10 @@ Contains all the track routes. """ from app import api from app import instances +from app import models from flask import Blueprint from flask import send_file -from app import models - track_bp = Blueprint("track", __name__, url_prefix="/") @@ -37,6 +36,5 @@ def get_sample_track(): Returns a sample track object. """ - return instances.tracks_instance.get_song_by_album( - "Legends Never Die", "Juice WRLD" - ) + return instances.tracks_instance.get_song_by_album("Legends Never Die", + "Juice WRLD") diff --git a/server/app/functions.py b/server/app/functions.py index 106a8a6e..b9293de3 100644 --- a/server/app/functions.py +++ b/server/app/functions.py @@ -79,6 +79,7 @@ class getArtistImage: class useImageDownloader: + def __init__(self, url: str, dest: str) -> None: self.url = url self.dest = dest @@ -95,6 +96,7 @@ class useImageDownloader: class CheckArtistImages: + def __init__(self): self.artists: list[str] = [] print("Checking for artist images") @@ -119,12 +121,8 @@ class CheckArtistImages: :param artistname: The artist name """ - img_path = ( - settings.APP_DIR - + "/images/artists/" - + helpers.create_safe_name(artistname) - + ".webp" - ) + img_path = (settings.APP_DIR + "/images/artists/" + + helpers.create_safe_name(artistname) + ".webp") if cls.check_if_exists(img_path): return "exists" @@ -151,8 +149,7 @@ def fetch_album_bio(title: str, albumartist: str) -> str | None: Returns the album bio for a given album. """ last_fm_url = "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key={}&artist={}&album={}&format=json".format( - settings.LAST_FM_API_KEY, albumartist, title - ) + settings.LAST_FM_API_KEY, albumartist, title) try: response = requests.get(last_fm_url) @@ -161,7 +158,8 @@ def fetch_album_bio(title: str, albumartist: str) -> str | None: return None try: - bio = data["album"]["wiki"]["summary"].split(' None: + def __init__(self, + p: models.Playlist, + construct_last_updated: bool = True) -> None: self.playlistid = p.playlistid self.name = p.name self.image = p.image diff --git a/src/composables/searchMusic.ts b/src/composables/searchMusic.ts index c5171f30..27d7e43a 100644 --- a/src/composables/searchMusic.ts +++ b/src/composables/searchMusic.ts @@ -83,4 +83,4 @@ export { }; // TODO: -// Rewrite this module using `useAxios` hook \ No newline at end of file +// Rewrite this module using `useAxios` hook