Restyle Move populate to new file (#48)

This commit is contained in:
restyled-io[bot]
2022-05-04 01:42:26 +03:00
committed by GitHub
parent 4c09350b41
commit 559b36bd7b
7 changed files with 34 additions and 35 deletions
+6 -7
View File
@@ -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