mirror of
https://github.com/ThePhaseless/Byparr.git
synced 2025-03-15 09:50:20 +08:00
optional xvfb support
This commit is contained in:
parent
0ccfa1f6a9
commit
2b28d0587a
@ -3,4 +3,5 @@ FROM debian:latest
|
|||||||
RUN apt update && apt upgrade -y && apt install -y chromium chromium-driver xvfb git
|
RUN apt update && apt upgrade -y && apt install -y chromium chromium-driver xvfb git
|
||||||
|
|
||||||
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||||
ENV PATH="/root/.local/bin:$PATH"
|
ENV PATH="/root/.local/bin:$PATH" \
|
||||||
|
UV_LINK_MODE=copy
|
13
README.md
13
README.md
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
An alternative to [FlareSolverr](https://github.com/FlareSolverr/FlareSolverr) as a drop-in replacement, build with [seleniumbase](https://seleniumbase.io/) and [FastAPI](https://fastapi.tiangolo.com).
|
An alternative to [FlareSolverr](https://github.com/FlareSolverr/FlareSolverr) as a drop-in replacement, build with [seleniumbase](https://seleniumbase.io/) and [FastAPI](https://fastapi.tiangolo.com).
|
||||||
|
|
||||||
> [!CAUTION]
|
|
||||||
> From now on, Byparr will clear all chrome processes longer than specified in `MAX_CHROME_LIFETIME` environment variable (default is 300 seconds). To disable this behavior, set `MAX_CHROME_LIFETIME` to `0`.
|
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> Due to recent challenge changes, this software does not guarantee that the Cloudflare challenge will be bypassed. Cloudflare likely requires valid network traffic originating from the user’s public IP address to mark a connection as legitimate. While this tool may bypass the initial browser check, it does not ensure that requests will consistently pass Cloudflare's validation. More testing and data are required to understand how Cloudflare identifies connections and requests as valid. Invalid requests will result in Byparr's looping and eventually time-outing.
|
> Due to recent challenge changes, this software does not guarantee that the Cloudflare challenge will be bypassed. Cloudflare likely requires valid network traffic originating from the user’s public IP address to mark a connection as legitimate. While this tool may bypass the initial browser check, it does not ensure that requests will consistently pass Cloudflare's validation. More testing and data are required to understand how Cloudflare identifies connections and requests as valid. Invalid requests will result in Byparr's looping and eventually time-outing.
|
||||||
|
|
||||||
@ -14,7 +11,7 @@ An alternative to [FlareSolverr](https://github.com/FlareSolverr/FlareSolverr) a
|
|||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> Thanks to FastAPI implementation, now you can also see the API documentation at `/docs` or `/` (redirect to `/docs`) endpoints.
|
> Thanks to FastAPI implementation, now you can also see the API documentation at `/docs` or `/` (redirect to `/docs`) endpoints.
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting (Docker required)
|
||||||
|
|
||||||
1. Clone repo to the host that has the container has issues on.
|
1. Clone repo to the host that has the container has issues on.
|
||||||
2. Using vscode and `SSH extension`, connect to the host and open repo in it.
|
2. Using vscode and `SSH extension`, connect to the host and open repo in it.
|
||||||
@ -26,6 +23,12 @@ An alternative to [FlareSolverr](https://github.com/FlareSolverr/FlareSolverr) a
|
|||||||
1. If code works, congrats! (not really) You are on your own.
|
1. If code works, congrats! (not really) You are on your own.
|
||||||
2. If it does not, try on another host or network and create an issue if problem persists.
|
2. If it does not, try on another host or network and create an issue if problem persists.
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
| Env | Default | Description |
|
||||||
|
| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| `USE_XVFB` | `false` | Use Xvfb instead of headless chromium. (Can cause performance hog [#14](https://github.com/ThePhaseless/Byparr/issues/14)) |
|
||||||
|
|
||||||
## Tags
|
## Tags
|
||||||
|
|
||||||
- `v*.*.*`/`latest` - Releases considered stable
|
- `v*.*.*`/`latest` - Releases considered stable
|
||||||
@ -35,7 +38,7 @@ An alternative to [FlareSolverr](https://github.com/FlareSolverr/FlareSolverr) a
|
|||||||
|
|
||||||
### Docker Compose
|
### Docker Compose
|
||||||
|
|
||||||
See `docker-compose.yaml`
|
See `compose.yaml`
|
||||||
|
|
||||||
### Docker
|
### Docker
|
||||||
|
|
||||||
|
8
main.py
8
main.py
@ -14,7 +14,7 @@ import src
|
|||||||
import src.utils
|
import src.utils
|
||||||
import src.utils.consts
|
import src.utils.consts
|
||||||
from src.models.requests import LinkRequest, LinkResponse, Solution
|
from src.models.requests import LinkRequest, LinkResponse, Solution
|
||||||
from src.utils import consts, kill_chromium_processes, logger
|
from src.utils import consts, logger
|
||||||
from src.utils.consts import LOG_LEVEL
|
from src.utils.consts import LOG_LEVEL
|
||||||
|
|
||||||
app = FastAPI(debug=LOG_LEVEL == logging.DEBUG, log_level=LOG_LEVEL)
|
app = FastAPI(debug=LOG_LEVEL == logging.DEBUG, log_level=LOG_LEVEL)
|
||||||
@ -35,8 +35,6 @@ async def health_check():
|
|||||||
health_check_request = read_item(
|
health_check_request = read_item(
|
||||||
LinkRequest.model_construct(url="https://prowlarr.servarr.com/v1/ping")
|
LinkRequest.model_construct(url="https://prowlarr.servarr.com/v1/ping")
|
||||||
)
|
)
|
||||||
if consts.MAX_CHROME_LIFETIME > 0:
|
|
||||||
kill_chromium_processes()
|
|
||||||
|
|
||||||
if health_check_request.solution.status != HTTPStatus.OK:
|
if health_check_request.solution.status != HTTPStatus.OK:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
@ -56,7 +54,9 @@ def read_item(request: LinkRequest) -> LinkResponse:
|
|||||||
response: LinkResponse
|
response: LinkResponse
|
||||||
|
|
||||||
# start_time = int(time.time() * 1000)
|
# start_time = int(time.time() * 1000)
|
||||||
with SB(uc=True, locale_code="en", test=False, ad_block=True) as sb:
|
with SB(
|
||||||
|
uc=True, locale_code="en", test=False, ad_block=True, xvfb=consts.USE_XVFB
|
||||||
|
) as sb:
|
||||||
try:
|
try:
|
||||||
sb: BaseCase
|
sb: BaseCase
|
||||||
global cookies # noqa: PLW0603
|
global cookies # noqa: PLW0603
|
||||||
|
@ -27,7 +27,7 @@ LOG_LEVEL = logging.getLevelNamesMapping()[LOG_LEVEL.upper()]
|
|||||||
|
|
||||||
VERSION = get_version_from_env() or "unknown"
|
VERSION = get_version_from_env() or "unknown"
|
||||||
|
|
||||||
MAX_CHROME_LIFETIME = int(os.getenv("MAX_CHROME_LIFETIME", "300"))
|
USE_XVFB = os.getenv("USE_XVFB") in ["true", "1"]
|
||||||
|
|
||||||
CHALLENGE_TITLES = [
|
CHALLENGE_TITLES = [
|
||||||
# Cloudflare
|
# Cloudflare
|
||||||
|
Loading…
x
Reference in New Issue
Block a user