diff options
-rw-r--r-- | readme.md | 5 | ||||
-rwxr-xr-x | update.py | 22 |
2 files changed, 19 insertions, 8 deletions
@@ -8,3 +8,8 @@ Script to update modpacks automatically Simply put the location of your `mods` folder in `pack-location.txt` and run `python update.py install` Requires the `requests` module. + +#### Maintenance: + +To check `downloads.txt` modlist for updates against `latest-urls.txt` modlist, run `python update.py check_updates` +To automatically populate `downloads.txt` with the most recent versions of mods listed in `latest-urls.txt` run `python update.py apply_updates` @@ -33,26 +33,27 @@ def install(): os.remove(os.path.join(INSTALL_DIR, jar)) print(f"Removing '{jar}'") - print("\nFinished updating pack!") + print("\nFinished installing mods!") # Using the latest urls, update downloads.txt to match the urls and have the correct sha1 def apply_updates(): - print("Reading update file...") + print("Populating downloads.txt...") mods = read_file("latest-urls.txt") - print("Downloading new versions of all mods...") + print("Getting new versions of all mods...") 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]}...") + print(f"Fetching {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!") + print("\nDone!\nUpdates applied to downloads.txt") + print("[!] No mods were installed. To update your mods folder, run 'update.py install'") # Find if any updates are available def check_updates(): - print("Reading update files...") + print("check_updates: Checking for updates to mods...") latest = read_file("latest-urls.txt") old = read_file("downloads.txt") old_urls = [mod[2] for mod in old] @@ -78,14 +79,19 @@ def read_file(fil): if len(sys.argv) < 2: - print(f"Usage: {sys.argv[0]} <apply_updates|find_updates>") - sys.exit(-1) + #install by default + install() elif sys.argv[1] == 'install': install() elif sys.argv[1] == 'apply_updates': apply_updates() elif sys.argv[1] == 'check_updates': check_updates() +elif 'h' in sys.argv[1]: + print(f"Usage: {sys.argv[0]} <install|apply_updates|check_updates>") + print(" install\tdownloads mods listed in downloads.txt and populates the mods folder specified in pack-location.txt") + print(" apply_updates\tusing the latest downloads in latest-urls.txt, repopulates downloads.txt to reflect the most recent mod versions") + print(" check_updates\tcompares downloads.txt and latest-urls.txt to see if any mods can be updated") else: print(f"Usage: {sys.argv[0]} <install|apply_updates|check_updates>") sys.exit(-1) |