PlaywrightCapture 1.28.4__py3-none-any.whl → 1.28.5__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.
@@ -159,8 +159,9 @@ class Capture():
159
159
  master_logger = logging.getLogger('playwrightcapture')
160
160
  master_logger.setLevel(loglevel)
161
161
  self.logger: Logger | PlaywrightCaptureLogAdapter
162
- if uuid is not None:
163
- self.logger = PlaywrightCaptureLogAdapter(master_logger, {'uuid': uuid})
162
+ self.uuid = uuid
163
+ if self.uuid is not None:
164
+ self.logger = PlaywrightCaptureLogAdapter(master_logger, {'uuid': self.uuid})
164
165
  else:
165
166
  self.logger = master_logger
166
167
  self.browser_name: BROWSER = browser if browser else 'chromium'
@@ -1073,20 +1074,6 @@ class Capture():
1073
1074
  except Exception as e:
1074
1075
  self.logger.exception(f'Error during instrumentation: {e}')
1075
1076
 
1076
- if multiple_downloads:
1077
- if len(multiple_downloads) == 1:
1078
- to_return["downloaded_filename"] = multiple_downloads[0][0]
1079
- to_return["downloaded_file"] = multiple_downloads[0][1]
1080
- else:
1081
- # we have multiple downloads, making it a zip
1082
- mem_zip = BytesIO()
1083
- to_return["downloaded_filename"] = 'multiple_downloads.zip'
1084
- with ZipFile(mem_zip, 'w') as z:
1085
- for i, f_details in enumerate(multiple_downloads):
1086
- filename, file_content = f_details
1087
- z.writestr(f'{i}_{filename}', file_content)
1088
- to_return["downloaded_file"] = mem_zip.getvalue()
1089
-
1090
1077
  if content := await self._failsafe_get_content(page):
1091
1078
  to_return['html'] = content
1092
1079
 
@@ -1199,6 +1186,20 @@ class Capture():
1199
1186
  finally:
1200
1187
  self.logger.debug('Finishing up capture.')
1201
1188
  if not capturing_sub:
1189
+ if multiple_downloads:
1190
+ if len(multiple_downloads) == 1:
1191
+ to_return["downloaded_filename"] = multiple_downloads[0][0]
1192
+ to_return["downloaded_file"] = multiple_downloads[0][1]
1193
+ else:
1194
+ # we have multiple downloads, making it a zip, make sure the filename is unique
1195
+ mem_zip = BytesIO()
1196
+ to_return["downloaded_filename"] = f'{self.uuid}_multiple_downloads.zip'
1197
+ with ZipFile(mem_zip, 'w') as z:
1198
+ for i, f_details in enumerate(multiple_downloads):
1199
+ filename, file_content = f_details
1200
+ z.writestr(f'{i}_{filename}', file_content)
1201
+ to_return["downloaded_file"] = mem_zip.getvalue()
1202
+
1202
1203
  try:
1203
1204
  to_return['storage'] = await self._failsafe_get_storage()
1204
1205
  to_return['cookies'] = await self._failsafe_get_cookies()
@@ -1241,6 +1242,8 @@ class Capture():
1241
1242
  return await self.context.storage_state(indexed_db=True)
1242
1243
  except (TimeoutError, asyncio.TimeoutError):
1243
1244
  self.logger.warning("Unable to get storage (timeout).")
1245
+ except Error as e:
1246
+ self.logger.warning(f"Unable to get storage: {e}")
1244
1247
  return None
1245
1248
 
1246
1249
  async def _failsafe_get_screenshot(self, page: Page) -> bytes:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: PlaywrightCapture
3
- Version: 1.28.4
3
+ Version: 1.28.5
4
4
  Summary: A simple library to capture websites using playwright
5
5
  License: BSD-3-Clause
6
6
  Author: Raphaël Vinot
@@ -1,9 +1,9 @@
1
1
  playwrightcapture/__init__.py,sha256=F90Y8wYS13tDjgsfjuFrCfmzQfdnH44G-ovuilJfLEE,511
2
- playwrightcapture/capture.py,sha256=Iicc_nNjlztCMGIJ9wSB6UhKoIcVJCh_00BssV68XDU,82297
2
+ playwrightcapture/capture.py,sha256=nsqlSSS-GhTVRMxGgeom-rnSwV7WMMvsAWU6vnvQO_k,82469
3
3
  playwrightcapture/exceptions.py,sha256=LhGJQCGHzEu7Sx2Dfl28OFeDg1OmrwufFjAWXlxQnEA,366
4
4
  playwrightcapture/helpers.py,sha256=Xqs09zHhzAWnpBtQ0A9YAxg80P3Lj7aBj5M2WuEr0so,1843
5
5
  playwrightcapture/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- playwrightcapture-1.28.4.dist-info/LICENSE,sha256=uwFc39fTLacBUG-XTuxX6IQKTKhg4z14gWOLt3ex4Ho,1775
7
- playwrightcapture-1.28.4.dist-info/METADATA,sha256=o32IMwzDiGFMVmlmaHJF0JTg0p2r5_kZ9KLXuJlVI9M,3075
8
- playwrightcapture-1.28.4.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
9
- playwrightcapture-1.28.4.dist-info/RECORD,,
6
+ playwrightcapture-1.28.5.dist-info/LICENSE,sha256=uwFc39fTLacBUG-XTuxX6IQKTKhg4z14gWOLt3ex4Ho,1775
7
+ playwrightcapture-1.28.5.dist-info/METADATA,sha256=fWObVPNLr1bws1WbdiAhVzYqCMV5x9Izw95MIzL7SDw,3075
8
+ playwrightcapture-1.28.5.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
9
+ playwrightcapture-1.28.5.dist-info/RECORD,,