Skip to content

Commit

Permalink
fix(plex): Fixed some errors around the scanner that was causing the …
Browse files Browse the repository at this point in the history
…scan to fail
  • Loading branch information
tidusjar committed Aug 20, 2024
1 parent be886ee commit d9787dc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
14 changes: 13 additions & 1 deletion src/Ombi.Schedule/Jobs/Ombi/RefreshMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Ombi.Api.Emby;
using Ombi.Api.Jellyfin;
using Ombi.Api.Plex;
using Ombi.Api.Plex.Models;
using Ombi.Api.TheMovieDb;
using Ombi.Api.TheMovieDb.Models;
using Ombi.Api.TvMaze;
Expand Down Expand Up @@ -286,7 +287,18 @@ private async Task StartPlexMovies(List<PlexServerContent> allMovies, PlexSettin
continue;
}
var servers = settings.Servers[0];
var metaData = await _plexApi.GetMetadata(servers.PlexAuthToken, settings.Servers[0].FullUri, movie.Key);
PlexMetadata metaData = null;

try
{
metaData = await _plexApi.GetMetadata(servers.PlexAuthToken, settings.Servers[0].FullUri, movie.Key);
}
catch (Exception e)
{
_log.LogError($"Could not find the metadata for title: '{movie.Title}', skipping");
_log.LogDebug(e, $"Could not find the metadata for title: '{movie.Title}', skipping");
continue;
}
var guids = new List<string>();

var meta = metaData.MediaContainer.Metadata.FirstOrDefault();
Expand Down
15 changes: 8 additions & 7 deletions src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,13 @@ public async Task MovieLoop(PlexServers servers, Mediacontainer content, HashSet
var existing = await Repo.GetFirstContentByCustom(x => x.Title == movie.title
&& x.ReleaseYear == movie.year.ToString()
&& x.Type == MediaType.Movie);


if (existing == null)
{
// Let's just check the key
existing = await Repo.GetByKey(movie.ratingKey);
}
if (existing != null)
{
// We need to see if this is a different quality,
Expand Down Expand Up @@ -340,13 +347,7 @@ public async Task MovieLoop(PlexServers servers, Mediacontainer content, HashSet

Logger.LogDebug($"We already have movie {movie.title}");
continue;
}

//var hasSameKey = await Repo.GetByKey(movie.ratingKey);
//if (hasSameKey != null)
//{
// await Repo.Delete(hasSameKey);
//}
}

Logger.LogDebug("Adding movie {0}", movie.title);
var guids = new List<string>();
Expand Down
2 changes: 1 addition & 1 deletion src/Ombi.Store/Repository/PlexContentRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public async Task<PlexServerContent> GetByType(string providerId, ProviderType t

public async Task<PlexServerContent> GetByKey(string key)
{
return await Db.PlexServerContent.Include(x => x.Seasons).FirstOrDefaultAsync(x => x.Key == key);
return await Db.PlexServerContent.Include(x => x.Seasons).Include(x => x.Episodes).FirstOrDefaultAsync(x => x.Key == key);
}

public IEnumerable<PlexServerContent> GetWhereContentByCustom(Expression<Func<PlexServerContent, bool>> predicate)
Expand Down

0 comments on commit d9787dc

Please sign in to comment.