From 329711ba53c352b01947044110ed74954eda4e68 Mon Sep 17 00:00:00 2001 From: MaxSaketh Date: Thu, 18 Jun 2026 16:10:26 +0530 Subject: [PATCH] refactor(torrents): use regex for magnet link extraction --- app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index f98e1e4..8b46aac 100644 --- a/app.py +++ b/app.py @@ -3,6 +3,7 @@ from fastapi.middleware.cors import CORSMiddleware import cloudscraper from bs4 import BeautifulSoup +import re requests = cloudscraper.create_scraper() app = FastAPI() @@ -45,7 +46,7 @@ def get_movie(url: str) -> dict: if not p.find("strong"): description = p.get_text(strip=True) break - torrents = soup.find_all("a", class_="mv_button_css") + torrents = soup.find_all("a", href=re.compile(r'magnet:\?xt=urn:btih:[^\s"]+')) torrent = [] for tor in torrents: link = tor.get("href")