Fixed the issue where we wouldn't correctly mark some shows as available when there was no provider id #2429

pull/2452/head
Jamie 6 years ago
parent e4f90e6c17
commit 51f5bbc6a8

@ -381,6 +381,19 @@ namespace Ombi.Schedule.Jobs.Plex
if (existingContent != null) if (existingContent != null)
{ {
// Let's make sure that we have some sort of ID e.g. Imdbid for this,
// Looks like it's possible to not have an Id for a show
// I suspect we cached that show just as it was added to Plex.
if (!existingContent.HasImdb && !existingContent.HasTheMovieDb && !existingContent.HasTvDb)
{
var showMetadata = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri,
existingContent.Key);
GetProviderIds(showMetadata, existingContent);
await Repo.Update(existingContent);
}
// Just check the key // Just check the key
if (existingKey != null) if (existingKey != null)
{ {
@ -478,9 +491,6 @@ namespace Ombi.Schedule.Jobs.Plex
// But it does not contain the `guid` property that we need to pull out thetvdb id... // But it does not contain the `guid` property that we need to pull out thetvdb id...
var showMetadata = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri, var showMetadata = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri,
show.ratingKey); show.ratingKey);
var providerIds =
PlexHelper.GetProviderIdFromPlexGuid(showMetadata.MediaContainer.Metadata.FirstOrDefault()
.guid);
var item = new PlexServerContent var item = new PlexServerContent
{ {
@ -492,20 +502,7 @@ namespace Ombi.Schedule.Jobs.Plex
Url = PlexHelper.GetPlexMediaUrl(servers.MachineIdentifier, show.ratingKey), Url = PlexHelper.GetPlexMediaUrl(servers.MachineIdentifier, show.ratingKey),
Seasons = new List<PlexSeasonsContent>() Seasons = new List<PlexSeasonsContent>()
}; };
if (providerIds.Type == ProviderType.ImdbId) GetProviderIds(showMetadata, item);
{
item.ImdbId = providerIds.ImdbId;
}
if (providerIds.Type == ProviderType.TheMovieDbId)
{
item.TheMovieDbId = providerIds.TheMovieDb;
}
if (providerIds.Type == ProviderType.TvDbId)
{
item.TvDbId = providerIds.TheTvDb;
}
// Let's just double check to make sure we do not have it now we have some id's // Let's just double check to make sure we do not have it now we have some id's
var existingImdb = false; var existingImdb = false;
@ -547,6 +544,27 @@ namespace Ombi.Schedule.Jobs.Plex
} }
} }
private static void GetProviderIds(PlexMetadata showMetadata, PlexServerContent existingContent)
{
var providerIds =
PlexHelper.GetProviderIdFromPlexGuid(showMetadata.MediaContainer.Metadata.FirstOrDefault()
.guid);
if (providerIds.Type == ProviderType.ImdbId)
{
existingContent.ImdbId = providerIds.ImdbId;
}
if (providerIds.Type == ProviderType.TheMovieDbId)
{
existingContent.TheMovieDbId = providerIds.TheMovieDb;
}
if (providerIds.Type == ProviderType.TvDbId)
{
existingContent.TvDbId = providerIds.TheTvDb;
}
}
/// <summary> /// <summary>
/// Gets all the library sections. /// Gets all the library sections.
/// If the user has specified only certain libraries then we will only look for those /// If the user has specified only certain libraries then we will only look for those

Loading…
Cancel
Save