diff --git a/frontools/screenshot.py b/frontools/screenshot.py index d4350fd..6bb0c52 100644 --- a/frontools/screenshot.py +++ b/frontools/screenshot.py @@ -42,7 +42,7 @@ async def screenshot_diff( async with right_source.get_browser( width=width, height=height ) as right_browser: - urls = [(theme, url) for (theme, site) in config.sites for url in site.urls] + urls = [(site_name, url) for (site_name, site) in config.sites for url in site.urls] await report_progress( "Screenshoting", @@ -50,16 +50,16 @@ async def screenshot_diff( ( url, _diff_url( - left_browser, right_browser, url, output_path / theme + left_browser, right_browser, url, output_path, site_name ), ) - for (theme, url) in urls + for (site_name, url) in urls ], nb_workers=3, ) -async def _diff_url(left: Browser, right: Browser, url: str, output_path: Path) -> None: +async def _diff_url(left: Browser, right: Browser, url: str, output_path: Path, site_name: str) -> None: try: left_bytes = await _screenshot_url(left, url) right_bytes = await _screenshot_url(right, url) @@ -81,10 +81,10 @@ async def _diff_url(left: Browser, right: Browser, url: str, output_path: Path) if not output_path.is_dir(): output_path.mkdir() - with open(output_path / f"{url_slug}_left", "wb") as screenshot_file: + with open(output_path / f"{site_name}_{url_slug}_left", "wb") as screenshot_file: screenshot_file.write(left_bytes) - with open(output_path / f"{url_slug}_right", "wb") as screenshot_file: + with open(output_path / f"{site_name}_{url_slug}_right", "wb") as screenshot_file: screenshot_file.write(right_bytes) except Exception as ex: print(f"Error while diffing {url} : {ex}")