mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Improved the search UI and made it more consistant.
Finished the Netflix API Part #884
This commit is contained in:
parent
18b12f1a97
commit
88c0651b1e
9 changed files with 98 additions and 7 deletions
|
@ -31,6 +31,6 @@ namespace Ombi.Api.Interfaces
|
|||
{
|
||||
public interface INetflixApi
|
||||
{
|
||||
NetflixMovieResult GetMovies(string movieName, string year = null);
|
||||
NetflixMovieResult CheckNetflix(string title, string year = null);
|
||||
}
|
||||
}
|
|
@ -58,5 +58,12 @@ namespace Ombi.Api.Models.Netflix
|
|||
public string Mediatype { get; set; }
|
||||
[JsonProperty(PropertyName = "runtime")]
|
||||
public string Runtime { get; set; }
|
||||
|
||||
|
||||
// For errors
|
||||
[JsonProperty(PropertyName = "errorcode")]
|
||||
public int ErrorCode { get; set; }
|
||||
[JsonProperty(PropertyName = "message")]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@
|
|||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Ombi.Api.Interfaces;
|
||||
using Ombi.Api.Models.Netflix;
|
||||
|
@ -43,10 +44,10 @@ namespace Ombi.Api
|
|||
private IApiRequest Api { get; }
|
||||
private Uri Endpoint => new Uri("http://netflixroulette.net/api/api.php");
|
||||
|
||||
public NetflixMovieResult GetMovies(string movieName, string year = null)
|
||||
public NetflixMovieResult CheckNetflix(string title, string year = null)
|
||||
{
|
||||
var request = new RestRequest();
|
||||
request.AddQueryParameter("title", movieName);
|
||||
request.AddQueryParameter("title", title);
|
||||
if (!string.IsNullOrEmpty(year))
|
||||
{
|
||||
request.AddQueryParameter("year", year);
|
||||
|
|
|
@ -304,6 +304,8 @@ $(function () {
|
|||
|
||||
var html = searchTemplate(context);
|
||||
$("#movieList").append(html);
|
||||
|
||||
checkNetflix(context.title, context.id);
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
@ -334,6 +336,9 @@ $(function () {
|
|||
var context = buildTvShowContext(result);
|
||||
var html = searchTemplate(context);
|
||||
$("#tvList").append(html);
|
||||
|
||||
checkNetflix(context.title, context.id);
|
||||
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
@ -343,6 +348,19 @@ $(function () {
|
|||
});
|
||||
};
|
||||
|
||||
function checkNetflix(title, id) {
|
||||
var url = createBaseUrl(base, '/searchextension/netflix/' + title);
|
||||
$.ajax(url).success(function (results) {
|
||||
|
||||
if (results.result) {
|
||||
// It's on Netflix
|
||||
$('#' + id + 'netflixTab')
|
||||
.html("<span class='label label-success'>Avaialble on Netflix</span>");
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function resetTvShows() {
|
||||
$("#tvList").html("");
|
||||
}
|
||||
|
|
62
Ombi.UI/Modules/SearchExtensionModule.cs
Normal file
62
Ombi.UI/Modules/SearchExtensionModule.cs
Normal file
|
@ -0,0 +1,62 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2017 Jamie Rees
|
||||
// File: SearchExtensionModule.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.Threading.Tasks;
|
||||
using Nancy;
|
||||
using Ombi.Api.Interfaces;
|
||||
using Ombi.Core;
|
||||
using Ombi.Core.SettingModels;
|
||||
|
||||
namespace Ombi.UI.Modules
|
||||
{
|
||||
public class SearchExtensionModule : BaseAuthModule
|
||||
{
|
||||
public SearchExtensionModule(ISettingsService<PlexRequestSettings> pr, ISecurityExtensions security, INetflixApi netflix) : base("searchextension",pr, security)
|
||||
{
|
||||
NetflixApi = netflix;
|
||||
|
||||
Get["/netflix/{searchTerm}", true] = async (x, ctx) => await Netflix(x.searchTerm);
|
||||
}
|
||||
|
||||
private INetflixApi NetflixApi { get; }
|
||||
|
||||
|
||||
public async Task<Response> Netflix(string title)
|
||||
{
|
||||
var result = NetflixApi.CheckNetflix(title);
|
||||
|
||||
if (!string.IsNullOrEmpty(result.Message))
|
||||
{
|
||||
return Response.AsJson(new { Result = false });
|
||||
}
|
||||
|
||||
return Response.AsJson(new { Result = true });
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -46,6 +46,7 @@ namespace Ombi.UI.NinjectModules
|
|||
Bind<ISlackApi>().To<SlackApi>();
|
||||
Bind<IApiRequest>().To<ApiRequest>();
|
||||
Bind<IWatcherApi>().To<WatcherApi>();
|
||||
Bind<INetflixApi>().To<NetflixRouletteApi>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -273,6 +273,7 @@
|
|||
<Compile Include="Modules\IssuesModule.cs" />
|
||||
<Compile Include="Modules\LandingPageModule.cs" />
|
||||
<Compile Include="Modules\LayoutModule.cs" />
|
||||
<Compile Include="Modules\SearchExtensionModule.cs" />
|
||||
<Compile Include="Modules\UserWizardModule.cs" />
|
||||
<Compile Include="NinjectModules\ApiModule.cs" />
|
||||
<Compile Include="NinjectModules\ConfigurationModule.cs" />
|
||||
|
|
|
@ -107,7 +107,7 @@
|
|||
}
|
||||
|
||||
<!-- Movie and TV Results template -->
|
||||
<script id="search-template" type="text/x-handlebars-template">
|
||||
<script id="search-template" type="text/x-handlebars-template">
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
|
||||
|
@ -134,7 +134,6 @@
|
|||
<h4>{{title}} ({{year}})</h4>
|
||||
</a>
|
||||
{{/if_eq}}
|
||||
{{#if_eq type "tv"}}
|
||||
{{#if available}}
|
||||
<span class="label label-success">@UI.Search_Available_on_plex</span>
|
||||
{{else}}
|
||||
|
@ -146,9 +145,11 @@
|
|||
<span class="label label-danger">@UI.Search_Not_Requested_Yet</span>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
<span id="{{id}}netflixTab"></span>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
{{/if_eq}}
|
||||
</div>
|
||||
<p>{{overview}}</p>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue