Skip to content

Commit

Permalink
look for mediainfo bundled library
Browse files Browse the repository at this point in the history
  • Loading branch information
getzze committed Jul 17, 2024
1 parent 718a0b0 commit 7a09a9f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion knowit/providers/mediainfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,21 @@ def _execute(self, filename):

return json.loads(data) if data else {}

@staticmethod
def _get_bundled_paths(os_family=None):
"""Return a tuple with the paths of the library bundled with the pymediainfo package."""
os_is_nt = (os_family or detect_os()) == 'windows'
# Only return the absolute paths
return tuple(f for f in MediaInfo._get_library_paths(os_is_nt) if os.path.isfile(f))

@classmethod
def create(cls, os_family=None, suggested_path=None):
"""Create the executor instance."""
for candidate in define_candidate(cls.locations, cls.names, os_family, suggested_path):
candidates = (
*cls._get_bundled_paths(os_family),
*define_candidate(cls.locations, cls.names, os_family, suggested_path),
)
for candidate in candidates:
if MediaInfo.can_parse(candidate):
lib, handle, lib_version_str, lib_version = MediaInfo._get_library(candidate)
lib.MediaInfo_Option.argtypes = [c_void_p, c_wchar_p, c_wchar_p]
Expand Down

0 comments on commit 7a09a9f

Please sign in to comment.