diff --git a/TODO.md b/TODO.md index 09db01c..c01f01a 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,5 @@ # TODO - [x] assets downloader +- [x] library parser - [ ] library downloader diff --git a/utils/version-parser/.gitignore b/utils/version-parser/.gitignore new file mode 100644 index 0000000..a6c57f5 --- /dev/null +++ b/utils/version-parser/.gitignore @@ -0,0 +1 @@ +*.json diff --git a/utils/version-parser/parser.py b/utils/version-parser/parser.py new file mode 100755 index 0000000..dd9aa12 --- /dev/null +++ b/utils/version-parser/parser.py @@ -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']) diff --git a/utils/version-parser/pyproject.toml b/utils/version-parser/pyproject.toml new file mode 100644 index 0000000..cb70edc --- /dev/null +++ b/utils/version-parser/pyproject.toml @@ -0,0 +1,3 @@ +[tool.black] +skip-string-normalization = true +line-length = 100