Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New features added #13

Merged
merged 22 commits into from
Mar 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion PlexRequests.Api.Interfaces/ICouchPotatoApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@

using System;

using PlexRequests.Api.Models.Movie;

namespace PlexRequests.Api.Interfaces
{
public interface ICouchPotatoApi
{
bool AddMovie(string imdbid, string apiKey, string title, Uri baseUrl);

CouchPotatoStatus GetStatus(Uri url, string apiKey);
}
}
1 change: 1 addition & 0 deletions PlexRequests.Api.Interfaces/IPlexApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public interface IPlexApi
PlexAuthentication SignIn(string username, string password);
PlexFriends GetUsers(string authToken);
PlexSearch SearchContent(string authToken, string searchTerm, Uri plexFullHost);
PlexStatus GetStatus(string authToken, Uri uri);

}
}
2 changes: 2 additions & 0 deletions PlexRequests.Api.Interfaces/ISonarrApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ public interface ISonarrApi

SonarrAddSeries AddSeries(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath,
bool episodes, string apiKey, Uri baseUrl);

SystemStatus SystemStatus(string apiKey, Uri baseUrl);
}
}
2 changes: 2 additions & 0 deletions PlexRequests.Api.Interfaces/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")]
13 changes: 13 additions & 0 deletions PlexRequests.Api.Models/Movie/CouchPotatoStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PlexRequests.Api.Models.Movie
{
public class CouchPotatoStatus
{
public bool success { get; set; }
}
}
3 changes: 1 addition & 2 deletions PlexRequests.Api.Models/Plex/PlexSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion

using System.Collections.Generic;
using System.Xml.Serialization;

