Matching¶
With Yukine, you can select tracks from a video file by matching against a properties of a specific, or all tracks.
You’re also able to use multiple matchers to select tracks and the ability to use regex.
By default if you have multiple matchers, only one of them needs to match for the track to be selected.
You can change this behavior by setting strict=True option in MatchSettings.Enabling strict matching
match_settings = MatchSettings(strict=True)
A more detailed example would be this. It searches for the ffprobe key through muxtools.ParsedFile language with the value jpn and another key title with the value Commentary with regex enabled.
What this is doing is looking for a track where the language is Japanese and the title contains the word Commentary.
Since setting regex to True it’ll treat the value as a regex pattern, this means it’ll match any track where the title contains the word Commentary.
Finally, since strict is set to True, it’ll only select a track if both matchers match.
Note
When using a match, the track option is ignored. Any tracks that match will be selected.
You can use MatchSettings(single=True) to select only the first track that matches.
Example Match
match_settings = MatchSettings(strict=True)
match = [
MatchCondition(key="language", value="jpn"),
MatchCondition(key="title", value="Commentary", regex=True),
]
Matches will work on both SetAudioTrack and SetSubtitleTrack. You cannot use matches for Video tracks.