diff --git a/PlexRequests.Api.Interfaces/ISickRageApi.cs b/PlexRequests.Api.Interfaces/ISickRageApi.cs
new file mode 100644
index 000000000..516b8784f
--- /dev/null
+++ b/PlexRequests.Api.Interfaces/ISickRageApi.cs
@@ -0,0 +1,40 @@
+#region Copyright
+// /************************************************************************
+// Copyright (c) 2016 Jamie Rees
+// File: ISickRageApi.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;
+using PlexRequests.Api.Models.SickRage;
+
+namespace PlexRequests.Api.Interfaces
+{
+ public interface ISickRageApi
+ {
+ SickRageTvAdd AddSeries(int tvdbId, bool latest, string quality, string apiKey,
+ Uri baseUrl);
+
+ SickRagePing Ping(string apiKey, Uri baseUrl);
+ }
+}
\ No newline at end of file
diff --git a/PlexRequests.Api.Interfaces/PlexRequests.Api.Interfaces.csproj b/PlexRequests.Api.Interfaces/PlexRequests.Api.Interfaces.csproj
index b76996490..3ea7be621 100644
--- a/PlexRequests.Api.Interfaces/PlexRequests.Api.Interfaces.csproj
+++ b/PlexRequests.Api.Interfaces/PlexRequests.Api.Interfaces.csproj
@@ -49,6 +49,7 @@
+
diff --git a/PlexRequests.Api.Models/PlexRequests.Api.Models.csproj b/PlexRequests.Api.Models/PlexRequests.Api.Models.csproj
index 1bdc4ffe9..87a9951a6 100644
--- a/PlexRequests.Api.Models/PlexRequests.Api.Models.csproj
+++ b/PlexRequests.Api.Models/PlexRequests.Api.Models.csproj
@@ -57,6 +57,9 @@
+
+
+
diff --git a/PlexRequests.Api.Models/SickRage/SickRagePing.cs b/PlexRequests.Api.Models/SickRage/SickRagePing.cs
new file mode 100644
index 000000000..e3a7528da
--- /dev/null
+++ b/PlexRequests.Api.Models/SickRage/SickRagePing.cs
@@ -0,0 +1,40 @@
+#region Copyright
+// /************************************************************************
+// Copyright (c) 2016 Jamie Rees
+// File: SickRagePing.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
+namespace PlexRequests.Api.Models.SickRage
+{
+ public class SickRagePingData
+ {
+ public int pid { get; set; }
+ }
+
+ public class SickRagePing
+ {
+ public SickRagePingData data { get; set; }
+ public string message { get; set; }
+ public string result { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/PlexRequests.Api.Models/SickRage/SickRageStatus.cs b/PlexRequests.Api.Models/SickRage/SickRageStatus.cs
new file mode 100644
index 000000000..2ea03632d
--- /dev/null
+++ b/PlexRequests.Api.Models/SickRage/SickRageStatus.cs
@@ -0,0 +1,35 @@
+#region Copyright
+// /************************************************************************
+// Copyright (c) 2016 Jamie Rees
+// File: SickRageStatus.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
+namespace PlexRequests.Api.Models.SickRage
+{
+ public static class SickRageStatus
+ {
+ public const string Wanted = "wanted";
+ public const string Skipped = "skipped";
+ public const string Ignored = "Ignored";
+ }
+}
\ No newline at end of file
diff --git a/PlexRequests.Api.Models/SickRage/SickRageTvAdd.cs b/PlexRequests.Api.Models/SickRage/SickRageTvAdd.cs
new file mode 100644
index 000000000..0fb021163
--- /dev/null
+++ b/PlexRequests.Api.Models/SickRage/SickRageTvAdd.cs
@@ -0,0 +1,41 @@
+#region Copyright
+// /************************************************************************
+// Copyright (c) 2016 Jamie Rees
+// File: SickRageTvAdd.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
+namespace PlexRequests.Api.Models.SickRage
+{
+ public class SickRageTvAddData
+ {
+ public string name { get; set; }
+ }
+
+ public class SickRageTvAdd
+ {
+ public SickRageTvAddData data { get; set; }
+ public string message { get; set; }
+ public string result { get; set; }
+ }
+
+}
\ No newline at end of file
diff --git a/PlexRequests.Api/SickrageApi.cs b/PlexRequests.Api/SickrageApi.cs
index 26dbdb3d7..a28ac21bf 100644
--- a/PlexRequests.Api/SickrageApi.cs
+++ b/PlexRequests.Api/SickrageApi.cs
@@ -1,4 +1,5 @@
#region Copyright
+
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: CouchPotatoApi.cs
@@ -23,46 +24,65 @@
// 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;
-using System.Collections.Generic;
+using System;
using NLog;
using PlexRequests.Api.Interfaces;
-using PlexRequests.Api.Models.Sonarr;
+using PlexRequests.Api.Models.SickRage;
using RestSharp;
namespace PlexRequests.Api
{
- public class SickrageApi
+ public class SickrageApi : ISickRageApi
{
+ private static Logger Log = LogManager.GetCurrentClassLogger();
+
public SickrageApi()
{
Api = new ApiRequest();
}
- private ApiRequest Api { get; set; }
- private static Logger Log = LogManager.GetCurrentClassLogger();
+
+ private ApiRequest Api { get; }
- public SonarrAddSeries AddSeries(int tvdbId, string status, string futureStatus, string quality, string apiKey, Uri baseUrl)
+ public SickRageTvAdd AddSeries(int tvdbId, bool latest, string quality, string apiKey,
+ Uri baseUrl)
{
- //localhost:8081/api/e738882774aeb0b2210f4bc578cbb584/?cmd=show.addnew&tvdbid=101501&status=skipped&future_status=wanted&initial=fullhdbluray&sdtv
+ string status;
+ var futureStatus = SickRageStatus.Wanted;
+
+ status = latest ? SickRageStatus.Skipped : SickRageStatus.Wanted;
var request = new RestRequest
{
Resource = "/api/{apiKey}/?cmd=show.addnew",
Method = Method.GET
};
-
+ request.AddUrlSegment("apiKey", apiKey);
request.AddQueryParameter("tvdbid", tvdbId.ToString());
request.AddQueryParameter("status", status);
request.AddQueryParameter("future_status", futureStatus);
request.AddQueryParameter("initial", quality);
-
- var obj = Api.ExecuteJson(request, baseUrl);
+
+ var obj = Api.Execute(request, baseUrl);
return obj;
}
+ public SickRagePing Ping(string apiKey, Uri baseUrl)
+ {
+ var request = new RestRequest
+ {
+ Resource = "/api/{apiKey}/?cmd=sb.ping",
+ Method = Method.GET
+ };
+
+ request.AddUrlSegment("apiKey", apiKey);
+ var obj = Api.ExecuteJson(request, baseUrl);
+
+ return obj;
+ }
}
}
\ No newline at end of file
diff --git a/PlexRequests.Helpers/HtmlRemover.cs b/PlexRequests.Helpers/HtmlRemover.cs
index 64d23a6de..43d484255 100644
--- a/PlexRequests.Helpers/HtmlRemover.cs
+++ b/PlexRequests.Helpers/HtmlRemover.cs
@@ -33,6 +33,10 @@ namespace PlexRequests.Helpers
{
public static string RemoveHtml(this string value)
{
+ if (string.IsNullOrEmpty(value))
+ {
+ return string.Empty;
+ }
var step1 = Regex.Replace(value, @"<[^>]+>| ", "").Trim();
var step2 = Regex.Replace(step1, @"\s{2,}", " ");
return step2;
diff --git a/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs b/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs
index 117157927..8e641181e 100644
--- a/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs
+++ b/PlexRequests.Services.Tests/PlexAvailabilityCheckerTests.cs
@@ -108,7 +108,7 @@ namespace PlexRequests.Services.Tests
var requestMock = new Mock();
var plexMock = new Mock();
- var searchResult = new PlexSearch { Video = new List