@ -107,7 +107,8 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -107,7 +107,8 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
channel,
allLanguageCodes,
version.MediaItem.Id,
version.MediaVersion);
version.MediaVersion,
shouldLogMessages);
sw.Stop();
if(shouldLogMessages)
{
@ -126,7 +127,8 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -126,7 +127,8 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
channel,
allLanguageCodes,
version.MediaItem.Id,
version.MediaVersion);
version.MediaVersion,
shouldLogMessages);
sw2.Stop();
if(shouldLogMessages)
{
@ -144,10 +146,13 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -144,10 +146,13 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
}
catch(Exceptionex)
{
_logger.LogError(ex,"Failed to execute audio stream selector script; falling back to built-in logic");
if(shouldLogMessages)
{
_logger.LogError(ex,"Failed to execute audio stream selector script; falling back to built-in logic");
@ -176,47 +181,52 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -176,47 +181,52 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
"Ignoring embedded subtitle with index {Index} that has not been extracted",
subtitle.StreamIndex);
if(shouldLogMessages)
{
_logger.LogDebug(
"Ignoring embedded subtitle with index {Index} that has not been extracted",
subtitle.StreamIndex);
}
candidateSubtitles.Remove(subtitle);
}
candidateSubtitles.Remove(subtitle);
}
elseif(string.IsNullOrWhiteSpace(subtitle.Path))
{
if(shouldLogMessages)
elseif(string.IsNullOrWhiteSpace(subtitle.Path))
{
_logger.LogDebug(
"BUG: ignoring embedded subtitle with index {Index} that is missing a path",
subtitle.StreamIndex);
if(shouldLogMessages)
{
_logger.LogDebug(
"BUG: ignoring embedded subtitle with index {Index} that is missing a path",
subtitle.StreamIndex);
}
candidateSubtitles.Remove(subtitle);
}
candidateSubtitles.Remove(subtitle);
}
}
}
@ -294,7 +304,8 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -294,7 +304,8 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@ -304,26 +315,32 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -304,26 +315,32 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
if(correctLanguage.Count!=0)
{
_logger.LogDebug(
"Found {Count} audio streams with preferred audio language code(s) {Code}",
correctLanguage.Count,
preferredLanguageCodes);
if(shouldLogMessages)
{
_logger.LogDebug(
"Found {Count} audio streams with preferred audio language code(s) {Code}",
@ -332,30 +349,43 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -332,30 +349,43 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
.ToList();
if(matchingTitle.Count!=0)
{
_logger.LogDebug(
"Found {Count} audio streams with preferred title {Title}",
matchingTitle.Count,
title);
if(shouldLogMessages)
{
_logger.LogDebug(
"Found {Count} audio streams with preferred title {Title}",
_logger.LogDebug("Found audio stream flagged as default");
if(shouldLogMessages)
{
_logger.LogDebug("Found audio stream flagged as default");
}
returnstream;
}
_logger.LogDebug("Unable to find default audio stream; selecting stream with most channels");
if(shouldLogMessages)
{
_logger.LogDebug("Unable to find default audio stream; selecting stream with most channels");
}
returnstreams.HeadOrNone();
}
@ -364,20 +394,33 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -364,20 +394,33 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
_logger.LogDebug("Checking for JS Script at {Path}",jsScriptPath);
if(shouldLogMessages)
{
_logger.LogDebug("Checking for JS Script at {Path}",jsScriptPath);
}
if(!_fileSystem.File.Exists(jsScriptPath))
{
_logger.LogDebug("Unable to locate episode audio stream selector script; falling back to built-in logic");
if(shouldLogMessages)
{
_logger.LogDebug(
"Unable to locate episode audio stream selector script; falling back to built-in logic");
}
returnOption<MediaStream>.None;
}
_logger.LogDebug("Found JS Script at {Path}",jsScriptPath);
if(shouldLogMessages)
{
_logger.LogDebug("Found JS Script at {Path}",jsScriptPath);
}
await_scriptEngine.LoadAsync(jsScriptPath);
@ -397,28 +440,40 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -397,28 +440,40 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
_logger.LogDebug("Checking for JS Script at {Path}",jsScriptPath);
if(shouldLogMessages)
{
_logger.LogDebug("Checking for JS Script at {Path}",jsScriptPath);
}
if(!_fileSystem.File.Exists(jsScriptPath))
{
_logger.LogDebug(
"Unable to locate movie audio stream selector script; falling back to built-in logic");
if(shouldLogMessages)
{
_logger.LogDebug(
"Unable to locate movie audio stream selector script; falling back to built-in logic");
}
returnOption<MediaStream>.None;
}
_logger.LogDebug("Found JS Script at {Path}",jsScriptPath);
if(shouldLogMessages)
{
_logger.LogDebug("Found JS Script at {Path}",jsScriptPath);
}
await_scriptEngine.LoadAsync(jsScriptPath);
@ -435,10 +490,10 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -435,10 +490,10 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@ -446,22 +501,32 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -446,22 +501,32 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector