mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
Fully switched the TV shows over to use the other provider.
This commit is contained in:
parent
46dc9d95f1
commit
7677831bbc
14 changed files with 231 additions and 30 deletions
|
@ -85,12 +85,14 @@ function movieSearch() {
|
|||
var query = $("#movieSearchContent").val();
|
||||
|
||||
$.ajax("/search/movie/" + query).success(function (results) {
|
||||
results.forEach(function (result) {
|
||||
var context = buildMovieContext(result);
|
||||
if (results.length > 0) {
|
||||
results.forEach(function(result) {
|
||||
var context = buildMovieContext(result);
|
||||
|
||||
var html = searchTemplate(context);
|
||||
$("#movieList").append(html);
|
||||
});
|
||||
var html = searchTemplate(context);
|
||||
$("#movieList").append(html);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -99,12 +101,13 @@ function tvSearch() {
|
|||
var query = $("#tvSearchContent").val();
|
||||
|
||||
$.ajax("/search/tv/" + query).success(function (results) {
|
||||
|
||||
results.data.forEach(function (result) {
|
||||
var context = buildTvShowContext(result);
|
||||
var html = searchTemplate(context);
|
||||
$("#tvList").append(html);
|
||||
});
|
||||
if (results.length > 0) {
|
||||
results.forEach(function(result) {
|
||||
var context = buildTvShowContext(result);
|
||||
var html = searchTemplate(context);
|
||||
$("#tvList").append(html);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -30,12 +30,10 @@ function buildTvShowContext(result) {
|
|||
var date = new Date(result.firstAired);
|
||||
var year = date.getFullYear();
|
||||
var context = {
|
||||
posterPath: result.posterPath,
|
||||
posterPath: result.banner,
|
||||
id: result.id,
|
||||
title: result.name,
|
||||
title: result.seriesName,
|
||||
overview: result.overview,
|
||||
voteCount: result.voteCount,
|
||||
voteAverage: result.voteAverage,
|
||||
year: year,
|
||||
type: "tv"
|
||||
};
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace PlexRequests.UI.Models
|
|||
public class RequestViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int Tmdbid { get; set; }
|
||||
public int ProviderId { get; set; }
|
||||
public string ImdbId { get; set; }
|
||||
public string Overview { get; set; }
|
||||
public string Title { get; set; }
|
||||
|
|
55
PlexRequests.UI/Models/SearchTvShowViewModel.cs
Normal file
55
PlexRequests.UI/Models/SearchTvShowViewModel.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2016 Jamie Rees
|
||||
// File: SearchTvShowViewModel.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.UI.Models
|
||||
{
|
||||
public class SearchTvShowViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string SeriesName { get; set; }
|
||||
public List<string> Aliases { get; set; }
|
||||
public string Banner { get; set; }
|
||||
public int SeriesId { get; set; }
|
||||
public string Status { get; set; }
|
||||
public string FirstAired { get; set; }
|
||||
public string Network { get; set; }
|
||||
public string NetworkId { get; set; }
|
||||
public string Runtime { get; set; }
|
||||
public List<string> Genre { get; set; }
|
||||
public string Overview { get; set; }
|
||||
public int LastUpdated { get; set; }
|
||||
public string AirsDayOfWeek { get; set; }
|
||||
public string AirsTime { get; set; }
|
||||
public string Rating { get; set; }
|
||||
public string ImdbId { get; set; }
|
||||
public string Zap2ItId { get; set; }
|
||||
public string Added { get; set; }
|
||||
public int SiteRating { get; set; }
|
||||
}
|
||||
}
|
|
@ -64,7 +64,7 @@ namespace PlexRequests.UI.Modules
|
|||
var dbMovies = Service.GetAll().Where(x => x.Type == RequestType.Movie);
|
||||
var viewModel = dbMovies.Select(tv => new RequestViewModel
|
||||
{
|
||||
Tmdbid = tv.ProviderId,
|
||||
ProviderId = tv.ProviderId,
|
||||
Type = tv.Type,
|
||||
Status = tv.Status,
|
||||
ImdbId = tv.ImdbId,
|
||||
|
@ -87,12 +87,12 @@ namespace PlexRequests.UI.Modules
|
|||
var dbTv = Service.GetAll().Where(x => x.Type == RequestType.TvShow);
|
||||
var viewModel = dbTv.Select(tv => new RequestViewModel
|
||||
{
|
||||
Tmdbid = tv.ProviderId,
|
||||
ProviderId = tv.ProviderId,
|
||||
Type = tv.Type,
|
||||
Status = tv.Status,
|
||||
ImdbId = tv.ImdbId,
|
||||
Id = tv.Id,
|
||||
PosterPath = tv.PosterPath,
|
||||
PosterPath = tv.ProviderId.ToString(),
|
||||
ReleaseDate = tv.ReleaseDate.Humanize(),
|
||||
RequestedDate = tv.RequestedDate.Humanize(),
|
||||
Approved = tv.Approved,
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Nancy;
|
||||
using Nancy.Responses.Negotiation;
|
||||
|
||||
|
@ -31,6 +34,7 @@ using PlexRequests.Api;
|
|||
using PlexRequests.Core;
|
||||
using PlexRequests.Helpers;
|
||||
using PlexRequests.Store;
|
||||
using PlexRequests.UI.Models;
|
||||
|
||||
namespace PlexRequests.UI.Modules
|
||||
{
|
||||
|
@ -73,7 +77,42 @@ namespace PlexRequests.UI.Modules
|
|||
private Response SearchTvShow(string searchTerm)
|
||||
{
|
||||
var tvShow = TvApi.SearchTv(searchTerm, AuthToken);
|
||||
return Response.AsJson(tvShow);
|
||||
|
||||
if (tvShow?.data == null)
|
||||
{
|
||||
return Response.AsJson("");
|
||||
}
|
||||
var model = new List<SearchTvShowViewModel>();
|
||||
|
||||
foreach (var t in tvShow.data)
|
||||
{
|
||||
model.Add(new SearchTvShowViewModel
|
||||
{
|
||||
Added = t.added,
|
||||
AirsDayOfWeek = t.airsDayOfWeek,
|
||||
AirsTime = t.airsTime,
|
||||
Aliases = t.aliases,
|
||||
// We are constructing the banner with the id:
|
||||
// http://thetvdb.com/banners/_cache/posters/ID-1.jpg
|
||||
Banner = t.id.ToString(),
|
||||
FirstAired = t.firstAired,
|
||||
Genre = t.genre,
|
||||
Id = t.id,
|
||||
ImdbId = t.imdbId,
|
||||
LastUpdated = t.lastUpdated,
|
||||
Network = t.network,
|
||||
NetworkId = t.networkId,
|
||||
Overview = t.overview,
|
||||
Rating = t.rating,
|
||||
Runtime = t.runtime,
|
||||
SeriesId = t.id,
|
||||
SeriesName = t.seriesName,
|
||||
SiteRating = t.siteRating,
|
||||
Status = t.status,
|
||||
Zap2ItId = t.zap2itId
|
||||
});
|
||||
}
|
||||
return Response.AsJson(model);
|
||||
}
|
||||
|
||||
private Response UpcomingMovies()
|
||||
|
@ -92,7 +131,7 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
private Response RequestMovie(int movieId)
|
||||
{
|
||||
var s = new SettingsService();
|
||||
var s = new SettingsService(Cache);
|
||||
if (s.CheckRequest(movieId))
|
||||
{
|
||||
return Response.AsJson(new { Result = false, Message = "Movie has already been requested!" });
|
||||
|
@ -111,7 +150,7 @@ namespace PlexRequests.UI.Modules
|
|||
private Response RequestTvShow(int showId, bool latest)
|
||||
{
|
||||
// Latest send to Sonarr and no need to store in DB
|
||||
var s = new SettingsService();
|
||||
var s = new SettingsService(Cache);
|
||||
if (s.CheckRequest(showId))
|
||||
{
|
||||
return Response.AsJson(new { Result = false, Message = "TV Show has already been requested!" });
|
||||
|
|
|
@ -142,6 +142,7 @@
|
|||
</Content>
|
||||
<Compile Include="Models\PlexAuth.cs" />
|
||||
<Compile Include="Models\RequestViewModel.cs" />
|
||||
<Compile Include="Models\SearchTvShowViewModel.cs" />
|
||||
<Compile Include="Models\SessionKeys.cs" />
|
||||
<Compile Include="Modules\AdminModule.cs" />
|
||||
<Compile Include="Modules\IndexModule.cs" />
|
||||
|
|
|
@ -37,9 +37,16 @@
|
|||
<div id="{{id}}Template">
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
{{#if_eq type "movie"}}
|
||||
{{#if posterPath}}
|
||||
<img src="http://image.tmdb.org/t/p/w150/{{posterPath}}" alt="poster">
|
||||
{{/if}}
|
||||
{{/if_eq}}
|
||||
{{#if_eq type "tv"}}
|
||||
{{#if posterPath}}
|
||||
<img width="150" src="http://thetvdb.com/banners/_cache/posters/{{posterPath}}-1.jpg" alt="poster">
|
||||
{{/if}}
|
||||
{{/if_eq}}
|
||||
</div>
|
||||
<div class="col-sm-5 ">
|
||||
<div>
|
||||
|
|
|
@ -48,9 +48,18 @@
|
|||
<script id="search-template" type="text/x-handlebars-template">
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
|
||||
{{#if_eq type "movie"}}
|
||||
{{#if posterPath}}
|
||||
<img src="http://image.tmdb.org/t/p/w150/{{posterPath}}" alt="poster">
|
||||
{{/if}}
|
||||
{{/if_eq}}
|
||||
{{#if_eq type "tv"}}
|
||||
{{#if posterPath}}
|
||||
<img width="150" src="http://thetvdb.com/banners/_cache/posters/{{posterPath}}-1.jpg" alt="poster">
|
||||
{{/if}}
|
||||
{{/if_eq}}
|
||||
|
||||
</div>
|
||||
<div class="col-sm-5 ">
|
||||
<div>
|
||||
|
@ -68,7 +77,7 @@
|
|||
{{/if_eq}}
|
||||
{{#if_eq type "tv"}}
|
||||
<div class="dropdown">
|
||||
<button id="{{id}}" class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||
<button id="{{id}}" class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||
<i class="fa fa-plus"></i> Request
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
|
@ -81,8 +90,11 @@
|
|||
<br />
|
||||
<br />
|
||||
<br />
|
||||
{{#if voteAverage}}
|
||||
|
||||
<small class="row">Vote Average: {{voteAverage}}</small>
|
||||
<small class="row">Vote Count: {{voteCount}}</small>
|
||||
{{/if}}
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue