|
|
|
@ -44,8 +44,24 @@ namespace NzbDrone.Core.Notifications.Plex
|
|
|
|
|
_logger.Trace("Sections response: {0}", response.Content);
|
|
|
|
|
CheckForError(response, settings);
|
|
|
|
|
|
|
|
|
|
return Json.Deserialize<PlexMediaContainer>(response.Content)
|
|
|
|
|
.Directories
|
|
|
|
|
if (response.Content.Contains("_children"))
|
|
|
|
|
{
|
|
|
|
|
return Json.Deserialize<PlexMediaContainerLegacy>(response.Content)
|
|
|
|
|
.Sections
|
|
|
|
|
.Where(d => d.Type == "show")
|
|
|
|
|
.Select(s => new PlexSection
|
|
|
|
|
{
|
|
|
|
|
Id = s.Id,
|
|
|
|
|
Language = s.Language,
|
|
|
|
|
Location = s.Locations.FirstOrDefault(),
|
|
|
|
|
Type = s.Type
|
|
|
|
|
})
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Json.Deserialize<PlexResponse<PlexSectionsContainer>>(response.Content)
|
|
|
|
|
.MediaContainer
|
|
|
|
|
.Sections
|
|
|
|
|
.Where(d => d.Type == "show")
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
@ -81,6 +97,11 @@ namespace NzbDrone.Core.Notifications.Plex
|
|
|
|
|
_logger.Trace("Version response: {0}", response.Content);
|
|
|
|
|
CheckForError(response, settings);
|
|
|
|
|
|
|
|
|
|
if (response.Content.Contains("MediaContainer"))
|
|
|
|
|
{
|
|
|
|
|
return Json.Deserialize<PlexResponse<PlexIdentity>>(response.Content).MediaContainer.Version;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Json.Deserialize<PlexIdentity>(response.Content).Version;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -93,7 +114,12 @@ namespace NzbDrone.Core.Notifications.Plex
|
|
|
|
|
_logger.Trace("Preferences response: {0}", response.Content);
|
|
|
|
|
CheckForError(response, settings);
|
|
|
|
|
|
|
|
|
|
return Json.Deserialize<PlexPreferences>(response.Content).Preferences;
|
|
|
|
|
if (response.Content.Contains("MediaContainer"))
|
|
|
|
|
{
|
|
|
|
|
return Json.Deserialize<PlexResponse<PlexPreferences>>(response.Content).MediaContainer.Preferences;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Json.Deserialize<PlexPreferencesLegacy>(response.Content).Preferences;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int? GetMetadataId(int sectionId, int tvdbId, string language, PlexServerSettings settings)
|
|
|
|
@ -107,8 +133,19 @@ namespace NzbDrone.Core.Notifications.Plex
|
|
|
|
|
_logger.Trace("Sections response: {0}", response.Content);
|
|
|
|
|
CheckForError(response, settings);
|
|
|
|
|
|
|
|
|
|
var items = Json.Deserialize<PlexSectionResponse>(response.Content)
|
|
|
|
|
.Items;
|
|
|
|
|
List<PlexSectionItem> items;
|
|
|
|
|
|
|
|
|
|
if (response.Content.Contains("_children"))
|
|
|
|
|
{
|
|
|
|
|
items = Json.Deserialize<PlexSectionResponseLegacy>(response.Content)
|
|
|
|
|
.Items;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
items = Json.Deserialize<PlexSectionResponse>(response.Content)
|
|
|
|
|
.Items;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (items == null || items.Empty())
|
|
|
|
|
{
|
|
|
|
@ -203,7 +240,9 @@ namespace NzbDrone.Core.Notifications.Plex
|
|
|
|
|
throw new PlexAuthenticationException("Unauthorized - Username or password is incorrect");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var error = Json.Deserialize<PlexError>(response.Content);
|
|
|
|
|
var error = response.Content.Contains("MediaContainer") ?
|
|
|
|
|
Json.Deserialize<PlexResponse<PlexError>>(response.Content).MediaContainer :
|
|
|
|
|
Json.Deserialize<PlexError>(response.Content);
|
|
|
|
|
|
|
|
|
|
if (error != null && !error.Error.IsNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
|