PlaywrightCapture 1.28.4__tar.gz → 1.28.5__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.28.4 → playwrightcapture-1.28.5}/PKG-INFO +1 -1
- {playwrightcapture-1.28.4 → playwrightcapture-1.28.5}/playwrightcapture/capture.py +19 -16
- {playwrightcapture-1.28.4 → playwrightcapture-1.28.5}/pyproject.toml +1 -1
- {playwrightcapture-1.28.4 → playwrightcapture-1.28.5}/LICENSE +0 -0
- {playwrightcapture-1.28.4 → playwrightcapture-1.28.5}/README.md +0 -0
- {playwrightcapture-1.28.4 → playwrightcapture-1.28.5}/playwrightcapture/__init__.py +0 -0
- {playwrightcapture-1.28.4 → playwrightcapture-1.28.5}/playwrightcapture/exceptions.py +0 -0
- {playwrightcapture-1.28.4 → playwrightcapture-1.28.5}/playwrightcapture/helpers.py +0 -0
- {playwrightcapture-1.28.4 → playwrightcapture-1.28.5}/playwrightcapture/py.typed +0 -0
@@ -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
|
-
|
163
|
-
|
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:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|