From bb69ac1fc1a176b0609a15ebc2ce228934a6f7c7 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sun, 3 Apr 2022 10:45:57 +0000 Subject: [PATCH] Restyled by yapf --- server/app/api/track.py | 6 +++--- server/app/functions.py | 22 +++++++++------------- server/app/lib/albumslib.py | 6 +++--- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/server/app/api/track.py b/server/app/api/track.py index aef0a83a..661d4bf7 100644 --- a/server/app/api/track.py +++ b/server/app/api/track.py @@ -16,8 +16,7 @@ def send_track_file(trackid): """ try: filepath = [ - file["filepath"] - for file in api.PRE_TRACKS + file["filepath"] for file in api.PRE_TRACKS if file["_id"]["$oid"] == trackid ][0] except (FileNotFoundError, IndexError): @@ -32,4 +31,5 @@ def get_sample_track(): Returns a sample track object. """ - return instances.songs_instance.get_song_by_album("Legends Never Die", "Juice WRLD") + return instances.songs_instance.get_song_by_album("Legends Never Die", + "Juice WRLD") diff --git a/server/app/functions.py b/server/app/functions.py index b3712eb8..046a3489 100644 --- a/server/app/functions.py +++ b/server/app/functions.py @@ -29,7 +29,6 @@ from progress.bar import Bar # from pprint import pprint - @helpers.background def reindex_tracks(): """ @@ -62,7 +61,8 @@ def populate(): """ start = time.time() - s, files = helpers.run_fast_scandir(settings.HOME_DIR, [".flac", ".mp3"], full=True) + s, files = helpers.run_fast_scandir(settings.HOME_DIR, [".flac", ".mp3"], + full=True) _bar = Bar("Processing files", max=len(files)) @@ -86,11 +86,8 @@ def populate(): end = time.time() print( - str(datetime.timedelta(seconds=round(end - start))) - + " elapsed for " - + str(len(files)) - + " files" - ) + str(datetime.timedelta(seconds=round(end - start))) + " elapsed for " + + str(len(files)) + " files") def fetch_image_path(artist: str) -> str or None: @@ -125,9 +122,8 @@ def populate_images(): _bar = Bar("Processing images", max=len(artists)) for artist in artists: - file_path = ( - helpers.app_dir + "/images/artists/" + artist.replace("/", "::") + ".webp" - ) + file_path = (helpers.app_dir + "/images/artists/" + + artist.replace("/", "::") + ".webp") if not os.path.exists(file_path): img_path = fetch_image_path(artist) @@ -358,8 +354,7 @@ def get_album_bio(title: str, albumartist: str): 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) @@ -368,7 +363,8 @@ def get_album_bio(title: str, albumartist: str): return None try: - bio = data["album"]["wiki"]["summary"].split(' models.Album: album["date"] = album_tracks[0]["date"] album["artistimage"] = urllib.parse.quote_plus( - album_tracks[0]["albumartist"] + ".webp" - ) + album_tracks[0]["albumartist"] + ".webp") album["image"] = get_album_image(album_tracks)