Browse Source

fix statistic updates (#399)

pull/401/head
Jason Dove 4 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/). @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
- 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
### Added

14
ErsatzTV.Core/Emby/EmbyMovieLibraryScanner.cs

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

11
ErsatzTV.Core/Emby/EmbyTelevisionLibraryScanner.cs

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

14
ErsatzTV.Core/Jellyfin/JellyfinMovieLibraryScanner.cs

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

12
ErsatzTV.Core/Jellyfin/JellyfinTelevisionLibraryScanner.cs

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

2
ErsatzTV.Core/Plex/PlexMovieLibraryScanner.cs

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

2
ErsatzTV.Core/Plex/PlexTelevisionLibraryScanner.cs

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

Loading…
Cancel
Save