feat: Add spotify to api routes
All checks were successful
Build Docker / BuildImage (push) Successful in 55s

This commit is contained in:
2025-10-26 21:31:30 +11:00
parent 9809fe0695
commit d4d6b47225

View File

@@ -7,6 +7,7 @@ from mail import sendEmail
from tools import getClientIP, getGitCommit, json_response, parse_date, get_tools_data from tools import getClientIP, getGitCommit, json_response, parse_date, get_tools_data
from blueprints.sol import sol_bp from blueprints.sol import sol_bp
from dateutil import parser as date_parser from dateutil import parser as date_parser
from blueprints.spotify import get_spotify_track
# Constants # Constants
HTTP_OK = 200 HTTP_OK = 200
@@ -43,6 +44,8 @@ def help():
"/project": "Get the current project from git", "/project": "Get the current project from git",
"/version": "Get the current version of the website", "/version": "Get the current version of the website",
"/page_date?url=URL&verbose=BOOL": "Get the last modified date of a webpage (verbose is optional, default false)", "/page_date?url=URL&verbose=BOOL": "Get the last modified date of a webpage (verbose is optional, default false)",
"/tools": "Get a list of tools used by Nathan Woodburn",
"/playing": "Get the currently playing Spotify track",
"/status": "Just check if the site is up", "/status": "Just check if the site is up",
"/ping": "Just check if the site is up", "/ping": "Just check if the site is up",
"/help": "Get this help message" "/help": "Get this help message"
@@ -180,6 +183,14 @@ def tools():
return json_response(request, {"tools": tools}, HTTP_OK) return json_response(request, {"tools": tools}, HTTP_OK)
@api_bp.route("/playing")
def playing():
"""Get the currently playing Spotify track."""
track_info = get_spotify_track()
if "error" in track_info:
return json_response(request, track_info, HTTP_OK)
return json_response(request, {"spotify": track_info}, HTTP_OK)
@api_bp.route("/page_date") @api_bp.route("/page_date")
def page_date(): def page_date():
url = request.args.get("url") url = request.args.get("url")