upsies.utils.mediainfo
Modules
Subtitles information |
|
Functions
- upsies.utils.mediainfo.get_container_format(path, default=<object object>)[source]
Return container format as
stror None if detection failsFor files, this is the most commonly used file extension in lowercase.
For DVD/Blu-ray trees, return
VIDEO_TSorBDMV.- Parameters:
path (str) –
Path to video file
For directories, the return value of
find_main_video()is used.default – Return value if path doesn’t exist, raise
ContentErrorif not provided
- Raises:
ContentError – if anything goes wrong
- upsies.utils.mediainfo.get_duration(path, default=<object object>)[source]
Return video duration in seconds (float)
- Parameters:
path (str) –
Path to video file
For directories, the return value of
find_main_video()is used.default – Return value if path doesn’t exist, raise
ContentErrorif not provided
- Raises:
ContentError – if anything goes wrong
- upsies.utils.mediainfo.get_duration_from_ffprobe(path, default=<object object>)[source]
Return video duration in seconds (float) from
ffprobe- Parameters:
path (str) –
Path to video file or directory
For directories, the return value of
find_main_video()is used.default – Return value if path doesn’t exist, raise
ContentErrorif not provided
- Raises:
ContentError – if anything goes wrong
- upsies.utils.mediainfo.get_duration_from_mediainfo(path, default=<object object>)[source]
Return video duration in seconds (float) from
mediainfo- Parameters:
path (str) –
Path to video file
For directories, the return value of
find_main_video()is used.default – Return value if path doesn’t exist, raise
ContentErrorif not provided
- Raises:
ContentError – if anything goes wrong
- upsies.utils.mediainfo.get_mediainfo_report(path)[source]
mediainfooutput as a stringThe parent directory of path is redacted.
- Parameters:
path (str) –
Path to video file or directory
For directories, the return value of
find_main_video()is used.- Raises:
ContentError – if anything goes wrong
- upsies.utils.mediainfo.get_tracks(path, default=<object object>)[source]
mediainfo --Output=JSONas dictionary that maps each track’s@typeto a list of track dictionaries- Parameters:
path (str) –
Path to video file or directory
For directories, the return value of
find_main_video()is used.default – Return value if path doesn’t exist, raise
ContentErrorif not provided
- Raises:
ContentError – if anything goes wrong
- upsies.utils.mediainfo.lookup(path, keys, type=None, default=<object object>)[source]
Return nested value from
get_tracks()- Parameters:
path (str) –
Path to video file
For directories, the return value of
find_main_video()is used.keys – Iterable of nested keys/indexes in the return value of
get_tracks()type –
Callable that takes a
strvalue from the tracks returned byget_tracks()and returns a desired type (e.g.int)Note
The default value is not converted with type and returned as is.
default – Return value if path doesn’t exist, raise
ValueErrorif not provided
For example, (“Audio”, 0, “Language”) returns the language of the first audio track. If no language is defined return default or raise
ContentErrorif default is not provided.In lists, instead of an index, you can use
"DEFAULT"to find the default track in that list, e.g. (“Audio”, “DEFAULT”, “Language”) returns the language of the default audio track. The default track is either marked specifically as such in the container or, if no track is marked, the first track is used.Any exception from type will bubble up and must be caught by the caller.
- Raises:
ContentError – if path does not exist or if keys does not resolve to a value and default is not provided.