server/tools: add script to check audio flags for posts
This commit is contained in:
parent
9329717335
commit
7a42c7a69b
3 changed files with 38 additions and 29 deletions
|
@ -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()
|
|
35
server/recheck-post-audio
Executable file
35
server/recheck-post-audio
Executable file
|
@ -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()
|
|
@ -164,8 +164,9 @@ class Image:
|
||||||
'-y', '/dev/null',
|
'-y', '/dev/null',
|
||||||
], get_logs=True).decode('utf-8', errors='replace')
|
], get_logs=True).decode('utf-8', errors='replace')
|
||||||
log_match = re.search(r'.*volumedetect.*mean_volume: (.*) dB', log)
|
log_match = re.search(r'.*volumedetect.*mean_volume: (.*) dB', log)
|
||||||
assert log_match
|
if not log_match or not log_match.groups():
|
||||||
assert log_match.groups()
|
raise errors.ProcessingError(
|
||||||
|
'A problem occured when trying to check for audio')
|
||||||
meanvol = float(log_match.groups()[0])
|
meanvol = float(log_match.groups()[0])
|
||||||
|
|
||||||
# -91.0 dB is the minimum for 16-bit audio, assume sound if > -80.0 dB
|
# -91.0 dB is the minimum for 16-bit audio, assume sound if > -80.0 dB
|
||||||
|
|
Loading…
Reference in a new issue