mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
Restyle Move populate to new file (#48)
This commit is contained in:
@@ -10,9 +10,9 @@ from app import api
|
||||
from app import helpers
|
||||
from app import settings
|
||||
from app.lib import watchdoge
|
||||
from app.lib.populate import Populate
|
||||
from PIL import Image
|
||||
from progress.bar import Bar
|
||||
from app.lib.populate import Populate
|
||||
|
||||
|
||||
@helpers.background
|
||||
@@ -76,9 +76,8 @@ def fetch_artist_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)
|
||||
@@ -100,8 +99,7 @@ def fetch_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)
|
||||
@@ -110,7 +108,8 @@ def fetch_album_bio(title: str, albumartist: str):
|
||||
return None
|
||||
|
||||
try:
|
||||
bio = data["album"]["wiki"]["summary"].split('<a href="https://www.last.fm/')[0]
|
||||
bio = data["album"]["wiki"]["summary"].split(
|
||||
'<a href="https://www.last.fm/')[0]
|
||||
except KeyError:
|
||||
bio = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user