fix(media-sync): Add sanity checks upon media server sync (#4493)

* Add sanity checks upon media server sync

Fixes Media content may be improperly imported into Ombi #4472

* Fix Jellyfin sync

* Refactor Emby and Jellyfin provider ids

* Use new method Any

* Fix log formatting
pull/4500/head
sephrat 3 years ago committed by GitHub
parent 4e7546f635
commit 9915234d38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,12 +1,10 @@
namespace Ombi.Api.Emby.Models.Movie using Ombi.Api.MediaServer.Models;
namespace Ombi.Api.Emby.Models.Movie
{ {
public class EmbyProviderids public class EmbyProviderids: BaseProviderids
{ {
public string Tmdb { get; set; }
public string Imdb { get; set; }
public string TmdbCollection { get; set; } public string TmdbCollection { get; set; }
public string Tvdb { get; set; }
public string Zap2It { get; set; } public string Zap2It { get; set; }
public string TvRage { get; set; } public string TvRage { get; set; }
} }

@ -12,6 +12,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" /> <ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
<ProjectReference Include="..\Ombi.Api.MediaServer\Ombi.Api.MediaServer.csproj" />
<ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" /> <ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" />
</ItemGroup> </ItemGroup>

@ -1,12 +1,10 @@
namespace Ombi.Api.Jellyfin.Models.Movie using Ombi.Api.MediaServer.Models;
namespace Ombi.Api.Jellyfin.Models.Movie
{ {
public class JellyfinProviderids public class JellyfinProviderids: BaseProviderids
{ {
public string Tmdb { get; set; }
public string Imdb { get; set; }
public string TmdbCollection { get; set; } public string TmdbCollection { get; set; }
public string Tvdb { get; set; }
public string Zap2It { get; set; } public string Zap2It { get; set; }
public string TvRage { get; set; } public string TvRage { get; set; }
} }

@ -13,6 +13,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" /> <ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
<ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" /> <ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" />
<ProjectReference Include="..\Ombi.Api.MediaServer\Ombi.Api.MediaServer.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -0,0 +1,11 @@
namespace Ombi.Api.MediaServer.Models
{
public class BaseProviderids
{
public string Tmdb { get; set; }
public string Imdb { get; set; }
public string Tvdb { get; set; }
public bool Any() =>
!string.IsNullOrEmpty(Imdb) || !string.IsNullOrEmpty(Tmdb) || !string.IsNullOrEmpty(Tvdb);
}
}

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<FileVersion>3.0.0.0</FileVersion>
<Version></Version>
<PackageVersion></PackageVersion>
<LangVersion>8.0</LangVersion>
<Configurations>Debug;Release;NonUiBuild</Configurations>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
<ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" />
</ItemGroup>
</Project>

@ -149,7 +149,7 @@ namespace Ombi.Schedule.Jobs.Emby
foreach (var tvShow in tv.Items) foreach (var tvShow in tv.Items)
{ {
processed++; processed++;
if (string.IsNullOrEmpty(tvShow.ProviderIds?.Tvdb)) if (!tvShow.ProviderIds.Any())
{ {
_logger.LogInformation("Provider Id on tv {0} is null", tvShow.Name); _logger.LogInformation("Provider Id on tv {0} is null", tvShow.Name);
continue; continue;
@ -249,6 +249,12 @@ namespace Ombi.Schedule.Jobs.Emby
var alreadyGoingToAdd = content.Any(x => x.EmbyId == movieInfo.Id); var alreadyGoingToAdd = content.Any(x => x.EmbyId == movieInfo.Id);
if (existingMovie == null && !alreadyGoingToAdd) if (existingMovie == null && !alreadyGoingToAdd)
{ {
if (!movieInfo.ProviderIds.Any())
{
_logger.LogWarning($"Movie {movieInfo.Name} has no relevant metadata. Skipping.");
return;
}
_logger.LogDebug("Adding new movie {0}", movieInfo.Name); _logger.LogDebug("Adding new movie {0}", movieInfo.Name);
content.Add(new EmbyContent content.Add(new EmbyContent
{ {

@ -152,6 +152,13 @@ namespace Ombi.Schedule.Jobs.Emby
if (existingEpisode == null && !existingInList) if (existingEpisode == null && !existingInList)
{ {
// Sanity checks
if (ep.IndexNumber == 0)
{
_logger.LogWarning($"Episode {ep.Name} has no episode number. Skipping.");
continue;
}
_logger.LogDebug("Adding new episode {0} to parent {1}", ep.Name, ep.SeriesName); _logger.LogDebug("Adding new episode {0} to parent {1}", ep.Name, ep.SeriesName);
// add it // add it
epToAdd.Add(new EmbyEpisode epToAdd.Add(new EmbyEpisode

@ -127,7 +127,7 @@ namespace Ombi.Schedule.Jobs.Jellyfin
{ {
processed++; processed++;
if (string.IsNullOrEmpty(tvShow.ProviderIds?.Tvdb)) if (!tvShow.ProviderIds.Any())
{ {
_logger.LogInformation("Provider Id on tv {0} is null", tvShow.Name); _logger.LogInformation("Provider Id on tv {0} is null", tvShow.Name);
continue; continue;
@ -217,6 +217,11 @@ namespace Ombi.Schedule.Jobs.Jellyfin
var alreadyGoingToAdd = content.Any(x => x.JellyfinId == movieInfo.Id); var alreadyGoingToAdd = content.Any(x => x.JellyfinId == movieInfo.Id);
if (existingMovie == null && !alreadyGoingToAdd) if (existingMovie == null && !alreadyGoingToAdd)
{ {
if (!movieInfo.ProviderIds.Any())
{
_logger.LogWarning($"Movie {movieInfo.Name} has no relevant metadata. Skipping.");
return;
}
_logger.LogDebug("Adding new movie {0}", movieInfo.Name); _logger.LogDebug("Adding new movie {0}", movieInfo.Name);
content.Add(new JellyfinContent content.Add(new JellyfinContent
{ {

@ -128,6 +128,13 @@ namespace Ombi.Schedule.Jobs.Jellyfin
if (existingEpisode == null && !existingInList) if (existingEpisode == null && !existingInList)
{ {
// Sanity checks
if (ep.IndexNumber == 0) // no check on season number, Season 0 can be Specials
{
_logger.LogWarning($"Episode {ep.Name} has no episode number. Skipping.");
continue;
}
_logger.LogDebug("Adding new episode {0} to parent {1}", ep.Name, ep.SeriesName); _logger.LogDebug("Adding new episode {0} to parent {1}", ep.Name, ep.SeriesName);
// add it // add it
epToAdd.Add(new JellyfinEpisode epToAdd.Add(new JellyfinEpisode

@ -342,6 +342,11 @@ namespace Ombi.Schedule.Jobs.Plex
} }
} }
if (!guids.Any())
{
Logger.LogWarning($"Movie {movie.title} has no relevant metadata. Skipping.");
continue;
}
var providerIds = PlexHelper.GetProviderIdsFromMetadata(guids.ToArray()); var providerIds = PlexHelper.GetProviderIdsFromMetadata(guids.ToArray());
var item = new PlexServerContent var item = new PlexServerContent

@ -179,6 +179,13 @@ namespace Ombi.Schedule.Jobs.Plex
episode.grandparentRatingKey = seriesExists.Key; episode.grandparentRatingKey = seriesExists.Key;
} }
// Sanity checks
if (episode.index == 0)
{
_log.LogWarning($"Episode {episode.title} has no episode number. Skipping.");
continue;
}
ep.Add(new PlexEpisode ep.Add(new PlexEpisode
{ {
EpisodeNumber = episode.index, EpisodeNumber = episode.index,

Loading…
Cancel
Save