Skip to content

Commit

Permalink
add failure exit whenever any hash fails
Browse files Browse the repository at this point in the history
  • Loading branch information
meisnate12 committed Jan 27, 2025
1 parent 47c8c50 commit 3d2214a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion check-imdb-hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
options.add_argument("--window-size=1920,1600")
options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36")

failed = []

with webdriver.Chrome(service=service, options=options) as driver:
logger.info(f"Chrome Browser Version: {driver.capabilities['browserVersion']}")
logger.info(f"Chrome Driver Version: {driver.capabilities['chrome']['chromedriverVersion']}")
Expand Down Expand Up @@ -89,6 +91,7 @@ def scan_for_hash(hash_type, special_text, filename):
logger.info(f"Extracted SHA-256 {hash_type} Hash: {sha256hash}")
else:
logger.info(f"Failed to retrieve SHA-256 {hash_type} Hash.")
failed.append(hash_type)

screenshot_count = 0

Expand Down Expand Up @@ -157,4 +160,8 @@ def page_end(screen, title="Page End"):
with open("README.md", "w", encoding="utf-8") as f:
f.writelines(readme_data)

logger.separator(f"{script_name} Finished\nTotal Runtime: {logger.runtime()}")
logger.separator(f"{script_name} Finished\nTotal Runtime: {logger.runtime()}")

if failed:
hashes = f"{' and '.join(failed if len(failed) < 3 else [f"{', '.join(failed[:-1])},", failed[-1]])}"
sys.exit(f"Failed to Find {hashes} Hash{'s' if failed > 1 else ''}")

0 comments on commit 3d2214a

Please sign in to comment.