Novik / ruTorrent

Yet another web front-end for rTorrent
Other
2.01k stars 408 forks source link

_cloudflare plugin: cloudscraper module can't be loaded in Python #2682

Closed snowdream closed 2 months ago

snowdream commented 2 months ago

Please complete the following tasks.

Tell us about your environment

Web Browser: Google Chrome 97.0.4692.71 ruTorrent: v4.3.5 PHP: PHP 8.2 OS: macOS 12.7.5

Tell us how you installed ruTorrent

apk add --no-cache rtorrent

Describe the bug

[25.06.2024 11:15:26] _cloudflare plugin: cloudscraper module can't be loaded in Python

Steps to reproduce

No response

Expected behavior

_cloudflare plugin works

Additional context

accroding : https://github.com/Novik/ruTorrent/issues/1870#issuecomment-480913560

I rewrited this stuff.
Corresponding code placed to the plugin _cloudflare.
This plugin works as middleware - it catch every GET request and check - do we have troubles with a cloudflare. And if yes, then tried to make scrape and repeat request with a new cookies.
For correct work you must

1. install python (I checked with 2.7, but I think, 3.x will works too)
2. install cfscrape with a pip
3. set $pathToExternals['python'] in the plugin's configuration to the correct value.
4. set environment variable PYTHONPATH for your web-server to the correct value.
Right now we do not have any reason to use this plugin.
  1. done (Python 3.12.3)
  2. done python3 -m venv $HOME/.venv \ && . $HOME/.venv/bin/activate \ && pip install cloudscraper
  3. done
  4. I use Nginx. how to set environment variable PYTHONPATH for nginx?
stickz commented 2 months ago

@snowdream I believe you need to use pip3 instead of pip now. The virtual python environment shouldn't be required.

pip3 install --upgrade --break-system-packages pip pip3 install --break-system-packages cfscrape cloudscraper

snowdream commented 2 months ago

@stickz Thank you for your help. it works! image