Lots of small fixes including #475

This commit is contained in:
tidusjar 2016-10-19 22:53:56 +01:00
parent ac51b39636
commit bcf1c9cd8e
7 changed files with 123 additions and 86 deletions

View file

@ -1,79 +1,89 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace PlexRequests.Api.Models.Tv namespace PlexRequests.Api.Models.Tv
{ {
public class TvMazeShow public class TvMazeShow
{ {
public int id { get; set; } public TvMazeShow()
public string url { get; set; } {
public string name { get; set; } Season = new List<TvMazeCustomSeason>();
public string type { get; set; } }
public string language { get; set; } public int id { get; set; }
public List<string> genres { get; set; } public string url { get; set; }
public string status { get; set; } public string name { get; set; }
public int runtime { get; set; } public string type { get; set; }
public string premiered { get; set; } public string language { get; set; }
public Schedule schedule { get; set; } public List<string> genres { get; set; }
public Rating rating { get; set; } public string status { get; set; }
public int weight { get; set; } public int runtime { get; set; }
public Network network { get; set; } public string premiered { get; set; }
public object webChannel { get; set; } public Schedule schedule { get; set; }
public Externals externals { get; set; } public Rating rating { get; set; }
public Image image { get; set; } public int weight { get; set; }
public string summary { get; set; } public Network network { get; set; }
public int updated { get; set; } public object webChannel { get; set; }
public Links _links { get; set; } public Externals externals { get; set; }
public int seasonCount { get; set; } public Image image { get; set; }
public Embedded _embedded { get; set; } public string summary { get; set; }
} public int updated { get; set; }
public Links _links { get; set; }
public class Season public List<TvMazeCustomSeason> Season { get; set; }
{ public Embedded _embedded { get; set; }
public int id { get; set; } }
public string url { get; set; }
public int number { get; set; } public class TvMazeCustomSeason
public string name { get; set; } {
public int? episodeOrder { get; set; } public int SeasonNumber { get; set; }
public string premiereDate { get; set; } public int EpisodeNumber { get; set; }
public string endDate { get; set; } }
public Network2 network { get; set; }
public object webChannel { get; set; } public class Season
public Image2 image { get; set; } {
public string summary { get; set; } public int id { get; set; }
public Links2 _links { get; set; } public string url { get; set; }
} public int number { get; set; }
public class Country2 public string name { get; set; }
{ public int? episodeOrder { get; set; }
public string name { get; set; } public string premiereDate { get; set; }
public string code { get; set; } public string endDate { get; set; }
public string timezone { get; set; } public Network2 network { get; set; }
} public object webChannel { get; set; }
public Image2 image { get; set; }
public class Network2 public string summary { get; set; }
{ public Links2 _links { get; set; }
public int id { get; set; } }
public string name { get; set; } public class Country2
public Country2 country { get; set; } {
} public string name { get; set; }
public string code { get; set; }
public class Image2 public string timezone { get; set; }
{ }
public string medium { get; set; }
public string original { get; set; } public class Network2
} {
public int id { get; set; }
public class Self2 public string name { get; set; }
{ public Country2 country { get; set; }
public string href { get; set; } }
}
public class Image2
public class Links2 {
{ public string medium { get; set; }
public Self2 self { get; set; } public string original { get; set; }
} }
public class Embedded public class Self2
{ {
public List<Season> seasons { get; set; } public string href { get; set; }
} }
public class Links2
{
public Self2 self { get; set; }
}
public class Embedded
{
public List<Season> seasons { get; set; }
}
} }

View file

