Улучшено логирование ошибок при поиске торрентов
This commit is contained in:
parent
fcfd741617
commit
15406c732b
1 changed files with 25 additions and 7 deletions
32
app.py
32
app.py
|
|
@ -283,15 +283,29 @@ async def search_torrents(movie_title: str, year: str = None, original_title: st
|
||||||
print(f"Searching '{search_query}' on {provider_name}")
|
print(f"Searching '{search_query}' on {provider_name}")
|
||||||
|
|
||||||
# Поиск на конкретном провайдере - исправленный эндпоинт
|
# Поиск на конкретном провайдере - исправленный эндпоинт
|
||||||
search_response = await client.get(
|
try:
|
||||||
f"{TORRENT_SEARCH_URL}/api/search/title/{provider_name}",
|
search_response = await client.get(
|
||||||
params={"query": search_query}
|
f"{TORRENT_SEARCH_URL}/api/search/title/{provider_name}",
|
||||||
)
|
params={"query": search_query},
|
||||||
|
timeout=30.0
|
||||||
|
)
|
||||||
|
except Exception as request_error:
|
||||||
|
print(f"Request error on {provider_name} for '{search_query}': {request_error}")
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
continue
|
||||||
|
|
||||||
if search_response.status_code == 200:
|
if search_response.status_code == 200:
|
||||||
results = search_response.json()
|
try:
|
||||||
|
results = search_response.json()
|
||||||
|
except Exception as json_error:
|
||||||
|
print(f"JSON parse error on {provider_name} for '{search_query}': {json_error}")
|
||||||
|
print(f"Response text (first 500 chars): {search_response.text[:500]}")
|
||||||
|
continue
|
||||||
if not isinstance(results, list):
|
if not isinstance(results, list):
|
||||||
print(f"Unexpected response format from {provider_name}: {type(results)}")
|
print(f"Unexpected response format from {provider_name}: {type(results)}")
|
||||||
|
if isinstance(results, dict):
|
||||||
|
print(f"Dict keys: {list(results.keys())}")
|
||||||
continue
|
continue
|
||||||
print(f"Found {len(results)} results for '{search_query}' on {provider_name}")
|
print(f"Found {len(results)} results for '{search_query}' on {provider_name}")
|
||||||
|
|
||||||
|
|
@ -340,7 +354,9 @@ async def search_torrents(movie_title: str, year: str = None, original_title: st
|
||||||
break
|
break
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error searching on {provider_name}: {e}")
|
print(f"Error searching on {provider_name}: {type(e).__name__}: {e}")
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Сортируем по количеству сидов и ограничиваем общее количество
|
# Сортируем по количеству сидов и ограничиваем общее количество
|
||||||
|
|
@ -458,7 +474,9 @@ async def search_torrent_by_id(torrent_id: str) -> dict:
|
||||||
print(f"Error searching by ID on {provider_name}: {response.status_code} - {response.text}")
|
print(f"Error searching by ID on {provider_name}: {response.status_code} - {response.text}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error searching on {provider_name}: {e}")
|
print(f"Error searching on {provider_name}: {type(e).__name__}: {e}")
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print(f"No results found for ID {torrent_id} on any provider")
|
print(f"No results found for ID {torrent_id} on any provider")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue