fix: пропал декоратор @app.post(/api/add-torrent), follow_redirects в tmdb-proxy

- Возвращён @app.post('/api/add-torrent') — был съеден при вставке
  proxy-torrent-download, из-за чего кнопка 'Добавить в клиент' всегда
  возвращала 404
- tmdb-proxy /proxy-torrent: добавлен follow_redirects=True — rutracker
  и kinozal отдают 302 перед .torrent файлом
This commit is contained in:
vrubelroman 2026-06-03 19:32:41 +00:00
parent a5497eef26
commit 127060d023
2 changed files with 4 additions and 2 deletions

View file

@ -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:

View file

@ -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,