mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 00:06:05 -07:00
small bit of work on #266
This commit is contained in:
parent
a5257a0fbf
commit
cd135d824c
4 changed files with 36 additions and 23 deletions
3
PlexRequests.UI/Content/search.js
vendored
3
PlexRequests.UI/Content/search.js
vendored
|
@ -443,7 +443,8 @@ $(function () {
|
||||||
requested: result.requested,
|
requested: result.requested,
|
||||||
approved: result.approved,
|
approved: result.approved,
|
||||||
available: result.available,
|
available: result.available,
|
||||||
episodes : result.episodes
|
episodes: result.episodes,
|
||||||
|
tvFullyAvailable: result.tvFullyAvailable
|
||||||
};
|
};
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,5 +50,6 @@ namespace PlexRequests.UI.Models
|
||||||
public string ImdbId { get; set; }
|
public string ImdbId { get; set; }
|
||||||
public int SiteRating { get; set; }
|
public int SiteRating { get; set; }
|
||||||
public Store.EpisodesModel[] Episodes { get; set; }
|
public Store.EpisodesModel[] Episodes { get; set; }
|
||||||
|
public bool TvFullyAvailable { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -40,7 +40,6 @@ using PlexRequests.Api.Models.Music;
|
||||||
using PlexRequests.Core;
|
using PlexRequests.Core;
|
||||||
using PlexRequests.Core.SettingModels;
|
using PlexRequests.Core.SettingModels;
|
||||||
using PlexRequests.Helpers;
|
using PlexRequests.Helpers;
|
||||||
using PlexRequests.Helpers.Exceptions;
|
|
||||||
using PlexRequests.Services.Interfaces;
|
using PlexRequests.Services.Interfaces;
|
||||||
using PlexRequests.Services.Notification;
|
using PlexRequests.Services.Notification;
|
||||||
using PlexRequests.Store;
|
using PlexRequests.Store;
|
||||||
|
@ -49,10 +48,9 @@ using PlexRequests.UI.Models;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Nancy.Extensions;
|
using Nancy.Extensions;
|
||||||
using Nancy.ModelBinding;
|
|
||||||
using Nancy.Responses;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using PlexRequests.Api.Models.Sonarr;
|
|
||||||
using PlexRequests.Api.Models.Tv;
|
using PlexRequests.Api.Models.Tv;
|
||||||
using PlexRequests.Core.Models;
|
using PlexRequests.Core.Models;
|
||||||
using PlexRequests.Helpers.Analytics;
|
using PlexRequests.Helpers.Analytics;
|
||||||
|
@ -289,6 +287,7 @@ namespace PlexRequests.UI.Modules
|
||||||
{
|
{
|
||||||
Analytics.TrackEventAsync(Category.Search, Action.TvShow, searchTerm, Username, CookieHelper.GetAnalyticClientId(Cookies));
|
Analytics.TrackEventAsync(Category.Search, Action.TvShow, searchTerm, Username, CookieHelper.GetAnalyticClientId(Cookies));
|
||||||
var plexSettings = await PlexService.GetSettingsAsync();
|
var plexSettings = await PlexService.GetSettingsAsync();
|
||||||
|
var providerId = string.Empty;
|
||||||
|
|
||||||
var apiTv = new List<TvMazeSearch>();
|
var apiTv = new List<TvMazeSearch>();
|
||||||
await Task.Factory.StartNew(() => new TvMazeApi().Search(searchTerm)).ContinueWith((t) =>
|
await Task.Factory.StartNew(() => new TvMazeApi().Search(searchTerm)).ContinueWith((t) =>
|
||||||
|
@ -313,10 +312,12 @@ namespace PlexRequests.UI.Modules
|
||||||
var viewTv = new List<SearchTvShowViewModel>();
|
var viewTv = new List<SearchTvShowViewModel>();
|
||||||
foreach (var t in apiTv)
|
foreach (var t in apiTv)
|
||||||
{
|
{
|
||||||
|
var tvInfoTask = Task.Run(() => TvApi.EpisodeLookup(t.show.id));
|
||||||
|
|
||||||
var banner = t.show.image?.medium;
|
var banner = t.show.image?.medium;
|
||||||
if (!string.IsNullOrEmpty(banner))
|
if (!string.IsNullOrEmpty(banner))
|
||||||
{
|
{
|
||||||
banner = banner.Replace("http", "https");
|
banner = banner.Replace("http", "https"); // Always use the Https banners
|
||||||
}
|
}
|
||||||
|
|
||||||
var viewT = new SearchTvShowViewModel
|
var viewT = new SearchTvShowViewModel
|
||||||
|
@ -336,8 +337,6 @@ namespace PlexRequests.UI.Modules
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var providerId = string.Empty;
|
|
||||||
|
|
||||||
if (plexSettings.AdvancedSearch)
|
if (plexSettings.AdvancedSearch)
|
||||||
{
|
{
|
||||||
providerId = viewT.Id.ToString();
|
providerId = viewT.Id.ToString();
|
||||||
|
@ -349,7 +348,7 @@ namespace PlexRequests.UI.Modules
|
||||||
}
|
}
|
||||||
else if (t.show?.externals?.thetvdb != null)
|
else if (t.show?.externals?.thetvdb != null)
|
||||||
{
|
{
|
||||||
int tvdbid = (int)t.show.externals.thetvdb;
|
var tvdbid = (int)t.show.externals.thetvdb;
|
||||||
|
|
||||||
if (dbTv.ContainsKey(tvdbid))
|
if (dbTv.ContainsKey(tvdbid))
|
||||||
{
|
{
|
||||||
|
@ -365,7 +364,15 @@ namespace PlexRequests.UI.Modules
|
||||||
viewT.Requested = true;
|
viewT.Requested = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var tvInfo = await tvInfoTask;
|
||||||
|
|
||||||
|
// Check if we have every episode in all seasons
|
||||||
|
var epModel = tvInfo.Select(tvIn => new Store.EpisodesModel { SeasonNumber = tvIn.season, EpisodeNumber = tvIn.number }).ToList();
|
||||||
|
var diff = viewT.Episodes.Except(epModel);
|
||||||
|
if (diff.Any())
|
||||||
|
{
|
||||||
|
viewT.TvFullyAvailable = true;
|
||||||
|
}
|
||||||
viewTv.Add(viewT);
|
viewTv.Add(viewT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,6 +184,9 @@
|
||||||
{{/if_eq}}
|
{{/if_eq}}
|
||||||
{{/if_eq}}
|
{{/if_eq}}
|
||||||
{{#if_eq type "tv"}}
|
{{#if_eq type "tv"}}
|
||||||
|
{{#if_eq tvFullyAvailable true}}
|
||||||
|
<button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> @UI.Search_Available</button>
|
||||||
|
{{else}}
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<button id="{{id}}" class="btn btn-primary-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
<button id="{{id}}" class="btn btn-primary-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||||
<i class="fa fa-plus"></i> @UI.Search_Request
|
<i class="fa fa-plus"></i> @UI.Search_Request
|
||||||
|
@ -198,6 +201,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{{/if_eq}}
|
{{/if_eq}}
|
||||||
|
{{/if_eq}}
|
||||||
|
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue