Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tidusjar committed Oct 9, 2016
1 parent 9a3eb5f commit 6e3e290
Show file tree
Hide file tree
Showing 22 changed files with 766 additions and 34 deletions.
1 change: 1 addition & 0 deletions PlexRequests.Api.Interfaces/IPlexApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ public interface IPlexApi
PlexSearch GetAllEpisodes(string authToken, Uri host, string section, int startPage, int returnCount);
PlexServer GetServer(string authToken);
PlexSeasonMetadata GetSeasons(string authToken, Uri plexFullHost, string ratingKey);
RecentlyAdded RecentlyAdded(string authToken, Uri plexFullHost);
}
}
84 changes: 84 additions & 0 deletions PlexRequests.Api.Models/Plex/RecentlyAdded.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: RecentlyAdded.cs
// Created By: Jamie Rees
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion

using System.Collections.Generic;

namespace PlexRequests.Api.Models.Plex
{
public class RecentlyAddedChild
{
public string _elementType { get; set; }
public string allowSync { get; set; }
public string librarySectionID { get; set; }
public string librarySectionTitle { get; set; }
public string librarySectionUUID { get; set; }
public int ratingKey { get; set; }
public string key { get; set; }
public int parentRatingKey { get; set; }
public string type { get; set; }
public string title { get; set; }
public string parentKey { get; set; }
public string parentTitle { get; set; }
public string parentSummary { get; set; }
public string summary { get; set; }
public int index { get; set; }
public int parentIndex { get; set; }
public string thumb { get; set; }
public string art { get; set; }
public string parentThumb { get; set; }
public int leafCount { get; set; }
public int viewedLeafCount { get; set; }
public int addedAt { get; set; }
public int updatedAt { get; set; }
public List<object> _children { get; set; }
public string studio { get; set; }
public string contentRating { get; set; }
public string rating { get; set; }
public int? viewCount { get; set; }
public int? lastViewedAt { get; set; }
public int? year { get; set; }
public int? duration { get; set; }
public string originallyAvailableAt { get; set; }
public string chapterSource { get; set; }
public string parentTheme { get; set; }
public string titleSort { get; set; }
public string tagline { get; set; }
public int? viewOffset { get; set; }
public string originalTitle { get; set; }
}

public class RecentlyAdded
{
public string _elementType { get; set; }
public string allowSync { get; set; }
public string identifier { get; set; }
public string mediaTagPrefix { get; set; }
public string mediaTagVersion { get; set; }
public string mixedParents { get; set; }
public List<RecentlyAddedChild> _children { get; set; }
}
}
1 change: 1 addition & 0 deletions PlexRequests.Api.Models/PlexRequests.Api.Models.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<Compile Include="Plex\PlexStatus.cs" />
<Compile Include="Plex\PlexMediaType.cs" />
<Compile Include="Plex\PlexUserRequest.cs" />
<Compile Include="Plex\RecentlyAdded.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SickRage\SickRageBase.cs" />
<Compile Include="SickRage\SickrageShows.cs" />
Expand Down
33 changes: 33 additions & 0 deletions PlexRequests.Api/PlexApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,39 @@ public PlexServer GetServer(string authToken)
return servers;
}

public RecentlyAdded RecentlyAdded(string authToken, Uri plexFullHost)
{
var request = new RestRequest
{
Method = Method.GET,
Resource = "library/recentlyAdded"
};

request.AddHeader("X-Plex-Token", authToken);
request.AddHeader("X-Plex-Client-Identifier", $"PlexRequests.Net{Version}");
request.AddHeader("X-Plex-Product", "Plex Requests .Net");
request.AddHeader("X-Plex-Version", Version);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");

try
{
var lib = RetryHandler.Execute(() => Api.ExecuteJson<RecentlyAdded>(request, plexFullHost),
(exception, timespan) => Log.Error(exception, "Exception when calling RecentlyAdded for Plex, Retrying {0}", timespan), new[] {
TimeSpan.FromSeconds (5),
TimeSpan.FromSeconds(10),
TimeSpan.FromSeconds(30)
});

return lib;
}
catch (Exception e)
{
Log.Error(e, "There has been a API Exception when attempting to get the Plex RecentlyAdded");
return new RecentlyAdded();
}
}

private void AddHeaders(ref RestRequest request, string authToken)
{
request.AddHeader("X-Plex-Token", authToken);
Expand Down
6 changes: 6 additions & 0 deletions PlexRequests.Api/TheMovieDbApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public async Task<Movie> GetMovieInformation(int tmdbId)
return movies;
}

public async Task<Movie> GetMovieInformation(string imdbId)
{
var movies = await Client.GetMovie(imdbId);
return movies;
}

[Obsolete("Should use TvMaze for TV")]
public async Task<TvShow> GetTvShowInformation(int tmdbId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<div class="content" style="box-sizing: border-box; display: block; Margin: 0 auto; max-width: 580px; padding: 10px;">

<!-- START CENTERED WHITE CONTAINER -->
<span class="preheader" style="color: transparent; display: none; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">This is preheader text. Some clients will show this text as a preview.</span>
<span class="preheader" style="color: transparent; display: none; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">Plex Requests</span>
<table class="main" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; background: #fff; border-radius: 3px;" width="100%">

<!-- START MAIN CONTENT AREA -->
Expand Down
1 change: 1 addition & 0 deletions PlexRequests.Core/SettingModels/PlexRequestSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public PlexRequestSettings()
public bool Wizard { get; set; }
public bool DisableTvRequestsByEpisode { get; set; }
public bool DisableTvRequestsBySeason { get; set; }
public bool SendRecentlyAddedEmail { get; set; }

/// <summary>
/// The CSS name of the theme we want
Expand Down
2 changes: 2 additions & 0 deletions PlexRequests.Core/SettingModels/ScheduledJobsSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public ScheduledJobsSettings()
StoreCleanup = 24;
UserRequestLimitResetter = 12;
PlexEpisodeCacher = 12;
RecentlyAdded = 168;
}

public int PlexAvailabilityChecker { get; set; }
Expand All @@ -48,5 +49,6 @@ public ScheduledJobsSettings()
public int StoreCleanup { get; set; }
public int UserRequestLimitResetter { get; set; }
public int PlexEpisodeCacher { get; set; }
public int RecentlyAdded { get; set; }
}
}
19 changes: 11 additions & 8 deletions PlexRequests.Services/Interfaces/ISonarrCacher.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
namespace PlexRequests.Services.Interfaces
{
public interface ISonarrCacher
{
void Queued();
int[] QueuedIds();
}
}
using System.Collections.Generic;
using PlexRequests.Services.Models;

namespace PlexRequests.Services.Interfaces
{
public interface ISonarrCacher
{
void Queued();
IEnumerable<SonarrCachedResult> QueuedIds();
}
}
1 change: 1 addition & 0 deletions PlexRequests.Services/Jobs/JobNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ public static class JobNames
public const string StoreCleanup = "Database Cleanup";
public const string RequestLimitReset = "Request Limit Reset";
public const string EpisodeCacher = "Plex Episode Cacher";
public const string RecentlyAddedEmail = "Recently Added Email Notification";
}
}
Loading

0 comments on commit 6e3e290

Please sign in to comment.