Merge pull request #738 from tidusjar/dev

Dev
pull/780/head
Jamie 8 years ago committed by GitHub
commit 4c1dcf848d

@ -47,25 +47,18 @@ namespace PlexRequests.Api
public async Task<List<SearchMovie>> SearchMovie(string searchTerm)
{
var results = await Client.SearchMovie(searchTerm);
return results.Results;
}
[Obsolete("Should use TvMaze for TV")]
public async Task<List<SearchTv>> SearchTv(string searchTerm)
{
var results = await Client.SearchTvShow(searchTerm);
return results.Results;
return results?.Results ?? new List<SearchMovie>();
}
public async Task<List<MovieResult>> GetCurrentPlayingMovies()
{
var movies = await Client.GetMovieList(MovieListType.NowPlaying);
return movies.Results;
return movies?.Results ?? new List<MovieResult>();
}
public async Task<List<MovieResult>> GetUpcomingMovies()
{
var movies = await Client.GetMovieList(MovieListType.Upcoming);
return movies.Results;
return movies?.Results ?? new List<MovieResult>();
}
public async Task<Movie> GetMovieInformation(int tmdbId)
@ -77,14 +70,7 @@ namespace PlexRequests.Api
public async Task<Movie> GetMovieInformation(string imdbId)
{
var movies = await Client.GetMovie(imdbId);
return movies;
}
[Obsolete("Should use TvMaze for TV")]
public async Task<TvShow> GetTvShowInformation(int tmdbId)
{
var show = await Client.GetTvShow(tmdbId);
return show;
return movies ?? new Movie();
}
}
}

@ -230,7 +230,7 @@ namespace PlexRequests.Services.Jobs
public IEnumerable<PlexContent> GetPlexTvShows(IEnumerable<PlexContent> content)
{
return content.Where(x => x.Type == Store.Models.Plex.PlexMediaType.Show.to);
return content.Where(x => x.Type == Store.Models.Plex.PlexMediaType.Show);
}
public bool IsTvShowAvailable(PlexContent[] plexShows, string title, string year, string providerId = null, int[] seasons = null)

