fix: ensure HTML response for search and fix player container
CI / Test (Python 3.11) (push) Has been cancelled
CI / Test (Python 3.12) (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Type Check (push) Has been cancelled
CI / Summary (push) Has been cancelled

- Added html=1 parameter support to router_anime.py for guaranteed HTML fragments
- Added missing #player-container to index.html for HTMX interactions
- Cleaned up legacy CSS .active classes interfering with Alpine.js x-show
This commit is contained in:
root
2026-03-24 12:26:58 +00:00
parent 4e313392d0
commit f99e739ff2
3 changed files with 11 additions and 10 deletions
+5 -3
View File
@@ -65,11 +65,12 @@ async def search_anime_unified(
q: str, q: str,
lang: str = "vostfr", lang: str = "vostfr",
include_metadata: bool = False, include_metadata: bool = False,
html: bool = Query(False),
): ):
""" """
Search across all anime providers using MetadataEnricher and health checks. Search across all anime providers using MetadataEnricher and health checks.
Results are grouped by provider for legacy UI compatibility. Results are grouped by provider for legacy UI compatibility.
Returns HTML for HTMX requests. Returns HTML for HTMX requests or if html=True parameter is set.
""" """
print(f"\n[SEARCH] Starting modern unified search for '{q}' in {lang}") print(f"\n[SEARCH] Starting modern unified search for '{q}' in {lang}")
start_time = time.time() start_time = time.time()
@@ -103,7 +104,7 @@ async def search_anime_unified(
seen_urls = set() seen_urls = set()
enricher = await get_metadata_enricher() enricher = await get_metadata_enricher()
enrichment_tasks = [] enrichment_tasks = []
enrichment_mapping = [] # List of (provider_id, index_in_provider_results) enrichment_mapping = []
for i, raw_result in enumerate(all_raw_results): for i, raw_result in enumerate(all_raw_results):
provider_info = task_metadata[i] provider_info = task_metadata[i]
@@ -172,7 +173,7 @@ async def search_anime_unified(
print(f"[SEARCH] Finished in {elapsed:.2f}s. Found {total_found} unique results across {len(results)} providers.") print(f"[SEARCH] Finished in {elapsed:.2f}s. Found {total_found} unique results across {len(results)} providers.")
# 6. Return HTML for HTMX or JSON for API # 6. Return HTML for HTMX or JSON for API
if request.headers.get("HX-Request"): if html or request.headers.get("HX-Request"):
return templates.TemplateResponse( return templates.TemplateResponse(
"components/anime_search_results.html", "components/anime_search_results.html",
{"request": request, "results": results} {"request": request, "results": results}
@@ -351,6 +352,7 @@ async def search_anime_mal_details(
await fetcher.close() await fetcher.close()
@router.post("/api/translate")
@router.post("/translate") @router.post("/translate")
async def translate_text(request: Request): async def translate_text(request: Request):
"""Translate text from English to French using Google Translate""" """Translate text from English to French using Google Translate"""
+1 -5
View File
@@ -172,11 +172,7 @@
} }
.tab-content { .tab-content {
/* Managed by Alpine.js x-show */ /* Handled by Alpine.js x-show */
}
.tab-content.active {
display: block;
} }
select { select {
+5 -2
View File
@@ -3,7 +3,7 @@
{% block content %} {% block content %}
{% include "components/header.html" %} {% include "components/header.html" %}
<!-- Main content - Shown only when authenticated --> <!-- Main content - Managed by Alpine state -->
<div id="main-content"> <div id="main-content">
{% include "components/home_section.html" %} {% include "components/home_section.html" %}
@@ -15,7 +15,7 @@
<h2>🎬 Rechercher un Anime</h2> <h2>🎬 Rechercher un Anime</h2>
</div> </div>
<div class="url-form"> <div class="url-form">
<form hx-get="/api/anime/search" <form hx-get="/api/anime/search?html=1"
hx-target="#animeSearchResults" hx-target="#animeSearchResults"
hx-indicator="#search-loading" hx-indicator="#search-loading"
class="input-group"> class="input-group">
@@ -44,6 +44,9 @@
<!-- Anime search results --> <!-- Anime search results -->
<div id="animeSearchResults" style="margin-bottom: 40px;"></div> <div id="animeSearchResults" style="margin-bottom: 40px;"></div>
<!-- Player container for HTMX injections -->
<div id="player-container"></div>
<hr style="border: none; border-top: 1px solid rgba(255,255,255,0.1); margin: 40px 0;"> <hr style="border: none; border-top: 1px solid rgba(255,255,255,0.1); margin: 40px 0;">
<!-- Latest Releases Section --> <!-- Latest Releases Section -->