From 3872b5ed0d06e8d47f6ac77f95ecb4c446b0ae1e Mon Sep 17 00:00:00 2001 From: neingeist Date: Mon, 14 Aug 2023 00:14:21 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20autopyvideothumbnailer:=20?= =?UTF-8?q?take=20cli=20argument=20for=20the=20dirs=20to=20search?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- make-video-thumbnails => autopyvideothumbnailer | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) rename make-video-thumbnails => autopyvideothumbnailer (88%) diff --git a/make-video-thumbnails b/autopyvideothumbnailer similarity index 88% rename from make-video-thumbnails rename to autopyvideothumbnailer index bfb55a5..67bc3df 100755 --- a/make-video-thumbnails +++ b/autopyvideothumbnailer @@ -6,6 +6,7 @@ import math import os import subprocess +import click from pymediainfo import MediaInfo @@ -58,10 +59,9 @@ def call_thumbnailer(video_file, width, rows, *, skip_seconds=10): ] ) - -def main(): +def process(searchdir): VIDEO_FILE_EXT = [".mp4", ".mkv", ".avi", ".mov", ".wmv"] - video_files = find_video_files(".", VIDEO_FILE_EXT) + video_files = find_video_files(searchdir, VIDEO_FILE_EXT) for video_file in video_files: # Skip if .jpg file already exists @@ -90,5 +90,15 @@ def main(): print(f"Error for {video_file}: {e}") +@click.command() +@click.argument('searchdirs', nargs=-1) +def main(searchdirs): + """Run pyvideothumbnailer for every video file found""" + if not searchdirs: + searchdirs=["."] + for searchdir in searchdirs: + process(searchdir) + + if __name__ == "__main__": main()