Skip to content

Commit b0ad0a5

Browse files
committed
first message
0 parents  commit b0ad0a5

6 files changed

Lines changed: 135 additions & 0 deletions

File tree

.github/workflows/regenerate.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Regenerate PluginMaster
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
jobs:
9+
generate:
10+
name: Regenerate PluginMaster
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/setup-python@v4
14+
with:
15+
python-version: '3.8'
16+
- uses: actions/checkout@v3
17+
- name: Generate PluginMaster
18+
run: python generate_pluginmaster.py
19+
- uses: EndBug/add-and-commit@v9
20+
with:
21+
author_name: GitHub Action
22+
author_email: github-actions[bot]@users.noreply.github.com
23+
message: Regenerate PluginMaster

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://raw.githubusercontent.com/HaySome22/Repository/master/pluginmaster.json

generate_pluginmaster.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import json
2+
import os
3+
from time import time
4+
from sys import argv
5+
from os.path import getmtime
6+
from zipfile import ZipFile, ZIP_DEFLATED
7+
8+
DOWNLOAD_URL = 'https://github.com/HaySome22/Repository/raw/master/plugins/{plugin_name}/latest.zip'
9+
10+
DEFAULTS = {
11+
'IsHide': False,
12+
'IsTestingExclusive': False,
13+
'ApplicableVersion': 'any',
14+
}
15+
16+
DUPLICATES = {
17+
'DownloadLinkInstall': ['DownloadLinkTesting', 'DownloadLinkUpdate'],
18+
}
19+
20+
TRIMMED_KEYS = [
21+
'Author',
22+
'Name',
23+
'Description',
24+
'InternalName',
25+
'AssemblyVersion',
26+
'RepoUrl',
27+
'ApplicableVersion',
28+
'Tags',
29+
'DalamudApiLevel',
30+
'IsTestingExclusive',
31+
'IconUrl',
32+
]
33+
34+
def main():
35+
# extract the manifests from inside the zip files
36+
master = extract_manifests()
37+
38+
# trim the manifests
39+
master = [trim_manifest(manifest) for manifest in master]
40+
41+
# convert the list of manifests into a master list
42+
add_extra_fields(master)
43+
44+
# update the LastUpdated field in master
45+
last_updated(master)
46+
47+
# write the master
48+
write_master(master)
49+
50+
def extract_manifests():
51+
manifests = []
52+
53+
for dirpath, dirnames, filenames in os.walk('./plugins'):
54+
if len(filenames) == 0 or 'latest.zip' not in filenames:
55+
continue
56+
plugin_name = dirpath.split('/')[-1]
57+
latest_zip = f'{dirpath}/latest.zip'
58+
print(f"plugin_name:{plugin_name}");
59+
with ZipFile(latest_zip) as z:
60+
manifest = json.loads(z.read(f'{plugin_name}.json').decode('utf-8'))
61+
manifests.append(manifest)
62+
return manifests
63+
64+
def add_extra_fields(manifests):
65+
for manifest in manifests:
66+
# generate the download link from the internal assembly name
67+
manifest['DownloadLinkInstall'] = DOWNLOAD_URL.format(plugin_name=manifest["InternalName"])
68+
# add default values if missing
69+
for k, v in DEFAULTS.items():
70+
if k not in manifest:
71+
manifest[k] = v
72+
# duplicate keys as specified in DUPLICATES
73+
for source, keys in DUPLICATES.items():
74+
for k in keys:
75+
if k not in manifest:
76+
manifest[k] = manifest[source]
77+
manifest['DownloadCount'] = 0
78+
79+
def write_master(master):
80+
# write as pretty json
81+
with open('pluginmaster.json', 'w') as f:
82+
json.dump(master, f, indent=4)
83+
84+
def trim_manifest(plugin):
85+
return {k: plugin[k] for k in TRIMMED_KEYS if k in plugin}
86+
87+
def last_updated(master):
88+
for plugin in master:
89+
latest = f'plugins/{plugin["InternalName"]}/latest.zip'
90+
modified = int(getmtime(latest))
91+
92+
if 'LastUpdated' not in plugin or modified != int(plugin['LastUpdated']):
93+
plugin['LastUpdated'] = str(modified)
94+
95+
if __name__ == '__main__':
96+
main()

pluginmaster.json

Whitespace-only changes.

plugins/YesTankYou/YesTankYou.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"Author": "",
3+
"Name": "YesTankYou",
4+
"InternalName": "YesTankYou",
5+
"AssemblyVersion": "7.2.0.5",
6+
"Description": "",
7+
"ApplicableVersion": "any",
8+
"DalamudApiLevel": 12,
9+
"LoadRequiredState": 0,
10+
"LoadSync": false,
11+
"CanUnloadAsync": false,
12+
"LoadPriority": 0,
13+
"Punchline": "",
14+
"AcceptsFeedback": true
15+
}

plugins/YesTankYou/latest.zip

559 KB
Binary file not shown.

0 commit comments

Comments
 (0)