Skip to content

Commit

Permalink
chg: Bump poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Jan 7, 2025
1 parent 74fe21f commit ce913bd
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 91 deletions.
1 change: 1 addition & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ strict = True
warn_return_any = False
show_error_context = True
pretty = True
follow_untyped_imports = True

[mypy-docs.source.*]
ignore_errors = True
18 changes: 9 additions & 9 deletions playwrightcapture/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from playwright._impl._errors import TargetClosedError
from playwright.async_api import async_playwright, Frame, Error, Page, Download, Request
from playwright.async_api import TimeoutError as PlaywrightTimeoutError
from playwright_stealth import stealth_async, StealthConfig # type: ignore[import-untyped]
from playwright_stealth import stealth_async, StealthConfig # type: ignore[attr-defined]
from puremagic import PureError, from_string
from w3lib.html import strip_html5_whitespace
from w3lib.url import canonicalize_url, safe_url_string
Expand All @@ -54,8 +54,8 @@
BROWSER = Literal['chromium', 'firefox', 'webkit']

try:
import pydub # type: ignore[import-untyped]
from speech_recognition import Recognizer, AudioFile # type: ignore[import-untyped]
from pydub import AudioSegment # type: ignore[attr-defined]
from speech_recognition import Recognizer, AudioFile
CAN_SOLVE_CAPTCHA = True
except ImportError:
CAN_SOLVE_CAPTCHA = False
Expand Down Expand Up @@ -95,7 +95,7 @@ def process(self, msg: str, kwargs: MutableMapping[str, Any]) -> tuple[str, Muta
# https://fingerprintjs.github.io/BotD/main/

@dataclass
class PCStealthConfig(StealthConfig): # type: ignore[misc]
class PCStealthConfig(StealthConfig):

@property
def enabled_scripts(self) -> Iterator[str]:
Expand Down Expand Up @@ -1356,12 +1356,12 @@ async def _recaptcha_solver(self, page: Page) -> bool:
mp3_content = await response.read()
with NamedTemporaryFile() as mp3_file, NamedTemporaryFile() as wav_file:
mp3_file.write(mp3_content)
pydub.AudioSegment.from_mp3(mp3_file.name).export(wav_file.name, format="wav")
recognizer = Recognizer()
recaptcha_audio = AudioFile(wav_file.name)
AudioSegment.from_mp3(mp3_file.name).export(wav_file.name, format="wav") # type: ignore[no-untyped-call]
recognizer = Recognizer() # type: ignore[no-untyped-call]
recaptcha_audio = AudioFile(wav_file.name) # type: ignore[no-untyped-call]
with recaptcha_audio as source:
audio = recognizer.record(source)
text = recognizer.recognize_google(audio)
audio = recognizer.record(source) # type: ignore[no-untyped-call]
text = recognizer.recognize_google(audio) # type: ignore[attr-defined]
await main_frame.get_by_role("textbox", name="Enter what you hear").fill(text)
await main_frame.get_by_role("button", name="Verify").click()
await self._safe_wait(page, 5)
Expand Down
Loading

0 comments on commit ce913bd

Please sign in to comment.