diff --git a/CHANGELOG.md b/CHANGELOG.md index c9bca60fc..c94d9bebc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix song playback with VAAPI and NVENC - Fix edge case where some local movies would not automatically be restored from trash - Fix synchronizing Jellyfin and Emby collection items +- Fix saving some external subtitle records to database ### Changed - Upgrade to dotnet 7 diff --git a/ErsatzTV.Infrastructure/Data/Repositories/MetadataRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/MetadataRepository.cs index b676b295b..0ba658b1f 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/MetadataRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/MetadataRepository.cs @@ -489,10 +489,10 @@ public class MetadataRepository : IMetadataRepository public async Task UpdateSubtitles(Metadata metadata, List subtitles) { - _logger.LogDebug( - "Updating {Count} subtitles; metadata is {Metadata}", - subtitles.Count, - metadata.GetType().Name); + // _logger.LogDebug( + // "Updating {Count} subtitles; metadata is {Metadata}", + // subtitles.Count, + // metadata.GetType().Name); int metadataId = metadata.Id; @@ -519,9 +519,9 @@ public class MetadataRepository : IMetadataRepository _ => None }; - _logger.LogDebug( - "Existing metadata is {Metadata}", - await maybeMetadata.Map(m => m.GetType().Name).IfNoneAsync("[none]")); + // _logger.LogDebug( + // "Existing metadata is {Metadata}", + // await maybeMetadata.Map(m => m.GetType().Name).IfNoneAsync("[none]")); foreach (Metadata existing in maybeMetadata) { @@ -530,11 +530,11 @@ public class MetadataRepository : IMetadataRepository .ToList(); var toUpdate = subtitles.Except(toAdd).ToList(); - _logger.LogDebug( - "Subtitles to add: {ToAdd}, to remove: {ToRemove}, to update: {ToUpdate}", - toAdd.Count, - toRemove.Count, - toUpdate.Count); + // _logger.LogDebug( + // "Subtitles to add: {ToAdd}, to remove: {ToRemove}, to update: {ToUpdate}", + // toAdd.Count, + // toRemove.Count, + // toUpdate.Count); if (toAdd.Any() || toRemove.Any() || toUpdate.Any()) { @@ -557,22 +557,24 @@ public class MetadataRepository : IMetadataRepository existingSubtitle.Language = incomingSubtitle.Language; existingSubtitle.SubtitleKind = incomingSubtitle.SubtitleKind; existingSubtitle.DateUpdated = incomingSubtitle.DateUpdated; + + dbContext.Entry(existingSubtitle).State = EntityState.Modified; } int count = await dbContext.SaveChangesAsync(); - _logger.LogDebug("Subtitles update changed {Count} records in the db", count); + // _logger.LogDebug("Subtitles update changed {Count} records in the db", count); return count > 0; } // nothing to do - _logger.LogDebug("Subtitle update requires no database changes"); + // _logger.LogDebug("Subtitle update requires no database changes"); return true; } // no metadata - _logger.LogDebug("Subtitle update failure due to missing metadata"); + // _logger.LogDebug("Subtitle update failure due to missing metadata"); return false; } diff --git a/ErsatzTV.Scanner/Core/Metadata/LocalStatisticsProvider.cs b/ErsatzTV.Scanner/Core/Metadata/LocalStatisticsProvider.cs index 75c3e709f..39fc98b31 100644 --- a/ErsatzTV.Scanner/Core/Metadata/LocalStatisticsProvider.cs +++ b/ErsatzTV.Scanner/Core/Metadata/LocalStatisticsProvider.cs @@ -248,7 +248,8 @@ public class LocalStatisticsProvider : ILocalStatisticsProvider { string sar = match.Groups[1].Value; string dar = match.Groups[2].Value; - foreach (FFprobeStream stream in Optional(ffprobe.streams?.Where(s => s.codec_type == "video")).Flatten()) + foreach (FFprobeStream stream in Optional(ffprobe.streams?.Where(s => s.codec_type == "video").ToList()) + .Flatten()) { FFprobeStream replacement = stream with { sample_aspect_ratio = sar, display_aspect_ratio = dar }; ffprobe.streams?.Remove(stream);