From 1a783ddec9de6019ee727458250ed4ea7e3463c2 Mon Sep 17 00:00:00 2001 From: Simon Conseil Date: Tue, 28 Apr 2015 00:18:29 +0200 Subject: [PATCH] Small cleanup. --- sigal/utils.py | 14 +++++++++----- sigal/video.py | 5 +++-- tests/test_gallery.py | 1 - 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sigal/utils.py b/sigal/utils.py index 604cd4e..a05ad5d 100644 --- a/sigal/utils.py +++ b/sigal/utils.py @@ -28,6 +28,10 @@ from subprocess import Popen, PIPE from . import compat +VIDEO_MIMES = {'.mp4': 'video/mp4', + '.webm': 'video/webm', + '.ogv': 'video/ogg'} + class Devnull(object): """'Black hole' for output that should not be printed""" @@ -99,16 +103,16 @@ def call_subprocess(cmd): stdout = stdout.decode('utf8') return p.returncode, stdout, stderr + def is_valid_html5_video(ext): """Checks if ext is a supported HTML5 video.""" - return ext in ('.mp4', '.webm', '.ogv') + return ext in VIDEO_MIMES.keys() + def get_mime(ext): """Returns mime type for extension.""" - mimes = {'.mp4': 'video/mp4', - '.webm': 'video/webm', - '.ogv': 'video/ogg'} - return mimes[ext] + return VIDEO_MIMES[ext] + class cached_property(object): """ A property that is only computed once per instance and then replaces diff --git a/sigal/video.py b/sigal/video.py index 0193824..0d7aed3 100644 --- a/sigal/video.py +++ b/sigal/video.py @@ -166,8 +166,9 @@ def process_video(filepath, outpath, settings): thumb_name = os.path.join(outpath, get_thumb(settings, filename)) try: generate_thumbnail( - outname, thumb_name, settings['thumb_size'], settings['thumb_video_delay'], - fit=settings['thumb_fit'], options=settings['jpg_options']) + outname, thumb_name, settings['thumb_size'], + settings['thumb_video_delay'], fit=settings['thumb_fit'], + options=settings['jpg_options']) except Exception: return Status.FAILURE diff --git a/tests/test_gallery.py b/tests/test_gallery.py index 759fcfa..559f0c9 100644 --- a/tests/test_gallery.py +++ b/tests/test_gallery.py @@ -114,7 +114,6 @@ def test_image(settings, tmpdir): def test_video(settings, tmpdir): settings['destination'] = str(tmpdir) - settings['use_orig'] = False m = Video('stallman software-freedom-day-low.ogv', 'video', settings) file_path = join('video', 'stallman software-freedom-day-low.webm') assert str(m) == file_path