forked from xjasonlyu/jellyfin-plugin-avdc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.py
43 lines (32 loc) · 1.01 KB
/
package.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
39
40
41
42
43
import hashlib
import json
import sys
from datetime import datetime
def md5sum(filename):
with open(filename, 'rb') as f:
return hashlib.md5(f.read()).hexdigest()
def generate(filename, version):
return {
"checksum": md5sum(filename),
"changelog": "Auto Released by Actions",
"targetAbi": "10.7.0.0",
"sourceUrl": "https://github.com/xjasonlyu/jellyfin-plugin-avdc/releases/download/"
f"v{version}/Jellyfin.AVDC@v{version}.zip",
"timestamp": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"),
"version": version
}
def main():
filename = sys.argv[1]
version = filename.split('@', maxsplit=1)[1] \
.removeprefix('v') \
.removesuffix('.zip')
with open('manifest.json') as f:
manifest = json.load(f)
manifest[0]['versions'].insert(
0,
generate(filename, version)
)
with open('manifest.json', 'w') as f:
json.dump(manifest, f, indent=2)
if __name__ == '__main__':
main()