⚙️ autopyvideothumbnailer: take cli argument for the dirs to search
This commit is contained in:
parent
a53fa548ef
commit
3872b5ed0d
1 changed files with 13 additions and 3 deletions
|
@ -6,6 +6,7 @@
|
||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import click
|
||||||
|
|
||||||
from pymediainfo import MediaInfo
|
from pymediainfo import MediaInfo
|
||||||
|
|
||||||
|
@ -58,10 +59,9 @@ def call_thumbnailer(video_file, width, rows, *, skip_seconds=10):
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def process(searchdir):
|
||||||
def main():
|
|
||||||
VIDEO_FILE_EXT = [".mp4", ".mkv", ".avi", ".mov", ".wmv"]
|
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:
|
for video_file in video_files:
|
||||||
# Skip if .jpg file already exists
|
# Skip if .jpg file already exists
|
||||||
|
@ -90,5 +90,15 @@ def main():
|
||||||
print(f"Error for {video_file}: {e}")
|
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__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
Loading…
Add table
Add a link
Reference in a new issue