Skip to content

Commit

Permalink
feat(plex): ⚡ Use the new Plex Pass includeGuids feature for syncing …
Browse files Browse the repository at this point in the history
…plex movies
  • Loading branch information
tidusjar committed Sep 16, 2021
1 parent fc69158 commit 7c5646d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/Ombi.Api.Plex/Models/Metadata.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Collections.Generic;

namespace Ombi.Api.Plex.Models
{
public class Metadata
Expand Down Expand Up @@ -44,7 +46,7 @@ public class Metadata
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; }
}
Expand Down
1 change: 1 addition & 0 deletions src/Ombi.Api.Plex/PlexApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public async Task<PlexContainer> GetLibrarySections(string authToken, string ple
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);
}
Expand Down
27 changes: 18 additions & 9 deletions src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,26 @@ private async Task<ProcessedContent> ProcessServer(PlexServers servers, bool rec
}

Logger.LogDebug("Adding movie {0}", movie.title);
var metaData = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri,
movie.ratingKey);

var meta = metaData.MediaContainer.Metadata.FirstOrDefault();
var guids = new List<string>
var guids = new List<string>();
if (!movie.Guid.Any())
{
meta.guid
};
if (meta.Guid != null)
var metaData = await PlexApi.GetMetadata(servers.PlexAuthToken, servers.FullUri,
movie.ratingKey);

var meta = metaData.MediaContainer.Metadata.FirstOrDefault();
guids.Add(meta.guid);
if (meta.Guid != null)
{
foreach (var g in meta.Guid)
{
guids.Add(g.Id);
}
}
}
else
{
foreach (var g in meta.Guid)
// Currently a Plex Pass feature only
foreach (var g in movie.Guid)
{
guids.Add(g.Id);
}
Expand Down

0 comments on commit 7c5646d

Please sign in to comment.