Skip to content

Commit

Permalink
Merge pull request #9 from JavierOramas/master
Browse files Browse the repository at this point in the history
Adding ignore option
  • Loading branch information
hiancdtrsnm authored Sep 12, 2020
2 parents 4427582 + 95112a0 commit a3470b5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions video_diet/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit a3470b5

Please sign in to comment.