PlaywrightCapture 1.31.5__py3-none-any.whl → 1.31.7__py3-none-any.whl

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.
@@ -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
- await self.context.add_cookies(self.cookies)
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
- to_return['cookies'] = await self.context.cookies()
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).")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: PlaywrightCapture
3
- Version: 1.31.5
3
+ Version: 1.31.7
4
4
  Summary: A simple library to capture websites using playwright
5
5
  License: BSD-3-Clause
6
6
  Author: Raphaël Vinot
@@ -0,0 +1,10 @@
1
+ playwrightcapture/__init__.py,sha256=NAL0-ymloDBm_ghp1PsefIwRMQmEFKPhn83WVUD7t_0,663
2
+ playwrightcapture/capture.py,sha256=rcMfnkp7s2WQX0VYhdjSBUFkTYoBDg9GWeBb3THD9QI,88651
3
+ playwrightcapture/exceptions.py,sha256=LhGJQCGHzEu7Sx2Dfl28OFeDg1OmrwufFjAWXlxQnEA,366
4
+ playwrightcapture/helpers.py,sha256=Xqs09zHhzAWnpBtQ0A9YAxg80P3Lj7aBj5M2WuEr0so,1843
5
+ playwrightcapture/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ playwrightcapture/socks5dnslookup.py,sha256=ZpOf8tgsRQZi-WDcn9JbbG1bKz9DSfK_jz1l53UI1Ho,4058
7
+ playwrightcapture-1.31.7.dist-info/LICENSE,sha256=uwFc39fTLacBUG-XTuxX6IQKTKhg4z14gWOLt3ex4Ho,1775
8
+ playwrightcapture-1.31.7.dist-info/METADATA,sha256=BTM3AQGpFYhcy7Eq6ZwqVlpKwYQd3m1x5ft2QoLySBs,3285
9
+ playwrightcapture-1.31.7.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
10
+ playwrightcapture-1.31.7.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- playwrightcapture/__init__.py,sha256=F90Y8wYS13tDjgsfjuFrCfmzQfdnH44G-ovuilJfLEE,511
2
- playwrightcapture/capture.py,sha256=CNV-TbnUj8HXFaEmxIxKTeuXsKkVFsA7bCdNJKCTvnI,87166
3
- playwrightcapture/exceptions.py,sha256=LhGJQCGHzEu7Sx2Dfl28OFeDg1OmrwufFjAWXlxQnEA,366
4
- playwrightcapture/helpers.py,sha256=Xqs09zHhzAWnpBtQ0A9YAxg80P3Lj7aBj5M2WuEr0so,1843
5
- playwrightcapture/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- playwrightcapture/socks5dnslookup.py,sha256=ZpOf8tgsRQZi-WDcn9JbbG1bKz9DSfK_jz1l53UI1Ho,4058
7
- playwrightcapture-1.31.5.dist-info/LICENSE,sha256=uwFc39fTLacBUG-XTuxX6IQKTKhg4z14gWOLt3ex4Ho,1775
8
- playwrightcapture-1.31.5.dist-info/METADATA,sha256=44oFmm1jYLUz1vPX2HJgCe3CJSO-BqMDzdIZfGBNtnw,3285
9
- playwrightcapture-1.31.5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
10
- playwrightcapture-1.31.5.dist-info/RECORD,,