Compare commits

..
69 Commits
Author SHA1 Message Date
ThePhaseless 0325877e19 [skip ci] clarified xvfb platform requirement 2025-01-02 12:35:30 +00:00
ThePhaseless c4159e5c38 disable headless on docker 2025-01-02 12:29:10 +00:00
ThePhaseless 83169ce019 add headless env 2025-01-02 12:18:21 +00:00
ThePhaseless 1c0929fbc5 check if url is valid 2025-01-02 12:17:43 +00:00
renovate[bot] 9170967455 Update dependency pytest-asyncio to v0.25.1 (#48)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-02 09:14:41 +00:00
renovate[bot] d5d0bf7923 Update dependency seleniumbase to v4.33.12 (#47)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-25 09:53:33 +00:00
renovate[bot] 17854c70ed Update dependency deptry to v0.21.2 (#45)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-20 05:22:27 +00:00
renovate[bot] e30954c98c Update dependency psutil to v6.1.1 (#44)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-19 22:35:44 +00:00
renovate[bot] 2556a1bc88 Update dependency ruff to v0.8.4 (#43)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-19 15:40:42 +00:00
renovate[bot] 6c065d4dd3 Update dependency pydantic to v2.10.4 (#42)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-18 21:51:16 +00:00
ThePhaseless 096eda0fa3 fix utils 2024-12-18 13:32:37 +00:00
ThePhaseless 2ebb1bd820 optional xvfb support 2024-12-18 13:29:00 +00:00
ThePhaseless bf37539890 do not use virtual display 2024-12-17 12:03:53 +00:00
ThePhaseless d7ef83b8c6 add tags info and use latest on stable release 2024-12-17 12:03:36 +00:00
renovate[bot] 1a7cd9d657 Update dependency seleniumbase to v4.33.11 (#41)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-16 00:47:28 +00:00
renovate[bot] f9387e6942 Update dependency uvicorn to v0.34.0 (#40)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-15 19:06:58 +00:00
renovate[bot] 9d8c8db979 Update dependency uvicorn to v0.33.0 (#39)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-14 15:46:21 +00:00
renovate[bot] 979e0b4803 Update dependency ruff to v0.8.3 (#38)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-14 04:02:50 +00:00
ThePhaseless 3dbe3c424c fix circular imports 2024-12-13 22:43:29 +00:00
ThePhaseless bbb7c73065 kill old processes 2024-12-13 22:38:47 +00:00
ThePhaseless 9a353b3da2 remove poetry remains 2024-12-13 22:30:58 +00:00
ThePhaseless 140a97003e update packages 2024-12-13 21:12:30 +00:00
ThePhaseless c9e29f578d save cookies between requests 2024-12-12 23:45:24 +00:00
ThePhaseless c37ab51179 combine apt installs to one 2024-12-11 01:04:08 +00:00
ThePhaseless 962db9409c pull before build and test 2024-12-11 01:02:59 +00:00
ThePhaseless 96a9cc7ba9 test, then build 2024-12-11 01:01:00 +00:00
ThePhaseless bf9460b960 delete unused file 2024-12-11 00:52:20 +00:00
ThePhaseless c0547192dd test only on amd64 2024-12-11 00:46:53 +00:00
ThePhaseless 008077076c try using arm builder 2024-12-11 00:44:22 +00:00
ThePhaseless b33444dc48 use matrix for build 2024-12-11 00:40:11 +00:00
ThePhaseless b8c8576e5a github actions shared lib fix 2024-12-11 00:21:07 +00:00
ThePhaseless 905d802a26 add back retires 2024-12-10 23:38:13 +00:00
ThePhaseless f99429fdea update all packages but install only needed 2024-12-10 23:28:29 +00:00
ThePhaseless 1a4ec03587 Merge pull request #37 from ThePhaseless/uv
Uv
2024-12-10 23:50:34 +01:00
ThePhaseless ee2630dce2 enable auto update 2024-12-10 22:48:53 +00:00
ThePhaseless 82130b77c0 fix docker and update readme 2024-12-10 22:48:35 +00:00
ThePhaseless faf7e5e51a migrate to uv 2024-12-10 22:16:30 +00:00
ThePhaseless 597faa48dc add response type 2024-12-10 21:54:39 +00:00
ThePhaseless a28dbbe972 use docker to test 2024-12-10 21:54:29 +00:00
ThePhaseless 82124dee9b force exit on exception 2024-12-10 21:29:20 +00:00
ThePhaseless 0551c7b82b use uv 2024-12-08 16:49:38 +00:00
ThePhaseless b483dba080 [skip ci] Mili to Mega 2024-12-02 10:29:13 +01:00
ThePhaseless 7533d039ac Merge pull request #30 from ThePhaseless/renovate/python-3.x
Update python Docker tag to v3.13
2024-11-30 14:26:22 +01:00
renovate[bot] 38b2ea0798 Update python Docker tag to v3.13 2024-11-30 12:59:43 +00:00
ThePhaseless 58ae7964df remove python action update script 2024-11-30 12:59:00 +00:00
ThePhaseless 5283fb2d0e exclude python from autoupdate 2024-11-30 12:58:02 +00:00
ThePhaseless b3e7662782 fix ruff 2024-11-30 12:48:04 +00:00
ThePhaseless 074a3dd712 [skip ci] fix renovate 2024-11-30 12:47:34 +00:00
ThePhaseless cb48f16370 update python version in action with base 2024-11-30 12:45:19 +00:00
ThePhaseless 637de7572d use latest cosign 2024-11-30 12:44:08 +00:00
ThePhaseless 7b55252a73 run ruff before tests 2024-11-30 12:43:56 +00:00
ThePhaseless cbe4cf57a5 use all urls always 2024-11-30 12:43:05 +00:00
ThePhaseless 0775d107ad add version control and more verbose error return 2024-11-30 12:42:51 +00:00
ThePhaseless d36972b80e update python in action 2024-11-30 12:42:17 +00:00
renovate[bot] 27ec17f7f2 Update dependency seleniumbase to v4.33.2 (#24)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-30 12:08:29 +00:00
ThePhaseless 0b2bf9e12a use dynamic driver symlink 2024-11-30 11:38:48 +00:00
renovate[bot] 8c6906c916 Update dependency ruff to v0.8.1 (#29)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-29 06:26:30 +00:00
renovate[bot] 3103051ccf Update dependency httpx to ^0.28.0 (#28)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-28 18:20:06 +00:00
ThePhaseless 8551bdfef8 Merge pull request #25 from ThePhaseless/renovate/docker-build-push-action-6.x
Update docker/build-push-action action to v6.10.0
2024-11-28 14:06:45 +01:00
renovate[bot] cdebe4be0e Update docker/build-push-action action to v6.10.0 2024-11-28 13:06:36 +00:00
ThePhaseless 543296ce68 update lockfile 2024-11-28 12:56:09 +00:00
ThePhaseless 7210ae4bc0 add and ignore pyautogui 2024-11-28 12:55:55 +00:00
ThePhaseless f782e1bed6 Create LICENSE 2024-11-28 13:40:46 +01:00
ThePhaseless 49329ec950 update lockfile 2024-11-28 12:35:29 +00:00
ThePhaseless 2ae289ef0c use renovate instead of dependabot 2024-11-28 12:33:04 +00:00
ThePhaseless 8ef570ec46 separate depedencies and fill out details 2024-11-28 12:32:55 +00:00
ThePhaseless e899f8d5ac Merge pull request #23 from ThePhaseless/renovate/configure
Configure Renovate
2024-11-28 13:28:06 +01:00
renovate[bot] ab0e7f9e43 Add renovate.json 2024-11-28 12:27:27 +00:00
ThePhaseless d26974e22a [skip ci] Add example issues for NAS devices 2024-11-26 21:15:34 +01:00
18 changed files with 1894 additions and 2356 deletions
+5 -3
View File
@@ -1,5 +1,7 @@
FROM python:3.12-bullseye
FROM debian:latest
RUN apt update && apt upgrade -y && apt install -y chromium chromium-driver xvfb
RUN apt update && apt upgrade -y && apt install -y chromium chromium-driver xvfb git
RUN curl -sSL https://install.python-poetry.org | python3 -
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.local/bin:$PATH" \
UV_LINK_MODE=copy
-16
View File
@@ -1,16 +0,0 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot
version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
- package-ecosystem: github-actions
directory: ".github/workflows/"
schedule:
interval: weekly
+19 -52
View File
@@ -23,50 +23,7 @@ env:
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- name: Set up Poetry
run: pip install poetry
- name: Setup a local virtual environment (if no poetry.toml file)
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v4
name: Define a cache for the virtual environment based on the dependencies lock file
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: |
poetry install
sudo apt update
sudo apt install -y xvfb scrot python3-tk
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install -y ./google-chrome-stable_current_amd64.deb
rm ./google-chrome-stable_current_amd64.deb
- name: Run tests
run: poetry run pytest --retries 2 -n auto --xvfb
- name: Upload screenshots if tests fail
if: failure()
uses: actions/upload-artifact@v4
with:
path: screenshots
build:
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
@@ -83,21 +40,19 @@ jobs:
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da #v3.7.0
with:
cosign-release: "v2.2.4"
uses: sigstore/cosign-installer@v3
# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
uses: docker/setup-buildx-action@v3
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
@@ -107,7 +62,7 @@ jobs:
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
uses: docker/metadata-action@v5
with:
tags: |
type=ref,event=branch
@@ -115,23 +70,35 @@ jobs:
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,enable=${{ github.event_name != 'pull_request' && github.ref_name == 'main' }}, value=latest
type=raw,enable=${{ github.ref_type == 'tag' }}, value=latest
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Test
id: test
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
cache-from: type=gha
pull: true
cache-to: type=gha,mode=max
target: test
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
uses: docker/build-push-action@v6
with:
context: .
pull: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: GITHUB_BUILD=true
build-args: GITHUB_BUILD=true,VERSION=${{ github.ref_name }}
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
+19 -12
View File
@@ -1,4 +1,4 @@
FROM python:3.12-slim-bullseye
FROM debian:bullseye-slim AS base
# Inspired by https://github.com/Hudrolax/uc-docker-alpine/
@@ -11,22 +11,29 @@ ENV \
PYTHONUNBUFFERED=1 \
# prevents python creating .pyc files
PYTHONDONTWRITEBYTECODE=1 \
# do not ask any interactive question
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=true \
PATH="${HOME}/.local/bin:$PATH" \
DISPLAY=:0
WORKDIR /app
EXPOSE 8191
RUN apt update &&\
apt install -y xvfb scrot python3-tk curl chromium chromium-driver
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH="${HOME}/.local/bin:$PATH"
COPY pyproject.toml poetry.lock ./
RUN poetry install
apt upgrade -y &&\
apt install -y --no-install-recommends --no-install-suggests xauth xvfb scrot python3-tk curl chromium chromium-driver ca-certificates x11-common
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
COPY pyproject.toml uv.lock ./
RUN uv sync
COPY . .
RUN cd .venv/lib/*/site-packages/seleniumbase/drivers && ln -s /usr/bin/chromedriver uc_driver
ENV USE_HEADLESS=false
FROM base AS test
RUN uv sync --group test
RUN ./test.sh
FROM base
EXPOSE 8191
HEALTHCHECK --interval=60s --timeout=30s --start-period=5s --retries=3 CMD [ "curl", "http://localhost:8191/health" ]
RUN ln /usr/bin/chromedriver ./.venv/lib/python3.12/site-packages/seleniumbase/drivers/uc_driver
CMD ["./cmd.sh"]
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+34 -18
View File
@@ -2,46 +2,62 @@
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).
> [!WARNING]
> [!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.
> [!WARNING]
> Support for NAS devices (like Synology) is minimal. Please report issues, but do not expect it to be fixed quickly. The only ARM device I have is a free Ampere Oracle VM, so I can only test ARM support on that.
> [!IMPORTANT]
> Support for NAS devices (like Synology) is minimal. Please report issues, but do not expect it to be fixed quickly. The only ARM device I have is a free Ampere Oracle VM, so I can only test ARM support on that. See [#22](https://github.com/ThePhaseless/Byparr/issues/22) and [#3](https://github.com/ThePhaseless/Byparr/issues/3)
> [!NOTE]
> 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.
2. Using vscode and `SSH extention`, connect to the host and open repo in it.
3. Download `devcontainers` extention and reopen repo in container (with `CTRL + SHIFT + P` -> `Reopen in devcontainer`)
2. Using vscode and `SSH extension`, connect to the host and open repo in it.
3. Download `Dev Containers` extension and reopen repo in container (with `CTRL + SHIFT + P` -> `Reopen in devcontainer`)
4. Forward port 6080 from devcontainer (port of noVNC server) to the host.
5. Open `http://localhost:6080` and connect to the virtual desktop.
6. Check if `chromium` works by running in VNC's terminal command `chromium --no-sandbox`.
7. If chromium works, run (or debug) tests from VS Code.
1. If code works, congrats! (/s) You are on your own.
2. If it does not, try another host or network, try again and create issue about the problem.
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.
## Options
| Env | Default | Description |
| -------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `USE_XVFB` | `false` | Use virtual desktop with Xvfb. (Linux only) (Can cause performance hog [#14](https://github.com/ThePhaseless/Byparr/issues/14)) |
| `USE_HEADLESS` | `true/false on docker` | Use headless chromium. |
## Tags
- `v*.*.*`/`latest` - Releases considered stable
- `main` - Latest release from main branch (untested)
## Usage
### Docker Compose
```yaml
services:
byparr:
image: ghcr.io/thephaseless/byparr:latest
environment:
- LOG_LEVEL=INFO # optional
ports:
- "8191:8191" # Optional if needed to make make requests/check docs on host
See `compose.yaml`
### Docker
```bash
docker run -p 8191:8191 ghcr.io/thephaseless/byparr:latest
```
### Local
```bash
uv sync && ./cmd.sh
```
## Need help with / TODO
- [x] Slimming container (only ~650 mB now!)
- [x] Slimming container (only ~650 MB now!)
- [x] Add more anti-bot challenges
- [x] Add docstrings
- [x] Add doc strings
- [x] Implement versioning
- [ ] Proxy support
- [x] Add more architectures support
+1 -1
View File
@@ -1,3 +1,3 @@
#!/bin/sh
. .venv/bin/activate && python3 main.py
uv run main.py
+1
View File
@@ -6,5 +6,6 @@ services:
dockerfile: Dockerfile
environment:
- LOG_LEVEL=INFO
- MAX_CHROME_LIFETIME=300
ports:
- "8191:8191"
+50 -16
View File
@@ -4,7 +4,7 @@ import logging
import time
from http import HTTPStatus
import uvicorn.config
import uvicorn
from bs4 import BeautifulSoup
from fastapi import FastAPI, HTTPException
from fastapi.responses import RedirectResponse
@@ -15,26 +15,27 @@ import src.utils
import src.utils.consts
from src.models.requests import LinkRequest, LinkResponse, Solution
from src.utils import logger
from src.utils.consts import LOG_LEVEL
from src.utils.consts import LOG_LEVEL, USE_HEADLESS, USE_XVFB
app = FastAPI(debug=LOG_LEVEL == logging.DEBUG, log_level=LOG_LEVEL)
cookies = []
@app.get("/")
def read_root():
"""Redirect to /docs."""
logger.info("Redirecting to /docs")
logger.debug("Redirecting to /docs")
return RedirectResponse(url="/docs", status_code=301)
@app.get("/health")
async def health_check():
"""Health check endpoint."""
logger.info("Health check")
health_check_request = read_item(
LinkRequest.model_construct(url="https://prowlarr.servarr.com/v1/ping")
)
if health_check_request.solution.status != HTTPStatus.OK:
raise HTTPException(
status_code=500,
@@ -45,24 +46,40 @@ async def health_check():
@app.post("/v1")
def read_item(request: LinkRequest):
def read_item(request: LinkRequest) -> LinkResponse:
"""Handle POST requests."""
start_time = int(time.time() * 1000)
# request.url = "https://nowsecure.nl"
logger.info(f"Request: {request}")
# Check is string is url
if not (request.url.startswith("http://") or request.url.startswith("https://")):
return LinkResponse.invalid(request.url)
response: LinkResponse
# start_time = int(time.time() * 1000)
try:
with SB(uc=True, locale_code="en", test=False, xvfb=True, ad_block=True) as sb:
with SB(
uc=True,
locale_code="en",
test=False,
ad_block=True,
xvfb=USE_XVFB,
headless=USE_HEADLESS,
) as sb:
try:
sb: BaseCase
global cookies # noqa: PLW0603
if cookies:
sb.uc_open_with_reconnect(request.url)
sb.add_cookies(cookies)
sb.uc_open_with_reconnect(request.url)
source = sb.get_page_source()
source_bs = BeautifulSoup(source, "html.parser")
title_tag = source_bs.title
logger.info(f"Got webpage: {request.url}")
logger.debug(f"Got webpage: {request.url}")
if title_tag and title_tag.string in src.utils.consts.CHALLENGE_TITLES:
logger.info("Challenge detected")
logger.debug("Challenge detected")
sb.uc_gui_click_captcha()
logger.info("Clicked captcha")
@@ -72,9 +89,7 @@ def read_item(request: LinkRequest):
if title_tag and title_tag.string in src.utils.consts.CHALLENGE_TITLES:
sb.save_screenshot(f"./screenshots/{request.url}.png")
raise HTTPException(
status_code=500, detail="Could not bypass challenge"
)
raise_captcha_bypass_error()
response = LinkResponse(
message="Success",
@@ -88,12 +103,31 @@ def read_item(request: LinkRequest):
),
startTimestamp=start_time,
)
except Exception as e:
logger.error(f"Error: {e}")
raise HTTPException(status_code=500, detail="Unknown error, check logs") from e
cookies = sb.get_cookies()
except Exception as e:
logger.error(f"Error: {e}")
if sb.driver:
sb.driver.quit()
raise HTTPException(
status_code=500, detail="Unknown error, check logs"
) from e
return response
def raise_captcha_bypass_error():
"""
Raise a 500 error if the challenge could not be bypassed.
This function should be called if the challenge is not bypassed after
clicking the captcha.
Returns:
None
"""
raise HTTPException(status_code=500, detail="Could not bypass challenge")
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8191, log_level=LOG_LEVEL) # noqa: S104
Generated
-2198
View File
File diff suppressed because it is too large Load Diff
-3
View File
@@ -1,3 +0,0 @@
[virtualenvs]
in-project = true
create = true
+29 -23
View File
@@ -1,30 +1,36 @@
[tool.poetry]
name = "byparr"
# cspell:disable
[project]
authors = [{ name = "ThePhaseless", email = "kukubaorch@gmail.com" }]
license = { text = "LICENSE" }
requires-python = "<4.0,>=3.12"
name = "Byparr"
version = "0.1.0"
description = ""
package-mode = false
authors = ["Your Name <you@example.com>"]
description = "API for getting cookies for Cloudflare challenges"
readme = "README.md"
dependencies = [
"beautifulsoup4==4.12.3",
"fastapi[standard]==0.115.6",
"psutil==6.1.1",
"pyautogui==0.9.54",
"pydantic==2.10.4",
"seleniumbase==4.33.12",
"uvicorn==0.34.0",
]
urls = { repository = "https://github.com/ThePhaseless/Byparr" }
[tool.poetry.dependencies]
python = "^3.12"
pytest = "^8"
fastapi = { extras = ["standard"], version = "^0" }
requests = "^2"
httpx = "^0.27"
pytest-asyncio = "^0"
ruff = "^0.8.0"
seleniumbase = "^4.32.12"
pyautogui = "^0.9.54"
beautifulsoup4 = "^4.12.3"
pytest-retry = "^1.6.3"
pytest-progress = "^1.3.0"
pytest-xdist = "^3.6.1"
[dependency-groups]
test = [
"httpx==0.28.1",
"pytest==8.3.4",
"pytest-asyncio==0.25.1",
"pytest-progress==1.3.0",
"pytest-retry==1.6.3",
"pytest-xdist==3.6.1",
]
dev = ["deptry==0.21.2", "ruff==0.8.4"]
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.deptry.per_rule_ignores]
DEP002 = ["pyautogui"]
[tool.ruff.lint]
ignore = [
+10
View File
@@ -0,0 +1,10 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"packageRules": [
{
"automerge": true,
"matchUpdateTypes": ["minor", "patch"]
}
]
}
+18 -7
View File
@@ -6,6 +6,8 @@ from typing import Any
from pydantic import BaseModel, Field
from src.utils import consts
class LinkRequest(BaseModel):
cmd: str = "get"
@@ -26,9 +28,14 @@ class Solution(BaseModel):
response: str
@classmethod
def empty(cls):
def invalid(cls, url: str):
"""
Return an empty Solution with default values.
Useful for returning an error response.
"""
return cls(
url="",
url=url,
status=HTTPStatus.INTERNAL_SERVER_ERROR,
cookies=[],
userAgent="",
@@ -43,19 +50,23 @@ class LinkResponse(BaseModel):
solution: Solution
startTimestamp: int # noqa: N815 # Ignore to preserve compatibility
endTimestamp: int = int(time.time() * 1000) # noqa: N815 # Ignore to preserve compatibility
version: str = "3.3.21" # TODO: Implement versioning
version: str = consts.VERSION
@classmethod
def invalid(cls):
def invalid(cls, url: str):
"""
Return an invalid LinkResponse with default error values.
This method is used to generate a response indicating an invalid request.
"""
return cls(
status="error",
message="Invalid request",
solution=Solution.empty(),
solution=Solution.invalid(url),
startTimestamp=int(time.time() * 1000),
endTimestamp=int(time.time() * 1000),
version="3.3.21",
)
class NoChromeExtensionError(Exception):
"""No chrome extention found."""
"""No chrome extension found."""
+26
View File
@@ -1,9 +1,35 @@
import logging
import os
def get_version_from_env():
"""
Retrieve the version from the environment variable 'VERSION'.
This function checks the 'VERSION' environment variable for a value
that starts with 'v' and returns the version without the prefix.
Returns:
str | None: The version string without the 'v' prefix, or None if
the 'VERSION' environment variable is not set or does not start
with 'v'.
"""
version_env = os.getenv("VERSION")
if not version_env or not version_env.startswith("v"):
return None
return version_env.removeprefix("v")
LOG_LEVEL = os.getenv("LOG_LEVEL") or "INFO"
LOG_LEVEL = logging.getLevelNamesMapping()[LOG_LEVEL.upper()]
VERSION = get_version_from_env() or "unknown"
USE_XVFB = os.getenv("USE_XVFB", "false") in ["true", "1"]
USE_HEADLESS = os.getenv("USE_HEADLESS", "true").lower() in ["true", "1"]
CHALLENGE_TITLES = [
# Cloudflare
"Just a moment...",
Executable
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
uv run pytest --retries 2 -n auto
+11 -7
View File
@@ -12,22 +12,20 @@ client = TestClient(app)
test_websites = [
"https://btmet.com/",
"https://ext.to/",
]
# Not testable on github actions
github_restricted = [
"https://www.ygg.re/",
"https://extratorrent.st/",
"https://idope.se/",
"https://speed.cd/login",
]
# if os.getenv("GITHUB_ACTIONS") != "true":
test_websites.extend(github_restricted)
@pytest.mark.parametrize("website", test_websites)
def test_bypass(website: str):
"""
Tests if the service can bypass cloudflare/DDOS-GUARD on given websites.
This test is skipped if the website is not reachable or does not have cloudflare/DDOS-GUARD.
"""
test_request = httpx.get(
website,
)
@@ -48,5 +46,11 @@ def test_bypass(website: str):
def test_health_check():
"""
Tests the health check endpoint.
This test ensures that the health check
endpoint returns HTTPStatus.OK.
"""
response = client.get("/health")
assert response.status_code == HTTPStatus.OK
Generated
+1467
View File
File diff suppressed because it is too large Load Diff