Browse Source

fix subtitle update bug (#1085)

* fix saving some subtitles to database

* fix ffprobe regression
pull/1086/head
Jason Dove 4 years ago committed by GitHub
parent
commit
6558c5bd69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 32
      ErsatzTV.Infrastructure/Data/Repositories/MetadataRepository.cs
  3. 3
      ErsatzTV.Scanner/Core/Metadata/LocalStatisticsProvider.cs

1
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 song playback with VAAPI and NVENC
- Fix edge case where some local movies would not automatically be restored from trash - Fix edge case where some local movies would not automatically be restored from trash
- Fix synchronizing Jellyfin and Emby collection items - Fix synchronizing Jellyfin and Emby collection items
- Fix saving some external subtitle records to database
### Changed ### Changed
- Upgrade to dotnet 7 - Upgrade to dotnet 7

32
ErsatzTV.Infrastructure/Data/Repositories/MetadataRepository.cs

@ -489,10 +489,10 @@ public class MetadataRepository : IMetadataRepository
public async Task<bool> UpdateSubtitles(Metadata metadata, List<Subtitle> subtitles) public async Task<bool> UpdateSubtitles(Metadata metadata, List<Subtitle> subtitles)
{ {
_logger.LogDebug( // _logger.LogDebug(
"Updating {Count} subtitles; metadata is {Metadata}", // "Updating {Count} subtitles; metadata is {Metadata}",
subtitles.Count, // subtitles.Count,
metadata.GetType().Name); // metadata.GetType().Name);
int metadataId = metadata.Id; int metadataId = metadata.Id;
@ -519,9 +519,9 @@ public class MetadataRepository : IMetadataRepository
_ => None _ => None
}; };
_logger.LogDebug( // _logger.LogDebug(
"Existing metadata is {Metadata}", // "Existing metadata is {Metadata}",
await maybeMetadata.Map(m => m.GetType().Name).IfNoneAsync("[none]")); // await maybeMetadata.Map(m => m.GetType().Name).IfNoneAsync("[none]"));
foreach (Metadata existing in maybeMetadata) foreach (Metadata existing in maybeMetadata)
{ {
@ -530,11 +530,11 @@ public class MetadataRepository : IMetadataRepository
.ToList(); .ToList();
var toUpdate = subtitles.Except(toAdd).ToList(); var toUpdate = subtitles.Except(toAdd).ToList();
_logger.LogDebug( // _logger.LogDebug(
"Subtitles to add: {ToAdd}, to remove: {ToRemove}, to update: {ToUpdate}", // "Subtitles to add: {ToAdd}, to remove: {ToRemove}, to update: {ToUpdate}",
toAdd.Count, // toAdd.Count,
toRemove.Count, // toRemove.Count,
toUpdate.Count); // toUpdate.Count);
if (toAdd.Any() || toRemove.Any() || toUpdate.Any()) if (toAdd.Any() || toRemove.Any() || toUpdate.Any())
{ {
@ -557,22 +557,24 @@ public class MetadataRepository : IMetadataRepository
existingSubtitle.Language = incomingSubtitle.Language; existingSubtitle.Language = incomingSubtitle.Language;
existingSubtitle.SubtitleKind = incomingSubtitle.SubtitleKind; existingSubtitle.SubtitleKind = incomingSubtitle.SubtitleKind;
existingSubtitle.DateUpdated = incomingSubtitle.DateUpdated; existingSubtitle.DateUpdated = incomingSubtitle.DateUpdated;
dbContext.Entry(existingSubtitle).State = EntityState.Modified;
} }
int count = await dbContext.SaveChangesAsync(); 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; return count > 0;
} }
// nothing to do // nothing to do
_logger.LogDebug("Subtitle update requires no database changes"); // _logger.LogDebug("Subtitle update requires no database changes");
return true; return true;
} }
// no metadata // no metadata
_logger.LogDebug("Subtitle update failure due to missing metadata"); // _logger.LogDebug("Subtitle update failure due to missing metadata");
return false; return false;
} }

3
ErsatzTV.Scanner/Core/Metadata/LocalStatisticsProvider.cs

@ -248,7 +248,8 @@ public class LocalStatisticsProvider : ILocalStatisticsProvider
{ {
string sar = match.Groups[1].Value; string sar = match.Groups[1].Value;
string dar = match.Groups[2].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 }; FFprobeStream replacement = stream with { sample_aspect_ratio = sar, display_aspect_ratio = dar };
ffprobe.streams?.Remove(stream); ffprobe.streams?.Remove(stream);

Loading…
Cancel
Save