Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
anime-kun32 authored Jan 7, 2025
1 parent e6a2d24 commit 22c0440
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# Fetch configurations from environment variables
API_BASE_URL = os.getenv("API_BASE_URL")
API_ORIGIN_HEADER = os.getenv("API_ORIGIN_HEADER")
CONSUMET_API_BASE_URL = os.getenv("CONSUMET_API_BASE_URL")

@app.get("/api/spotlight")
async def get_spotlight(request: Request):
Expand Down Expand Up @@ -62,6 +63,19 @@ async def get_spotlight(request: Request):
if anilist_id:
anime["anilistId"] = anilist_id

# Fetch trailer from Consumet API
try:
trailer_response = await client.get(
f"{CONSUMET_API_BASE_URL}/meta/anilist/info/{anilist_id}"
)
trailer_data = trailer_response.json()

if trailer_data.get("success"):
anime["trailer"] = trailer_data["data"].get("trailerUrl") # Adjust based on actual response structure
except Exception as trailer_error:
# Log the error or handle it as needed
print(f"Error fetching trailer for Anilist ID {anilist_id}: {trailer_error}")

updated_spotlight.append(anime)

return {"success": True, "data": {"spotlightAnimes": updated_spotlight}}
Expand Down

0 comments on commit 22c0440

Please sign in to comment.