fix: improve AniDB anime detection error handling in webhook processing

- Fix typo in variable name (matching_enty → matching_entry)
- Fall through to TMDB TV processing when AniDB mapping is not found
- Log warning when episode number is missing for AniDB match
This commit is contained in:
FuzzyGrim
2026-02-22 23:40:21 +01:00
parent 57074348ea
commit dcd467cea6
2 changed files with 28 additions and 10 deletions

View File

@@ -60,15 +60,33 @@ class BaseWebhookProcessor:
anidb_id = ids.get("anidb_id")
if user.anime_enabled and anidb_id:
mapping_data = self._fetch_mapping_data()
matching_enty = mapping_data.get(anidb_id)
if not matching_enty:
matching_entry = mapping_data.get(anidb_id)
if not matching_entry:
logger.info(
"AniDB ID %s not found in mapping, "
"falling through to TV processing",
anidb_id,
)
elif not payload["Metadata"]["index"]:
logger.warning(
"No episode number found for AniDB ID: %s",
anidb_id,
)
else:
episode_number = payload["Metadata"]["index"]
logger.info(
"Detected anime via AniDB ID: %s. Matching MAL ID: %s, Episode: %d",
anidb_id,
matching_entry["mal_id"],
episode_number,
)
self._handle_anime(
matching_entry["mal_id"],
episode_number,
payload,
user,
)
return
episode_number = payload['Metadata']['index']
if not episode_number:
return
logger.info("Detected anime via AniDB ID: %s. Matching MAL ID: %s, Episode: %d", ids["anidb_id"], matching_enty["mal_id"], episode_number)
self._handle_anime(matching_enty["mal_id"], episode_number, payload, user)
return
media_id, season_number, episode_number = self._find_tv_media_id(ids)
if not media_id:

View File

@@ -94,8 +94,8 @@ class PlexWebhookProcessor(BaseWebhookProcessor):
)
def extract_hama_anidb_id(guid):
"""
Extracts the AniDB ID from a Hama agent GUID string.
"""Extract the AniDB ID from a Hama agent GUID string.
e.g., "com.plexapp.agents.hama://anidb-12834/1/2?lang=en" -> "12834"
"""
if guid and "hama://anidb-" in guid: