diff --git a/app/app.py b/app/app.py index 8690edc..4e3225b 100644 --- a/app/app.py +++ b/app/app.py @@ -1185,7 +1185,7 @@ async def proxy_torrent_download(url: str = Query(...)): params={"url": url}, timeout=30.0 ) - if proxy_resp.status_code == 200: + if proxy_resp.status_code == 200 or (proxy_resp.status_code < 400 and len(proxy_resp.content) > 100): content_type = proxy_resp.headers.get("content-type", "application/x-bittorrent") return Response( content=proxy_resp.content, @@ -1225,6 +1225,8 @@ async def proxy_torrent_download(url: str = Query(...)): except Exception as e: print(f"Error in proxy-torrent-download: {e}") raise HTTPException(status_code=500, detail=f"Ошибка прокси: {str(e)}") + +@app.post("/api/add-torrent") async def add_torrent_to_client(torrent_id: str = Form(...), magnet: str = Form(""), torrent_title: str = Form("")): """Добавление торрента в qBittorrent через прямое API""" try: diff --git a/searchFilms/tmdb-proxy/tmdb_proxy.py b/searchFilms/tmdb-proxy/tmdb_proxy.py index 651e084..56fa67a 100644 --- a/searchFilms/tmdb-proxy/tmdb_proxy.py +++ b/searchFilms/tmdb-proxy/tmdb_proxy.py @@ -137,7 +137,7 @@ async def proxy_torrent(url: str = Query(..., description="URL .torrent файл async with httpx.AsyncClient(timeout=30.0) as client: try: logger.info(f"Proxying .torrent download: {url}") - response = await client.get(url, timeout=30.0) + response = await client.get(url, timeout=30.0, follow_redirects=True) response.raise_for_status() return Response( content=response.content,