lacuscore 1.13.4__tar.gz → 1.13.6__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.
- {lacuscore-1.13.4 → lacuscore-1.13.6}/PKG-INFO +1 -1
- {lacuscore-1.13.4 → lacuscore-1.13.6}/lacuscore/helpers.py +24 -10
- {lacuscore-1.13.4 → lacuscore-1.13.6}/lacuscore/lacuscore.py +2 -2
- {lacuscore-1.13.4 → lacuscore-1.13.6}/pyproject.toml +1 -1
- {lacuscore-1.13.4 → lacuscore-1.13.6}/LICENSE +0 -0
- {lacuscore-1.13.4 → lacuscore-1.13.6}/README.md +0 -0
- {lacuscore-1.13.4 → lacuscore-1.13.6}/lacuscore/__init__.py +0 -0
- {lacuscore-1.13.4 → lacuscore-1.13.6}/lacuscore/lacus_monitoring.py +0 -0
- {lacuscore-1.13.4 → lacuscore-1.13.6}/lacuscore/py.typed +0 -0
- {lacuscore-1.13.4 → lacuscore-1.13.6}/lacuscore/task_logger.py +0 -0
@@ -5,6 +5,7 @@ from __future__ import annotations
|
|
5
5
|
import json
|
6
6
|
import sys
|
7
7
|
|
8
|
+
from datetime import datetime, timedelta
|
8
9
|
from enum import IntEnum, unique
|
9
10
|
from logging import LoggerAdapter
|
10
11
|
from typing import Any, Literal
|
@@ -218,6 +219,28 @@ class CaptureSettings(BaseModel):
|
|
218
219
|
@field_validator('cookies', mode='before')
|
219
220
|
@classmethod
|
220
221
|
def load_cookies_json(cls, cookies: Any) -> list[dict[str, Any]] | None:
|
222
|
+
|
223
|
+
def __prepare_cookie(cookie: dict[str, Any]) -> dict[str, str | float | bool]:
|
224
|
+
if len(cookie) == 1:
|
225
|
+
# {'name': 'value'} => {'name': 'name', 'value': 'value'}
|
226
|
+
name, value = cookie.popitem()
|
227
|
+
if name and value:
|
228
|
+
cookie = {'name': name, 'value': value}
|
229
|
+
if not cookie.get('name') or not cookie.get('value'):
|
230
|
+
# invalid cookie, ignoring
|
231
|
+
return {}
|
232
|
+
|
233
|
+
if 'expires' in cookie and isinstance(cookie['expires'], str):
|
234
|
+
# Make it a float, as expected by Playwright
|
235
|
+
try:
|
236
|
+
cookie['expires'] = datetime.fromisoformat(cookie['expires']).timestamp()
|
237
|
+
except ValueError:
|
238
|
+
# if it ends with a Z, it fails in python < 3.12
|
239
|
+
# And we don't really care.
|
240
|
+
# make it expire 10 days from now
|
241
|
+
cookie['expires'] = (datetime.now() + timedelta(days=10)).timestamp()
|
242
|
+
return cookie
|
243
|
+
|
221
244
|
if not cookies:
|
222
245
|
return None
|
223
246
|
if isinstance(cookies, str):
|
@@ -236,16 +259,7 @@ class CaptureSettings(BaseModel):
|
|
236
259
|
to_return = []
|
237
260
|
for cookie in cookies:
|
238
261
|
if isinstance(cookie, dict):
|
239
|
-
|
240
|
-
to_return.append(cookie)
|
241
|
-
elif len(cookie) == 1:
|
242
|
-
# {'name': 'value'} => {'name': 'name', 'value': 'value'}
|
243
|
-
name, value = cookie.popitem()
|
244
|
-
if name and value:
|
245
|
-
to_return.append({'name': name, 'value': value})
|
246
|
-
else:
|
247
|
-
# invalid cookie, ignoring
|
248
|
-
pass
|
262
|
+
to_return.append(__prepare_cookie(cookie))
|
249
263
|
return to_return
|
250
264
|
return None
|
251
265
|
|
@@ -132,7 +132,7 @@ class LacusCore():
|
|
132
132
|
user_agent: str | None=None,
|
133
133
|
proxy: str | dict[str, str] | None=None,
|
134
134
|
general_timeout_in_sec: int | None=None,
|
135
|
-
cookies: list[dict[str, Any]] | None=None,
|
135
|
+
cookies: list[dict[str, Any]] | list[Cookie] | None=None,
|
136
136
|
storage: dict[str, Any] | None=None,
|
137
137
|
headers: dict[str, str] | None=None,
|
138
138
|
http_credentials: dict[str, str] | None=None,
|
@@ -164,7 +164,7 @@ class LacusCore():
|
|
164
164
|
user_agent: str | None=None,
|
165
165
|
proxy: str | dict[str, str] | None=None,
|
166
166
|
general_timeout_in_sec: int | None=None,
|
167
|
-
cookies: list[dict[str, Any]] | None=None,
|
167
|
+
cookies: list[dict[str, Any]] | list[Cookie] | None=None,
|
168
168
|
storage: dict[str, Any] | None=None,
|
169
169
|
headers: dict[str, str] | None=None,
|
170
170
|
http_credentials: dict[str, str] | None=None,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|