diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ceb19567..b338b4972 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Reduce memory use due to library scan operations - Fix some instances of filler getting "stuck" when a filler item is encountered that's too long for the gap +- Properly ignore Plex `Other Videos` libraries (`movie` libraries where agent is `com.plexapp.agents.none`) ### Added - Add `metadata_kind` field to search index to allow searching for items with a particular metdata source diff --git a/ErsatzTV.Infrastructure/Data/Repositories/MediaSourceRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/MediaSourceRepository.cs index be24e7dbf..1c359ce6b 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/MediaSourceRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/MediaSourceRepository.cs @@ -148,16 +148,20 @@ public class MediaSourceRepository : IMediaSourceRepository } } + var libraryIds = toDelete.Map(l => l.Id).ToList(); + List deletedMediaIds = await dbContext.MediaItems + .Filter(mi => libraryIds.Contains(mi.LibraryPath.LibraryId)) + .Map(mi => mi.Id) + .ToListAsync(); + foreach (PlexLibrary delete in toDelete) { - dbContext.Entry(delete).State = EntityState.Deleted; + dbContext.PlexLibraries.Remove(delete); } - List ids = await DisablePlexLibrarySync(toDelete.Map(l => l.Id).ToList()); - await dbContext.SaveChangesAsync(); - return ids; + return deletedMediaIds; } public async Task> UpdateLibraries( diff --git a/ErsatzTV.Infrastructure/Plex/Models/PlexLibraryResponse.cs b/ErsatzTV.Infrastructure/Plex/Models/PlexLibraryResponse.cs index 8bc985c69..20d0e5421 100644 --- a/ErsatzTV.Infrastructure/Plex/Models/PlexLibraryResponse.cs +++ b/ErsatzTV.Infrastructure/Plex/Models/PlexLibraryResponse.cs @@ -5,6 +5,7 @@ public class PlexLibraryResponse public string Key { get; set; } public string Title { get; set; } public string Type { get; set; } + public string Agent { get; set; } public int Hidden { get; set; } public string Uuid { get; set; } } diff --git a/ErsatzTV.Infrastructure/Plex/PlexServerApiClient.cs b/ErsatzTV.Infrastructure/Plex/PlexServerApiClient.cs index 7ee4d3b7c..24d0c8605 100644 --- a/ErsatzTV.Infrastructure/Plex/PlexServerApiClient.cs +++ b/ErsatzTV.Infrastructure/Plex/PlexServerApiClient.cs @@ -13,8 +13,8 @@ namespace ErsatzTV.Infrastructure.Plex; public class PlexServerApiClient : IPlexServerApiClient { private readonly IFallbackMetadataProvider _fallbackMetadataProvider; - private readonly PlexEtag _plexEtag; private readonly ILogger _logger; + private readonly PlexEtag _plexEtag; public PlexServerApiClient( IFallbackMetadataProvider fallbackMetadataProvider, @@ -64,6 +64,7 @@ public class PlexServerApiClient : IPlexServerApiClient await service.GetLibraries(token.AuthToken).Map(r => r.MediaContainer.Directory); return directory // .Filter(l => l.Hidden == 0) + .Filter(l => (l.Agent ?? string.Empty).ToLowerInvariant() is not "com.plexapp.agents.none") .Filter(l => l.Type.ToLowerInvariant() is "movie" or "show") .Map(Project) .Somes()