Browse Source

properly ignore plex other videos libraries (#801)

pull/802/head
Jason Dove 4 years ago committed by GitHub
parent
commit
9e0972fec0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 12
      ErsatzTV.Infrastructure/Data/Repositories/MediaSourceRepository.cs
  3. 1
      ErsatzTV.Infrastructure/Plex/Models/PlexLibraryResponse.cs
  4. 3
      ErsatzTV.Infrastructure/Plex/PlexServerApiClient.cs

1
CHANGELOG.md

@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -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

12
ErsatzTV.Infrastructure/Data/Repositories/MediaSourceRepository.cs

@ -148,16 +148,20 @@ public class MediaSourceRepository : IMediaSourceRepository @@ -148,16 +148,20 @@ public class MediaSourceRepository : IMediaSourceRepository
}
}
var libraryIds = toDelete.Map(l => l.Id).ToList();
List<int> 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<int> ids = await DisablePlexLibrarySync(toDelete.Map(l => l.Id).ToList());
await dbContext.SaveChangesAsync();
return ids;
return deletedMediaIds;
}
public async Task<List<int>> UpdateLibraries(

1
ErsatzTV.Infrastructure/Plex/Models/PlexLibraryResponse.cs

@ -5,6 +5,7 @@ public class PlexLibraryResponse @@ -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; }
}

3
ErsatzTV.Infrastructure/Plex/PlexServerApiClient.cs

@ -13,8 +13,8 @@ namespace ErsatzTV.Infrastructure.Plex; @@ -13,8 +13,8 @@ namespace ErsatzTV.Infrastructure.Plex;
public class PlexServerApiClient : IPlexServerApiClient
{
private readonly IFallbackMetadataProvider _fallbackMetadataProvider;
private readonly PlexEtag _plexEtag;
private readonly ILogger<PlexServerApiClient> _logger;
private readonly PlexEtag _plexEtag;
public PlexServerApiClient(
IFallbackMetadataProvider fallbackMetadataProvider,
@ -64,6 +64,7 @@ public class PlexServerApiClient : IPlexServerApiClient @@ -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()

Loading…
Cancel
Save