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
{
public class Metadata
@ -44,7 +46,7 @@ namespace Ombi.Api.Plex.Models
public string grandparentTheme { get; set; }
public string chapterSource { 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 Writer[] Writer { get; set; }
}

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

@ -287,14 +287,14 @@ namespace Ombi.Schedule.Jobs.Plex
}
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,
movie.ratingKey);
var meta = metaData.MediaContainer.Metadata.FirstOrDefault();
var guids = new List<string>
{
meta.guid
};
guids.Add(meta.guid);
if (meta.Guid != null)
{
foreach (var g in meta.Guid)
@ -302,6 +302,15 @@ namespace Ombi.Schedule.Jobs.Plex
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());

Loading…
Cancel
Save