CogentRedTester / mpv-sub-select

An advanced conditional subtitle track selector for mpv player
MIT License
89 stars 8 forks source link

Add experimental option to select audio tracks. #17

Closed CogentRedTester closed 1 year ago

CogentRedTester commented 1 year ago

Add new experimental option to select audio tracks.

When this option is enabled then the script will go through the list of preferences, but instead of comparing the sub tracks against the current audio track it will compare it against all audio tracks. If any audio tracks match the alang and there are subs that match the slang and filters, then that audio track will be selected.

If multiple audio tracks match a preference then the track that occurs first in the track list will be chosen. This option does not break observe_audio_switches but will disable the force_prediction and detect_incorrect_predictions options.

The whitelist and blacklist will still only work with subs, but the condition filter can be used to implement audio-specific filtering behaviour.

Resolves #6

pintassilgo commented 1 year ago

Hi, thanks, I'm using this patch and it seems to be working fine with one exception, the script wasn't working with one of the videos I tested:

[sub_select] 
[sub_select] stack traceback:
[sub_select]    [C]: in function 'format'
[sub_select]    /home/__/.config/mpv/scripts/sub-select.lua:212: in function 'is_valid_sub'
[sub_select]    /home/__/.config/mpv/scripts/sub-select.lua:253: in function 'find_valid_tracks'
[sub_select]    /home/__/.config/mpv/scripts/sub-select.lua:275: in function </home/__/.config/mpv/scripts/sub-select.lua:273>
[sub_select]    (tail call): ?
[sub_select]    /home/__/.config/mpv/scripts/sub-select.lua:346: in function 'fn'
[sub_select]    mp.defaults:597: in function 'handler'
[sub_select]    mp.defaults:510: in function 'call_event_handlers'
[sub_select]    mp.defaults:552: in function 'dispatch_events'
[sub_select]    mp.defaults:503: in function <mp.defaults:502>
[sub_select]    [C]: ?
[sub_select]    [C]: ?
[sub_select] Lua error: /home/__/.config/mpv/scripts/sub-select.lua:212: bad argument #2 to 'format' (string expected, got nil)

So I removed these lines https://github.com/CogentRedTester/mpv-sub-select/blob/0f6e408372a7ec5a9b7be33521d6b18ab50d72b3/sub-select.lua#L212-L216 and it was fixed.

CogentRedTester commented 1 year ago

@pintassilgo could you please check if the latest commit has fixed the crash?

pintassilgo commented 1 year ago

Fixed, thanks.