mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
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
This commit is contained in:
parent
4e7546f635
commit
9915234d38
12 changed files with 83 additions and 19 deletions
|
@ -1,12 +1,10 @@
|
||||||
namespace Ombi.Api.Emby.Models.Movie
|
using Ombi.Api.MediaServer.Models;
|
||||||
{
|
|
||||||
public class EmbyProviderids
|
|
||||||
{
|
|
||||||
public string Tmdb { get; set; }
|
|
||||||
public string Imdb { get; set; }
|
|
||||||
public string TmdbCollection { get; set; }
|
|
||||||
|
|
||||||
public string Tvdb { get; set; }
|
namespace Ombi.Api.Emby.Models.Movie
|
||||||
|
{
|
||||||
|
public class EmbyProviderids: BaseProviderids
|
||||||
|
{
|
||||||
|
public string TmdbCollection { 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;
|
||||||
{
|
|
||||||
public class JellyfinProviderids
|
|
||||||
{
|
|
||||||
public string Tmdb { get; set; }
|
|
||||||
public string Imdb { get; set; }
|
|
||||||
public string TmdbCollection { get; set; }
|
|
||||||
|
|
||||||
public string Tvdb { get; set; }
|
namespace Ombi.Api.Jellyfin.Models.Movie
|
||||||
|
{
|
||||||
|
public class JellyfinProviderids: BaseProviderids
|
||||||
|
{
|
||||||
|
public string TmdbCollection { 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>
|
11
src/Ombi.Api.MediaServer/Models/BaseProviderids.cs
Normal file
11
src/Ombi.Api.MediaServer/Models/BaseProviderids.cs
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
18
src/Ombi.Api.MediaServer/Ombi.Api.MediaServer.csproj
Normal file
18
src/Ombi.Api.MediaServer/Ombi.Api.MediaServer.csproj
Normal file
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace Ombi.Schedule.Jobs.Jellyfin
|
||||||
public async Task Execute(IJobExecutionContext job)
|
public async Task Execute(IJobExecutionContext job)
|
||||||
{
|
{
|
||||||
var settings = await _settings.GetSettingsAsync();
|
var settings = await _settings.GetSettingsAsync();
|
||||||
|
|
||||||
Api = _apiFactory.CreateClient(settings);
|
Api = _apiFactory.CreateClient(settings);
|
||||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||||
.SendAsync(NotificationHub.NotificationEvent, "Jellyfin Episode Sync Started");
|
.SendAsync(NotificationHub.NotificationEvent, "Jellyfin Episode Sync Started");
|
||||||
|
@ -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…
Add table
Add a link
Reference in a new issue