FF-1771: Video has stream original language is now supported

This commit is contained in:
John Andrews
2024-09-12 07:54:07 +12:00
parent 04a6eec666
commit 925e933359
2 changed files with 33 additions and 1 deletions

View File

@@ -337,13 +337,22 @@ public class VideoHasStream : VideoNode
/// <returns>the match result</returns>
private bool LanguageMatches(NodeParameters args, string lang, string streamLanguage)
{
lang = args.ReplaceVariables(lang.Replace("{orig}", "{OriginalLanguage}"), stripMissing: false);
if (args.Variables.TryGetValue("OriginalLanguage", out var oOrigLanguage) && oOrigLanguage is string origLanguage &&
string.IsNullOrWhiteSpace(origLanguage) == false)
{
lang = lang.Replace("OriginalLanguage", origLanguage, StringComparison.InvariantCultureIgnoreCase);
lang = lang.Replace("original", origLanguage);
lang = lang.Replace("orig", origLanguage);
}
string iso1 = LanguageHelper.GetIso1Code(streamLanguage);
string iso2 = LanguageHelper.GetIso2Code(streamLanguage);
string english = LanguageHelper.GetEnglishFor(streamLanguage);
var iso1Matches = ValueMatch(lang, iso1) == MatchResult.Matched;
var iso2Matches = ValueMatch(lang, iso2) == MatchResult.Matched;
var engMatches = ValueMatch(lang, english) == MatchResult.Matched;
bool anyMatches = iso1Matches || iso2Matches || engMatches;
if(anyMatches == false)
{

View File

@@ -372,6 +372,29 @@ public class VideoHasStreamTests : VideoTestBase
}
}
[TestMethod]
public void VideoHasStream_Audio_Lang_Variable()
{
var args = GetVideoNodeParameters();
var vf = new VideoFile();
vf.PreExecute(args);
Assert.AreEqual(1, vf.Execute(args));
VideoHasStream element = new();
element.Stream = "Audio";
element.PreExecute(args);
foreach (var lang in new[] { "orig", "original", "OriginalLanguage", "{OriginalLanguage}", "{orig}", })
{
Logger.ILog("###### Testing: " + lang);
args.Variables["OriginalLanguage"] = "eng";
element.Language = lang;
int output = element.Execute(args);
Assert.AreEqual(1, output);
}
}
[TestMethod]
public void VideoHasStream_Audio_Lang_Fail()
{