This commit is contained in:
Jean-Marie Mineau 2024-10-29 10:42:16 +01:00
parent 9027220508
commit 096e38ec12
2 changed files with 10 additions and 9 deletions

View file

@ -158,9 +158,10 @@ def main():
for sha256 in sha256s: for sha256 in sha256s:
if args.output_dir and (args.output_dir / sha256).exists(): if args.output_dir and (args.output_dir / sha256).exists():
continue continue
with zipfile.ZipFile( apk_bin = download_apk(sha256, api_key, logfile=logfile)
io.BytesIO(download_apk(sha256, api_key, logfile=logfile)) if apk_bin is None:
) as apk: continue
with zipfile.ZipFile(io.BytesIO(apk_bin)) as apk:
entry = analyze(apk, sha256, verbose=args.pprint) entry = analyze(apk, sha256, verbose=args.pprint)
if args.pprint: if args.pprint:
pprint.pprint(entry) pprint.pprint(entry)

View file

@ -38,10 +38,10 @@ def download_apk(
else: else:
print(log) print(log)
time.sleep(delay) time.sleep(delay)
log = f"[{datetime.today().strftime('%Y-%m-%d %H:%M:%S')}] Failed to download {sha256}, abort" log = f"[{datetime.today().strftime('%Y-%m-%d %H:%M:%S')}] Failed to download {sha256}, abort"
if logfile: if logfile:
with logfile.open("a") as file: with logfile.open("a") as file:
file.write(f"{log}\n") file.write(f"{log}\n")
else: else:
print(log) print(log)
return None return None