From 32c32e2f884adf136cc5c42ab8f32a8058ea7707 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 2 Mar 2024 17:18:55 -0800 Subject: [PATCH] Fixed: Issue extracting subtitle information for unknown episodes --- .../Extras/Subtitles/ExistingSubtitleImporter.cs | 9 +++++---- .../Aggregation/Aggregators/AggregateSubtitleInfo.cs | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs b/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs index 6c5a5481e..05fdf5770 100644 --- a/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs +++ b/src/NzbDrone.Core/Extras/Subtitles/ExistingSubtitleImporter.cs @@ -4,6 +4,7 @@ using System.Linq; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Core.Extras.Files; +using NzbDrone.Core.Languages; using NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Tv; @@ -78,11 +79,11 @@ namespace NzbDrone.Core.Extras.Subtitles SeasonNumber = localEpisode.SeasonNumber, EpisodeFileId = firstEpisode.EpisodeFileId, RelativePath = series.Path.GetRelativePath(possibleSubtitleFile), - Language = localEpisode.SubtitleInfo.Language, - LanguageTags = localEpisode.SubtitleInfo.LanguageTags, - Title = localEpisode.SubtitleInfo.Title, + Language = localEpisode.SubtitleInfo?.Language ?? Language.Unknown, + LanguageTags = localEpisode.SubtitleInfo?.LanguageTags ?? new List(), + Title = localEpisode.SubtitleInfo?.Title, Extension = extension, - Copy = localEpisode.SubtitleInfo.Copy + Copy = localEpisode.SubtitleInfo?.Copy ?? 0 }; subtitleFiles.Add(subtitleFile); diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Aggregation/Aggregators/AggregateSubtitleInfo.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Aggregation/Aggregators/AggregateSubtitleInfo.cs index 5beabf7d5..65eaf0cca 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Aggregation/Aggregators/AggregateSubtitleInfo.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Aggregation/Aggregators/AggregateSubtitleInfo.cs @@ -2,6 +2,7 @@ using System; using System.IO; using System.Linq; using NLog; +using NzbDrone.Common.Extensions; using NzbDrone.Core.Download; using NzbDrone.Core.Extras.Subtitles; using NzbDrone.Core.Parser; @@ -30,6 +31,11 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Aggregation.Aggregators return localEpisode; } + if (localEpisode.Episodes.Empty()) + { + return localEpisode; + } + var firstEpisode = localEpisode.Episodes.First(); var episodeFile = firstEpisode.EpisodeFile.Value; localEpisode.SubtitleInfo = CleanSubtitleTitleInfo(episodeFile, path);