PlaywrightCapture 1.31.5__tar.gz → 1.31.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {playwrightcapture-1.31.5 → playwrightcapture-1.31.7}/PKG-INFO +1 -1
- {playwrightcapture-1.31.5 → playwrightcapture-1.31.7}/playwrightcapture/__init__.py +4 -0
- {playwrightcapture-1.31.5 → playwrightcapture-1.31.7}/playwrightcapture/capture.py +55 -15
- {playwrightcapture-1.31.5 → playwrightcapture-1.31.7}/pyproject.toml +1 -1
- {playwrightcapture-1.31.5 → playwrightcapture-1.31.7}/LICENSE +0 -0
- {playwrightcapture-1.31.5 → playwrightcapture-1.31.7}/README.md +0 -0
- {playwrightcapture-1.31.5 → playwrightcapture-1.31.7}/playwrightcapture/exceptions.py +0 -0
- {playwrightcapture-1.31.5 → playwrightcapture-1.31.7}/playwrightcapture/helpers.py +0 -0
- {playwrightcapture-1.31.5 → playwrightcapture-1.31.7}/playwrightcapture/py.typed +0 -0
- {playwrightcapture-1.31.5 → playwrightcapture-1.31.7}/playwrightcapture/socks5dnslookup.py +0 -0
@@ -1,4 +1,6 @@
|
|
1
1
|
from .capture import Capture # noqa
|
2
|
+
from .capture import CaptureResponse # noqa
|
3
|
+
from .capture import SetCookieParam, Cookie # noqa
|
2
4
|
from .helpers import get_devices # noqa
|
3
5
|
from .exceptions import (PlaywrightCaptureException, UnknownPlaywrightDeviceType, # noqa
|
4
6
|
UnknownPlaywrightBrowser, UnknownPlaywrightDevice,
|
@@ -6,6 +8,8 @@ from .exceptions import (PlaywrightCaptureException, UnknownPlaywrightDeviceType
|
|
6
8
|
|
7
9
|
__all__ = [
|
8
10
|
'Capture',
|
11
|
+
'CaptureResponse',
|
12
|
+
'SetCookieParam', 'Cookie',
|
9
13
|
'get_devices',
|
10
14
|
'PlaywrightCaptureException',
|
11
15
|
'UnknownPlaywrightDeviceType',
|
@@ -46,18 +46,6 @@ if sys.version_info < (3, 11):
|
|
46
46
|
else:
|
47
47
|
from asyncio import timeout
|
48
48
|
|
49
|
-
if sys.version_info < (3, 12):
|
50
|
-
from typing_extensions import TypedDict
|
51
|
-
else:
|
52
|
-
from typing import TypedDict
|
53
|
-
|
54
|
-
if TYPE_CHECKING:
|
55
|
-
from playwright._impl._api_structures import (SetCookieParam, Geolocation,
|
56
|
-
HttpCredentials, Headers,
|
57
|
-
ViewportSize, Cookie,
|
58
|
-
ProxySettings, StorageState)
|
59
|
-
BROWSER = Literal['chromium', 'firefox', 'webkit']
|
60
|
-
|
61
49
|
try:
|
62
50
|
if sys.version_info < (3, 10):
|
63
51
|
from pydub import AudioSegment # type: ignore[attr-defined]
|
@@ -68,6 +56,54 @@ try:
|
|
68
56
|
except ImportError:
|
69
57
|
CAN_SOLVE_CAPTCHA = False
|
70
58
|
|
59
|
+
# ####
|
60
|
+
# This bit is required as long as we need to support python < 3.12, stop removing it, you idiot
|
61
|
+
# That's the runtime failure: https://github.com/ail-project/lacus/actions/runs/16447900822/job/46484807036
|
62
|
+
# And the MyPy failure: https://github.com/ail-project/LacusCore/actions/runs/16447753492/job/46484287947
|
63
|
+
if sys.version_info < (3, 12):
|
64
|
+
from typing_extensions import TypedDict
|
65
|
+
else:
|
66
|
+
from typing import TypedDict
|
67
|
+
|
68
|
+
# These two classes are copies of te ones in Playwright, we need them until we can discard python 3.11
|
69
|
+
# They come from this file:
|
70
|
+
# https://github.com/microsoft/playwright-python/blob/main/playwright/_impl/_api_structures.py
|
71
|
+
|
72
|
+
|
73
|
+
class SetCookieParam(TypedDict, total=False):
|
74
|
+
name: str
|
75
|
+
value: str
|
76
|
+
url: str
|
77
|
+
domain: str
|
78
|
+
path: str
|
79
|
+
expires: float
|
80
|
+
httpOnly: bool
|
81
|
+
secure: bool
|
82
|
+
sameSite: Literal["Lax", "None", "Strict"]
|
83
|
+
partitionKey: str
|
84
|
+
|
85
|
+
|
86
|
+
class Cookie(TypedDict, total=False):
|
87
|
+
name: str
|
88
|
+
value: str
|
89
|
+
domain: str
|
90
|
+
path: str
|
91
|
+
expires: float
|
92
|
+
httpOnly: bool
|
93
|
+
secure: bool
|
94
|
+
sameSite: Literal["Lax", "None", "Strict"]
|
95
|
+
partitionKey: str
|
96
|
+
|
97
|
+
# ####################################
|
98
|
+
|
99
|
+
|
100
|
+
if TYPE_CHECKING:
|
101
|
+
from playwright._impl._api_structures import (Geolocation,
|
102
|
+
HttpCredentials, Headers,
|
103
|
+
ViewportSize,
|
104
|
+
ProxySettings, StorageState)
|
105
|
+
BROWSER = Literal['chromium', 'firefox', 'webkit']
|
106
|
+
|
71
107
|
|
72
108
|
class CaptureResponse(TypedDict, total=False):
|
73
109
|
|
@@ -299,7 +335,7 @@ class Capture():
|
|
299
335
|
return self._cookies
|
300
336
|
|
301
337
|
@cookies.setter
|
302
|
-
def cookies(self, cookies: list[dict[str, Any]] | None) -> None:
|
338
|
+
def cookies(self, cookies: list[SetCookieParam | dict[str, Any]] | None) -> None:
|
303
339
|
'''Cookies to send along to the initial request.
|
304
340
|
:param cookies: The cookies, in this format: https://playwright.dev/python/docs/api/class-browsercontext#browser-context-add-cookies
|
305
341
|
'''
|
@@ -515,7 +551,9 @@ class Capture():
|
|
515
551
|
|
516
552
|
if self.cookies:
|
517
553
|
try:
|
518
|
-
|
554
|
+
# NOTE: Ignore type until we can use python 3.12 + only
|
555
|
+
# playwrightcapture.capture.SetCookieParam == playwright._impl._api_structures.SetCookieParam
|
556
|
+
await self.context.add_cookies(self.cookies) # type: ignore[arg-type]
|
519
557
|
except Exception:
|
520
558
|
self.logger.exception(f'Unable to set cookies: {self.cookies}')
|
521
559
|
|
@@ -1237,7 +1275,9 @@ class Capture():
|
|
1237
1275
|
|
1238
1276
|
try:
|
1239
1277
|
async with timeout(15):
|
1240
|
-
|
1278
|
+
# NOTE: Ignore type until we can use python 3.12 + only
|
1279
|
+
# playwrightcapture.capture.SetCookieParam == playwright._impl._api_structures.SetCookieParam
|
1280
|
+
to_return['cookies'] = await self.context.cookies() # type: ignore[typeddict-item]
|
1241
1281
|
except (TimeoutError, asyncio.TimeoutError):
|
1242
1282
|
self.logger.warning("Unable to get cookies (timeout).")
|
1243
1283
|
errors.append("Unable to get the cookies (timeout).")
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|