Skip to content

fix(rutracker): make the Cloudflare path actually work - #426

Open
dethlex wants to merge 1 commit into
werwolfby:developfrom
dethlex:fix/rutracker-cloudflare
Open

fix(rutracker): make the Cloudflare path actually work#426
dethlex wants to merge 1 commit into
werwolfby:developfrom
dethlex:fix/rutracker-cloudflare

Conversation

@dethlex

@dethlex dethlex commented Aug 10, 2026

Copy link
Copy Markdown

Closes #425

@Egorkat

Egorkat commented Aug 26, 2026

Copy link
Copy Markdown

While testing this fix, found that parse_url() was missed — it still makes a bare request with no cf_clearance/User-Agent, so Cloudflare blocks it and the page has no <h1>, causing a silent "CantParse" failure. This breaks the "Add Torrent by URL" preview/validation flow (and likely periodic topic re-checks) even with this PR applied.

Suggested addition on top of this PR:

     def parse_url(self, url):
         match = self._regex.match(url)
         if match is None:
             return None

-        r = requests.get(url, allow_redirects=False, **self.tracker_settings.get_requests_kwargs())
+        r = requests.get(url, allow_redirects=False, headers=self.headers, cookies=self.cookies,
+                          **self.tracker_settings.get_requests_kwargs())

         soup = get_soup(r.text)

@Egorkat

Egorkat commented Aug 26, 2026

Copy link
Copy Markdown

And in RutrackerPlugin:

     def parse_url(self, url):
+        # cf_clearance is required here too, or Cloudflare returns a challenge page with no <h1>
+        with DBSession() as db:
+            cred = db.query(self.credentials_class).first()
+            headers = parse_headers_field(cred.headers) if cred else None
+            cookies = parse_cookies_field(cred.cookies) if cred else None
+        self.tracker.headers = headers or {}
+        self.tracker.cookies = cookies or {}
         return self.tracker.parse_url(url)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rutracker.org закрылся за Cloudflare как у Lostfilm

2 participants