diff options
author | Dylan Jones <dylanjones2011@gmail.com> | 2019-01-29 21:06:02 -0500 |
---|---|---|
committer | Dylan Jones <dylanjones2011@gmail.com> | 2019-01-29 21:06:02 -0500 |
commit | 191c477916477477bc3dd7b776fc0216c3970d7f (patch) | |
tree | 16b182dcefa0896f872e7813ef3b567e64e2e7c0 | |
parent | ef95964d175e7dc62dec58c9b4612ad446518f42 (diff) | |
download | modpackman-191c477916477477bc3dd7b776fc0216c3970d7f.tar.gz modpackman-191c477916477477bc3dd7b776fc0216c3970d7f.zip |
make it work more
-rw-r--r-- | downloads.txt | 6 | ||||
-rwxr-xr-x | update.py | 21 |
2 files changed, 19 insertions, 8 deletions
diff --git a/downloads.txt b/downloads.txt new file mode 100644 index 0000000..6549d94 --- /dev/null +++ b/downloads.txt @@ -0,0 +1,6 @@ +# Format: <jarname> <hex digested sha1> <direct download url> +opencomputers.jar 70feadd549255477810dff7145cade9d507b2dec https://media.forgecdn.net/files/2638/675/OpenComputers-MC1.12.2-1.7.3.146.jar +thaumcraft.jar fe0899048f1796df04e9727bbf1898df30492a00 https://media.forgecdn.net/files/2629/23/Thaumcraft-1.12.2-6.1.BETA26.jar +twilightforest.jar 418e55d39800696341d888dd9f407daee3748276 https://media.forgecdn.net/files/2618/264/twilightforest-1.12.2-3.8.689-universal.jar +connectedtextures.jar 03be3e20dacf6b52abcee09436b2d06c06f2add0 https://media.forgecdn.net/files/2642/375/CTM-MC1.12.2-0.3.3.22.jar +baubles.jar cb13fcfb18a9cb0cbd825fd5fe8d813c77368549 https://media.forgecdn.net/files/2518/667/Baubles-1.12-1.5.2.jar @@ -11,6 +11,7 @@ with open("pack-location.txt", "r") as f: INSTALL_DIR = f.read().strip() +# Apply updates to the actual mod pack def apply_updates(): print("Updating pack...") # (fname, url) @@ -20,12 +21,12 @@ def apply_updates(): with open("downloads.txt", "r") as f: for line in f: - dl = line.strip().split(" ") + mod = line.strip().split(" ") if len(line) >= 1 and line[0] != '#': # run strip on each element mod = tuple(map(lambda x: x.strip(), mod)) - mods.append(dl) - names.add(dl[0]) + mods.append(mod) + names.add(mod[0]) for mod in mods: if mod[0] in os.listdir(INSTALL_DIR) and hashlib.sha1(open(os.path.join(INSTALL_DIR, mod[0]), 'rb').read()).hexdigest() == mod[1]: print("Skipping " + mod[0] + ", already up to date") @@ -44,10 +45,12 @@ def apply_updates(): print("\nFinished updating pack!") + +# Using the latest urls, update downloads.txt to match the urls and have the correct sha1 def find_updates(): print("Reading update file...") mods = set() - with open('updates.txt') as f: + with open('latest-urls.txt') as f: for line in f: mod = line.strip().split() if len(line) >= 1 and line[0] != '#': @@ -58,18 +61,20 @@ def find_updates(): with open('downloads.txt', 'w') as f: f.write('# Format: <jarname> <hex digested sha1> <direct download url>\n') for mod in mods: + print(f"Downloading {mod[0]}...") resp = requests.get(mod[1]) hsh = hashlib.sha1(resp.content) f.write(f'{mod[0]} {hsh.hexdigest()} {resp.url}\n') + print("\nDone downloading updates!") if len(sys.argv) < 2: - print(f"Usage: {sys.argv[0]} <update|find_updates>") + print(f"Usage: {sys.argv[0]} <apply_updates|find_updates>") sys.exit(-1) -elif sys.argv[1] == 'update': - update() +elif sys.argv[1] == 'apply_updates': + apply_updates() elif sys.argv[1] == 'find_updates': find_updates() else: - print(f"Usage: {sys.argv[0]} <update|find_updates>") + print(f"Usage: {sys.argv[0]} <apply_updates|find_updates>") sys.exit(-1) |