From 127060d02355c88d9e081f5986d4c32656ac4757 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Wed, 3 Jun 2026 19:32:41 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=BF=D1=80=D0=BE=D0=BF=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=B4=D0=B5=D0=BA=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=20@app.p?= =?UTF-8?q?ost(/api/add-torrent),=20follow=5Fredirects=20=D0=B2=20tmdb-pro?= =?UTF-8?q?xy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Возвращён @app.post('/api/add-torrent') — был съеден при вставке proxy-torrent-download, из-за чего кнопка 'Добавить в клиент' всегда возвращала 404 - tmdb-proxy /proxy-torrent: добавлен follow_redirects=True — rutracker и kinozal отдают 302 перед .torrent файлом --- app/app.py | 4 +++- searchFilms/tmdb-proxy/tmdb_proxy.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) 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,