forked from lovasoa/ophirofox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-manifest.py
executable file
·54 lines (40 loc) · 1.27 KB
/
update-manifest.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
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
import json
import sys
import urllib.request
from pathlib import Path
BASE = Path(__file__).parent
def get_extension_manifest():
with (BASE / "ophirofox" / "manifest.json").open('r') as f:
return json.load(f)
def get_github_releases():
url = "https://api.github.com/repos/lovasoa/ophirofox/releases"
return json.load(urllib.request.urlopen(url))
def version_details(release):
version = release["tag_name"][1:]
for asset in release["assets"]:
if asset["name"].endswith(".xpi"):
yield {
"version": version,
"update_link": asset["browser_download_url"],
"update_info_url": release["html_url"],
}
return
def update_manifest():
manifest = get_extension_manifest()
return {
"addons": {
manifest["browser_specific_settings"]["gecko"]["id"]: {
"updates": [
version
for release in get_github_releases()
for version in version_details(release)
if not release["draft"]
]
}
}
}
def main():
json.dump(obj=update_manifest(), fp=sys.stdout, indent=2)
if __name__ == "__main__":
main()