mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-12-27 09:56:33 +00:00
Add subtitle parser errors to log if available (#12479)
This commit is contained in:
parent
cd95eabcc6
commit
1451cbc39e
|
@ -187,6 +187,7 @@
|
|||
- [HonestlyWhoKnows](https://github.com/honestlywhoknows)
|
||||
- [TheMelmacian](https://github.com/TheMelmacian)
|
||||
- [ItsAllAboutTheCode](https://github.com/ItsAllAboutTheCode)
|
||||
- [pret0rian8](https://github.com/pret0rian)
|
||||
|
||||
# Emby Contributors
|
||||
|
||||
|
|
|
@ -54,12 +54,23 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|||
{
|
||||
break;
|
||||
}
|
||||
|
||||
_logger.LogError(
|
||||
"{ErrorCount} errors encountered while parsing '{FileExtension}' subtitle using the {SubtitleFormatParser} format parser",
|
||||
subtitleFormat.ErrorCount,
|
||||
fileExtension,
|
||||
subtitleFormat.Name);
|
||||
else if (subtitleFormat.TryGetErrors(out var errors))
|
||||
{
|
||||
_logger.LogError(
|
||||
"{ErrorCount} errors encountered while parsing '{FileExtension}' subtitle using the {SubtitleFormatParser} format parser, errors: {Errors}",
|
||||
subtitleFormat.ErrorCount,
|
||||
fileExtension,
|
||||
subtitleFormat.Name,
|
||||
errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogError(
|
||||
"{ErrorCount} errors encountered while parsing '{FileExtension}' subtitle using the {SubtitleFormatParser} format parser",
|
||||
subtitleFormat.ErrorCount,
|
||||
fileExtension,
|
||||
subtitleFormat.Name);
|
||||
}
|
||||
}
|
||||
|
||||
if (subtitle.Paragraphs.Count == 0)
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using Nikse.SubtitleEdit.Core.SubtitleFormats;
|
||||
|
||||
namespace MediaBrowser.MediaEncoding.Subtitles;
|
||||
|
||||
internal static class SubtitleFormatExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Will try to find errors if supported by provider.
|
||||
/// </summary>
|
||||
/// <param name="format">The subtitle format.</param>
|
||||
/// <param name="errors">The out errors value.</param>
|
||||
/// <returns>True if errors are available for given format.</returns>
|
||||
public static bool TryGetErrors(this SubtitleFormat format, [NotNullWhen(true)] out string? errors)
|
||||
{
|
||||
errors = format switch
|
||||
{
|
||||
SubStationAlpha ssa => ssa.Errors,
|
||||
AdvancedSubStationAlpha assa => assa.Errors,
|
||||
SubRip subRip => subRip.Errors,
|
||||
MicroDvd microDvd => microDvd.Errors,
|
||||
DCinemaSmpte2007 smpte2007 => smpte2007.Errors,
|
||||
DCinemaSmpte2010 smpte2010 => smpte2010.Errors,
|
||||
_ => null,
|
||||
};
|
||||
|
||||
return !string.IsNullOrWhiteSpace(errors);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue