From 6d6d4113b9cbad1657f86fa86d5b02fef48ec627 Mon Sep 17 00:00:00 2001 From: Javier Oramas Date: Sat, 12 Sep 2020 19:12:18 -0400 Subject: [PATCH 1/2] add ignore path or file and ignore file extension --- video_diet/main.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/video_diet/main.py b/video_diet/main.py index c3082c7..ef8e145 100644 --- a/video_diet/main.py +++ b/video_diet/main.py @@ -28,6 +28,15 @@ def folder(path: Path = typer.Argument( dir_okay=True, readable=True, resolve_path=True +), ignore_extension: str = typer.Option( + default=None +), ignore_path: Path = typer.Option( + default=None, + exists=True, + file_okay=True, + dir_okay=True, + readable=True, + resolve_path=True )): """ Convert all videos in a folder @@ -38,10 +47,16 @@ def folder(path: Path = typer.Argument( for dir, folders, files in os.walk(path): base_dir = Path(dir) for file in files: + file = base_dir / file guess = filetype.guess(str(file)) if guess and 'video' in guess.mime: + + if (not (ignore_extension == None) and str(file).lower().endswith(ignore_extension)) or (not (ignore_path == None) and str(ignore_path) in str(file)) : + typer.secho(f'ignoring: {file}') + continue + videos.append(file) manager = enlighten.get_manager() From 370a3c6d8f78b2e92b5c93992d68e6e872df864a Mon Sep 17 00:00:00 2001 From: Javier Oramas Date: Sat, 12 Sep 2020 19:18:58 -0400 Subject: [PATCH 2/2] updated readme and contributors --- CONTRIBUTING.md | 1 + README.md | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0ad7d0a..3ebf911 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,6 +4,7 @@ * Leynier Gutiérrez González ([@leynier](https://github.com/leynier)) * Hian Cañizares Díaz ([@hiancdtrsnm](https://github.com/hiancdtrsnm)) +* Javier A. Oramas López ([@JavierOramas](https://github.com/javieroramas)) You can help out by: diff --git a/README.md b/README.md index 908bea6..0697bc0 100644 --- a/README.md +++ b/README.md @@ -56,12 +56,23 @@ video-diet file test.mp4 ``` This option conserve the original file -## For a folder +### For a folder ```bash video-diet folder ~/Videos ``` This option replaces the original file for the converted files +#### Ignoring files on the folder +```bash +video-diet folder ~/Videos --ignore-extension .mp4 +``` +This option ignores all the .mp4 files on ~/Videos + +```bash +video-diet folder ~/Videos --ignore-path ~/Videos/subfolder +``` +This option ignores all the files on ~/Videos/subfolder + ## Note The video conversion can take some time. Depending on the original video properties; the conversion time can be longer than the video.