Browse Source

pre-commit - update and run

pull/492/head
Simon Conseil 3 years ago
parent
commit
7b0fee1eec
  1. 4
      .pre-commit-config.yaml
  2. 2
      src/sigal/gallery.py
  3. 19
      src/sigal/video.py

4
.pre-commit-config.yaml

@ -17,12 +17,12 @@ repos:
args: ["--py38-plus"]
- repo: https://github.com/timothycrosley/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black

2
src/sigal/gallery.py

@ -181,7 +181,7 @@ class Media:
converter=s['video_converter'],
black_retries=s['thumb_video_black_retries'],
black_offset=s['thumb_video_black_retry_offset'],
black_max_colors=s['thumb_video_black_max_colors']
black_max_colors=s['thumb_video_black_max_colors'],
)
except Exception as e:
self.logger.error('Failed to generate thumbnail: %s', e)

19
src/sigal/video.py

@ -174,7 +174,16 @@ def generate_video(source, outname, settings):
def generate_thumbnail(
source, outname, box, delay, fit=True, options=None, converter="ffmpeg", black_retries=0, black_offset=1, black_max_colors=4
source,
outname,
box,
delay,
fit=True,
options=None,
converter="ffmpeg",
black_retries=0,
black_offset=1,
black_max_colors=4,
):
"""Create a thumbnail image for the video source, based on ffmpeg."""
logger = logging.getLogger(__name__)
@ -192,10 +201,12 @@ def generate_thumbnail(
img = PILImage.open(tmpfile)
colors = img.getcolors(maxcolors=black_max_colors)
if colors is None:
# There were more colors than maxcolors in the image, it looks suitable for a valid thumbnail
# There were more colors than maxcolors in the image, it
# looks suitable for a valid thumbnail
break
else:
# Only found 'maxcolors' unique colors, looks like a solid color, try again with another seek delay
# Only found 'maxcolors' unique colors, looks like a solid
# color, try again with another seek delay
currentTry += 1
iDelay += abs(black_offset)
else:
@ -247,7 +258,7 @@ def process_video(media):
converter=settings["video_converter"],
black_retries=settings['thumb_video_black_retries'],
black_offset=settings['thumb_video_black_retry_offset'],
black_max_colors=settings['thumb_video_black_max_colors']
black_max_colors=settings['thumb_video_black_max_colors'],
)
return status.value

Loading…
Cancel
Save