diff --git a/scrapthechan/scraper.py b/scrapthechan/scraper.py index ece3cda..50411b0 100644 --- a/scrapthechan/scraper.py +++ b/scrapthechan/scraper.py @@ -110,11 +110,16 @@ class Scraper: retries -= 1 else: break + if retries == 0: + print(f"Cannot retrieve {f.download_url}, {filepath}.") + return if is_same_filename: - f1_hexdig, f1_dig = self._hash_file(orig_filepath, f.hash_algorithm) - f2_hexdig, f2_dig = self._hash_file(filepath, f.hash_algorithm) - if f1_hexdig == f2_hexdig or f1_dig == f2_dig: + _, f1_dig = self._hash_file(orig_filepath, f.hash_algorithm) + _, f2_dig = self._hash_file(filepath, f.hash_algorithm) + if f1_dig == f2_dig: remove(filepath) + except FileNotFoundError as e: + print("File Not Found", filepath) except HTTPError as e: print("HTTP Error", e.code, e.reason, f.download_url) if exists(filepath):