feat(plex): Use the new Plex Pass includeGuids feature for syncing plex movies

pull/4311/head
tidusjar 3 years ago
parent fc69158597
commit 7c5646d416

@ -1,3 +1,5 @@
using System.Collections.Generic;
namespace Ombi.Api.Plex.Models namespace Ombi.Api.Plex.Models
{ {
public class Metadata public class Metadata
@ -44,7 +46,7 @@ namespace Ombi.Api.Plex.Models
public string grandparentTheme { get; set; } public string grandparentTheme { get; set; }
public string chapterSource { get; set; } public string chapterSource { get; set; }
public Medium[] Media { get; set; } public Medium[] Media { get; set; }
public PlexGuids[] Guid { get; set; } public List<PlexGuids> Guid { get; set; } = new List<PlexGuids>();
// public Director[] Director { get; set; } // public Director[] Director { get; set; }
// public Writer[] Writer { get; set; } // public Writer[] Writer { get; set; }
} }

@ -123,6 +123,7 @@ namespace Ombi.Api.Plex
public async Task<PlexContainer> GetLibrary(string authToken, string plexFullHost, string libraryId) public async Task<PlexContainer> GetLibrary(string authToken, string plexFullHost, string libraryId)
{ {
var request = new Request($"library/sections/{libraryId}/all", plexFullHost, HttpMethod.Get); var request = new Request($"library/sections/{libraryId}/all", plexFullHost, HttpMethod.Get);
request.AddQueryString("includeGuids","1");
await AddHeaders(request, authToken); await AddHeaders(request, authToken);
return await Api.Request<PlexContainer>(request); return await Api.Request<PlexContainer>(request);
} }

@ -287,14 +287,14 @@ namespace Ombi.Schedule.Jobs.Plex
} }
Logger.LogDebug("Adding movie {0}", movie.title); Logger.LogDebug("Adding movie {0}", movie.title);
var guids = new List<string>();
if (!movie.Guid.Any())
{
var metaData = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri, var metaData = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri,
movie.ratingKey); movie.ratingKey);
var meta = metaData.MediaContainer.Metadata.FirstOrDefault(); var meta = metaData.MediaContainer.Metadata.FirstOrDefault();
var guids = new List<string> guids.Add(meta.guid);
{
meta.guid
};
if (meta.Guid != null) if (meta.Guid != null)
{ {
foreach (var g in meta.Guid) foreach (var g in meta.Guid)
@ -302,6 +302,15 @@ namespace Ombi.Schedule.Jobs.Plex
guids.Add(g.Id); guids.Add(g.Id);
} }
} }
}
else
{
// Currently a Plex Pass feature only
foreach (var g in movie.Guid)
{
guids.Add(g.Id);
}
}
var providerIds = PlexHelper.GetProviderIdsFromMetadata(guids.ToArray()); var providerIds = PlexHelper.GetProviderIdsFromMetadata(guids.ToArray());

Loading…
Cancel
Save