Improve audio/subtitle propagation when episodes have different streams - #96
Improve audio/subtitle propagation when episodes have different streams#96devildant wants to merge 4 commits into
Conversation
|
I've tested all the slightly dodgy scenarios my deranged brain could come up with ^^, but it would be good to have other testers |
|
Will take a look into this and #97 when I can get a chance, been kind of busy so I haven't really had a whole lot of time to sit down and look at these PRs yet. |
|
No problem, it's the holiday period :) I'm currently using my 2 PRs, which gives me more time for testing 😀 |
|
It's ok for me, I didn't have any problems |
|
Did you mean to comment that on the closed PR :P @devildant I'm still thinking about this one mainly btw, I'll probably get around to merging and pushing some others out first before I get around to looking more into this PR. |
|
No, no, it was just to say that I've been using the code from this PR since I created it and it works well. |
Context
This pull request improves the audio and subtitle propagation logic in Plex-Auto-Languages to better handle TV shows where episodes do not all expose the exact same audio and subtitle streams.
Currently, PAL propagates the selected tracks from a reference episode. This works well when all episodes have the same audio and subtitle streams, but it can produce unnatural results when some episodes have fewer audio tracks, fewer subtitles, or missing
forcedsubtitle tracks.The goal of this change is to preserve Plex’s natural behavior as much as possible, while avoiding inconsistent combinations such as:
or:
Identified issues
1. Propagating
Nonefrom an episode with no subtitle streamsSome episodes may have burned-in subtitles and therefore contain no subtitle stream that Plex can select.
In that case, the reference episode may be played with:
But this does not necessarily mean the user wants to disable subtitles for the whole show. It may simply mean that the episode has no subtitle stream available.
Example:
Before:
After:
2. Reference audio missing on the target episode
Another issue happens when the selected audio stream on the reference episode does not exist on another episode.
Example:
If the user selects on episode 1:
Episode 2 does not have French audio.
Before:
Unnatural result:
After:
This avoids applying a subtitle choice that belongs to an audio stream that could not be applied.
3. Natural fallback when the reference audio is missing and the reference has no subtitle selected
However, there is one case where doing nothing is not enough.
Example:
User sequence:
Episode 2 does not have French audio, but it does have French subtitles.
Expected natural behavior:
Reason:
This change therefore adds a specific fallback:
Example:
This fallback only uses non-forced subtitle tracks.
4. Reference with a single audio stream applied to a multi-audio target
A selected audio stream on an episode that only has one audio stream is not necessarily a strong user preference. It may simply be the only available stream.
Example:
If the user plays episode 2:
Before:
But on episode 2, Japanese audio was not necessarily an explicit user choice: it was the only available audio stream.
After:
However, subtitles may still be applied if the target episode is already using the same audio language as the reference.
Allowed example:
Blocked example:
5. Forced subtitle handling
The forced subtitle logic must remain the priority when a matching forced subtitle exists on the target episode.
Example:
Expected result:
This logic remains unchanged: if the matching forced subtitle exists, it is selected.
6. Missing forced subtitle: fallback or disable depending on the audio language
The most subtle case is when the forced subtitle selected on the reference episode does not exist on the target episode.
Two situations must be handled differently.
Case A: audio and forced subtitle are in different languages
Example:
The
French forcedsubtitle does not exist on the target episode, but a full French subtitle exists.Expected behavior:
Reason:
Result:
Case B: audio and forced subtitle are in the same language
Example:
The
French forcedsubtitle does not exist on the target episode, but a full French subtitle exists.Expected behavior:
Reason:
Result:
7. Missing regular subtitle
If the user selects a regular subtitle on the reference episode, but that subtitle does not exist on the target episode, PAL should not aggressively disable the existing subtitle selection.
Example:
Expected behavior:
This avoids clearing an existing selection when there is no clear equivalent subtitle available.
Summary of added rules
Validation examples
Example 1
Action:
Expected result on episode 2:
Reason:
Example 2
Action:
Expected result on episode 2:
Reason:
Example 3
Action:
Expected result on episode 2:
Reason:
Example 4
Action:
Expected result on episode 1:
Reason:
Known limitations
This change does not attempt to fix incorrect file metadata.
PAL still depends on the information exposed by Plex:
If two tracks are incorrectly tagged, have no distinctive name, or use different language codes despite visually appearing as the same language, PAL may still not select the expected track.
Examples of cases not covered:
In these cases, the issue is more likely caused by file metadata or by what Plex exposes through its API.
Goal of this PR
This PR aims to make track propagation safer and closer to Plex’s natural behavior when episodes of the same show do not expose exactly the same audio and subtitle streams.
It mainly avoids: