mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
loop over all compatible SubtitleFormats
This commit is contained in:
parent
1db748399c
commit
78f437401b
@ -30,17 +30,23 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public SubtitleTrackInfo Parse(Stream stream, string fileExtension)
|
public SubtitleTrackInfo Parse(Stream stream, string fileExtension)
|
||||||
{
|
{
|
||||||
var subtitleFormat = SubtitleFormat.AllSubtitleFormats.FirstOrDefault(asf => asf.Extension.Equals(fileExtension, StringComparison.OrdinalIgnoreCase));
|
|
||||||
if (subtitleFormat == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Unsupported format: " + fileExtension);
|
|
||||||
}
|
|
||||||
|
|
||||||
var lines = stream.ReadAllLines().ToList();
|
|
||||||
var subtitle = new Subtitle();
|
var subtitle = new Subtitle();
|
||||||
subtitleFormat.LoadSubtitle(subtitle, lines, fileExtension);
|
var lines = stream.ReadAllLines().ToList();
|
||||||
if (subtitleFormat.ErrorCount > 0)
|
|
||||||
|
var subtitleFormats = SubtitleFormat.AllSubtitleFormats.Where(asf => asf.Extension.Equals(fileExtension, StringComparison.OrdinalIgnoreCase));
|
||||||
|
foreach (var subtitleFormat in subtitleFormats)
|
||||||
{
|
{
|
||||||
|
if (subtitleFormat == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Unsupported format: " + fileExtension);
|
||||||
|
}
|
||||||
|
|
||||||
|
subtitleFormat.LoadSubtitle(subtitle, lines, fileExtension);
|
||||||
|
if (subtitleFormat.ErrorCount == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
_logger.LogError("{ErrorCount} errors encountered while parsing subtitle", subtitleFormat.ErrorCount);
|
_logger.LogError("{ErrorCount} errors encountered while parsing subtitle", subtitleFormat.ErrorCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user