From 2304d490a5cb3020f674802ec6e58b9fe8fcb90a Mon Sep 17 00:00:00 2001 From: snoutie <71790678+SnoutBug@users.noreply.github.com> Date: Sun, 6 Mar 2022 16:09:18 +0100 Subject: [PATCH] Add files via upload --- auto_update.py | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/auto_update.py b/auto_update.py index 1973405..8c7809c 100644 --- a/auto_update.py +++ b/auto_update.py @@ -38,26 +38,31 @@ for tag in response: tags.append(str(tag['name'])) -print('Starting to update.\nYou can always cancel the download by pressing CTRL + C') - -for mod in repodb['mods']: - mod_id = str(repodb['mods'][mod]['modData'].get('resource_id')) - mod_title = str(repodb['mods'][mod]['modData'].get('title')) - if mod_id in tags: - print('Getting textures for ' + mod_title) - url = 'https://github.com/SnoutBug/BeamNG_terrainMaterialCache/releases/download/' + mod_id + '/main.tar.gz' - filename = mod_id + '.tar.gz' - urllib.request.urlretrieve(url, filename) - with tarfile.open(filename) as tar: - tar.extractall(cache) - os.remove(filename) +print('\n\nStarting to update.\nYou can always cancel the download by pressing CTRL + C') +print('\nLooking for modded maps...') + +try: + for mod in repodb['mods']: + mod_id = str(repodb['mods'][mod]['modData'].get('resource_id')) + mod_title = str(repodb['mods'][mod]['modData'].get('title')) + if mod_id in tags: + print('Getting textures for ' + mod_title) + url = 'https://github.com/SnoutBug/BeamNG_terrainMaterialCache/releases/download/' + mod_id + '/main.tar.gz' + filename = mod_id + '.tar.gz' + urllib.request.urlretrieve(url, filename) + with tarfile.open(filename) as tar: + tar.extractall(cache) + os.remove(filename) -url = 'https://github.com/SnoutBug/BeamNG_terrainMaterialCache/releases/download/default/' -for map in default: - print('Getting textures for ' + re.sub('\.tar.gz$', '', map)) - urllib.request.urlretrieve(url + map, map) - with tarfile.open(map) as tar: - tar.extractall(cache) - os.remove(map) + print('\nLooking for default maps...') + url = 'https://github.com/SnoutBug/BeamNG_terrainMaterialCache/releases/download/default/' + for map in default: + print('Getting textures for ' + re.sub('\.tar.gz$', '', map)) + urllib.request.urlretrieve(url + map, map) + with tarfile.open(map) as tar: + tar.extractall(cache) + os.remove(map) -print('All Done!') + print('All Done!') +except KeyboardInterrupt: + print('\nYou cancelled the download.')