Fix finding hearing impaired flag changes

This commit is contained in:
RatzzFatzz
2025-12-17 13:32:23 +01:00
parent 957295127a
commit 76d25fca1b
5 changed files with 12 additions and 6 deletions

View File

@@ -123,7 +123,7 @@ public class AttributeChangeProcessor {
public void findHearingImpairedTracksAndApplyChanges(FileInfo fileInfo) {
fileInfo.getTracks().stream()
.filter(track -> !track.commentary())
.filter(track -> !track.hearingImpaired())
.filter(track -> track.trackName() != null)
.filter(track -> hearingImpairedKeywords.stream().anyMatch(keyword -> track.trackName().toLowerCase().contains(keyword.toLowerCase(Locale.ROOT))))
.forEach(attr -> {

View File

@@ -127,7 +127,7 @@ public class MkvFileProcessor implements FileProcessor {
(Boolean) properties.getOrDefault("default_track", false),
(Boolean) properties.getOrDefault("forced_track", false),
(Boolean) properties.getOrDefault("commentary_track", false),
(Boolean) properties.getOrDefault("hearing_impaired_track", false),
(Boolean) properties.getOrDefault("flag_hearing_impaired", false),
TrackType.valueOf(((String) attribute.get("type")).toUpperCase(Locale.ENGLISH))));
}
}

View File

@@ -16,6 +16,8 @@ public record TrackAttributes(int id, String language, String trackName,
return id == attribute.id
&& defaultt == attribute.defaultt
&& forced == attribute.forced
&& commentary == attribute.commentary
&& hearingImpaired == attribute.hearingImpaired
&& Objects.equals(language, attribute.language)
&& Objects.equals(trackName, attribute.trackName)
&& type == attribute.type;
@@ -28,6 +30,8 @@ public record TrackAttributes(int id, String language, String trackName,
", trackName='" + trackName + '\'' +
", defaultt=" + defaultt +
", forced=" + forced +
", commentary=" + commentary +
", hearingImpaired=" + hearingImpaired +
", type=" + type +
']';
}

View File

@@ -248,7 +248,7 @@ class AttributeChangeProcessorTest {
Set.of("SDH"),
Map.ofEntries(on(withName(SUB_GER, "SDH")))
),
Arguments.of(List.of(withName(AUDIO_GER_COMMENTARY, "SDH")),
Arguments.of(List.of(withName(AUDIO_GER_HEARING, "SDH")),
Set.of("SDH"),
Map.ofEntries()
),
@@ -260,7 +260,7 @@ class AttributeChangeProcessorTest {
}
@ParameterizedTest
@MethodSource("findCommentaryTracksAndApplyChanges")
@MethodSource("findHearingImpairedTracksAndApplyChanges")
void findHearingImpairedTracksAndApplyChanges(List<TrackAttributes> tracks, Set<String> keywords, Map<TrackAttributes, Boolean> changes) {
AttributeChangeProcessor attributeChangeProcessor = new AttributeChangeProcessor(new String[]{}, Set.of(), Set.of(), keywords);

View File

@@ -57,6 +57,8 @@ class MkvFileProcessorTest {
"default_track": true,
"enabled_track": true,
"forced_track": false,
"commentary_track": true,
"flag_hearing_impaired": true,
"language": "eng",
"number": 3
},
@@ -88,8 +90,8 @@ class MkvFileProcessorTest {
assertEquals("eng", sub.language());
assertTrue(sub.defaultt());
assertFalse(sub.forced());
assertFalse(sub.hearingImpaired());
assertFalse(sub.commentary());
assertTrue(sub.hearingImpaired());
assertTrue(sub.commentary());
assertEquals(TrackType.SUBTITLES, sub.type());
}