summaryrefslogtreecommitdiff
path: root/libmat2/__init__.py
diff options
context:
space:
mode:
authorjvoisin2018-10-18 19:19:56 +0200
committerjvoisin2018-10-22 12:58:01 +0200
commite70ea811c99c16f3382c08153eda573df0825536 (patch)
treef1c05ca94b9d2ab09f74cfa6c7191bf73bf104e2 /libmat2/__init__.py
parent2ae5d909c3e30c009bfc45bceba96ddd82f3e198 (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__.py18
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
3import os
4import collections 3import collections
5import enum 4import enum
6import importlib 5import importlib
7from typing import Dict, Optional 6from typing import Dict, Optional
8 7
8from . import exiftool, video
9
9# make pyflakes happy 10# make pyflakes happy
10assert Dict 11assert Dict
11assert Optional 12assert Optional
@@ -37,24 +38,13 @@ DEPENDENCIES = {
37 'mutagen': 'Mutagen', 38 'mutagen': 'Mutagen',
38 } 39 }
39 40
40def _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
54def check_dependencies() -> dict: 43def 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