mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
feat(sync): Detect reidentified movies in Emby and Jellyfin
This commit is contained in:
parent
5973056393
commit
5938077d82
2 changed files with 60 additions and 27 deletions
|
@ -265,23 +265,22 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
return;
|
||||
}
|
||||
_logger.LogDebug($"Adding new movie {movieInfo.Name}");
|
||||
|
||||
content.Add(new EmbyContent
|
||||
{
|
||||
ImdbId = movieInfo.ProviderIds.Imdb,
|
||||
TheMovieDbId = movieInfo.ProviderIds?.Tmdb,
|
||||
Title = movieInfo.Name,
|
||||
Type = MediaType.Movie,
|
||||
EmbyId = movieInfo.Id,
|
||||
Url = EmbyHelper.GetEmbyMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname),
|
||||
AddedAt = DateTime.UtcNow,
|
||||
Quality = has4K ? null : quality,
|
||||
Has4K = has4K
|
||||
});
|
||||
var newMovie = new EmbyContent();
|
||||
newMovie.AddedAt = DateTime.UtcNow;
|
||||
MapEmbyContent(newMovie, movieInfo, server, has4K, quality);
|
||||
content.Add(newMovie);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!quality.Equals(existingMovie?.Quality, StringComparison.InvariantCultureIgnoreCase))
|
||||
var movieHasChanged = false;
|
||||
if(existingMovie.ImdbId != movieInfo.ProviderIds.Imdb || existingMovie.TheMovieDbId != movieInfo.ProviderIds.Tmdb)
|
||||
{
|
||||
_logger.LogDebug($"Updating existing movie '{movieInfo.Name}'");
|
||||
MapEmbyContent(existingMovie, movieInfo, server, has4K, quality);
|
||||
movieHasChanged = true;
|
||||
|
||||
}
|
||||
else if (!quality.Equals(existingMovie?.Quality, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
_logger.LogDebug($"We have found another quality for Movie '{movieInfo.Name}', Quality: '{quality}'");
|
||||
existingMovie.Quality = has4K ? null : quality;
|
||||
|
@ -290,6 +289,11 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
// Probably could refactor here
|
||||
// If a 4k movie comes in (we don't store the quality on 4k)
|
||||
// it will always get updated even know it's not changed
|
||||
movieHasChanged = true;
|
||||
}
|
||||
|
||||
if(movieHasChanged)
|
||||
{
|
||||
toUpdate.Add(existingMovie);
|
||||
}
|
||||
else
|
||||
|
@ -300,6 +304,17 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
}
|
||||
}
|
||||
|
||||
private void MapEmbyContent(EmbyContent content, EmbyMovie movieInfo, EmbyServers server, bool has4K, string quality){
|
||||
content.ImdbId = movieInfo.ProviderIds.Imdb;
|
||||
content.TheMovieDbId = movieInfo.ProviderIds?.Tmdb;
|
||||
content.Title = movieInfo.Name;
|
||||
content.Type = MediaType.Movie;
|
||||
content.EmbyId = movieInfo.Id;
|
||||
content.Url = EmbyHelper.GetEmbyMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname);
|
||||
content.Quality = has4K ? null : quality;
|
||||
content.Has4K = has4K;
|
||||
}
|
||||
|
||||
private bool ValidateSettings(EmbyServers server)
|
||||
{
|
||||
if (server?.Ip == null || string.IsNullOrEmpty(server?.ApiKey))
|
||||
|
|
|
@ -230,22 +230,22 @@ namespace Ombi.Schedule.Jobs.Jellyfin
|
|||
return;
|
||||
}
|
||||
_logger.LogDebug($"Adding new movie {movieInfo.Name}");
|
||||
content.Add(new JellyfinContent
|
||||
{
|
||||
ImdbId = movieInfo.ProviderIds.Imdb,
|
||||
TheMovieDbId = movieInfo.ProviderIds?.Tmdb,
|
||||
Title = movieInfo.Name,
|
||||
Type = MediaType.Movie,
|
||||
JellyfinId = movieInfo.Id,
|
||||
Url = JellyfinHelper.GetJellyfinMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname),
|
||||
AddedAt = DateTime.UtcNow,
|
||||
Quality = has4K ? null : quality,
|
||||
Has4K = has4K
|
||||
});
|
||||
var newMovie = new JellyfinContent();
|
||||
newMovie.AddedAt = DateTime.UtcNow;
|
||||
MapJellyfinMovie(newMovie, movieInfo, server, has4K, quality);
|
||||
content.Add(newMovie);;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!quality.Equals(existingMovie?.Quality, StringComparison.InvariantCultureIgnoreCase))
|
||||
var movieHasChanged = false;
|
||||
if(existingMovie.ImdbId != movieInfo.ProviderIds.Imdb || existingMovie.TheMovieDbId != movieInfo.ProviderIds.Tmdb)
|
||||
{
|
||||
_logger.LogDebug($"Updating existing movie '{movieInfo.Name}'");
|
||||
MapJellyfinMovie(existingMovie, movieInfo, server, has4K, quality);
|
||||
movieHasChanged = true;
|
||||
|
||||
}
|
||||
else if (!quality.Equals(existingMovie?.Quality, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
_logger.LogDebug($"We have found another quality for Movie '{movieInfo.Name}', Quality: '{quality}'");
|
||||
existingMovie.Quality = has4K ? null : quality;
|
||||
|
@ -255,6 +255,12 @@ namespace Ombi.Schedule.Jobs.Jellyfin
|
|||
// If a 4k movie comes in (we don't store the quality on 4k)
|
||||
// it will always get updated even know it's not changed
|
||||
toUpdate.Add(existingMovie);
|
||||
movieHasChanged = true;
|
||||
}
|
||||
|
||||
if(movieHasChanged)
|
||||
{
|
||||
toUpdate.Add(existingMovie);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -264,6 +270,18 @@ namespace Ombi.Schedule.Jobs.Jellyfin
|
|||
}
|
||||
}
|
||||
|
||||
private void MapJellyfinMovie(JellyfinContent content, JellyfinMovie movieInfo, JellyfinServers server, bool has4K, string quality)
|
||||
{
|
||||
content.ImdbId = movieInfo.ProviderIds.Imdb;
|
||||
content.TheMovieDbId = movieInfo.ProviderIds?.Tmdb;
|
||||
content.Title = movieInfo.Name;
|
||||
content.Type = MediaType.Movie;
|
||||
content.JellyfinId = movieInfo.Id;
|
||||
content.Url = JellyfinHelper.GetJellyfinMediaUrl(movieInfo.Id, server?.ServerId, server.ServerHostname);
|
||||
content.Quality = has4K ? null : quality;
|
||||
content.Has4K = has4K;
|
||||
}
|
||||
|
||||
private bool ValidateSettings(JellyfinServers server)
|
||||
{
|
||||
if (server?.Ip == null || string.IsNullOrEmpty(server?.ApiKey))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue