mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
add lyrics route and methods
This commit is contained in:
@@ -17,6 +17,7 @@ from app.api import (
|
||||
search,
|
||||
send_file,
|
||||
settings,
|
||||
lyrics
|
||||
)
|
||||
|
||||
|
||||
@@ -43,5 +44,6 @@ def create_api():
|
||||
app.register_blueprint(imgserver.api)
|
||||
app.register_blueprint(settings.api)
|
||||
app.register_blueprint(colors.api)
|
||||
app.register_blueprint(lyrics.api)
|
||||
|
||||
return app
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
from flask import Blueprint, request
|
||||
|
||||
from app.lib.lyrics import get_lyrics
|
||||
|
||||
api = Blueprint("lyrics", __name__, url_prefix="")
|
||||
|
||||
|
||||
@api.route("/lyrics", methods=["POST"])
|
||||
def send_lyrics():
|
||||
"""
|
||||
Returns the lyrics for a track
|
||||
"""
|
||||
data = request.get_json()
|
||||
|
||||
filepath = data.get("filepath", None)
|
||||
|
||||
if filepath is None:
|
||||
return {"error": "No filepath provided"}, 400
|
||||
|
||||
lyrics = get_lyrics(filepath)
|
||||
|
||||
if lyrics is None:
|
||||
return {"error": "No lyrics found"}, 204
|
||||
|
||||
return {"lyrics": lyrics}, 200
|
||||
Reference in New Issue
Block a user