|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Common;
|
|
|
|
|
using NzbDrone.Common.Cache;
|
|
|
|
|
using NzbDrone.Common.Serializer;
|
|
|
|
@ -19,10 +20,12 @@ namespace NzbDrone.Core.Notifications.Plex
|
|
|
|
|
public class PlexServerProxy : IPlexServerProxy
|
|
|
|
|
{
|
|
|
|
|
private readonly ICached<String> _authCache;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
public PlexServerProxy(ICacheManager cacheManager)
|
|
|
|
|
public PlexServerProxy(ICacheManager cacheManager, Logger logger)
|
|
|
|
|
{
|
|
|
|
|
_authCache = cacheManager.GetCache<String>(GetType(), "authCache");
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<PlexDirectory> GetTvSections(PlexServerSettings settings)
|
|
|
|
@ -32,6 +35,9 @@ namespace NzbDrone.Core.Notifications.Plex
|
|
|
|
|
|
|
|
|
|
var response = client.Execute(request);
|
|
|
|
|
|
|
|
|
|
CheckForError(response.Content);
|
|
|
|
|
_logger.Trace("Sections response: {0}", response.Content);
|
|
|
|
|
|
|
|
|
|
return Json.Deserialize<PlexMediaContainer>(response.Content)
|
|
|
|
|
.Directories
|
|
|
|
|
.Where(d => d.Type == "show")
|
|
|
|
@ -45,6 +51,9 @@ namespace NzbDrone.Core.Notifications.Plex
|
|
|
|
|
var client = GetPlexServerClient(settings);
|
|
|
|
|
|
|
|
|
|
var response = client.Execute(request);
|
|
|
|
|
|
|
|
|
|
CheckForError(response.Content);
|
|
|
|
|
_logger.Trace("Update response: {0}", response.Content);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String Authenticate(string username, string password)
|
|
|
|
@ -53,6 +62,7 @@ namespace NzbDrone.Core.Notifications.Plex
|
|
|
|
|
var client = GetMyPlexClient(username, password);
|
|
|
|
|
|
|
|
|
|
var response = client.Execute(request);
|
|
|
|
|
|
|
|
|
|
CheckForError(response.Content);
|
|
|
|
|
|
|
|
|
|
var user = Json.Deserialize<PlexUser>(JObject.Parse(response.Content).SelectToken("user").ToString());
|
|
|
|
|