better manifest
This commit is contained in:
@@ -11,11 +11,24 @@ IMAGEDIR = os.path.abspath(IMAGEDIR)
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
exts = ('.jpg', '.jpeg', '.png', '.webp', '.gif')
|
exts = ('.jpg', '.jpeg', '.png', '.webp', '.gif')
|
||||||
files = [f for f in sorted(os.listdir(IMAGEDIR)) if f.lower().endswith(exts)]
|
|
||||||
|
files = [
|
||||||
|
f for f in os.listdir(IMAGEDIR)
|
||||||
|
if f.lower().endswith(exts)
|
||||||
|
]
|
||||||
|
|
||||||
|
# Newest images first
|
||||||
|
files.sort(
|
||||||
|
key=lambda f: os.path.getctime(os.path.join(IMAGEDIR, f)),
|
||||||
|
reverse=True
|
||||||
|
)
|
||||||
|
|
||||||
out = os.path.join(IMAGEDIR, 'manifest.json')
|
out = os.path.join(IMAGEDIR, 'manifest.json')
|
||||||
|
|
||||||
with open(out, 'w', encoding='utf-8') as fh:
|
with open(out, 'w', encoding='utf-8') as fh:
|
||||||
json.dump(files, fh, indent=2)
|
json.dump(files, fh, indent=2)
|
||||||
|
|
||||||
print(f'Wrote {len(files)} entries to {out}')
|
print(f'Wrote {len(files)} entries to {out}')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
Reference in New Issue
Block a user