mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-31 20:24:21 -04: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)
|
- [HonestlyWhoKnows](https://github.com/honestlywhoknows)
|
||||||
- [TheMelmacian](https://github.com/TheMelmacian)
|
- [TheMelmacian](https://github.com/TheMelmacian)
|
||||||
- [ItsAllAboutTheCode](https://github.com/ItsAllAboutTheCode)
|
- [ItsAllAboutTheCode](https://github.com/ItsAllAboutTheCode)
|
||||||
|
- [pret0rian8](https://github.com/pret0rian)
|
||||||
|
|
||||||
# Emby Contributors
|
# Emby Contributors
|
||||||
|
|
||||||
|
@ -54,12 +54,23 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else if (subtitleFormat.TryGetErrors(out var errors))
|
||||||
_logger.LogError(
|
{
|
||||||
"{ErrorCount} errors encountered while parsing '{FileExtension}' subtitle using the {SubtitleFormatParser} format parser",
|
_logger.LogError(
|
||||||
subtitleFormat.ErrorCount,
|
"{ErrorCount} errors encountered while parsing '{FileExtension}' subtitle using the {SubtitleFormatParser} format parser, errors: {Errors}",
|
||||||
fileExtension,
|
subtitleFormat.ErrorCount,
|
||||||
subtitleFormat.Name);
|
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)
|
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…
x
Reference in New Issue
Block a user