From 5b93282b780f4bfa7f100222f413c6046471aba1 Mon Sep 17 00:00:00 2001 From: Drewster727 Date: Sat, 26 Mar 2016 12:06:52 -0500 Subject: [PATCH 1/8] show the movie/show title when requesting. --- PlexRequests.UI/Content/search.js | 2 +- PlexRequests.UI/Modules/SearchModule.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PlexRequests.UI/Content/search.js b/PlexRequests.UI/Content/search.js index 62ed6843b..cea4eca66 100644 --- a/PlexRequests.UI/Content/search.js +++ b/PlexRequests.UI/Content/search.js @@ -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(" Requested"); $('#' + buttonId).removeClass("btn-primary-outline"); diff --git a/PlexRequests.UI/Modules/SearchModule.cs b/PlexRequests.UI/Modules/SearchModule.cs index 1a77c6247..3370725e5 100644 --- a/PlexRequests.UI/Modules/SearchModule.cs +++ b/PlexRequests.UI/Modules/SearchModule.cs @@ -282,7 +282,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 = $"{model.Title} was successfully added!" }); } catch (Exception e) { @@ -408,7 +408,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 = $"{model.Title} was successfully added!" }); } private bool CheckIfTitleExistsInPlex(string title, string year) From 9518f4da89086232a3dd005b37b6074bf60c8d73 Mon Sep 17 00:00:00 2001 From: Drewster727 Date: Sat, 26 Mar 2016 12:31:02 -0500 Subject: [PATCH 2/8] #86 - display movie/show title + year in request notifications. --- PlexRequests.UI/Modules/SearchModule.cs | 47 ++++++++++++++----------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/PlexRequests.UI/Modules/SearchModule.cs b/PlexRequests.UI/Modules/SearchModule.cs index 3370725e5..2a98e8933 100644 --- a/PlexRequests.UI/Modules/SearchModule.cs +++ b/PlexRequests.UI/Modules/SearchModule.cs @@ -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, Message = $"{model.Title} was successfully added!" }); + return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullMovieName} was successfully added!" }); } catch (Exception e) { @@ -300,30 +302,33 @@ namespace PlexRequests.UI.Modules /// 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 ? "Message From SickRage: " + 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 JsonResponseModel { Result = true, Message = $"{model.Title} was successfully added!" }); + return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullShowName} was successfully added!" }); } private bool CheckIfTitleExistsInPlex(string title, string year) From f07771e2a10a167366b3bcba29b8613ecae979ea Mon Sep 17 00:00:00 2001 From: Drewster727 Date: Sun, 27 Mar 2016 14:13:05 -0500 Subject: [PATCH 3/8] add ubuntu/debian instructions --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/README.md b/README.md index 01f89ee0d..9c0ad5a8c 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,44 @@ 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 ues /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/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/PlexRequests.exe 80 +end script + +Reboot and 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! From d8bcf85cc98454e720a025a330e84609eecd3309 Mon Sep 17 00:00:00 2001 From: Drewster727 Date: Sun, 27 Mar 2016 14:17:08 -0500 Subject: [PATCH 4/8] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9c0ad5a8c..5fd7e6a07 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Create an upstart script to auto-start PlexRequests with your system (using port * sudo nano /etc/init/plexrequests.conf * paste in the following: +``` start on runlevel [2345] stop on runlevel [016] @@ -72,6 +73,7 @@ end script script exec /usr/bin/mono /opt/PlexRequests/PlexRequests.exe 80 end script +``` Reboot and open up your browser to check that it's running! * sudo shutdown -r 00 From 96189964e37b1d8772316c09c90fa272764b7b95 Mon Sep 17 00:00:00 2001 From: Drewster727 Date: Sun, 27 Mar 2016 14:18:34 -0500 Subject: [PATCH 5/8] Update README.md --- README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5fd7e6a07..063df9a5e 100644 --- a/README.md +++ b/README.md @@ -43,21 +43,24 @@ Looking for a Docker Image? Well [rogueosb](https://github.com/rogueosb/) has cr 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 ues /opt/PlexRequests as an example) -* sudo mkdir /opt/PlexRequests +```sudo mkdir /opt/PlexRequests``` Download the release zip -* sudo wget {release zip file url} -* sudo unzip PlexRequests.zip -d /opt/PlexRequests +``` +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 +```sudo apt-get install mono-devel``` Verify Mono properly runs PlexRequests -* sudo /usr/bin/mono /opt/PlexRequests/PlexRequests.exe +```sudo /usr/bin/mono /opt/PlexRequests/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: +```sudo nano /etc/init/plexrequests.conf``` + +paste in the following: ``` start on runlevel [2345] @@ -76,7 +79,7 @@ end script ``` Reboot and open up your browser to check that it's running! -* sudo shutdown -r 00 +```sudo shutdown -r 00``` # Contributors From 1f7bda882b8a7c4fcf71fc8a51c1f56c7ece0a66 Mon Sep 17 00:00:00 2001 From: Drewster727 Date: Sun, 27 Mar 2016 14:20:14 -0500 Subject: [PATCH 6/8] Update README.md --- README.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 063df9a5e..c322f1537 100644 --- a/README.md +++ b/README.md @@ -42,25 +42,29 @@ Looking for a Docker Image? Well [rogueosb](https://github.com/rogueosb/) has cr 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 ues /opt/PlexRequests as an example) +###Create a location to drop the files (up to you, we'll ues /opt/PlexRequests as an example) + ```sudo mkdir /opt/PlexRequests``` -Download the release zip +###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) +###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 +###Verify Mono properly runs PlexRequests + ```sudo /usr/bin/mono /opt/PlexRequests/PlexRequests.exe``` -Create an upstart script to auto-start PlexRequests with your system (using port 80 in this example) +###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: +####Paste in the following: ``` start on runlevel [2345] @@ -78,7 +82,8 @@ script end script ``` -Reboot and open up your browser to check that it's running! +###Reboot, then open up your browser to check that it's running! + ```sudo shutdown -r 00``` # Contributors From d12344074775d8cc9eef1e48395e7ac6626004e0 Mon Sep 17 00:00:00 2001 From: Drewster727 Date: Sun, 27 Mar 2016 14:21:19 -0500 Subject: [PATCH 7/8] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c322f1537..8db0c694e 100644 --- a/README.md +++ b/README.md @@ -42,29 +42,29 @@ Looking for a Docker Image? Well [rogueosb](https://github.com/rogueosb/) has cr 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 ues /opt/PlexRequests as an example) +####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 +####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) +####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 +####Verify Mono properly runs PlexRequests ```sudo /usr/bin/mono /opt/PlexRequests/PlexRequests.exe``` -###Create an upstart script to auto-start PlexRequests with your system (using port 80 in this example) +####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: +#####Paste in the following: ``` start on runlevel [2345] @@ -82,7 +82,7 @@ script end script ``` -###Reboot, then open up your browser to check that it's running! +####Reboot, then open up your browser to check that it's running! ```sudo shutdown -r 00``` From b72e897198703d0b36bcd7438ab7ed27db4fa142 Mon Sep 17 00:00:00 2001 From: Drewster727 Date: Sun, 27 Mar 2016 14:24:15 -0500 Subject: [PATCH 8/8] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8db0c694e..2376c1bae 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ sudo unzip PlexRequests.zip -d /opt/PlexRequests ####Verify Mono properly runs PlexRequests -```sudo /usr/bin/mono /opt/PlexRequests/PlexRequests.exe``` +```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) @@ -78,7 +78,7 @@ pre-start script end script script - exec /usr/bin/mono /opt/PlexRequests/PlexRequests.exe 80 + exec /usr/bin/mono /opt/PlexRequests/Release/PlexRequests.exe 80 end script ```