Browse Source

fix subtitle update bug (#1085)

* fix saving some subtitles to database

* fix ffprobe regression
pull/1086/head
Jason Dove 3 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/). @@ -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

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

@ -489,10 +489,10 @@ public class MetadataRepository : IMetadataRepository @@ -489,10 +489,10 @@ public class MetadataRepository : IMetadataRepository
public async Task<bool> UpdateSubtitles(Metadata metadata, List<Subtitle> 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 @@ -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 @@ -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 @@ -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;
}

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

@ -248,7 +248,8 @@ public class LocalStatisticsProvider : ILocalStatisticsProvider @@ -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);

Loading…
Cancel
Save