namespace PlexRequests.Api.Models
namespace PlexRequests.Api.Models.Plex
{
[XmlRoot(ElementName = "Part")]
public class Part
Expand Down
89 changes: 89 additions & 0 deletions PlexRequests.Api.Models/Plex/PlexStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace PlexRequests.Api.Models.Plex
{
[XmlRoot(ElementName = "Directory")]
public class Directory
{
[XmlAttribute(AttributeName = "count")]
public string Count { get; set; }
[XmlAttribute(AttributeName = "key")]
public string Key { get; set; }
[XmlAttribute(AttributeName = "title")]
public string Title { get; set; }
}

[XmlRoot(ElementName = "MediaContainer")]
public class PlexStatus
{
[XmlElement(ElementName = "Directory")]
public List<Directory> Directory { get; set; }
[XmlAttribute(AttributeName = "size")]
public string Size { get; set; }
[XmlAttribute(AttributeName = "allowCameraUpload")]
public string AllowCameraUpload { get; set; }
[XmlAttribute(AttributeName = "allowChannelAccess")]
public string AllowChannelAccess { get; set; }
[XmlAttribute(AttributeName = "allowMediaDeletion")]
public string AllowMediaDeletion { get; set; }
[XmlAttribute(AttributeName = "allowSync")]
public string AllowSync { get; set; }
[XmlAttribute(AttributeName = "backgroundProcessing")]
public string BackgroundProcessing { get; set; }
[XmlAttribute(AttributeName = "certificate")]
public string Certificate { get; set; }
[XmlAttribute(AttributeName = "companionProxy")]
public string CompanionProxy { get; set; }
[XmlAttribute(AttributeName = "friendlyName")]
public string FriendlyName { get; set; }
[XmlAttribute(AttributeName = "machineIdentifier")]
public string MachineIdentifier { get; set; }
[XmlAttribute(AttributeName = "multiuser")]
public string Multiuser { get; set; }
[XmlAttribute(AttributeName = "myPlex")]
public string MyPlex { get; set; }
[XmlAttribute(AttributeName = "myPlexMappingState")]
public string MyPlexMappingState { get; set; }
[XmlAttribute(AttributeName = "myPlexSigninState")]
public string MyPlexSigninState { get; set; }
[XmlAttribute(AttributeName = "myPlexSubscription")]
public string MyPlexSubscription { get; set; }
[XmlAttribute(AttributeName = "myPlexUsername")]
public string MyPlexUsername { get; set; }
[XmlAttribute(AttributeName = "platform")]
public string Platform { get; set; }
[XmlAttribute(AttributeName = "platformVersion")]
public string PlatformVersion { get; set; }
[XmlAttribute(AttributeName = "requestParametersInCookie")]
public string RequestParametersInCookie { get; set; }
[XmlAttribute(AttributeName = "sync")]
public string Sync { get; set; }
[XmlAttribute(AttributeName = "transcoderActiveVideoSessions")]
public string TranscoderActiveVideoSessions { get; set; }
[XmlAttribute(AttributeName = "transcoderAudio")]
public string TranscoderAudio { get; set; }
[XmlAttribute(AttributeName = "transcoderLyrics")]
public string TranscoderLyrics { get; set; }
[XmlAttribute(AttributeName = "transcoderPhoto")]
public string TranscoderPhoto { get; set; }
[XmlAttribute(AttributeName = "transcoderSubtitles")]
public string TranscoderSubtitles { get; set; }
[XmlAttribute(AttributeName = "transcoderVideo")]
public string TranscoderVideo { get; set; }
[XmlAttribute(AttributeName = "transcoderVideoBitrates")]
public string TranscoderVideoBitrates { get; set; }
[XmlAttribute(AttributeName = "transcoderVideoQualities")]
public string TranscoderVideoQualities { get; set; }
[XmlAttribute(AttributeName = "transcoderVideoResolutions")]
public string TranscoderVideoResolutions { get; set; }
[XmlAttribute(AttributeName = "updatedAt")]
public string UpdatedAt { get; set; }
[XmlAttribute(AttributeName = "version")]
public string Version { get; set; }
}
}
2 changes: 1 addition & 1 deletion PlexRequests.Api.Models/Plex/PlexUserRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// ************************************************************************/
#endregion

namespace PlexRequests.Api.Models
namespace PlexRequests.Api.Models.Plex
{
public class PlexUserRequest
{
Expand Down
3 changes: 3 additions & 0 deletions PlexRequests.Api.Models/PlexRequests.Api.Models.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Movie\CouchPotatoAdd.cs" />
<Compile Include="Movie\CouchPotatoStatus.cs" />
<Compile Include="Plex\PlexAuthentication.cs" />
<Compile Include="Plex\PlexError.cs" />
<Compile Include="Plex\PlexFriends.cs" />
<Compile Include="Plex\PlexSearch.cs" />
<Compile Include="Plex\PlexStatus.cs" />
<Compile Include="Plex\PlexUserRequest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Sonarr\SonarrAddSeries.cs" />
<Compile Include="Sonarr\SonarrProfile.cs" />
<Compile Include="Sonarr\SystemStatus.cs" />
<Compile Include="Tv\Authentication.cs" />
<Compile Include="Tv\TvSearchResult.cs" />
<Compile Include="Tv\TvShow.cs" />
Expand Down
2 changes: 2 additions & 0 deletions PlexRequests.Api.Models/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")]
51 changes: 51 additions & 0 deletions PlexRequests.Api.Models/Sonarr/SystemStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: SystemStatus.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.Sonarr
{
public class SystemStatus
{
public string version { get; set; }
public string buildTime { get; set; }
public bool isDebug { get; set; }
public bool isProduction { get; set; }
public bool isAdmin { get; set; }
public bool isUserInteractive { get; set; }
public string startupPath { get; set; }
public string appData { get; set; }
public string osVersion { get; set; }
public bool isMonoRuntime { get; set; }
public bool isMono { get; set; }
public bool isLinux { get; set; }
public bool isOsx { get; set; }
public bool isWindows { get; set; }
public string branch { get; set; }
public string authentication { get; set; }
public string sqliteVersion { get; set; }
public string urlBase { get; set; }
public string runtimeVersion { get; set; }
}
}
13 changes: 10 additions & 3 deletions PlexRequests.Api/ApiRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,17 @@ public T ExecuteXml<T>(IRestRequest request, Uri baseUri) where T : class
throw new ApplicationException(message, response.ErrorException);
}

var json = JsonConvert.DeserializeObject<T>(response.Content);

return json;
try
{

var json = JsonConvert.DeserializeObject<T>(response.Content);
return json;
}
catch (Exception e)
{
Log.Fatal(e);
throw;
}
}

public T DeserializeXml<T>(string input)
Expand Down
22 changes: 22 additions & 0 deletions PlexRequests.Api/CouchPotatoApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

using NLog;
using PlexRequests.Api.Interfaces;
using PlexRequests.Api.Models.Movie;

using RestSharp;

namespace PlexRequests.Api
Expand Down Expand Up @@ -71,5 +73,25 @@ public bool AddMovie(string imdbid, string apiKey, string title, Uri baseUrl)
}
return false;
}

