files
ensure_path(pathIn, caller)
Utility function for other functions to make sure a path was passed to them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pathIn
|
PathLike
|
Supposed passed Path |
required |
caller
|
Any
|
Caller name used for the exception and error message |
required |
Source code in muxtools/utils/files.py
ensure_path_exists(pathIn, caller, allow_dir=False)
Utility function for other functions to make sure a path was passed to them and that it exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pathIn
|
PathLike | list[PathLike] | GlobSearch
|
Supposed passed Path |
required |
caller
|
Any
|
Caller name used for the exception and error message |
required |
Source code in muxtools/utils/files.py
find_tracks(file, name=None, lang=None, type=None, use_regex=True, reverse_lang=False, custom_condition=None)
Convenience function to find tracks with some conditions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file
|
PathLike
|
File to parse with MediaInfo. |
required |
name
|
str | None
|
Name to match, case insensitively. |
None
|
lang
|
str | None
|
Language to match. This can be any of the possible formats like English/eng/en and is case insensitive. |
None
|
type
|
TrackType | None
|
Track Type to search for. |
None
|
use_regex
|
bool
|
Use regex for the name search instead of checking for equality. |
True
|
reverse_lang
|
bool
|
If you want the |
False
|
custom_condition
|
Callable[[Track], bool] | None
|
Here you can pass any function to create your own conditions. (They have to return a bool) For example: custom_condition=lambda track: track.codec_id == "A_EAC3" |
None
|
Source code in muxtools/utils/files.py
get_absolute_track(file, track, type, caller=None, quiet_fail=False)
Finds the absolute track for a relative track number of a specific type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file
|
PathLike
|
String or pathlib based Path |
required |
track
|
int
|
Relative track number |
required |
type
|
TrackType
|
TrackType of the requested relative track |
required |
quiet_fail
|
bool
|
Raise an exception but don't print it before. Only used for internals. |
False
|
Source code in muxtools/utils/files.py
get_absolute_tracknum(file, track, type, caller=None)
Finds the absolute track number for a relative track number of a specific type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file
|
PathLike
|
String or pathlib based Path |
required |
track
|
int
|
Relative track number |
required |
type
|
TrackType
|
TrackType of the requested relative track |
required |
Source code in muxtools/utils/files.py
get_crc32(file)
Generates crc32 checksum for file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file
|
PathLike
|
Input file |
required |
Returns:
Type | Description |
---|---|
str
|
Checksum for file |
get_track_list(file, caller=None)
Makes a sanitized mediainfo track list
Source code in muxtools/utils/files.py
uniquify_path(path)
Extends path to not conflict with existing files
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file
|
Input file |
required |
Returns:
Type | Description |
---|---|
str
|
Unique path |