fix: improve torapi-qbit fallback check for empty magnets

This commit is contained in:
vrubelroman 2026-06-03 10:06:29 +00:00
parent 135d51a00e
commit b971294909

View file

@ -443,8 +443,8 @@ async def search_torrent_by_id(torrent_id: str) -> dict:
print(f"Warning: No hash found and no valid magnet link. Hash: {hash_value}, Magnet: {result.get('Magnet', 'None')[:50]}") print(f"Warning: No hash found and no valid magnet link. Hash: {hash_value}, Magnet: {result.get('Magnet', 'None')[:50]}")
magnet = "" magnet = ""
# Пробуем локальный torapi-qbit если хэш пустой # Пробуем локальный torapi-qbit если хэш пустой или битый
if not hash_value or not magnet or 'urn:btih:' not in magnet or len(magnet) < 30: if not hash_value or not re.search(r'urn:btih:([a-fA-F0-9]{40}|[a-zA-Z0-9]{32})', magnet):
try: try:
torapi_add_url = os.getenv("TORAPI_ADD_URL", "http://localhost:8444") torapi_add_url = os.getenv("TORAPI_ADD_URL", "http://localhost:8444")
fb_resp = await client.get( fb_resp = await client.get(