Added the support for TV Series integrating with Sonarr

This commit is contained in:
Jamie Rees 2016-03-13 20:58:42 +00:00
commit 5dd9885885
15 changed files with 250 additions and 10 deletions

View file

@ -60,6 +60,43 @@ namespace PlexRequests.Api {
}
}
/// <summary>
/// Looks up a localized string similar to {
/// &quot;title&quot;: &quot;Archer (2009)&quot;,
/// &quot;seasons&quot;: [
/// {
/// &quot;seasonNumber&quot;: 5,
/// &quot;monitored&quot;: true
/// },
/// {
/// &quot;seasonNumber&quot;: 4,
/// &quot;monitored&quot;: true
/// },
/// {
/// &quot;seasonNumber&quot;: 3,
/// &quot;monitored&quot;: true
/// },
/// {
/// &quot;seasonNumber&quot;: 2,
/// &quot;monitored&quot;: true
/// },
/// {
/// &quot;seasonNumber&quot;: 1,
/// &quot;monitored&quot;: true
/// },
/// {
/// &quot;seasonNumber&quot;: 0,
/// &quot;monitored&quot;: false
/// }
/// ],
/// &quot;pat [rest of string was truncated]&quot;;.
/// </summary>
internal static string Sonarr_AddSeriesResult {
get {
return ResourceManager.GetString("Sonarr_AddSeriesResult", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to [
/// {

View file

@ -117,6 +117,47 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Sonarr_AddSeriesResult" xml:space="preserve">
<value>{
"title": "Archer (2009)",
"seasons": [
{
"seasonNumber": 5,
"monitored": true
},
{
"seasonNumber": 4,
"monitored": true
},
{
"seasonNumber": 3,
"monitored": true
},
{
"seasonNumber": 2,
"monitored": true
},
{
"seasonNumber": 1,
"monitored": true
},
{
"seasonNumber": 0,
"monitored": false
}
],
"path": "T:\\Archer (2009)",
"qualityProfileId": 1,
"seasonFolder": true,
"monitored": true,
"tvdbId": 110381,
"tvRageId": 23354,
"cleanTitle": "archer2009",
"imdbId": "tt1486217",
"titleSlug": "archer-2009",
"id": 1
}</value>
</data>
<data name="Sonarr_Profiles" xml:space="preserve">
<value>[
{

View file

@ -42,5 +42,13 @@ namespace PlexRequests.Api.Mocks
var obj = JsonConvert.DeserializeObject<List<SonarrProfile>>(json);
return obj;
}
public SonarrAddSeries AddSeries(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath, bool episodes,
string apiKey, Uri baseUrl)
{
var json = MockApiData.Sonarr_AddSeriesResult;
var obj = JsonConvert.DeserializeObject<SonarrAddSeries>(json);
return obj;
}
}
}

View file

@ -45,7 +45,7 @@ namespace PlexRequests.Api
public List<SonarrProfile> GetProfiles(string apiKey, Uri baseUrl)
{
var request = new RestRequest { Resource = "/api/profile", Method = Method.GET};
var request = new RestRequest { Resource = "/api/profile", Method = Method.GET };
request.AddHeader("X-Api-Key", apiKey);
@ -53,5 +53,50 @@ namespace PlexRequests.Api
return obj;
}
public SonarrAddSeries AddSeries(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath, bool episodes, string apiKey, Uri baseUrl)
{
var request = new RestRequest
{
Resource = "/api/Series?",
Method = Method.POST
};
var options = new SonarrAddSeries();
if (episodes == true)
{
options.addOptions = new AddOptions
{
ignoreEpisodesWithFiles = true,
ignoreEpisodesWithoutFiles = true,
searchForMissingEpisodes = false
};
}
else
{
options.addOptions = new AddOptions
{
ignoreEpisodesWithFiles = false,
searchForMissingEpisodes = true,
ignoreEpisodesWithoutFiles = false
};
}
options.seasonFolder = seasonFolders;
options.title = title;
options.qualityProfileId = qualityId;
options.tvdbId = tvdbId;
options.titleSlug = title;
options.seasons = new List<Season>();
options.rootFolderPath = rootPath;
request.AddHeader("X-Api-Key", apiKey);
request.AddJsonBody(options);
var obj = Api.ExecuteJson<SonarrAddSeries>(request, baseUrl);
return obj;
}
}
}