lacuscore 1.9.5__py3-none-any.whl → 1.10.0__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.
lacuscore/lacuscore.py CHANGED
@@ -531,6 +531,27 @@ class LacusCore():
531
531
  browser_engine = 'firefox'
532
532
  else:
533
533
  browser_engine = 'webkit'
534
+
535
+ cookies: list[dict[str, Any]] = []
536
+ if to_capture.get('cookies') and to_capture['cookies'] is not None:
537
+ # In order to properly pass the cookies to playwright,
538
+ # each of then must have a name, a value and either a domain + path or a URL
539
+ # Name and value are mandatory, and we cannot auto-fill them.
540
+ # If the cookie doesn't have a domain + path OR a URL, we fill the domain
541
+ # with the hostname of the URL we try to capture and the path with "/"
542
+ for cookie in to_capture['cookies']:
543
+ if len(cookie) == 1:
544
+ # we have a cookie in the format key: value
545
+ name, value = cookie.popitem()
546
+ cookie = {'name': name, 'value': value}
547
+ if 'name' not in cookie or 'value' not in cookie:
548
+ logger.warning(f'Invalid cookie: {cookie}')
549
+ continue
550
+ if 'domain' not in cookie and 'url' not in cookie:
551
+ cookie['domain'] = splitted_url.hostname
552
+ cookie['path'] = '/'
553
+ cookies.append(cookie)
554
+
534
555
  try:
535
556
  logger.debug(f'Capturing {url}')
536
557
  stats_pipeline.sadd(f'stats:{today}:captures', url)
@@ -543,7 +564,7 @@ class LacusCore():
543
564
  uuid=uuid) as capture:
544
565
  # required by Mypy: https://github.com/python/mypy/issues/3004
545
566
  capture.headers = to_capture.get('headers') # type: ignore[assignment]
546
- capture.cookies = to_capture.get('cookies') # type: ignore[assignment]
567
+ capture.cookies = cookies # type: ignore[assignment]
547
568
  capture.viewport = to_capture.get('viewport') # type: ignore[assignment]
548
569
  capture.user_agent = to_capture.get('user_agent') # type: ignore[assignment]
549
570
  capture.http_credentials = to_capture.get('http_credentials') # type: ignore[assignment]
@@ -583,7 +604,7 @@ class LacusCore():
583
604
  except RetryCapture as e:
584
605
  raise e
585
606
  except PlaywrightCaptureException as e:
586
- logger.exception(f'Invalid parameters for the capture of {url} - {e}')
607
+ logger.warning(f'Invalid parameters for the capture of {url} - {e}')
587
608
  result = {'error': f'Invalid parameters for the capture of {url} - {e}'}
588
609
  raise CaptureError(f'Invalid parameters for the capture of {url} - {e}')
589
610
  except asyncio.CancelledError:
@@ -612,7 +633,7 @@ class LacusCore():
612
633
  logger.debug(f'Retrying {url} for the first time.')
613
634
  retry = True
614
635
  self.redis.setex(f'lacus:capture_retry:{uuid}',
615
- self.max_capture_time * (self.max_retries + 1),
636
+ self.max_capture_time * (self.max_retries + 10),
616
637
  self.max_retries)
617
638
  else:
618
639
  current_retry = int(_current_retry.decode())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lacuscore
3
- Version: 1.9.5
3
+ Version: 1.10.0
4
4
  Summary: Core of Lacus, usable as a module
5
5
  Home-page: https://github.com/ail-project/LacusCore
6
6
  License: BSD-3-Clause
@@ -28,8 +28,8 @@ Requires-Dist: Sphinx (>=7.2,<8.0) ; (python_version >= "3.9") and (extra == "do
28
28
  Requires-Dist: async-timeout (>=4.0.3,<5.0.0) ; python_version < "3.11"
29
29
  Requires-Dist: defang (>=0.5.3,<0.6.0)
30
30
  Requires-Dist: dnspython (>=2.6.1,<3.0.0)
31
- Requires-Dist: playwrightcapture[recaptcha] (>=1.24.11,<2.0.0)
32
- Requires-Dist: redis[hiredis] (>=5.0.4,<6.0.0)
31
+ Requires-Dist: playwrightcapture[recaptcha] (>=1.25.0,<2.0.0)
32
+ Requires-Dist: redis[hiredis] (>=5.0.7,<6.0.0)
33
33
  Requires-Dist: requests (>=2.32.3,<3.0.0)
34
34
  Requires-Dist: ua-parser (>=0.18.0,<0.19.0)
35
35
  Project-URL: Documentation, https://lacuscore.readthedocs.io/en/latest/
@@ -1,10 +1,10 @@
1
1
  lacuscore/__init__.py,sha256=hM4lKoPNybDCUMWdXTVVI1gRk_riLvRZ7IwFbamZLzE,341
2
2
  lacuscore/helpers.py,sha256=lULN7HhY-4a4HG-ybIt4jO3wEGTxkm_jKNqsGpNZo4Y,2711
3
3
  lacuscore/lacus_monitoring.py,sha256=UOfE_1-_rhVeKJXQ_m9XxYkr7VwyQnA6iK-x_tcXJfo,2775
4
- lacuscore/lacuscore.py,sha256=6YQ6ORW9yJP-cEf7zmPC196zVJI2-nI3Sq9M0VoDxWQ,42843
4
+ lacuscore/lacuscore.py,sha256=n0hjyuJpz5G4s5mRzTAtSCHaPtPqdMaTEO7o-2N88JI,44048
5
5
  lacuscore/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  lacuscore/task_logger.py,sha256=8WbdJdKnGeFCxt9gtCNLI9vAQQZbsy2I5PRQpHP7XFU,1916
7
- lacuscore-1.9.5.dist-info/LICENSE,sha256=4C4hLYrIkUD96Ggk-y_Go1Qf7PBZrEm9PSeTGe2nd4s,1516
8
- lacuscore-1.9.5.dist-info/METADATA,sha256=aNJ8gH24KtwIpcyHRkCsfz-kfcC8dLQfVkadqY7knko,2629
9
- lacuscore-1.9.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
10
- lacuscore-1.9.5.dist-info/RECORD,,
7
+ lacuscore-1.10.0.dist-info/LICENSE,sha256=4C4hLYrIkUD96Ggk-y_Go1Qf7PBZrEm9PSeTGe2nd4s,1516
8
+ lacuscore-1.10.0.dist-info/METADATA,sha256=PmC32J2hEc1hyXiX4wQOjAcnJDLlVIqvj-Yw8pJc13Q,2629
9
+ lacuscore-1.10.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
10
+ lacuscore-1.10.0.dist-info/RECORD,,