Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
SnoutBug authored Mar 6, 2022
1 parent 36d3a10 commit 2304d49
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions auto_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')

0 comments on commit 2304d49

Please sign in to comment.