From 8899c8d5821ac06f0dd09fbb2a7a0577fa9d5eb2 Mon Sep 17 00:00:00 2001 From: Nayil Mukhametshin <66028747+nlscc@users.noreply.github.com> Date: Thu, 30 Jul 2020 13:38:56 +0100 Subject: add support for saving to directories --- README.md | 4 ++-- samloader/main.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index de66c0e..af0633c 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Download firmware for Samsung devices (without any extra Windows drivers). ## Usage `checkupdate [model] [region]`: Check the latest firmware version -`download [version] [model] [region] [outfile]`: Download the specified firmware version for a given phone and region +`download [version] [model] [region] [out]`: Download the specified firmware version for a given phone and region to a specified file or directory `decrypt2 [version] [model] [region] [infile] [outfile]`: Decrypt enc2 encrypted firmwares @@ -12,7 +12,7 @@ Download firmware for Samsung devices (without any extra Windows drivers). ``` $ samloader checkupdate GT-I8190N BTU I8190NXXAMJ2/I8190NBTUAMJ1/I8190NXXAMJ2/I8190NXXAMJ2 -$ samloader download I8190NXXAMJ2/I8190NBTUAMJ1/I8190NXXAMJ2/I8190NXXAMJ2 GT-I8190N BTU GT-I8190N_BTU_1_20131118100230_9ae3yzkqmu_fac.zip.enc2 +$ samloader download I8190NXXAMJ2/I8190NBTUAMJ1/I8190NXXAMJ2/I8190NXXAMJ2 GT-I8190N BTU . Downloading file /neofus/9/GT-I8190N_BTU_1_20131118100230_9ae3yzkqmu_fac.zip.enc2 ... [################################] 10570/10570 - 00:02:02 Done! diff --git a/samloader/main.py b/samloader/main.py index e8fca4f..a4896bb 100644 --- a/samloader/main.py +++ b/samloader/main.py @@ -38,15 +38,17 @@ def checkupdate(model, region): @click.argument("version") @click.argument("model") @click.argument("region") -@click.argument("outfile") -def download(version, model, region, outfile): +@click.argument("out") +def download(version, model, region, out): client = fusclient.FUSClient() path, filename = getbinaryfile(client, version, region, model) print("Downloading file {} ...".format(path+filename)) initdownload(client, filename) r = client.downloadfile(path+filename) length = int(r.headers["Content-Length"]) - with open(outfile, "wb") as f: + if os.path.isdir(out): + out = os.path.join(out, filename) + with open(out, "wb") as f: for chunk in progress.bar(r.iter_content(chunk_size=0x10000), expected_size=(length/0x10000)+1): if chunk: f.write(chunk) -- cgit v1.2.3