version parser

This commit is contained in:
Alexander Popov 2024-03-31 17:57:49 +03:00
parent 9b2fdfda39
commit 219cae9a82
Signed by: iiiypuk
GPG Key ID: E47FE0AB36CD5ED6
4 changed files with 35 additions and 0 deletions

View File

@ -1,4 +1,5 @@
# TODO
- [x] assets downloader
- [x] library parser
- [ ] library downloader

1
utils/version-parser/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.json

30
utils/version-parser/parser.py Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env python3
import sys
import json
TYPE = 'linux'
# TYPE='windows'
# TYPE='macos'
if __name__ == '__main__':
if len(sys.argv) < 2:
print('add file')
exit(-1)
else:
version_file = sys.argv[1]
with open(version_file, 'r') as f:
a = json.loads(f.read())
print('Game ID: {0}'.format(a['id']))
print('Main class: {0}'.format(a['mainClass']))
print('Assets index: {0}'.format(a['assetIndex']['id']))
for library in a['libraries']:
if 'rules' in library:
if 'os' in library['rules'][0]:
if TYPE == library['rules'][0]['os']['name']:
print(library['downloads']['artifact']['path'])
else:
print(library['downloads']['artifact']['path'])

View File

@ -0,0 +1,3 @@
[tool.black]
skip-string-normalization = true
line-length = 100