-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_file_size.py
36 lines (31 loc) · 1021 Bytes
/
get_file_size.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
import json
import requests
# 请修改下面两行
url = 'https://github.com/radxa-build/rock-3c/releases/download/b36/rock-3c_debian_bullseye_cli_b36.img.xz'
date = '2023-08-03'
url = url.replace('github.com', 'gate.radxa.com')
ver = url[:-2] + 'sha512'
res = requests.head(url, allow_redirects=True)
length = res.headers.get('Content-Length')
name = url.split('/')[-1].split('.')[0]
_json = {
'id': name,
'name': name,
'size': int(length),
# 图片地址
'pic_url': "https://imager.radxa.com/image/debian.svg",
# desc 为描述
"desc": "This flavor is officially supported, tested, and recommended for all users." if 'cli' not in url else "This flavor is quite minimal and is intended for headless usage.",
'time': date,
'edit': True,
'edit_version': 1,
"hide": False,
"checksum_method": "sha512",
"checksum_file": "url",
"checksum_url": ver,
"extension": "xz",
"download_url": url,
# 排序
'sort': '0'
}
print(json.dumps(_json, indent=4))