fix(player): preserve the forced-subtitle class across episode boundaries
Plex treats a subtitle stream as forced when its title says "Forced" even with the API flag unset. Every forced comparison now uses that effective forced-ness on both sides: the match scorer, the low-metadata hard gate, the Jellyfin OnlyForced/Smart profile modes, and stream-index negotiation. Carrying a track choice into the next episode no longer reuses the same-item identity matchers. A sealed SubtitlePreference (off / track reference / semantic intent) replaces the id-'navigation' pseudo-track through the whole preference channel, and cross-item intents hard-require language and forced-class parity. When the next episode has no track of the same class, the intent declines and selection falls through to the server's own per-episode choice instead of latching onto a full track by position and persisting that mistake back to the server. Intents wait for pending native tracks under the same catalog-completeness rule as source ids, so an early decline cannot retire the selection listener before the real track arrives. Ref #1716
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:plezy/media/media_source_info.dart';
|
||||
import 'package:plezy/mpv/mpv.dart';
|
||||
import 'package:plezy/utils/subtitle_forced_semantics.dart';
|
||||
|
||||
MediaSubtitleTrack _row({bool forced = false, String? title, String? displayTitle}) =>
|
||||
MediaSubtitleTrack(id: 1, selected: false, forced: forced, title: title, displayTitle: displayTitle);
|
||||
|
||||
void main() {
|
||||
group('MediaSubtitleTrack.effectiveForced', () {
|
||||
test('flag alone qualifies', () {
|
||||
expect(_row(forced: true).effectiveForced, isTrue);
|
||||
});
|
||||
|
||||
test('title alone qualifies', () {
|
||||
expect(_row(title: 'FR Forced').effectiveForced, isTrue);
|
||||
});
|
||||
|
||||
test('displayTitle alone qualifies', () {
|
||||
expect(_row(displayTitle: 'Français (Forced SRT)').effectiveForced, isTrue);
|
||||
});
|
||||
|
||||
test('neither flag nor title qualifies', () {
|
||||
expect(_row(title: 'French', displayTitle: 'Français (SRT)').effectiveForced, isFalse);
|
||||
expect(_row().effectiveForced, isFalse);
|
||||
});
|
||||
});
|
||||
|
||||
group('SubtitleTrack.effectiveForced', () {
|
||||
test('flag alone qualifies', () {
|
||||
expect(const SubtitleTrack(id: '1', isForced: true).effectiveForced, isTrue);
|
||||
});
|
||||
|
||||
test('title alone qualifies', () {
|
||||
expect(const SubtitleTrack(id: '1', title: 'FR Forced [ASS]').effectiveForced, isTrue);
|
||||
});
|
||||
|
||||
test('plain title does not qualify', () {
|
||||
expect(const SubtitleTrack(id: '1', title: 'French').effectiveForced, isFalse);
|
||||
expect(const SubtitleTrack(id: '1').effectiveForced, isFalse);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -17,6 +17,24 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('titleSaysForced', () {
|
||||
test('matches the forced token anywhere in the title', () {
|
||||
expect(titleSaysForced('Forced'), isTrue);
|
||||
expect(titleSaysForced('FORCED'), isTrue);
|
||||
expect(titleSaysForced('FR Forced [ASS]'), isTrue);
|
||||
expect(titleSaysForced('French (Forced)'), isTrue);
|
||||
expect(titleSaysForced('forced.eng'), isTrue);
|
||||
});
|
||||
|
||||
test('requires a whole token, not a substring', () {
|
||||
expect(titleSaysForced('unforced'), isFalse);
|
||||
expect(titleSaysForced('Reinforced'), isFalse);
|
||||
expect(titleSaysForced('French'), isFalse);
|
||||
expect(titleSaysForced(''), isFalse);
|
||||
expect(titleSaysForced(null), isFalse);
|
||||
});
|
||||
});
|
||||
|
||||
group('resolveTrackLanguageDisplay', () {
|
||||
test('resolves 2-letter, 3-letter, and bibliographic codes', () {
|
||||
expect(resolveTrackLanguageDisplay(language: 'en'), 'English');
|
||||
|
||||
Reference in New Issue
Block a user