diff options
-rw-r--r-- | downloads.txt | 4 | ||||
-rw-r--r-- | thaumplified-downloads.txt (renamed from prev-downloads.txt) | 0 | ||||
-rwxr-xr-x | update.py | 62 |
3 files changed, 24 insertions, 42 deletions
diff --git a/downloads.txt b/downloads.txt index 6549d94..96a4981 100644 --- a/downloads.txt +++ b/downloads.txt @@ -1,6 +1,6 @@ # Format: <jarname> <hex digested sha1> <direct download url> +twilightforest.jar 418e55d39800696341d888dd9f407daee3748276 https://media.forgecdn.net/files/2618/264/twilightforest-1.12.2-3.8.689-universal.jar +baubles.jar cb13fcfb18a9cb0cbd825fd5fe8d813c77368549 https://media.forgecdn.net/files/2518/667/Baubles-1.12-1.5.2.jar 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 diff --git a/prev-downloads.txt b/thaumplified-downloads.txt index 0e3c6d2..0e3c6d2 100644 --- a/prev-downloads.txt +++ b/thaumplified-downloads.txt @@ -14,19 +14,9 @@ with open("pack-location.txt", "r") as f: # Apply updates to the actual mod pack def install(): print("Updating pack...") - # (fname, url) - mods = [] - # Set of jar file names - names = set() - - with open("downloads.txt", "r") as f: - for line in f: - 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(mod) - names.add(mod[0]) + # (fname, checksum, url) + mods = read_file("downloads.txt") + names = [mod[0] for mod in mods] 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") @@ -49,14 +39,7 @@ def install(): # Using the latest urls, update downloads.txt to match the urls and have the correct sha1 def apply_updates(): print("Reading update file...") - mods = set() - with open('latest-urls.txt') as f: - for line in f: - 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.add(mod) + mods = read_file("latest-urls.txt") print("Downloading new versions of all mods...") with open('downloads.txt', 'w') as f: f.write('# Format: <jarname> <hex digested sha1> <direct download url>\n') @@ -70,28 +53,27 @@ def apply_updates(): # Find if any updates are available def check_updates(): print("Reading update files...") - latest_urls = {} - with open('latest-urls.txt') as f: - for line in f: - mod = line.strip().split() - if len(line) >= 1 and line[0] != '#': - # run strip on each element - mod = tuple(map(lambda x: x.strip(), mod)) - latest_urls[mod[0]] = mod[1] - old_urls = {} - with open('downloads.txt') as f: + latest = read_file("latest-urls.txt") + old = read_file("downloads.txt") + old_urls = [mod[2] for mod in old] + + print("Checking updates...\nThe following mods have updates available:\n") + for mod in latest: + resp = requests.get(mod[1]) + if not resp.url in old_urls: + print(f" -> Found update for {mod[0]}: {resp.url.split('/')[-1]}") + print("\nFinished checking for updates!") + +def read_file(fil): + strings = set() + with open(fil) as f: for line in f: - mod = line.strip().split() + string = line.strip().split() if len(line) >= 1 and line[0] != '#': # run strip on each element - mod = tuple(map(lambda x: x.strip(), mod)) - old_urls[mod[0]] = mod[2] - print("Checking updates...\nThe following mods have updates available:\n") - for mod in latest_urls: - resp = requests.get(latest_urls[mod]) - if resp.url != old_urls[mod]: - print(f" -> Found update for {mod}!") - print("Finished checking for updates!") + string = tuple(map(lambda x: x.strip(), string)) + strings.add(string) + return strings if len(sys.argv) < 2: |