summaryrefslogtreecommitdiff
path: root/server/szuru-admin
diff options
context:
space:
mode:
authorHunternif <hunternif@gmail.com>2025-02-15 18:12:57 +0000
committerHunternif <hunternif@gmail.com>2025-02-15 18:12:57 +0000
commit6a5300502df8b4de9c8f269b444cd309f02b28ad (patch)
tree0cf2ba56bce802c94ad324f9eda7a31d37a42e2e /server/szuru-admin
parent34e7c883808738871aed371948a3c9896a95905c (diff)
parent376f687c386f65522b2f65e98b998b21af26ee29 (diff)
Merge branch 'master' into hunternif
Diffstat (limited to 'server/szuru-admin')
-rwxr-xr-xserver/szuru-admin17
1 files changed, 17 insertions, 0 deletions
diff --git a/server/szuru-admin b/server/szuru-admin
index 004a751..08ba182 100755
--- a/server/szuru-admin
+++ b/server/szuru-admin
@@ -91,6 +91,15 @@ def reset_filenames() -> None:
rename_in_dir("posts/custom-thumbnails/")
+def regenerate_thumbnails() -> None:
+ for post in db.session.query(model.Post).all():
+ print("Generating tumbnail for post %d ..." % post.post_id, end="\r")
+ try:
+ postfuncs.generate_post_thumbnail(post)
+ except Exception:
+ pass
+
+
def main() -> None:
parser_top = ArgumentParser(
description="Collection of CLI commands for an administrator to use",
@@ -114,6 +123,12 @@ def main() -> None:
help="reset and rename the content and thumbnail "
"filenames in case of a lost/changed secret key",
)
+ parser.add_argument(
+ "--regenerate-thumbnails",
+ action="store_true",
+ help="regenerate the thumbnails for posts if the "
+ "thumbnail files are missing",
+ )
command = parser_top.parse_args()
try:
@@ -123,6 +138,8 @@ def main() -> None:
check_audio()
elif command.reset_filenames:
reset_filenames()
+ elif command.regenerate_thumbnails:
+ regenerate_thumbnails()
except errors.BaseError as e:
print(e, file=stderr)