Merge pull request #104 from Drewster727/dev

#86 - display movie/show title + year in request notifications
pull/110/head
Jamie 9 years ago
commit cccb71b605

@ -91,7 +91,7 @@ function sendRequestAjax(data, type, url, buttonId) {
success: function (response) {
console.log(response);
if (response.result === true) {
generateNotify("Success!", "success");
generateNotify(response.message || "Success!", "success");
$('#' + buttonId).html("<i class='fa fa-check'></i> Requested");
$('#' + buttonId).removeClass("btn-primary-outline");

@ -172,30 +172,32 @@ namespace PlexRequests.UI.Modules
private Response RequestMovie(int movieId)
{
var movieApi = new TheMovieDbApi();
var movieInfo = movieApi.GetMovieInformation(movieId).Result;
string fullMovieName = string.Format("{0}{1}", movieInfo.Title, movieInfo.ReleaseDate.HasValue ? $" ({movieInfo.ReleaseDate.Value.Year})" : string.Empty);
Log.Trace("Getting movie info from TheMovieDb");
Log.Trace(movieInfo.DumpJson);
//#if !DEBUG
Log.Info("Requesting movie with id {0}", movieId);
if (RequestService.CheckRequest(movieId))
{
Log.Trace("movie with id {0} exists", movieId);
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Movie has already been requested!" });
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{fullMovieName} has already been requested!" });
}
Log.Debug("movie with id {0} doesnt exists", movieId);
var movieApi = new TheMovieDbApi();
var movieInfo = movieApi.GetMovieInformation(movieId).Result;
Log.Trace("Getting movie info from TheMovieDb");
Log.Trace(movieInfo.DumpJson);
//#if !DEBUG
try
{
if (CheckIfTitleExistsInPlex(movieInfo.Title, movieInfo.ReleaseDate?.Year.ToString()))
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{movieInfo.Title} is already in Plex!" });
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{fullMovieName} is already in Plex!" });
}
}
catch (ApplicationSettingsException)
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"We could not check if {movieInfo.Title} is in Plex, are you sure it's correctly setup?" });
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"We could not check if {fullMovieName} is in Plex, are you sure it's correctly setup?" });
}
//#endif
@ -282,7 +284,7 @@ namespace PlexRequests.UI.Modules
var notificationModel = new NotificationModel { Title = model.Title, User = model.RequestedBy, DateTime = DateTime.Now, NotificationType = NotificationType.NewRequest };
NotificationService.Publish(notificationModel);
return Response.AsJson(new JsonResponseModel { Result = true });
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullMovieName} was successfully added!" });
}
catch (Exception e)
{
@ -300,30 +302,33 @@ namespace PlexRequests.UI.Modules
/// <returns></returns>
private Response RequestTvShow(int showId, string seasons)
{
if (RequestService.CheckRequest(showId))
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = "TV Show has already been requested!" });
}
var tvApi = new TvMazeApi();
var showInfo = tvApi.ShowLookupByTheTvDbId(showId);
DateTime firstAir;
DateTime.TryParse(showInfo.premiered, out firstAir);
string fullShowName = $"{showInfo.name} ({firstAir.Year})";
//#if !DEBUG
if (RequestService.CheckRequest(showId))
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{fullShowName} has already been requested!" });
}
try
{
if (CheckIfTitleExistsInPlex(showInfo.name, showInfo.premiered?.Substring(0, 4))) // Take only the year Format = 2014-01-01
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{showInfo.name} is already in Plex!" });
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{fullShowName} is already in Plex!" });
}
}
catch (ApplicationSettingsException)
{
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"We could not check if {showInfo.name} is in Plex, are you sure it's correctly setup?" });
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"We could not check if {fullShowName} is in Plex, are you sure it's correctly setup?" });
}
//#endif
DateTime firstAir;
DateTime.TryParse(showInfo.premiered, out firstAir);
var model = new RequestedModel
{
ProviderId = showInfo.externals?.thetvdb ?? 0,
@ -372,7 +377,7 @@ namespace PlexRequests.UI.Modules
Log.Debug("Adding tv to database requests (No approval required & Sonarr)");
RequestService.AddRequest(model);
return Response.AsJson(new JsonResponseModel { Result = true });
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullShowName} was successfully added!" });
}
var notify1 = new NotificationModel { Title = model.Title, User = model.RequestedBy, DateTime = DateTime.Now, NotificationType = NotificationType.NewRequest };
NotificationService.Publish(notify1);
@ -394,7 +399,7 @@ namespace PlexRequests.UI.Modules
var notify2 = new NotificationModel { Title = model.Title, User = model.RequestedBy, DateTime = DateTime.Now, NotificationType = NotificationType.NewRequest };
NotificationService.Publish(notify2);
return Response.AsJson(new JsonResponseModel { Result = true });
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullShowName} was successfully added!" });
}
return Response.AsJson(new JsonResponseModel { Result = false, Message = result?.message != null ? "<b>Message From SickRage: </b>" + result.message : "Something went wrong adding the movie to SickRage! Please check your settings." });
}
@ -408,7 +413,7 @@ namespace PlexRequests.UI.Modules
var notificationModel = new NotificationModel { Title = model.Title, User = model.RequestedBy, DateTime = DateTime.Now, NotificationType = NotificationType.NewRequest };
NotificationService.Publish(notificationModel);
return Response.AsJson(new { Result = true });
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullShowName} was successfully added!" });
}
private bool CheckIfTitleExistsInPlex(string title, string year)

@ -38,6 +38,54 @@ You will then have a admin menu option once registered where you can setup Sonar
Looking for a Docker Image? Well [rogueosb](https://github.com/rogueosb/) has created a docker image for us, You can find it [here](https://github.com/rogueosb/docker-plexrequestsnet) :smile:
#Debian/Ubuntu
To configure PlexRequests to run on debian/ubuntu and set it to start up with the system, do the following (via terminal):
####Create a location to drop the files (up to you, we'll use /opt/PlexRequests as an example)
```sudo mkdir /opt/PlexRequests```
####Download the release zip
```
sudo wget {release zip file url}
sudo unzip PlexRequests.zip -d /opt/PlexRequests
```
####Install Mono (this app will be used to actually run the .net libraries and executable)
```sudo apt-get install mono-devel```
####Verify Mono properly runs PlexRequests
```sudo /usr/bin/mono /opt/PlexRequests/Release/PlexRequests.exe```
####Create an upstart script to auto-start PlexRequests with your system (using port 80 in this example)
```sudo nano /etc/init/plexrequests.conf```
#####Paste in the following:
```
start on runlevel [2345]
stop on runlevel [016]
respawn
expect fork
pre-start script
# echo ""
end script
script
exec /usr/bin/mono /opt/PlexRequests/Release/PlexRequests.exe 80
end script
```
####Reboot, then open up your browser to check that it's running!
```sudo shutdown -r 00```
# Contributors
We are looking for any contributions to the project! Just pick up a task, if you have any questions ask and i'll get straight on it!

Loading…
Cancel
Save