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 43e00ab..123646a 100644 --- a/README.md +++ b/README.md @@ -60,12 +60,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. 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()