update references to codey.lol -> codey.horse [new domain]

This commit is contained in:
2026-02-21 08:00:38 -05:00
parent d6689b9c38
commit 83285ff08c
6 changed files with 89 additions and 31 deletions

View File

@@ -4,6 +4,7 @@ import regex
import aiosqlite as sqlite3
from fastapi import FastAPI, HTTPException, Depends
from fastapi_throttle import RateLimiter
from fastapi.requests import Request
from fastapi.responses import JSONResponse
from typing import LiteralString, Optional, Union, Iterable
from regex import Pattern
@@ -128,7 +129,7 @@ class LyricSearch(FastAPI):
return JSONResponse(content=[])
return JSONResponse(content=typeahead)
async def lyric_search_handler(self, data: ValidLyricRequest) -> JSONResponse:
async def lyric_search_handler(self, data: ValidLyricRequest, request: Request) -> JSONResponse:
"""
Search for lyrics.
@@ -317,4 +318,13 @@ class LyricSearch(FastAPI):
if not data.extra:
result.pop("src")
# Check if the request is coming from the old domain
host = request.headers.get("host", "")
if "api.codey.lol" in host:
warning_message = "Warning: The API domain is moving to api.codey.horse. Please update your scripts to use the new domain."
if "lyrics" in result:
result["lyrics"] = f"{warning_message}<br>{result['lyrics']}"
elif "lrc" in result:
result["lrc"] = f"{warning_message}\n{result['lrc']}"
return JSONResponse(content=result)