/// <summary>
/// Gets the status.
/// </summary>
/// <param name="url">The URL.</param>
/// <param name="apiKey">The API key.</param>
/// <returns></returns>
public CouchPotatoStatus GetStatus(Uri url, string apiKey)
{
Log.Trace("Getting CP Status, ApiKey = {0}", apiKey);
var request = new RestRequest
{
Resource = "api/{apikey}/app.available/",
Method = Method.GET
};

request.AddUrlSegment("apikey", apiKey);

return Api.Execute<CouchPotatoStatus>(request,url);
}
}
}
5 changes: 5 additions & 0 deletions PlexRequests.Api/Mocks/MockSonarrApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,10 @@ public SonarrAddSeries AddSeries(int tvdbId, string title, int qualityId, bool s
var obj = JsonConvert.DeserializeObject<SonarrAddSeries>(json);
return obj;
}

public SystemStatus SystemStatus(string apiKey, Uri baseUrl)
{
throw new NotImplementedException();
}
}
}
19 changes: 19 additions & 0 deletions PlexRequests.Api/PlexApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ public PlexSearch SearchContent(string authToken, string searchTerm, Uri plexFul

return search;
}

public PlexStatus GetStatus(string authToken, Uri uri)
{
var request = new RestRequest
{
Method = Method.GET,
};

request.AddHeader("X-Plex-Client-Identifier", "Test213");
request.AddHeader("X-Plex-Product", "Request Plex");
request.AddHeader("X-Plex-Version", Version);
request.AddHeader("X-Plex-Token", authToken);
request.AddHeader("Content-Type", "application/xml");

var api = new ApiRequest();
var users = api.ExecuteXml<PlexStatus>(request, uri);

return users;
}
}
}

1 change: 1 addition & 0 deletions PlexRequests.Api/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")]
10 changes: 10 additions & 0 deletions PlexRequests.Api/SonarrApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,15 @@ public SonarrAddSeries AddSeries(int tvdbId, string title, int qualityId, bool s

return obj;
}

public SystemStatus SystemStatus(string apiKey, Uri baseUrl)
{
var request = new RestRequest { Resource = "/api/system/status", Method = Method.GET };
request.AddHeader("X-Api-Key", apiKey);

var obj = Api.ExecuteJson<SystemStatus>(request, baseUrl);

return obj;
}
}
}
5 changes: 5 additions & 0 deletions PlexRequests.Core.Tests/PlexRequests.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<Otherwise />
</Choose>
<ItemGroup>
<Compile Include="StatusCheckerTests.cs" />
<Compile Include="AuthenticationSettingsTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand All @@ -71,6 +72,10 @@
<Project>{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}</Project>
<Name>PlexRequests.Core</Name>
</ProjectReference>
<ProjectReference Include="..\PlexRequests.Helpers\PlexRequests.Helpers.csproj">
<Project>{1252336D-42A3-482A-804C-836E60173DFA}</Project>
<Name>PlexRequests.Helpers</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
Expand Down
1 change: 1 addition & 0 deletions PlexRequests.Core.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersionAttribute("1.0.0.0")]
Loading