move fetching album bio to a class

This commit is contained in:
geoffrey45
2022-05-10 13:17:01 +03:00
parent 8dfa6834ad
commit d52c8ac8fe
2 changed files with 23 additions and 14 deletions
+6 -6
View File
@@ -4,13 +4,13 @@ Contains all the album routes.
from typing import List
from app import api
from app import functions
from app import helpers
from app import models
from app.lib import albumslib
from app.lib import trackslib
from flask import Blueprint
from flask import request
from app.functions import FetchAlbumBio
album_bp = Blueprint("album", __name__, url_prefix="")
@@ -58,14 +58,14 @@ def get_album_tracks():
def get_album_bio():
"""Returns the album bio for the given album."""
data = request.get_json()
fetch_bio = FetchAlbumBio(data["album"], data["albumartist"])()
bio = fetch_bio()
bio = functions.fetch_album_bio(data["album"], data["albumartist"])
if bio is not None:
return {"bio": bio}
else:
if bio is None:
return {"bio": "No bio found."}, 404
return {"bio": bio}
@album_bp.route("/album/artists", methods=["POST"])
def get_albumartists():