diff --git a/generate_pluginmaster.py b/generate_pluginmaster.py index e49ab17..9e2966f 100644 --- a/generate_pluginmaster.py +++ b/generate_pluginmaster.py @@ -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) diff --git a/pluginmaster.json b/pluginmaster.json index 8d341c6..cdb67a8 100644 --- a/pluginmaster.json +++ b/pluginmaster.json @@ -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" } ] \ No newline at end of file diff --git a/unofficial.json b/unofficial.json index 7faf3aa..ad2f546 100644 --- a/unofficial.json +++ b/unofficial.json @@ -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" } ] \ No newline at end of file