@ -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)
{
@ -143,11 +145,14 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -143,11 +145,14 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
}
}
catch(Exceptionex)
{
if(shouldLogMessages)
{
_logger.LogError(ex,"Failed to execute audio stream selector script; falling back to built-in logic");
@ -176,6 +181,9 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -176,6 +181,9 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
varcandidateSubtitles=subtitles.ToList();
// next engine doesn't need to specifically enable or pre-extract embedded subtitles
@ -187,7 +195,8 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -187,7 +195,8 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
_logger.LogDebug("Ignoring embedded subtitles for channel {Number}",channel.Number);
@ -220,6 +229,7 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -220,6 +229,7 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@ -294,7 +304,8 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -294,7 +304,8 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@ -303,27 +314,33 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -303,27 +314,33 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
.ToList();
if(correctLanguage.Count!=0)
{
if(shouldLogMessages)
{
_logger.LogDebug(
"Found {Count} audio streams with preferred audio language code(s) {Code}",
@ -331,31 +348,44 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -331,31 +348,44 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
_logger.LogDebug("Found audio stream flagged as default");
}
returnstream;
}
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(!_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;
}
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(!_fileSystem.File.Exists(jsScriptPath))
{
if(shouldLogMessages)
{
_logger.LogDebug(
"Unable to locate movie audio stream selector script; falling back to built-in logic");
}
returnOption<MediaStream>.None;
}
if(shouldLogMessages)
{
_logger.LogDebug("Found JS Script at {Path}",jsScriptPath);
}
await_scriptEngine.LoadAsync(jsScriptPath);
@ -435,34 +490,44 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector
@@ -435,34 +490,44 @@ public class FFmpegStreamSelector : IFFmpegStreamSelector