fix: Address critical issues from PR review

Fix 4 critical issues identified in code review:

**Error Handling Improvements:**
- Replace bare except blocks with specific exception handlers
- Add logging for TimeoutException and ConnectError
- Prevent silent failures in season loading
- Remove misleading "0 episodes" on error

**Robustness Fixes:**
- Add safe None handling in title comparison (main.py)
  Prevents crash when title is None
- Add URL validation before encodeURIComponent (anime.js)
  Prevents crash when anime.url is undefined
- Fix unreachable code in retry logic (recommendations.py)
  Preserve retry context in exception messages

**Changes:**
- animesama.py: Specific exception handling with print statements
- main.py: Safe None handling with (x.get('title') or '')
- anime.js: URL validation before encoding
- recommendations.py: Better exception messages with retry context

All fixes tested and working correctly.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
root
2026-01-29 19:07:23 +00:00
parent d82bec92b4
commit 764b4e2edd
4 changed files with 34 additions and 21 deletions
+1 -1
View File
@@ -524,7 +524,7 @@ async def search_anime_unified(q: str, lang: str = "vostfr", include_metadata: b
for provider_id in results:
results[provider_id].sort(key=lambda x: (
-x.get('_relevance_boost', 0), # Exact matches first
x.get('title', '').lower().find(q.lower()) # Then by position of match
(x.get('title') or '').lower().find(q.lower()) # Then by position of match
))
# Remove temporary boost field
for item in results[provider_id]: