Created
February 25, 2019 21:19
-
-
Save meganukebmp/1a9961996a90a3a17320f9ed11a7daa4 to your computer and use it in GitHub Desktop.
LineageOS batch downloader for archive purposes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a5y17lte userdebug cm-14.1 M | |
a7y17lte userdebug cm-14.1 M | |
addison userdebug cm-14.1 M | |
cancro userdebug cm-14.1 M | |
chagalllte userdebug cm-14.1 M | |
chagallwifi userdebug cm-14.1 M | |
chaozu userdebug cm-14.1 M | |
falcon userdebug cm-14.1 M | |
flo userdebug cm-14.1 M | |
flounder userdebug cm-14.1 M | |
flounder_lte userdebug cm-14.1 M | |
g2m userdebug cm-14.1 M | |
gohan userdebug cm-14.1 M | |
h830 userdebug cm-14.1 M | |
h850 userdebug cm-14.1 M | |
h870 userdebug cm-14.1 M | |
h910 userdebug cm-14.1 M | |
h918 userdebug cm-14.1 M | |
hammerhead userdebug cm-14.1 M | |
harpia userdebug cm-14.1 M | |
hero2lte userdebug cm-14.1 M | |
herolte userdebug cm-14.1 M | |
hlte userdebug cm-14.1 M | |
hltetmo userdebug cm-14.1 M | |
i9300 userdebug cm-14.1 M | |
ido userdebug cm-14.1 M | |
ivy userdebug cm-14.1 M | |
jag3gds userdebug cm-14.1 M | |
jagnm userdebug cm-14.1 M | |
jasmine userdebug cm-14.1 M | |
jfltevzw userdebug cm-14.1 M | |
jfltexx userdebug cm-14.1 M | |
karin userdebug cm-14.1 M | |
karin_windy userdebug cm-14.1 M | |
kingdom userdebug cm-14.1 M | |
klimtwifi userdebug cm-14.1 M | |
kltesprsports userdebug cm-14.1 M | |
libra userdebug cm-14.1 M | |
ls997 userdebug cm-14.1 M | |
lt02ltespr userdebug cm-14.1 M | |
lux userdebug cm-14.1 M | |
m8 userdebug cm-14.1 M | |
m8d userdebug cm-14.1 M | |
maserati userdebug cm-14.1 M | |
merlin userdebug cm-14.1 M | |
n1awifi userdebug cm-14.1 M | |
n2awifi userdebug cm-14.1 M | |
nx512j userdebug cm-14.1 M | |
osprey userdebug cm-14.1 M | |
P024 userdebug cm-14.1 M | |
paella userdebug cm-14.1 M | |
peregrine userdebug cm-14.1 M | |
piccolo userdebug cm-14.1 M | |
seed userdebug cm-14.1 M | |
shieldtablet userdebug cm-14.1 M | |
spyder userdebug cm-14.1 M | |
sumire userdebug cm-14.1 M | |
surnia userdebug cm-14.1 M | |
suzuran userdebug cm-14.1 M | |
t0lte userdebug cm-14.1 M | |
targa userdebug cm-14.1 M | |
thea userdebug cm-14.1 M | |
tenshi userdebug cm-14.1 M | |
titan userdebug cm-14.1 M | |
tulip userdebug cm-14.1 M | |
umts_spyder userdebug cm-14.1 M | |
us996 userdebug cm-14.1 M | |
us997 userdebug cm-14.1 M | |
v1awifi userdebug cm-14.1 M | |
v480 userdebug cm-14.1 M | |
vegetalte userdebug cm-14.1 M | |
victara userdebug cm-14.1 M | |
vs995 userdebug cm-14.1 M | |
w5 userdebug cm-14.1 M | |
w7 userdebug cm-14.1 M | |
xt897 userdebug cm-14.1 M | |
zerofltexx userdebug cm-14.1 M | |
zeroltexx userdebug cm-14.1 M |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import urllib | |
import urllib.request | |
import os | |
import sys | |
import hashlib | |
# BUF_SIZE is totally arbitrary, change for your app! | |
BUF_SIZE = 65536 # lets read stuff in 64kb chunks! | |
file = open("devices.txt", "r") | |
for i in file: | |
devicename = i.split(" ")[0] | |
if not os.path.exists("./" + devicename): | |
os.makedirs("./" + devicename) | |
contents = urllib.request.urlopen("https://download.lineageos.org/api/v1/" + devicename + "/nightly/autodownloader").read() | |
data = json.loads(contents.decode('utf-8'))["response"] | |
print("\n=================================") | |
print("Number of builds: " + str(len(data))) | |
print("Device: " + devicename) | |
print("---------------------------------") | |
for n in data: | |
print("Downloading " + n["filename"] + "...", end=" ", flush=True) | |
filedata = urllib.request.urlopen(n["url"]) | |
structuredfiledata = filedata.read() | |
# Write Files | |
with open("./" + devicename + "/" + n["filename"], "wb") as f: | |
f.write(structuredfiledata) | |
print("Done!", flush=True) | |
# Write SHAs | |
with open("./" + devicename + "/" + n["filename"] + ".sha256", "wt") as f: | |
f.write(n["id"] + " " + n["filename"]) | |
# Calculate shas | |
print("Calculating SHA256... ", end=" ", flush=True) | |
sha256 = hashlib.sha256() | |
with open("./" + devicename + "/" + n["filename"], 'rb') as f: | |
while True: | |
BUF = f.read(BUF_SIZE) | |
if not BUF: | |
break | |
sha256.update(BUF) | |
if sha256.hexdigest() == n["id"]: | |
print("Done!", flush=True) | |
else: | |
print("DIGEST MISSMATCH!", flush=True) | |
sys.exit("DIGEST MISSMATCH " + sha256.hexdigest + " != " + n["id"]) | |
print("=================================") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment