Browse Source

fix statistic updates (#399)

pull/401/head
Jason Dove 5 years ago committed by GitHub
parent
commit
b5de5e2b7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 14
      ErsatzTV.Core/Emby/EmbyMovieLibraryScanner.cs
  3. 11
      ErsatzTV.Core/Emby/EmbyTelevisionLibraryScanner.cs
  4. 14
      ErsatzTV.Core/Jellyfin/JellyfinMovieLibraryScanner.cs
  5. 12
      ErsatzTV.Core/Jellyfin/JellyfinTelevisionLibraryScanner.cs
  6. 2
      ErsatzTV.Core/Plex/PlexMovieLibraryScanner.cs
  7. 2
      ErsatzTV.Core/Plex/PlexTelevisionLibraryScanner.cs

1
CHANGELOG.md

@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed ### Fixed
- Add downsampling to support transcoding 10-bit HEVC content with the h264_vaapi encoder - Add downsampling to support transcoding 10-bit HEVC content with the h264_vaapi encoder
- Fix updating statistics when media items are replaced
## [0.0.62-alpha] - 2021-10-05 ## [0.0.62-alpha] - 2021-10-05
### Added ### Added

14
ErsatzTV.Core/Emby/EmbyMovieLibraryScanner.cs

@ -96,6 +96,8 @@ namespace ErsatzTV.Core.Emby
foreach (EmbyMovie incoming in validMovies) foreach (EmbyMovie incoming in validMovies)
{ {
EmbyMovie incomingMovie = incoming;
decimal percentCompletion = (decimal) validMovies.IndexOf(incoming) / validMovies.Count; decimal percentCompletion = (decimal) validMovies.IndexOf(incoming) / validMovies.Count;
await _mediator.Publish(new LibraryScanProgress(library.Id, percentCompletion)); await _mediator.Publish(new LibraryScanProgress(library.Id, percentCompletion));
@ -122,12 +124,14 @@ namespace ErsatzTV.Core.Emby
updateStatistics = true; updateStatistics = true;
incoming.LibraryPathId = library.Paths.Head().Id; incoming.LibraryPathId = library.Paths.Head().Id;
Option<EmbyMovie> updated = await _movieRepository.UpdateEmby(incoming); Option<EmbyMovie> maybeUpdated = await _movieRepository.UpdateEmby(incoming);
if (updated.IsSome) foreach (EmbyMovie updated in maybeUpdated)
{ {
await _searchIndex.UpdateItems( await _searchIndex.UpdateItems(
_searchRepository, _searchRepository,
new List<MediaItem> { updated.ValueUnsafe() }); new List<MediaItem> { updated });
incomingMovie = updated;
} }
} }
catch (Exception ex) catch (Exception ex)
@ -174,12 +178,12 @@ namespace ErsatzTV.Core.Emby
_logger.LogDebug("Refreshing {Attribute} for {Path}", "Statistics", localPath); _logger.LogDebug("Refreshing {Attribute} for {Path}", "Statistics", localPath);
Either<BaseError, bool> refreshResult = Either<BaseError, bool> refreshResult =
await _localStatisticsProvider.RefreshStatistics(ffprobePath, incoming, localPath); await _localStatisticsProvider.RefreshStatistics(ffprobePath, incomingMovie, localPath);
await refreshResult.Match( await refreshResult.Match(
async _ => async _ =>
{ {
Option<MediaItem> updated = await _searchRepository.GetItemToIndex(incoming.Id); Option<MediaItem> updated = await _searchRepository.GetItemToIndex(incomingMovie.Id);
if (updated.IsSome) if (updated.IsSome)
{ {
await _searchIndex.UpdateItems( await _searchIndex.UpdateItems(

11
ErsatzTV.Core/Emby/EmbyTelevisionLibraryScanner.cs

@ -326,6 +326,7 @@ namespace ErsatzTV.Core.Emby
{ {
foreach (EmbyEpisode incoming in episodes) foreach (EmbyEpisode incoming in episodes)
{ {
EmbyEpisode incomingEpisode = incoming;
var updateStatistics = false; var updateStatistics = false;
Option<EmbyItemEtag> maybeExisting = existingEpisodes.Find(ie => ie.ItemId == incoming.ItemId); Option<EmbyItemEtag> maybeExisting = existingEpisodes.Find(ie => ie.ItemId == incoming.ItemId);
@ -349,12 +350,14 @@ namespace ErsatzTV.Core.Emby
incoming.SeasonId = season.Id; incoming.SeasonId = season.Id;
incoming.LibraryPathId = library.Paths.Head().Id; incoming.LibraryPathId = library.Paths.Head().Id;
Option<EmbyEpisode> updated = await _televisionRepository.Update(incoming); Option<EmbyEpisode> maybeUpdated = await _televisionRepository.Update(incoming);
if (updated.IsSome) foreach (EmbyEpisode updated in maybeUpdated)
{ {
await _searchIndex.UpdateItems( await _searchIndex.UpdateItems(
_searchRepository, _searchRepository,
new List<MediaItem> { updated.ValueUnsafe() }); new List<MediaItem> { updated });
incomingEpisode = updated;
} }
} }
catch (Exception ex) catch (Exception ex)
@ -403,7 +406,7 @@ namespace ErsatzTV.Core.Emby
_logger.LogDebug("Refreshing {Attribute} for {Path}", "Statistics", localPath); _logger.LogDebug("Refreshing {Attribute} for {Path}", "Statistics", localPath);
Either<BaseError, bool> refreshResult = Either<BaseError, bool> refreshResult =
await _localStatisticsProvider.RefreshStatistics(ffprobePath, incoming, localPath); await _localStatisticsProvider.RefreshStatistics(ffprobePath, incomingEpisode, localPath);
refreshResult.Match( refreshResult.Match(
_ => { }, _ => { },

14
ErsatzTV.Core/Jellyfin/JellyfinMovieLibraryScanner.cs

@ -96,6 +96,8 @@ namespace ErsatzTV.Core.Jellyfin
foreach (JellyfinMovie incoming in validMovies) foreach (JellyfinMovie incoming in validMovies)
{ {
JellyfinMovie incomingMovie = incoming;
decimal percentCompletion = (decimal) validMovies.IndexOf(incoming) / validMovies.Count; decimal percentCompletion = (decimal) validMovies.IndexOf(incoming) / validMovies.Count;
await _mediator.Publish(new LibraryScanProgress(library.Id, percentCompletion)); await _mediator.Publish(new LibraryScanProgress(library.Id, percentCompletion));
@ -122,12 +124,14 @@ namespace ErsatzTV.Core.Jellyfin
updateStatistics = true; updateStatistics = true;
incoming.LibraryPathId = library.Paths.Head().Id; incoming.LibraryPathId = library.Paths.Head().Id;
Option<JellyfinMovie> updated = await _movieRepository.UpdateJellyfin(incoming); Option<JellyfinMovie> maybeUpdated = await _movieRepository.UpdateJellyfin(incoming);
if (updated.IsSome) foreach (JellyfinMovie updated in maybeUpdated)
{ {
await _searchIndex.UpdateItems( await _searchIndex.UpdateItems(
_searchRepository, _searchRepository,
new List<MediaItem> { updated.ValueUnsafe() }); new List<MediaItem> { updated });
incomingMovie = updated;
} }
} }
catch (Exception ex) catch (Exception ex)
@ -174,12 +178,12 @@ namespace ErsatzTV.Core.Jellyfin
_logger.LogDebug("Refreshing {Attribute} for {Path}", "Statistics", localPath); _logger.LogDebug("Refreshing {Attribute} for {Path}", "Statistics", localPath);
Either<BaseError, bool> refreshResult = Either<BaseError, bool> refreshResult =
await _localStatisticsProvider.RefreshStatistics(ffprobePath, incoming, localPath); await _localStatisticsProvider.RefreshStatistics(ffprobePath, incomingMovie, localPath);
await refreshResult.Match( await refreshResult.Match(
async _ => async _ =>
{ {
Option<MediaItem> updated = await _searchRepository.GetItemToIndex(incoming.Id); Option<MediaItem> updated = await _searchRepository.GetItemToIndex(incomingMovie.Id);
if (updated.IsSome) if (updated.IsSome)
{ {
await _searchIndex.UpdateItems( await _searchIndex.UpdateItems(

12
ErsatzTV.Core/Jellyfin/JellyfinTelevisionLibraryScanner.cs

@ -327,6 +327,8 @@ namespace ErsatzTV.Core.Jellyfin
{ {
foreach (JellyfinEpisode incoming in episodes) foreach (JellyfinEpisode incoming in episodes)
{ {
JellyfinEpisode incomingEpisode = incoming;
var updateStatistics = false; var updateStatistics = false;
Option<JellyfinItemEtag> maybeExisting = existingEpisodes.Find(ie => ie.ItemId == incoming.ItemId); Option<JellyfinItemEtag> maybeExisting = existingEpisodes.Find(ie => ie.ItemId == incoming.ItemId);
@ -350,12 +352,14 @@ namespace ErsatzTV.Core.Jellyfin
incoming.SeasonId = season.Id; incoming.SeasonId = season.Id;
incoming.LibraryPathId = library.Paths.Head().Id; incoming.LibraryPathId = library.Paths.Head().Id;
Option<JellyfinEpisode> updated = await _televisionRepository.Update(incoming); Option<JellyfinEpisode> maybeUpdated = await _televisionRepository.Update(incoming);
if (updated.IsSome) foreach (JellyfinEpisode updated in maybeUpdated)
{ {
await _searchIndex.UpdateItems( await _searchIndex.UpdateItems(
_searchRepository, _searchRepository,
new List<MediaItem> { updated.ValueUnsafe() }); new List<MediaItem> { updated });
incomingEpisode = updated;
} }
} }
catch (Exception ex) catch (Exception ex)
@ -404,7 +408,7 @@ namespace ErsatzTV.Core.Jellyfin
_logger.LogDebug("Refreshing {Attribute} for {Path}", "Statistics", localPath); _logger.LogDebug("Refreshing {Attribute} for {Path}", "Statistics", localPath);
Either<BaseError, bool> refreshResult = Either<BaseError, bool> refreshResult =
await _localStatisticsProvider.RefreshStatistics(ffprobePath, incoming, localPath); await _localStatisticsProvider.RefreshStatistics(ffprobePath, incomingEpisode, localPath);
refreshResult.Match( refreshResult.Match(
_ => { }, _ => { },

2
ErsatzTV.Core/Plex/PlexMovieLibraryScanner.cs

@ -183,7 +183,7 @@ namespace ErsatzTV.Core.Plex
_logger.LogDebug("Refreshing {Attribute} for {Path}", "Statistics", localPath); _logger.LogDebug("Refreshing {Attribute} for {Path}", "Statistics", localPath);
Either<BaseError, bool> refreshResult = Either<BaseError, bool> refreshResult =
await _localStatisticsProvider.RefreshStatistics(ffprobePath, incoming, localPath); await _localStatisticsProvider.RefreshStatistics(ffprobePath, existing, localPath);
await refreshResult.Match( await refreshResult.Match(
async _ => async _ =>

2
ErsatzTV.Core/Plex/PlexTelevisionLibraryScanner.cs

@ -542,7 +542,7 @@ namespace ErsatzTV.Core.Plex
_logger.LogDebug("Refreshing {Attribute} for {Path}", "Statistics", localPath); _logger.LogDebug("Refreshing {Attribute} for {Path}", "Statistics", localPath);
Either<BaseError, bool> refreshResult = Either<BaseError, bool> refreshResult =
await _localStatisticsProvider.RefreshStatistics(ffprobePath, incoming, localPath); await _localStatisticsProvider.RefreshStatistics(ffprobePath, existing, localPath);
await refreshResult.Match( await refreshResult.Match(
async _ => async _ =>

Loading…
Cancel
Save