mirror of
https://github.com/Dvorinka/SpotifyRecAlg.git
synced 2026-06-03 20:13:03 +00:00
23 lines
598 B
Python
23 lines
598 B
Python
from flask_openapi3 import APIBlueprint, Tag
|
|
|
|
from swingmusic.api.apischemas import AlbumHashSchema
|
|
from swingmusic.store.albums import AlbumStore as Store
|
|
|
|
bp_tag = Tag(name="Colors", description="Get item colors")
|
|
api = APIBlueprint("colors", __name__, url_prefix="/colors", abp_tags=[bp_tag])
|
|
|
|
|
|
@api.get("/album/<albumhash>")
|
|
def get_album_color(path: AlbumHashSchema):
|
|
"""
|
|
Get album color
|
|
"""
|
|
album = Store.get_album_by_hash(path.albumhash)
|
|
|
|
msg = {"color": ""}
|
|
|
|
if album is None or len(album.colors) == 0:
|
|
return msg, 404
|
|
|
|
return {"color": album.colors[0]}
|