@ -93,8 +93,18 @@ namespace PlexRequests.Api
request.AddHeader("Content-Type", "application/json"); request.AddHeader("Content-Type", "application/json");
var obj = Api.Execute<TvMazeShow>(request, new Uri(Uri)); var obj = Api.Execute<TvMazeShow>(request, new Uri(Uri));
obj.seasonCount = GetSeasonCount(obj.id);
var episodes = EpisodeLookup(obj.id).ToList();
foreach (var e in episodes)
{
obj.Season.Add(new TvMazeCustomSeason
{
SeasonNumber = e.season,
EpisodeNumber = e.number
});
}
return obj; return obj;
} }
@ -110,6 +120,7 @@ namespace PlexRequests.Api
return Api.Execute<List<TvMazeSeasons>>(request, new Uri(Uri)); return Api.Execute<List<TvMazeSeasons>>(request, new Uri(Uri));
} }
public int GetSeasonCount(int id) public int GetSeasonCount(int id)
{ {
var obj = GetSeasons(id); var obj = GetSeasons(id);

View file

@ -271,7 +271,7 @@ namespace PlexRequests.Services.Jobs
{ {
if (advanced) if (advanced)
{ {
if (show.ProviderId == providerId) if (show.ProviderId == providerId && seasons != null)
{ {
if (seasons.Any(season => show.Seasons.Contains(season))) if (seasons.Any(season => show.Seasons.Contains(season)))
{ {

View file

@ -112,6 +112,10 @@ namespace PlexRequests.Services.Jobs
// Loop through the metadata and create the model to insert into the DB // Loop through the metadata and create the model to insert into the DB
foreach (var metadataVideo in metadata.Video) foreach (var metadataVideo in metadata.Video)
{ {
if(string.IsNullOrEmpty(metadataVideo.GrandparentTitle))
{
continue;
}
var epInfo = PlexHelper.GetSeasonsAndEpisodesFromPlexGuid(metadataVideo.Guid); var epInfo = PlexHelper.GetSeasonsAndEpisodesFromPlexGuid(metadataVideo.Guid);
entities.TryAdd( entities.TryAdd(
new PlexEpisodes new PlexEpisodes

View file

@ -349,8 +349,7 @@ namespace PlexRequests.UI.Modules
providerId = viewT.Id.ToString(); providerId = viewT.Id.ToString();
} }
var plexShow = Checker.GetTvShow(plexTvShows.ToArray(), t.show.name, t.show.premiered?.Substring(0, 4), var plexShow = Checker.GetTvShow(plexTvShows.ToArray(), t.show.name, t.show.premiered?.Substring(0, 4), providerId);
providerId);
if (plexShow != null) if (plexShow != null)
{ {
viewT.Available = true; viewT.Available = true;
@ -590,7 +589,7 @@ namespace PlexRequests.UI.Modules
RequestedUsers = new List<string> { Username }, RequestedUsers = new List<string> { Username },
Issues = IssueState.None, Issues = IssueState.None,
ImdbId = showInfo.externals?.imdb ?? string.Empty, ImdbId = showInfo.externals?.imdb ?? string.Empty,
SeasonCount = showInfo.seasonCount, SeasonCount = showInfo.Season.Count,
TvDbId = showId.ToString() TvDbId = showId.ToString()
}; };
@ -703,7 +702,18 @@ namespace PlexRequests.UI.Modules
} }
else else
{ {
if (Checker.IsTvShowAvailable(shows.ToArray(), showInfo.name, showInfo.premiered?.Substring(0, 4), providerId, model.SeasonList)) if (plexSettings.EnableTvEpisodeSearching)
{
foreach (var s in showInfo.Season)
{
var result = Checker.IsEpisodeAvailable(showId.ToString(), s.SeasonNumber, s.EpisodeNumber);
if (result)
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{fullShowName} {Resources.UI.Search_AlreadyInPlex}" });
}
}
}
else if (Checker.IsTvShowAvailable(shows.ToArray(), showInfo.name, showInfo.premiered?.Substring(0, 4), providerId, model.SeasonList))
{ {
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{fullShowName} {Resources.UI.Search_AlreadyInPlex}" }); return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{fullShowName} {Resources.UI.Search_AlreadyInPlex}" });
} }

View file

@ -59,7 +59,9 @@ namespace PlexRequests.UI.Modules
{ {
return Response.AsJson(new JsonUpdateAvailableModel { UpdateAvailable = false }); return Response.AsJson(new JsonUpdateAvailableModel { UpdateAvailable = false });
} }
#if DEBUG
return Response.AsJson(new JsonUpdateAvailableModel {UpdateAvailable = false});
#endif
var checker = new StatusChecker(); var checker = new StatusChecker();
var release = await Cache.GetOrSetAsync(CacheKeys.LastestProductVersion, async() => await checker.GetStatus(), 30); var release = await Cache.GetOrSetAsync(CacheKeys.LastestProductVersion, async() => await checker.GetStatus(), 30);

View file

@ -82,7 +82,7 @@
<div class="form-group"> <div class="form-group">
<label for="RecentlyAdded" class="control-label">Recently Added Email (hours)</label> <label for="RecentlyAdded" class="control-label">Recently Added Email (hours)</label>
<div> <div>
<input type="text" class="form-control form-control-custom " id="RecentlyAdded" name="RecentlyAddedModel" value="@Model.RecentlyAddedModel"> <input type="text" class="form-control form-control-custom " id="RecentlyAdded" name="RecentlyAdded" value="@Model.RecentlyAdded">
</div> </div>
</div> </div>