diff options
| author | jvoisin | 2018-10-18 19:19:56 +0200 |
|---|---|---|
| committer | jvoisin | 2018-10-22 12:58:01 +0200 |
| commit | e70ea811c99c16f3382c08153eda573df0825536 (patch) | |
| tree | f1c05ca94b9d2ab09f74cfa6c7191bf73bf104e2 /libmat2/__init__.py | |
| parent | 2ae5d909c3e30c009bfc45bceba96ddd82f3e198 (diff) | |
Implement support for .avi files, via ffmpeg
- This commit introduces optional dependencies (namely ffmpeg):
mat2 will spit a warning when trying to process an .avi file
if ffmpeg isn't installed.
- Since metadata are obtained via exiftool, this commit
also refactors a bit our exfitool wrapper.
Diffstat (limited to 'libmat2/__init__.py')
| -rw-r--r-- | libmat2/__init__.py | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/libmat2/__init__.py b/libmat2/__init__.py index f55a14c..399a364 100644 --- a/libmat2/__init__.py +++ b/libmat2/__init__.py | |||
| @@ -1,11 +1,12 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | 2 | ||
| 3 | import os | ||
| 4 | import collections | 3 | import collections |
| 5 | import enum | 4 | import enum |
| 6 | import importlib | 5 | import importlib |
| 7 | from typing import Dict, Optional | 6 | from typing import Dict, Optional |
| 8 | 7 | ||
| 8 | from . import exiftool, video | ||
| 9 | |||
| 9 | # make pyflakes happy | 10 | # make pyflakes happy |
| 10 | assert Dict | 11 | assert Dict |
| 11 | assert Optional | 12 | assert Optional |
| @@ -37,24 +38,13 @@ DEPENDENCIES = { | |||
| 37 | 'mutagen': 'Mutagen', | 38 | 'mutagen': 'Mutagen', |
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | def _get_exiftool_path() -> str: # pragma: no cover | ||
| 41 | exiftool_path = '/usr/bin/exiftool' | ||
| 42 | if os.path.isfile(exiftool_path): | ||
| 43 | if os.access(exiftool_path, os.X_OK): | ||
| 44 | return exiftool_path | ||
| 45 | |||
| 46 | # ArchLinux | ||
| 47 | exiftool_path = '/usr/bin/vendor_perl/exiftool' | ||
| 48 | if os.path.isfile(exiftool_path): | ||
| 49 | if os.access(exiftool_path, os.X_OK): | ||
| 50 | return exiftool_path | ||
| 51 | 41 | ||
| 52 | raise ValueError | ||
| 53 | 42 | ||
| 54 | def check_dependencies() -> dict: | 43 | def check_dependencies() -> dict: |
| 55 | ret = collections.defaultdict(bool) # type: Dict[str, bool] | 44 | ret = collections.defaultdict(bool) # type: Dict[str, bool] |
| 56 | 45 | ||
| 57 | ret['Exiftool'] = True if _get_exiftool_path() else False | 46 | ret['Exiftool'] = True if exiftool._get_exiftool_path() else False |
| 47 | ret['Ffmpeg'] = True if video._get_ffmpeg_path() else False | ||
| 58 | 48 | ||
| 59 | for key, value in DEPENDENCIES.items(): | 49 | for key, value in DEPENDENCIES.items(): |
| 60 | ret[value] = True | 50 | ret[value] = True |
