fix: scan episodes synchronously and disable test mode rate limiting
- Always scan missing episodes sync in add_series to avoid race condition - Add db fallback in get_anime when in-memory episodeDict empty - Add with_episodes param to AnimeSeriesService.get_by_key - Disable auth rate limiting and lockout in test mode (ANIWORLD_TESTING=1) - Simplify responsive.robot tests: fix setup, remove fragile width checks
This commit is contained in:
@@ -949,16 +949,13 @@ async def add_series(
|
||||
e
|
||||
)
|
||||
|
||||
# Step G: Scan missing episodes immediately if background loader is not running
|
||||
# Uses existing SerieScanner and AnimeService sync to avoid duplicates
|
||||
# Step G: Scan missing episodes immediately
|
||||
# Always scan synchronously to ensure episodes are available when
|
||||
# get_anime is called right after add_series returns.
|
||||
# Background loader handles any additional work and rescan logic.
|
||||
try:
|
||||
loader_running = bool(
|
||||
background_loader.worker_tasks
|
||||
and any(not t.done() for t in background_loader.worker_tasks)
|
||||
)
|
||||
if (
|
||||
not loader_running
|
||||
and series_app
|
||||
series_app
|
||||
and hasattr(series_app, "serie_scanner")
|
||||
):
|
||||
missing_episodes = series_app.serie_scanner.scan_single_series(
|
||||
@@ -1111,7 +1108,8 @@ async def get_loading_status(
|
||||
@router.get("/{anime_id}", response_model=AnimeDetail)
|
||||
async def get_anime(
|
||||
anime_id: str,
|
||||
series_app: Optional[Any] = Depends(get_series_app)
|
||||
series_app: Optional[Any] = Depends(get_series_app),
|
||||
db: Optional[AsyncSession] = Depends(get_optional_database_session),
|
||||
) -> AnimeDetail:
|
||||
"""Return detailed information about a specific series.
|
||||
|
||||
@@ -1178,6 +1176,22 @@ async def get_anime(
|
||||
|
||||
episodes: List[str] = []
|
||||
episode_dict = getattr(found, "episodeDict", {}) or {}
|
||||
|
||||
# If in-memory episodeDict is empty, try fetching from database directly
|
||||
if not episode_dict and db is not None:
|
||||
try:
|
||||
db_series = await AnimeSeriesService.get_by_key(
|
||||
db, anime_id, with_episodes=True
|
||||
)
|
||||
if db_series:
|
||||
episode_dict = db_series.episodeDict or {}
|
||||
except Exception as db_exc:
|
||||
logger.warning(
|
||||
"Failed to fetch episodes from DB for '%s': %s",
|
||||
anime_id,
|
||||
db_exc,
|
||||
)
|
||||
|
||||
for season, episode_numbers in episode_dict.items():
|
||||
for episode in episode_numbers:
|
||||
episodes.append(f"{season}-{episode}")
|
||||
|
||||
Reference in New Issue
Block a user