Skip to content

Commit

Permalink
add cache, pip, progress and fix bypass
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePhaseless committed Nov 25, 2024
1 parent 73b3967 commit 369faea
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"

- name: Set up Poetry
run: pip install poetry
Expand All @@ -55,7 +56,13 @@ jobs:
rm ./google-chrome-stable_current_amd64.deb
- name: Run tests
run: poetry run pytest --retries 3 --retry-delay 5
run: poetry run pytest --retries 2 --show-progress

- name: Upload screenshots if tests fail
if: failure()
uses: actions/upload-artifact@v4
with:
path: screenshots

build:
needs: test
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ def read_item(request: LinkRequest):
source_bs = BeautifulSoup(source, "html.parser")
title_tag = source_bs.title
logger.info(f"Got webpage: {request.url}")
if title_tag in src.utils.consts.CHALLENGE_TITLES:
if title_tag and title_tag.string in src.utils.consts.CHALLENGE_TITLES:
logger.info("Challenge detected")
sb.uc_gui_click_captcha()
logger.info("Clicked captcha")
sb.save_screenshot("screenshot.png")

source = sb.get_page_source()
source_bs = BeautifulSoup(source, "html.parser")
title_tag = source_bs.title

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"
)
Expand Down
15 changes: 14 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ seleniumbase = "^4.32.12"
pyautogui = "^0.9.54"
beautifulsoup4 = "^4.12.3"
pytest-retry = "^1.6.3"
pytest-progress = "^1.3.0"


[build-system]
Expand Down

0 comments on commit 369faea

Please sign in to comment.