mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-11 07:46:05 -07:00
precheck and disable the episode boxes if we already have requested it. TODO check sonarr to see if it's already there. #254
This commit is contained in:
parent
767a045864
commit
d458dca541
8 changed files with 285 additions and 227 deletions
|
@ -1,148 +1,148 @@
|
||||||
#region Copyright
|
#region Copyright
|
||||||
// /************************************************************************
|
// /************************************************************************
|
||||||
// Copyright (c) 2016 Jamie Rees
|
// Copyright (c) 2016 Jamie Rees
|
||||||
// File: ApiRequest.cs
|
// File: ApiRequest.cs
|
||||||
// Created By: Jamie Rees
|
// Created By: Jamie Rees
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||||||
// a copy of this software and associated documentation files (the
|
// a copy of this software and associated documentation files (the
|
||||||
// "Software"), to deal in the Software without restriction, including
|
// "Software"), to deal in the Software without restriction, including
|
||||||
// without limitation the rights to use, copy, modify, merge, publish,
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
// permit persons to whom the Software is furnished to do so, subject to
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
// the following conditions:
|
// the following conditions:
|
||||||
//
|
//
|
||||||
// The above copyright notice and this permission notice shall be
|
// The above copyright notice and this permission notice shall be
|
||||||
// included in all copies or substantial portions of the Software.
|
// included in all copies or substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// ************************************************************************/
|
// ************************************************************************/
|
||||||
#endregion
|
#endregion
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
using PlexRequests.Api.Interfaces;
|
using PlexRequests.Api.Interfaces;
|
||||||
using PlexRequests.Helpers.Exceptions;
|
using PlexRequests.Helpers.Exceptions;
|
||||||
|
|
||||||
using RestSharp;
|
using RestSharp;
|
||||||
|
|
||||||
namespace PlexRequests.Api
|
namespace PlexRequests.Api
|
||||||
{
|
{
|
||||||
public class ApiRequest : IApiRequest
|
public class ApiRequest : IApiRequest
|
||||||
{
|
{
|
||||||
private readonly JsonSerializerSettings _settings = new JsonSerializerSettings
|
private readonly JsonSerializerSettings _settings = new JsonSerializerSettings
|
||||||
{
|
{
|
||||||
NullValueHandling = NullValueHandling.Ignore,
|
NullValueHandling = NullValueHandling.Ignore,
|
||||||
MissingMemberHandling = MissingMemberHandling.Ignore
|
MissingMemberHandling = MissingMemberHandling.Ignore
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An API request handler
|
/// An API request handler
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The type of class you want to deserialize</typeparam>
|
/// <typeparam name="T">The type of class you want to deserialize</typeparam>
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
/// <param name="baseUri">The base URI.</param>
|
/// <param name="baseUri">The base URI.</param>
|
||||||
/// <returns>The type of class you want to deserialize</returns>
|
/// <returns>The type of class you want to deserialize</returns>
|
||||||
public T Execute<T>(IRestRequest request, Uri baseUri) where T : new()
|
public T Execute<T>(IRestRequest request, Uri baseUri) where T : new()
|
||||||
{
|
{
|
||||||
var client = new RestClient { BaseUrl = baseUri };
|
var client = new RestClient { BaseUrl = baseUri };
|
||||||
|
|
||||||
var response = client.Execute<T>(request);
|
var response = client.Execute<T>(request);
|
||||||
Log.Trace("Api Content Response:");
|
Log.Trace("Api Content Response:");
|
||||||
Log.Trace(response.Content);
|
Log.Trace(response.Content);
|
||||||
|
|
||||||
if (response.ErrorException != null)
|
if (response.ErrorException != null)
|
||||||
{
|
{
|
||||||
var message = "Error retrieving response. Check inner details for more info.";
|
var message = "Error retrieving response. Check inner details for more info.";
|
||||||
Log.Error(response.ErrorException);
|
Log.Error(response.ErrorException);
|
||||||
throw new ApiRequestException(message, response.ErrorException);
|
throw new ApiRequestException(message, response.ErrorException);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.Data;
|
return response.Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRestResponse Execute(IRestRequest request, Uri baseUri)
|
public IRestResponse Execute(IRestRequest request, Uri baseUri)
|
||||||
{
|
{
|
||||||
var client = new RestClient { BaseUrl = baseUri };
|
var client = new RestClient { BaseUrl = baseUri };
|
||||||
|
|
||||||
var response = client.Execute(request);
|
var response = client.Execute(request);
|
||||||
|
|
||||||
if (response.ErrorException != null)
|
if (response.ErrorException != null)
|
||||||
{
|
{
|
||||||
Log.Error(response.ErrorException);
|
Log.Error(response.ErrorException);
|
||||||
var message = "Error retrieving response. Check inner details for more info.";
|
var message = "Error retrieving response. Check inner details for more info.";
|
||||||
throw new ApiRequestException(message, response.ErrorException);
|
throw new ApiRequestException(message, response.ErrorException);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T ExecuteXml<T>(IRestRequest request, Uri baseUri) where T : class
|
public T ExecuteXml<T>(IRestRequest request, Uri baseUri) where T : class
|
||||||
{
|
{
|
||||||
var client = new RestClient { BaseUrl = baseUri };
|
var client = new RestClient { BaseUrl = baseUri };
|
||||||
|
|
||||||
var response = client.Execute(request);
|
var response = client.Execute(request);
|
||||||
|
|
||||||
if (response.ErrorException != null)
|
if (response.ErrorException != null)
|
||||||
{
|
{
|
||||||
Log.Error(response.ErrorException);
|
Log.Error(response.ErrorException);
|
||||||
var message = "Error retrieving response. Check inner details for more info.";
|
var message = "Error retrieving response. Check inner details for more info.";
|
||||||
throw new ApiRequestException(message, response.ErrorException);
|
throw new ApiRequestException(message, response.ErrorException);
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = DeserializeXml<T>(response.Content);
|
var result = DeserializeXml<T>(response.Content);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T ExecuteJson<T>(IRestRequest request, Uri baseUri) where T : new()
|
public T ExecuteJson<T>(IRestRequest request, Uri baseUri) where T : new()
|
||||||
{
|
{
|
||||||
var client = new RestClient { BaseUrl = baseUri };
|
var client = new RestClient { BaseUrl = baseUri };
|
||||||
var response = client.Execute(request);
|
var response = client.Execute(request);
|
||||||
Log.Trace("Api Content Response:");
|
Log.Trace("Api Content Response:");
|
||||||
Log.Trace(response.Content);
|
Log.Trace(response.Content);
|
||||||
if (response.ErrorException != null)
|
if (response.ErrorException != null)
|
||||||
{
|
{
|
||||||
Log.Error(response.ErrorException);
|
Log.Error(response.ErrorException);
|
||||||
var message = "Error retrieving response. Check inner details for more info.";
|
var message = "Error retrieving response. Check inner details for more info.";
|
||||||
throw new ApiRequestException(message, response.ErrorException);
|
throw new ApiRequestException(message, response.ErrorException);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.Trace("Deserialzing Object");
|
Log.Trace("Deserialzing Object");
|
||||||
var json = JsonConvert.DeserializeObject<T>(response.Content, _settings);
|
var json = JsonConvert.DeserializeObject<T>(response.Content, _settings);
|
||||||
Log.Trace("Finished Deserialzing Object");
|
Log.Trace("Finished Deserialzing Object");
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
private T DeserializeXml<T>(string input)
|
private T DeserializeXml<T>(string input)
|
||||||
where T : class
|
where T : class
|
||||||
{
|
{
|
||||||
var ser = new XmlSerializer(typeof(T));
|
var ser = new XmlSerializer(typeof(T));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var sr = new StringReader(input))
|
using (var sr = new StringReader(input))
|
||||||
return (T)ser.Deserialize(sr);
|
return (T)ser.Deserialize(sr);
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException e)
|
catch (InvalidOperationException e)
|
||||||
{
|
{
|
||||||
Log.Error(e);
|
Log.Error(e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
20
PlexRequests.UI/Content/search.js
vendored
20
PlexRequests.UI/Content/search.js
vendored
|
@ -442,7 +442,8 @@ $(function () {
|
||||||
imdb: result.imdbId,
|
imdb: result.imdbId,
|
||||||
requested: result.requested,
|
requested: result.requested,
|
||||||
approved: result.approved,
|
approved: result.approved,
|
||||||
available: result.available
|
available: result.available,
|
||||||
|
episodes : result.episodes
|
||||||
};
|
};
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
@ -585,8 +586,6 @@ $(function () {
|
||||||
|
|
||||||
var model = [];
|
var model = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var $checkedEpisodes = $('.selectedEpisodes:checkbox:checked');
|
var $checkedEpisodes = $('.selectedEpisodes:checkbox:checked');
|
||||||
$checkedEpisodes.each(function (index, element) {
|
$checkedEpisodes.each(function (index, element) {
|
||||||
var $element = $('#' + element.id);
|
var $element = $('#' + element.id);
|
||||||
|
@ -616,7 +615,7 @@ $(function () {
|
||||||
|
|
||||||
function buildSeasonsCount(result) {
|
function buildSeasonsCount(result) {
|
||||||
return {
|
return {
|
||||||
seasonNumber: result.season
|
seasonNumber: result.seasonNumber
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,17 +623,10 @@ $(function () {
|
||||||
function buildEpisodesView(result) {
|
function buildEpisodesView(result) {
|
||||||
return {
|
return {
|
||||||
id: result.id,
|
id: result.id,
|
||||||
url: result.url,
|
|
||||||
name: result.name,
|
name: result.name,
|
||||||
season: result.season,
|
season: result.seasonNumber,
|
||||||
number: result.number,
|
number: result.episodeNumber,
|
||||||
airdate: result.airdate,
|
requested: result.requested
|
||||||
airtime: result.airtime,
|
|
||||||
airstamp: result.airstamp,
|
|
||||||
runtime: result.runtime,
|
|
||||||
image: result.image,
|
|
||||||
summary: result.summary,
|
|
||||||
links : result._links
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -33,13 +33,11 @@ using PlexRequests.Api.Interfaces;
|
||||||
using PlexRequests.Api.Models.SickRage;
|
using PlexRequests.Api.Models.SickRage;
|
||||||
using PlexRequests.Api.Models.Sonarr;
|
using PlexRequests.Api.Models.Sonarr;
|
||||||
using PlexRequests.Core.SettingModels;
|
using PlexRequests.Core.SettingModels;
|
||||||
using PlexRequests.Helpers;
|
|
||||||
using PlexRequests.Store;
|
using PlexRequests.Store;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using PlexRequests.Helpers.Exceptions;
|
using PlexRequests.Helpers.Exceptions;
|
||||||
using PlexRequests.UI.Models;
|
|
||||||
|
|
||||||
namespace PlexRequests.UI.Helpers
|
namespace PlexRequests.UI.Helpers
|
||||||
{
|
{
|
||||||
|
@ -73,15 +71,16 @@ namespace PlexRequests.UI.Helpers
|
||||||
int.TryParse(sonarrSettings.QualityProfile, out qualityProfile);
|
int.TryParse(sonarrSettings.QualityProfile, out qualityProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Does series exist?
|
|
||||||
var series = await GetSonarrSeries(sonarrSettings, model.ProviderId);
|
|
||||||
|
|
||||||
|
var seriesTask = GetSonarrSeries(sonarrSettings, model.ProviderId);
|
||||||
|
|
||||||
// Series Exists
|
|
||||||
if (episodeRequest)
|
if (episodeRequest)
|
||||||
{
|
{
|
||||||
|
// Does series exist?
|
||||||
|
var series = await seriesTask;
|
||||||
if (series != null)
|
if (series != null)
|
||||||
{
|
{
|
||||||
|
// Series Exists
|
||||||
// Request the episodes in the existing series
|
// Request the episodes in the existing series
|
||||||
RequestEpisodesWithExistingSeries(model, series, sonarrSettings);
|
RequestEpisodesWithExistingSeries(model, series, sonarrSettings);
|
||||||
}
|
}
|
||||||
|
@ -113,13 +112,12 @@ namespace PlexRequests.UI.Helpers
|
||||||
|
|
||||||
// We now have the series in Sonarr
|
// We now have the series in Sonarr
|
||||||
RequestEpisodesWithExistingSeries(model, series, sonarrSettings);
|
RequestEpisodesWithExistingSeries(model, series, sonarrSettings);
|
||||||
|
|
||||||
return addResult;
|
return addResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var result = SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
var result = SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
||||||
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, model.SeasonCount, model.SeasonList, sonarrSettings.ApiKey,
|
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, model.SeasonCount, model.SeasonList, sonarrSettings.ApiKey,
|
||||||
sonarrSettings.FullUri);
|
sonarrSettings.FullUri);
|
||||||
|
|
37
PlexRequests.UI/Models/EpisodeListViewModel.cs
Normal file
37
PlexRequests.UI/Models/EpisodeListViewModel.cs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2016 Jamie Rees
|
||||||
|
// File: EpisodeListViewModel.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.UI.Models
|
||||||
|
{
|
||||||
|
public class EpisodeListViewModel
|
||||||
|
{
|
||||||
|
public int SeasonNumber { get; set; }
|
||||||
|
public int EpisodeNumber { get; set; }
|
||||||
|
public bool Requested { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,53 +1,54 @@
|
||||||
#region Copyright
|
#region Copyright
|
||||||
// /************************************************************************
|
// /************************************************************************
|
||||||
// Copyright (c) 2016 Jamie Rees
|
// Copyright (c) 2016 Jamie Rees
|
||||||
// File: SearchTvShowViewModel.cs
|
// File: SearchTvShowViewModel.cs
|
||||||
// Created By: Jamie Rees
|
// Created By: Jamie Rees
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||||||
// a copy of this software and associated documentation files (the
|
// a copy of this software and associated documentation files (the
|
||||||
// "Software"), to deal in the Software without restriction, including
|
// "Software"), to deal in the Software without restriction, including
|
||||||
// without limitation the rights to use, copy, modify, merge, publish,
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
// permit persons to whom the Software is furnished to do so, subject to
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
// the following conditions:
|
// the following conditions:
|
||||||
//
|
//
|
||||||
// The above copyright notice and this permission notice shall be
|
// The above copyright notice and this permission notice shall be
|
||||||
// included in all copies or substantial portions of the Software.
|
// included in all copies or substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// ************************************************************************/
|
// ************************************************************************/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace PlexRequests.UI.Models
|
namespace PlexRequests.UI.Models
|
||||||
{
|
{
|
||||||
public class SearchTvShowViewModel : SearchViewModel
|
public class SearchTvShowViewModel : SearchViewModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string SeriesName { get; set; }
|
public string SeriesName { get; set; }
|
||||||
public List<string> Aliases { get; set; }
|
public List<string> Aliases { get; set; }
|
||||||
public string Banner { get; set; }
|
public string Banner { get; set; }
|
||||||
public int SeriesId { get; set; }
|
public int SeriesId { get; set; }
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
public string FirstAired { get; set; }
|
public string FirstAired { get; set; }
|
||||||
public string Network { get; set; }
|
public string Network { get; set; }
|
||||||
public string NetworkId { get; set; }
|
public string NetworkId { get; set; }
|
||||||
public string Runtime { get; set; }
|
public string Runtime { get; set; }
|
||||||
public List<string> Genre { get; set; }
|
public List<string> Genre { get; set; }
|
||||||
public string Overview { get; set; }
|
public string Overview { get; set; }
|
||||||
public int LastUpdated { get; set; }
|
public int LastUpdated { get; set; }
|
||||||
public string AirsDayOfWeek { get; set; }
|
public string AirsDayOfWeek { get; set; }
|
||||||
public string AirsTime { get; set; }
|
public string AirsTime { get; set; }
|
||||||
public string Rating { get; set; }
|
public string Rating { get; set; }
|
||||||
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; }
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -124,7 +124,7 @@ namespace PlexRequests.UI.Modules
|
||||||
Get["/notifyuser", true] = async (x, ct) => await GetUserNotificationSettings();
|
Get["/notifyuser", true] = async (x, ct) => await GetUserNotificationSettings();
|
||||||
|
|
||||||
Get["/seasons"] = x => GetSeasons();
|
Get["/seasons"] = x => GetSeasons();
|
||||||
Get["/episodes"] = x => GetEpisodes();
|
Get["/episodes", true] = async (x, ct) => await GetEpisodes();
|
||||||
}
|
}
|
||||||
private TvMazeApi TvApi { get; }
|
private TvMazeApi TvApi { get; }
|
||||||
private IPlexApi PlexApi { get; }
|
private IPlexApi PlexApi { get; }
|
||||||
|
@ -356,6 +356,7 @@ namespace PlexRequests.UI.Modules
|
||||||
var dbt = dbTv[tvdbid];
|
var dbt = dbTv[tvdbid];
|
||||||
|
|
||||||
viewT.Requested = true;
|
viewT.Requested = true;
|
||||||
|
viewT.Episodes = dbt.Episodes;
|
||||||
viewT.Approved = dbt.Approved;
|
viewT.Approved = dbt.Approved;
|
||||||
viewT.Available = dbt.Available;
|
viewT.Available = dbt.Available;
|
||||||
}
|
}
|
||||||
|
@ -545,10 +546,11 @@ namespace PlexRequests.UI.Modules
|
||||||
if (episodeModel != null)
|
if (episodeModel != null)
|
||||||
{
|
{
|
||||||
episodeRequest = true;
|
episodeRequest = true;
|
||||||
|
showId = episodeModel.ShowId;
|
||||||
var s = await sonarrSettings;
|
var s = await sonarrSettings;
|
||||||
if (!s.Enabled)
|
if (!s.Enabled)
|
||||||
{
|
{
|
||||||
return Response.AsJson("This is currently only supported with Sonarr");
|
return Response.AsJson(new JsonResponseModel { Message = "This is currently only supported with Sonarr", Result = false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -924,12 +926,35 @@ namespace PlexRequests.UI.Modules
|
||||||
return Response.AsJson(model);
|
return Response.AsJson(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response GetEpisodes()
|
private async Task<Response> GetEpisodes()
|
||||||
{
|
{
|
||||||
|
var allResults = await RequestService.GetAllAsync();
|
||||||
|
var model = new List<EpisodeListViewModel>();
|
||||||
var seriesId = (int)Request.Query.tvId;
|
var seriesId = (int)Request.Query.tvId;
|
||||||
|
var enumerable = allResults as RequestedModel[] ?? allResults.ToArray();
|
||||||
|
|
||||||
|
var dbDbShow = enumerable.FirstOrDefault(x => x.Type == RequestType.TvShow && x.TvDbId == seriesId.ToString());
|
||||||
var show = TvApi.ShowLookupByTheTvDbId(seriesId);
|
var show = TvApi.ShowLookupByTheTvDbId(seriesId);
|
||||||
var seasons = TvApi.EpisodeLookup(show.id);
|
var seasons = TvApi.EpisodeLookup(show.id);
|
||||||
return Response.AsJson(seasons);
|
|
||||||
|
|
||||||
|
foreach (var ep in seasons)
|
||||||
|
{
|
||||||
|
var requested = dbDbShow?.Episodes
|
||||||
|
.Any(episodesModel =>
|
||||||
|
ep.number == episodesModel.EpisodeNumber && ep.season == episodesModel.SeasonNumber);
|
||||||
|
|
||||||
|
model.Add(new EpisodeListViewModel
|
||||||
|
{
|
||||||
|
Id = show.id,
|
||||||
|
SeasonNumber = ep.season,
|
||||||
|
EpisodeNumber = ep.number,
|
||||||
|
Requested = requested ?? false,
|
||||||
|
Name = ep.name
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response.AsJson(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> CheckRequestLimit(PlexRequestSettings s, RequestType type)
|
public async Task<bool> CheckRequestLimit(PlexRequestSettings s, RequestType type)
|
||||||
|
|
|
@ -200,6 +200,7 @@
|
||||||
<Compile Include="ModelDataProviders\UserUpdateViewModelDataProvider.cs" />
|
<Compile Include="ModelDataProviders\UserUpdateViewModelDataProvider.cs" />
|
||||||
<Compile Include="ModelDataProviders\RequestedModelDataProvider.cs" />
|
<Compile Include="ModelDataProviders\RequestedModelDataProvider.cs" />
|
||||||
<Compile Include="Models\DatatablesModel.cs" />
|
<Compile Include="Models\DatatablesModel.cs" />
|
||||||
|
<Compile Include="Models\EpisodeListViewModel.cs" />
|
||||||
<Compile Include="Models\EpisodeRequestModel.cs" />
|
<Compile Include="Models\EpisodeRequestModel.cs" />
|
||||||
<Compile Include="Models\IssuesDetailsViewModel.cs" />
|
<Compile Include="Models\IssuesDetailsViewModel.cs" />
|
||||||
<Compile Include="Models\IssuesViewMOdel.cs" />
|
<Compile Include="Models\IssuesViewMOdel.cs" />
|
||||||
|
|
|
@ -361,7 +361,11 @@
|
||||||
<script id="episode-template" type="text/x-handlebars-template">
|
<script id="episode-template" type="text/x-handlebars-template">
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<div class="checkbox" style="margin-bottom:0px; margin-top:0px;">
|
<div class="checkbox" style="margin-bottom:0px; margin-top:0px;">
|
||||||
<input type="checkbox" class="selectedEpisodes" id="{{id}}" epNumber="{{number}}" epSeason="{{season}}" name="{{id}}"><label for="{{id}}">{{number}}. {{name}}</label>
|
{{#if_eq requested true}}
|
||||||
|
<input type="checkbox" checked="checked" disabled="disabled" class="selectedEpisodes" id="{{id}}" epNumber="{{number}}" epSeason="{{season}}" name="{{id}}"><label for="{{id}}">{{number}}. {{name}}</label>
|
||||||
|
{{else}}
|
||||||
|
<input type="checkbox" class="selectedEpisodes" id="{{id}}" epNumber="{{number}}" epSeason="{{season}}" name="{{id}}"><label for="{{id}}">{{number}}. {{name}}</label>
|
||||||
|
{{/if_eq}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue