diff options
author | Antoine Beaupré <anarcat@debian.org> | 2017-12-30 12:18:30 -0500 |
---|---|---|
committer | Antoine Beaupré <anarcat@debian.org> | 2017-12-30 12:18:30 -0500 |
commit | 88c8bd4cd2ee4707f8a43be4d89c4e040dcced2f (patch) | |
tree | 01b10a0d80509730942706333f173c5aa7f239eb /raphodo/metadatavideo.py | |
parent | c5fc6c6030d7d9d1b2af3d5165bebed3decd741b (diff) |
New upstream version 0.9.6upstream/0.9.6
Diffstat (limited to 'raphodo/metadatavideo.py')
-rwxr-xr-x | raphodo/metadatavideo.py | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/raphodo/metadatavideo.py b/raphodo/metadatavideo.py index 4af2d92..efa17fc 100755 --- a/raphodo/metadatavideo.py +++ b/raphodo/metadatavideo.py @@ -34,23 +34,44 @@ from raphodo.utilities import datetime_roughly_equal try: import pymediainfo have_pymediainfo = True + pymedia_library_file = 'libmediainfo.so.0' except ImportError: have_pymediainfo = False libmediainfo_missing = None if have_pymediainfo: + libmediainfo_missing = False try: - # Attempt to parse null... it will fail if libmediainfo is not present, which is - # what we want to check - pymediainfo.MediaInfo.parse('/dev/null') - libmediainfo_missing = False - except OSError: - have_pymediainfo = False - libmediainfo_missing = True + if not pymediainfo.MediaInfo.can_parse(library_file=pymedia_library_file): + # attempt to work around MediaInfoLib issue #695: + # 'SONAME is different when compiling with CMake and autotools' + pymedia_library_file = 'libmediainfo.so.17' + if not pymediainfo.MediaInfo.can_parse(library_file=pymedia_library_file): + have_pymediainfo = False + libmediainfo_missing = True + except TypeError: + # older versions of pymediainfo do not have the library_file option + pymedia_library_file = None + if not pymediainfo.MediaInfo.can_parse(): + have_pymediainfo = False + libmediainfo_missing = True + except AttributeError: + try: + # Attempt to parse null... it will fail if libmediainfo is not present, which is + # what we want to check + pymediainfo.MediaInfo.parse('/dev/null') + except OSError: + have_pymediainfo = False + libmediainfo_missing = True + pymedia_library_file = None + def pymedia_version_info() -> Optional[str]: if have_pymediainfo: - return pymediainfo.__version__ + if pymedia_library_file == 'libmediainfo.so.0': + return pymediainfo.__version__ + else: + return '{} (using {})'.format(pymediainfo.__version__, pymedia_library_file) else: return None @@ -72,8 +93,14 @@ class MetaData: self.metadata_string_format = dict() self.et_process = et_process if have_pymediainfo: - self.media_info = pymediainfo.MediaInfo.parse( - full_file_name) # type: pymediainfo.MediaInfo + if pymedia_library_file is not None: + self.media_info = pymediainfo.MediaInfo.parse( + filename=full_file_name, library_file=pymedia_library_file + ) # type: pymediainfo.MediaInfo + else: + self.media_info = pymediainfo.MediaInfo.parse( + filename=full_file_name + ) # type: pymediainfo.MediaInfo else: self.media_info = None |