summaryrefslogtreecommitdiff
path: root/server/szuru-admin
diff options
context:
space:
mode:
authorShyam Sunder <sgsunder1@gmail.com>2022-03-30 23:04:16 -0400
committerShyam Sunder <sgsunder1@gmail.com>2022-03-30 23:04:16 -0400
commit6088e89ea1258ddd7686370355ca2ce4a026f759 (patch)
tree2dff3924f539c98a763652fe5c15188fbcbcdb3d /server/szuru-admin
parent79d0efc25b42d5c750743bd9c0d6c0d18df8e147 (diff)
server/szuru-admin: Add thumbnail regeneration script
Closes #467
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)