-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcat_asset_download_counts.py
38 lines (27 loc) · 1014 Bytes
/
cat_asset_download_counts.py
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
33
34
35
36
37
38
# -*- coding: utf-8 -*-
# Copyright 2021 UuuNyaa <[email protected]>
# This file is part of blender_mmd_assets.
import json
import sys
import requests
def list_asset_download_counts(session, repo):
response = session.get(f'https://api.github.com/repos/{repo}/releases')
response.raise_for_status()
releases = json.loads(response.text)
assets = []
for release in releases:
for asset in release['assets']:
assets.append({
'updated_at': asset['updated_at'],
'name': asset['name'],
'size': asset['size'],
'download_count': asset['download_count'],
})
return assets
if __name__ == '__main__':
if len(sys.argv) != 2:
print(f'ERROR: invalid arguments: {[a for a in sys.argv]}', file=sys.stderr)
exit(1)
repo = sys.argv[1]
session = requests.Session()
print(json.dumps(list(reversed(list_asset_download_counts(session, repo))), indent=2, ensure_ascii=False))