-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_index.py
More file actions
32 lines (27 loc) · 1.17 KB
/
update_index.py
File metadata and controls
32 lines (27 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import json
import subprocess
import os
from pprint import pprint
os.makedirs('addons', exist_ok=True)
addons = json.load(open('addons.json', 'r'))['addons']
for addon in addons:
api = 'https://api.github.com/repos'
owner = addon['repository']['owner']
name = addon['repository']['name']
release = addon['release']
s = subprocess.check_output(['curl', f'{api}/{owner}/{name}/releases/{release}']).decode('utf-8')
api_response = json.loads(s)
for asset in api_response['assets']:
browser_download_url = asset['browser_download_url']
subprocess.run(['curl', browser_download_url, '-L', '-O'])
# Generate the index.json file based on the archives we just downloaded.
subprocess.run(['blender', '--command', 'extension', 'server-generate', '--repo-dir=.'])
# Update the archive URL to point to the GitHub release.
with open('index.json', 'r') as fp:
data = json.load(fp)
for datum in data['data']:
archive_url = f'{datum['website']}/releases/download/{datum['version']}/{datum['archive_url']}'
datum['archive_url'] = archive_url
# Write the new index.json file.
with open('index.json', 'w') as fp:
json.dump(data, fp, indent=4)