fix: use LastUpdate instead of LastUpdated

This commit is contained in:
Anna 2022-02-03 11:40:15 -05:00
parent 43ee44c9f6
commit 7a7fcd823a
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
3 changed files with 21 additions and 11 deletions

View File

@ -1,6 +1,7 @@
import yaml
import json
import os
from datetime import datetime
from time import time
from sys import argv
from os.path import getmtime
@ -51,8 +52,8 @@ def main():
# write the master
write_master(info, master)
# update the LastUpdated field in master
last_updated(info)
# update the LastUpdate field in master
last_update(info)
def extract_manifests(info):
manifests = []
@ -90,16 +91,25 @@ def write_master(info, master):
def trim_manifest(plugin):
return {k: plugin[k] for k in TRIMMED_KEYS if k in plugin}
def last_updated(info):
def last_update(info):
with open(info['master_name']) as f:
master = json.load(f)
for plugin in master:
latest = f'{info["plugins_dir"]}/{plugin["InternalName"]}/latest.zip'
modified = int(getmtime(latest))
if 'LastUpdated' not in plugin or modified != int(plugin['LastUpdated']):
plugin['LastUpdated'] = str(modified)
modified = 0
with ZipFile(latest) as z:
for zip_info in z.infolist():
info_mod = datetime(*zip_info.date_time).timestamp()
if info_mod > modified:
modified = int(info_mod)
if info_mod == datetime(1970, 1, 1):
modified = int(getmtime(latest))
if 'LastUpdate' not in plugin or modified != int(plugin['LastUpdate']):
plugin['LastUpdate'] = str(modified)
with open(info['master_name'], 'w') as f:
json.dump(master, f, indent=4)

View File

@ -14,7 +14,7 @@
"IsTestingExclusive": false,
"DownloadLinkTesting": "https://git.sr.ht/~jkcclemens/plugin_repo/blob/main/plugins/ChatTwo/latest.zip",
"DownloadLinkUpdate": "https://git.sr.ht/~jkcclemens/plugin_repo/blob/main/plugins/ChatTwo/latest.zip",
"LastUpdated": "1643750754"
"LastUpdate": "1643750752"
},
{
"Author": "ascclemens",
@ -30,6 +30,6 @@
"IsTestingExclusive": false,
"DownloadLinkTesting": "https://git.sr.ht/~jkcclemens/plugin_repo/blob/main/plugins/NominaOcculta/latest.zip",
"DownloadLinkUpdate": "https://git.sr.ht/~jkcclemens/plugin_repo/blob/main/plugins/NominaOcculta/latest.zip",
"LastUpdated": "1642020965"
"LastUpdate": "1642038964"
}
]

View File

@ -12,7 +12,7 @@
"IsTestingExclusive": false,
"DownloadLinkTesting": "https://git.sr.ht/~jkcclemens/plugin_repo/blob/main/unofficial/DalamudPython/latest.zip",
"DownloadLinkUpdate": "https://git.sr.ht/~jkcclemens/plugin_repo/blob/main/unofficial/DalamudPython/latest.zip",
"LastUpdated": "1641412908"
"LastUpdate": "1641412906"
},
{
"Author": "ascclemens",
@ -28,7 +28,7 @@
"IsTestingExclusive": false,
"DownloadLinkTesting": "https://git.sr.ht/~jkcclemens/plugin_repo/blob/main/unofficial/Macrology/latest.zip",
"DownloadLinkUpdate": "https://git.sr.ht/~jkcclemens/plugin_repo/blob/main/unofficial/Macrology/latest.zip",
"LastUpdated": "1641412754"
"LastUpdate": "1641412754"
},
{
"Author": "ascclemens",
@ -44,6 +44,6 @@
"IsTestingExclusive": false,
"DownloadLinkTesting": "https://git.sr.ht/~jkcclemens/plugin_repo/blob/main/unofficial/RoleplayersToolbox/latest.zip",
"DownloadLinkUpdate": "https://git.sr.ht/~jkcclemens/plugin_repo/blob/main/unofficial/RoleplayersToolbox/latest.zip",
"LastUpdated": "1641412669"
"LastUpdate": "1641412668"
}
]