@ -132,10 +132,11 @@ namespace PlexRequests.Services.Jobs
private void GenerateMovieHtml(RecentlyAddedModel movies, PlexSettings plexSettings, StringBuilder sb)
{
var orderedMovies = movies?._children?.OrderByDescending(x => x?.addedAt.UnixTimeStampToDateTime()).ToList() ?? new List<RecentlyAddedChild>();
sb.Append("<h1>New Movies:</h1><br/><br/>");
sb.Append(
"<table border=\"0\" cellpadding=\"0\" align=\"center\" cellspacing=\"0\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;\" width=\"100%\">");
foreach (var movie in movies._children.OrderByDescending(x => x.addedAt.UnixTimeStampToDateTime()))
foreach (var movie in orderedMovies)
{
var plexGUID = string.Empty;
try
@ -147,7 +148,10 @@ namespace PlexRequests.Services.Jobs
var imdbId = PlexHelper.GetProviderIdFromPlexGuid(plexGUID);
var info = _movieApi.GetMovieInformation(imdbId).Result;
if (info == null)
{
throw new Exception($"Movie with Imdb id {imdbId} returned null from the MovieApi");
}
AddImageInsideTable(sb, $"https://image.tmdb.org/t/p/w500{info.BackdropPath}");
sb.Append("<tr>");
@ -259,9 +263,6 @@ namespace PlexRequests.Services.Jobs
if (!testEmail)
{
//if (newletterSettings.SendToPlexUsers)
//{
var users = UserHelper.GetUsersWithFeature(Features.RequestAddedNotification);
if (users != null)
{
@ -273,7 +274,6 @@ namespace PlexRequests.Services.Jobs
}
}
}
//}
if (newletterSettings.CustomUsersEmailAddresses != null
&& newletterSettings.CustomUsersEmailAddresses.Any())

@ -62,7 +62,7 @@ namespace PlexRequests.UI.Jobs
var jobList = new List<IJobDetail>
{
JobBuilder.Create<PlexAvailabilityChecker>().WithIdentity("PlexAvailabilityChecker", "Plex").Build(),
JobBuilder.Create<PlexContentCacher>().WithIdentity("PlexContentCacher", "Plex").Build(),
JobBuilder.Create<PlexContentCacher>().WithIdentity("PlexContentCacher", "PlexCacher").Build(),
JobBuilder.Create<PlexEpisodeCacher>().WithIdentity("PlexEpisodeCacher", "Plex").Build(),
JobBuilder.Create<PlexUserChecker>().WithIdentity("PlexUserChecker", "Plex").Build(),
JobBuilder.Create<SickRageCacher>().WithIdentity("SickRageCacher", "Cache").Build(),
@ -93,8 +93,8 @@ namespace PlexRequests.UI.Jobs
var jobs = CreateJobs();
var triggers = CreateTriggers();
var jobDetails = jobs as IJobDetail[] ?? jobs.ToArray();
var triggerDetails = triggers as ITrigger[] ?? triggers.ToArray();
var jobDetails = jobs as IJobDetail[] ?? jobs.OrderByDescending(x => x.Key.Name).ToArray();
var triggerDetails = triggers as ITrigger[] ?? triggers.OrderByDescending(x => x.Key.Name).ToArray();
if (jobDetails.Length != triggerDetails.Length)
{
@ -175,7 +175,7 @@ namespace PlexRequests.UI.Jobs
.Build();
var plexCacher =
TriggerBuilder.Create()
.WithIdentity("PlexContentCacher", "Plex")
.WithIdentity("PlexContentCacher", "PlexCacher")
.StartNow()
.WithSimpleSchedule(x => x.WithIntervalInMinutes(s.PlexContentCacher).RepeatForever())
.Build();
@ -183,49 +183,49 @@ namespace PlexRequests.UI.Jobs
var plexUserChecker =
TriggerBuilder.Create()
.WithIdentity("PlexUserChecker", "Plex")
.StartNow()
.StartAt(DateBuilder.FutureDate(30, IntervalUnit.Minute))
.WithSimpleSchedule(x => x.WithIntervalInMinutes(s.PlexUserChecker).RepeatForever())
.Build();
var srCacher =
TriggerBuilder.Create()
.WithIdentity("SickRageCacher", "Cache")
.StartNow()
.StartAt(DateBuilder.FutureDate(2, IntervalUnit.Minute))
.WithSimpleSchedule(x => x.WithIntervalInMinutes(s.SickRageCacher).RepeatForever())
.Build();
var sonarrCacher =
TriggerBuilder.Create()
.WithIdentity("SonarrCacher", "Cache")
.StartNow()
.StartAt(DateBuilder.FutureDate(3, IntervalUnit.Minute))
.WithSimpleSchedule(x => x.WithIntervalInMinutes(s.SonarrCacher).RepeatForever())
.Build();
var cpCacher =
TriggerBuilder.Create()
.WithIdentity("CouchPotatoCacher", "Cache")
.StartNow()
.StartAt(DateBuilder.FutureDate(4, IntervalUnit.Minute))
.WithSimpleSchedule(x => x.WithIntervalInMinutes(s.CouchPotatoCacher).RepeatForever())
.Build();
var storeBackup =
TriggerBuilder.Create()
.WithIdentity("StoreBackup", "Database")
.StartNow()
.StartAt(DateBuilder.FutureDate(20, IntervalUnit.Minute))
.WithSimpleSchedule(x => x.WithIntervalInHours(s.StoreBackup).RepeatForever())
.Build();
var storeCleanup =
TriggerBuilder.Create()
.WithIdentity("StoreCleanup", "Database")
.StartNow()
.StartAt(DateBuilder.FutureDate(35, IntervalUnit.Minute))
.WithSimpleSchedule(x => x.WithIntervalInHours(s.StoreCleanup).RepeatForever())
.Build();
var userRequestLimiter =
TriggerBuilder.Create()
.WithIdentity("UserRequestLimiter", "Request")
.StartAt(DateBuilder.FutureDate(5, IntervalUnit.Minute))
.StartAt(DateBuilder.FutureDate(25, IntervalUnit.Minute))
// Everything has started on application start, lets wait 5 minutes
.WithSimpleSchedule(x => x.WithIntervalInHours(s.UserRequestLimitResetter).RepeatForever())
.Build();
@ -233,7 +233,7 @@ namespace PlexRequests.UI.Jobs
var plexEpCacher =
TriggerBuilder.Create()
.WithIdentity("PlexEpisodeCacher", "Cache")
.StartAt(DateBuilder.FutureDate(5, IntervalUnit.Minute))
.StartAt(DateBuilder.FutureDate(10, IntervalUnit.Minute))
.WithSimpleSchedule(x => x.WithIntervalInHours(s.PlexEpisodeCacher).RepeatForever())
.Build();
@ -243,14 +243,13 @@ namespace PlexRequests.UI.Jobs
.WithIdentity("RecentlyAddedModel", "Email")
.StartNow()
.WithCronSchedule(s.RecentlyAddedCron)
.WithSimpleSchedule(x => x.WithIntervalInHours(2).RepeatForever())
.Build();
var fault =
TriggerBuilder.Create()
.WithIdentity("FaultQueueHandler", "Fault")
//.StartAt(DateBuilder.FutureDate(10, IntervalUnit.Minute))
.StartNow()
.StartAt(DateBuilder.FutureDate(13, IntervalUnit.Minute))
.WithSimpleSchedule(x => x.WithIntervalInHours(s.FaultQueueHandler).RepeatForever())
.Build();

@ -977,7 +977,12 @@ namespace PlexRequests.UI.Modules
StoreBackup = s.StoreBackup,
StoreCleanup = s.StoreCleanup,
JobRecorder = dict,
RecentlyAddedCron = s.RecentlyAddedCron
RecentlyAddedCron = s.RecentlyAddedCron,
PlexContentCacher = s.PlexContentCacher,
FaultQueueHandler = s.FaultQueueHandler,
PlexEpisodeCacher = s.PlexEpisodeCacher,
PlexUserChecker = s.PlexUserChecker,
UserRequestLimitResetter = s.UserRequestLimitResetter
};
return View["SchedulerSettings", model];
}

@ -104,7 +104,8 @@ namespace PlexRequests.UI.Modules
|| x.Name.Equals(JobNames.EpisodeCacher)
|| x.Name.Equals(JobNames.PlexChecker)
|| x.Name.Equals(JobNames.SonarrCacher)
|| x.Name.Equals(JobNames.SrCacher));
|| x.Name.Equals(JobNames.SrCacher)
|| x.Name.Equals(JobNames.PlexCacher));
return Response.AsJson(cacherJobs.Any()

@ -257,7 +257,7 @@ namespace PlexRequests.UI.Modules
var movieInfoTask = await MovieApi.GetMovieInformation(movie.Id).ConfigureAwait(false);
// TODO needs to be careful about this, it's adding extra time to search...
// https://www.themoviedb.org/talk/5807f4cdc3a36812160041f2
imdbId = movieInfoTask.ImdbId;
imdbId = movieInfoTask?.ImdbId;
counter++;
}
@ -492,6 +492,15 @@ namespace PlexRequests.UI.Modules
Analytics.TrackEventAsync(Category.Search, Action.Request, "Movie", Username,
CookieHelper.GetAnalyticClientId(Cookies));
var movieInfo = await MovieApi.GetMovieInformation(movieId);
if (movieInfo == null)
{
return
Response.AsJson(new JsonResponseModel
{
Result = false,
Message = "There was an issue adding this movie!"
});
}
var fullMovieName =
$"{movieInfo.Title}{(movieInfo.ReleaseDate.HasValue ? $" ({movieInfo.ReleaseDate.Value.Year})" : string.Empty)}";

@ -11,7 +11,7 @@
formAction = "/" + baseUrl.ToHtmlString();
}
var isAdmin = Html.HasAnyPermission(true, Permissions.Administrator) || Html.HasAnyPermission(Permissions.ManageRequests);
var isAdmin = Html.HasAnyPermission(true, Permissions.Administrator, Permissions.ManageRequests);
}
<h1>Details</h1>

Loading…
Cancel
Save