diff --git a/server/generate-thumb b/server/generate-thumb deleted file mode 100755 index 87d7e02..0000000 --- a/server/generate-thumb +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python3 - -''' -Generates thumbnails for posts from CLI. Useful for testing changes to -thumbnail generators, and for weird inputs. -''' - -import argparse -import os.path -import sys -from szurubooru.func import posts - -def main(): - parser = argparse.ArgumentParser('Starts szurubooru using waitress.') - parser.add_argument('post_id', metavar='POST', help='post to generate thumbnail for') - args = parser.parse_args() - - try: - post = posts.get_post_by_id(args.post_id) - posts.generate_post_thumbnail(post) - except posts.PostNotFoundError: - pass - except: - raise - -if __name__ == '__main__': - main() diff --git a/server/recheck-post-audio b/server/recheck-post-audio new file mode 100755 index 0000000..c7200d3 --- /dev/null +++ b/server/recheck-post-audio @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +''' +Checks post audio and list disrepancies between the content and flags. +''' + +from szurubooru import db, model, errors +from szurubooru.func import files, images +from szurubooru.func import posts as postfuncs + +def main(): + post_list = (db.session + .query(model.Post) + .filter(model.Post.type == model.Post.TYPE_VIDEO) + .order_by(model.Post.post_id) + .all()) + + for post in post_list: + print('Checking post %d ...' % post.post_id, end='\r') + content = files.get(postfuncs.get_post_content_path(post)) + + has_existing_flag = model.Post.FLAG_SOUND in post.flags + try: + has_sound_data = images.Image(content).check_for_sound() + except errors.ProcessingError: + print('Post %d caused an error when checking for sound' % post.post_id) + + if has_sound_data and not has_existing_flag: + print('Post %d has sound data but is not flagged' % post.post_id) + if not has_sound_data and has_existing_flag: + print('Post %d has no sound data but is flagged' % post.post_id) + + +if __name__ == '__main__': + main() diff --git a/server/szurubooru/func/images.py b/server/szurubooru/func/images.py index 6e88ab4..1a96dcc 100644 --- a/server/szurubooru/func/images.py +++ b/server/szurubooru/func/images.py @@ -164,8 +164,9 @@ class Image: '-y', '/dev/null', ], get_logs=True).decode('utf-8', errors='replace') log_match = re.search(r'.*volumedetect.*mean_volume: (.*) dB', log) - assert log_match - assert log_match.groups() + if not log_match or not log_match.groups(): + raise errors.ProcessingError( + 'A problem occured when trying to check for audio') meanvol = float(log_match.groups()[0]) # -91.0 dB is the minimum for 16-bit audio, assume sound if > -80.0 dB