This commit is contained in:
tidusjar 2016-04-07 22:15:47 +01:00
commit 53734d967b
12 changed files with 429 additions and 116 deletions

View file

@ -192,7 +192,8 @@ label {
color: #ccc; } color: #ccc; }
.form-control-search { .form-control-search {
padding: 25px 105px 25px 16px; } padding: 13px 105px 13px 16px;
height: 100%; }
.form-control-withbuttons { .form-control-withbuttons {
padding-right: 105px; } padding-right: 105px; }

View file

@ -1 +1 @@
@media(min-width:768px){.row{position:relative;}.bottom-align-text{position:absolute;bottom:0;right:0;}}@media(max-width:48em){.home{padding-top:1rem;}}@media(min-width:48em){.home{padding-top:4rem;}}.btn{border-radius:.25rem !important;}.multiSelect{background-color:#4e5d6c;}.form-control-custom{background-color:#4e5d6c !important;color:#fff !important;border-radius:0;box-shadow:0 0 0 !important;}h1{font-size:3.5rem !important;font-weight:600 !important;}.request-title{margin-top:0 !important;font-size:1.9rem !important;}p{font-size:1.1rem !important;}label{display:inline-block !important;margin-bottom:.5rem !important;font-size:16px !important;}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:focus{background:#4e5d6c;}.navbar .nav a .fa,.dropdown-menu a .fa{font-size:130%;top:1px;position:relative;display:inline-block;margin-right:5px;}.dropdown-menu a .fa{top:2px;}.btn-danger-outline{color:#d9534f !important;background-color:transparent;background-image:none;border-color:#d9534f !important;}.btn-danger-outline:focus,.btn-danger-outline.focus,.btn-danger-outline:active,.btn-danger-outline.active,.btn-danger-outline:hover,.open>.btn-danger-outline.dropdown-toggle{color:#fff !important;background-color:#d9534f !important;border-color:#d9534f !important;}.btn-primary-outline{color:#ff761b !important;background-color:transparent;background-image:none;border-color:#ff761b !important;}.btn-primary-outline:focus,.btn-primary-outline.focus,.btn-primary-outline:active,.btn-primary-outline.active,.btn-primary-outline:hover,.open>.btn-primary-outline.dropdown-toggle{color:#fff !important;background-color:#df691a !important;border-color:#df691a !important;}.btn-info-outline{color:#5bc0de !important;background-color:transparent;background-image:none;border-color:#5bc0de !important;}.btn-info-outline:focus,.btn-info-outline.focus,.btn-info-outline:active,.btn-info-outline.active,.btn-info-outline:hover,.open>.btn-info-outline.dropdown-toggle{color:#fff !important;background-color:#5bc0de !important;border-color:#5bc0de !important;}.btn-warning-outline{color:#f0ad4e !important;background-color:transparent;background-image:none;border-color:#f0ad4e !important;}.btn-warning-outline:focus,.btn-warning-outline.focus,.btn-warning-outline:active,.btn-warning-outline.active,.btn-warning-outline:hover,.open>.btn-warning-outline.dropdown-toggle{color:#fff !important;background-color:#f0ad4e !important;border-color:#f0ad4e !important;}.btn-success-outline{color:#5cb85c !important;background-color:transparent;background-image:none;border-color:#5cb85c !important;}.btn-success-outline:focus,.btn-success-outline.focus,.btn-success-outline:active,.btn-success-outline.active,.btn-success-outline:hover,.open>.btn-success-outline.dropdown-toggle{color:#fff !important;background-color:#5cb85c !important;border-color:#5cb85c !important;}#movieList .mix{display:none;}#tvList .mix{display:none;}.scroll-top-wrapper{position:fixed;opacity:0;visibility:hidden;overflow:hidden;text-align:center;z-index:99999999;background-color:#4e5d6c;color:#eee;width:50px;height:48px;line-height:48px;right:30px;bottom:30px;padding-top:2px;border-top-left-radius:10px;border-top-right-radius:10px;border-bottom-right-radius:10px;border-bottom-left-radius:10px;-webkit-transition:all .5s ease-in-out;-moz-transition:all .5s ease-in-out;-ms-transition:all .5s ease-in-out;-o-transition:all .5s ease-in-out;transition:all .5s ease-in-out;}.scroll-top-wrapper:hover{background-color:#637689;}.scroll-top-wrapper.show{visibility:visible;cursor:pointer;opacity:1;}.scroll-top-wrapper i.fa{line-height:inherit;}.no-search-results{text-align:center;}.no-search-results .no-search-results-icon{font-size:10em;color:#4e5d6c;}.no-search-results .no-search-results-text{margin:20px 0;color:#ccc;}.form-control-search{padding:25px 105px 25px 16px;}.form-control-withbuttons{padding-right:105px;}.input-group-addon .btn-group{position:absolute;right:45px;z-index:3;top:13px;box-shadow:0 0 0;}.input-group-addon .btn-group .btn{border:1px solid rgba(255,255,255,.7) !important;padding:3px 12px;color:rgba(255,255,255,.7) !important;}.btn-split .btn{border-radius:0 !important;}.btn-split .btn:not(.dropdown-toggle){border-radius:.25rem 0 0 .25rem !important;}.btn-split .btn.dropdown-toggle{border-radius:0 .25rem .25rem 0 !important;padding:12px 8px;} @media(min-width:768px){.row{position:relative;}.bottom-align-text{position:absolute;bottom:0;right:0;}}@media(max-width:48em){.home{padding-top:1rem;}}@media(min-width:48em){.home{padding-top:4rem;}}.btn{border-radius:.25rem !important;}.multiSelect{background-color:#4e5d6c;}.form-control-custom{background-color:#4e5d6c !important;color:#fff !important;border-radius:0;box-shadow:0 0 0 !important;}h1{font-size:3.5rem !important;font-weight:600 !important;}.request-title{margin-top:0 !important;font-size:1.9rem !important;}p{font-size:1.1rem !important;}label{display:inline-block !important;margin-bottom:.5rem !important;font-size:16px !important;}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:focus{background:#4e5d6c;}.navbar .nav a .fa,.dropdown-menu a .fa{font-size:130%;top:1px;position:relative;display:inline-block;margin-right:5px;}.dropdown-menu a .fa{top:2px;}.btn-danger-outline{color:#d9534f !important;background-color:transparent;background-image:none;border-color:#d9534f !important;}.btn-danger-outline:focus,.btn-danger-outline.focus,.btn-danger-outline:active,.btn-danger-outline.active,.btn-danger-outline:hover,.open>.btn-danger-outline.dropdown-toggle{color:#fff !important;background-color:#d9534f !important;border-color:#d9534f !important;}.btn-primary-outline{color:#ff761b !important;background-color:transparent;background-image:none;border-color:#ff761b !important;}.btn-primary-outline:focus,.btn-primary-outline.focus,.btn-primary-outline:active,.btn-primary-outline.active,.btn-primary-outline:hover,.open>.btn-primary-outline.dropdown-toggle{color:#fff !important;background-color:#df691a !important;border-color:#df691a !important;}.btn-info-outline{color:#5bc0de !important;background-color:transparent;background-image:none;border-color:#5bc0de !important;}.btn-info-outline:focus,.btn-info-outline.focus,.btn-info-outline:active,.btn-info-outline.active,.btn-info-outline:hover,.open>.btn-info-outline.dropdown-toggle{color:#fff !important;background-color:#5bc0de !important;border-color:#5bc0de !important;}.btn-warning-outline{color:#f0ad4e !important;background-color:transparent;background-image:none;border-color:#f0ad4e !important;}.btn-warning-outline:focus,.btn-warning-outline.focus,.btn-warning-outline:active,.btn-warning-outline.active,.btn-warning-outline:hover,.open>.btn-warning-outline.dropdown-toggle{color:#fff !important;background-color:#f0ad4e !important;border-color:#f0ad4e !important;}.btn-success-outline{color:#5cb85c !important;background-color:transparent;background-image:none;border-color:#5cb85c !important;}.btn-success-outline:focus,.btn-success-outline.focus,.btn-success-outline:active,.btn-success-outline.active,.btn-success-outline:hover,.open>.btn-success-outline.dropdown-toggle{color:#fff !important;background-color:#5cb85c !important;border-color:#5cb85c !important;}#movieList .mix{display:none;}#tvList .mix{display:none;}.scroll-top-wrapper{position:fixed;opacity:0;visibility:hidden;overflow:hidden;text-align:center;z-index:99999999;background-color:#4e5d6c;color:#eee;width:50px;height:48px;line-height:48px;right:30px;bottom:30px;padding-top:2px;border-top-left-radius:10px;border-top-right-radius:10px;border-bottom-right-radius:10px;border-bottom-left-radius:10px;-webkit-transition:all .5s ease-in-out;-moz-transition:all .5s ease-in-out;-ms-transition:all .5s ease-in-out;-o-transition:all .5s ease-in-out;transition:all .5s ease-in-out;}.scroll-top-wrapper:hover{background-color:#637689;}.scroll-top-wrapper.show{visibility:visible;cursor:pointer;opacity:1;}.scroll-top-wrapper i.fa{line-height:inherit;}.no-search-results{text-align:center;}.no-search-results .no-search-results-icon{font-size:10em;color:#4e5d6c;}.no-search-results .no-search-results-text{margin:20px 0;color:#ccc;}.form-control-search{padding:13px 105px 13px 16px;height:100%;}.form-control-withbuttons{padding-right:105px;}.input-group-addon .btn-group{position:absolute;right:45px;z-index:3;top:13px;box-shadow:0 0 0;}.input-group-addon .btn-group .btn{border:1px solid rgba(255,255,255,.7) !important;padding:3px 12px;color:rgba(255,255,255,.7) !important;}.btn-split .btn{border-radius:0 !important;}.btn-split .btn:not(.dropdown-toggle){border-radius:.25rem 0 0 .25rem !important;}.btn-split .btn.dropdown-toggle{border-radius:0 .25rem .25rem 0 !important;padding:12px 8px;}

View file

@ -246,7 +246,8 @@ $border-radius: 10px;
} }
.form-control-search { .form-control-search {
padding: 25px 105px 25px 16px; padding: 13px 105px 13px 16px;
height: 100%;
} }
.form-control-withbuttons { .form-control-withbuttons {

View file

@ -30,7 +30,6 @@ $(function () {
if (searchTimer) { if (searchTimer) {
clearTimeout(searchTimer); clearTimeout(searchTimer);
} }
$('#movieSearchButton').attr("class", "fa fa-spinner fa-spin");
searchTimer = setTimeout(movieSearch, 400); searchTimer = setTimeout(movieSearch, 400);
}); });
@ -50,7 +49,6 @@ $(function () {
if (searchTimer) { if (searchTimer) {
clearTimeout(searchTimer); clearTimeout(searchTimer);
} }
$('#tvSearchButton').attr("class", "fa fa-spinner fa-spin");
searchTimer = setTimeout(tvSearch, 400); searchTimer = setTimeout(tvSearch, 400);
}); });
@ -90,7 +88,6 @@ $(function () {
if (searchTimer) { if (searchTimer) {
clearTimeout(searchTimer); clearTimeout(searchTimer);
} }
$('#musicSearchButton').attr("class", "fa fa-spinner fa-spin");
searchTimer = setTimeout(musicSearch, 400); searchTimer = setTimeout(musicSearch, 400);
}); });
@ -175,7 +172,7 @@ $(function () {
function movieSearch() { function movieSearch() {
var query = $("#movieSearchContent").val(); var query = $("#movieSearchContent").val();
getMovies("/search/movie/" + query); query ? getMovies("/search/movie/" + query) : resetMovies();
} }
function moviesComingSoon() { function moviesComingSoon() {
@ -187,9 +184,9 @@ $(function () {
} }
function getMovies(url) { function getMovies(url) {
$("#movieList").html(""); resetMovies();
$('#movieSearchButton').attr("class", "fa fa-spinner fa-spin");
$.ajax(url).success(function (results) { $.ajax(url).success(function (results) {
if (results.length > 0) { if (results.length > 0) {
results.forEach(function (result) { results.forEach(function (result) {
@ -206,14 +203,19 @@ $(function () {
}); });
}; };
function resetMovies() {
$("#movieList").html("");
}
function tvSearch() { function tvSearch() {
var query = $("#tvSearchContent").val(); var query = $("#tvSearchContent").val();
getTvShows("/search/tv/" + query); query ? getTvShows("/search/tv/" + query) : resetTvShows();
} }
function getTvShows(url) { function getTvShows(url) {
$("#tvList").html(""); resetTvShows();
$('#tvSearchButton').attr("class", "fa fa-spinner fa-spin");
$.ajax(url).success(function (results) { $.ajax(url).success(function (results) {
if (results.length > 0) { if (results.length > 0) {
results.forEach(function (result) { results.forEach(function (result) {
@ -229,14 +231,19 @@ $(function () {
}); });
}; };
function resetTvShows() {
$("#tvList").html("");
}
function musicSearch() { function musicSearch() {
var query = $("#musicSearchContent").val(); var query = $("#musicSearchContent").val();
getMusic("/search/music/" + query); query ? getMusic("/search/music/" + query) : resetMusic();
} }
function getMusic(url) { function getMusic(url) {
$("#musicList").html(""); resetMusic();
$('#musicSearchButton').attr("class", "fa fa-spinner fa-spin");
$.ajax(url).success(function (results) { $.ajax(url).success(function (results) {
if (results.length > 0) { if (results.length > 0) {
results.forEach(function (result) { results.forEach(function (result) {
@ -254,6 +261,10 @@ $(function () {
}); });
}; };
function resetMusic() {
$("#musicList").html("");
}
function getCoverArt(artistId) { function getCoverArt(artistId) {
$.ajax("/search/music/coverart/" + artistId).success(function (result) { $.ajax("/search/music/coverart/" + artistId).success(function (result) {
if (result) { if (result) {
@ -274,7 +285,10 @@ $(function () {
voteAverage: result.voteAverage, voteAverage: result.voteAverage,
year: year, year: year,
type: "movie", type: "movie",
imdb: result.imdbId imdb: result.imdbId,
requested: result.requested,
approved: result.approved,
available: result.available
}; };
return context; return context;
@ -290,7 +304,10 @@ $(function () {
overview: result.overview, overview: result.overview,
year: year, year: year,
type: "tv", type: "tv",
imdb: result.imdbId imdb: result.imdbId,
requested: result.requested,
approved: result.approved,
available: result.available
}; };
return context; return context;
} }
@ -307,7 +324,10 @@ $(function () {
coverArtUrl: result.coverArtUrl, coverArtUrl: result.coverArtUrl,
artist: result.artist, artist: result.artist,
releaseType: result.releaseType, releaseType: result.releaseType,
country: result.country country: result.country,
requested: result.requested,
approved: result.approved,
available: result.available
}; };
return context; return context;

View file

@ -0,0 +1,35 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: PlexType.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 enum MovieSearchType
{
Upcoming,
CurrentlyPlaying,
Search
}
}

View file

@ -0,0 +1,50 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: SearchTvShowViewModel.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
using System;
using System.Collections.Generic;
namespace PlexRequests.UI.Models
{
public class SearchMovieViewModel : SearchViewModel
{
public bool Adult { get; set; }
public string BackdropPath { get; set; }
public List<int> GenreIds { get; set; }
public int Id { get; set; }
public string OriginalLanguage { get; set; }
public string OriginalTitle { get; set; }
public string Overview { get; set; }
public double Popularity { get; set; }
public string PosterPath { get; set; }
public DateTime? ReleaseDate { get; set; }
public string Title { get; set; }
public bool Video { get; set; }
public double VoteAverage { get; set; }
public int VoteCount { get; set; }
}
}

View file

@ -1,41 +1,41 @@
#region Copyright #region Copyright
// /************************************************************************ // /************************************************************************
// Copyright (c) 2016 Jamie Rees // Copyright (c) 2016 Jamie Rees
// File: SearchMusicViewModel.cs // File: SearchMusicViewModel.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
namespace PlexRequests.UI.Models namespace PlexRequests.UI.Models
{ {
public class SearchMusicViewModel public class SearchMusicViewModel : SearchViewModel
{ {
public string Id { get; set; } public string Id { get; set; }
public string Overview { get; set; } public string Overview { get; set; }
public string CoverArtUrl { get; set; } public string CoverArtUrl { get; set; }
public string Title { get; set; } public string Title { get; set; }
public string Artist { get; set; } public string Artist { get; set; }
public string ReleaseDate { get; set; } public string ReleaseDate { get; set; }
public int TrackCount { get; set; } public int TrackCount { get; set; }
public string ReleaseType { get; set; } public string ReleaseType { get; set; }
public string Country { get; set; } public string Country { get; set; }
} }
} }

View file

@ -29,7 +29,7 @@ using System.Collections.Generic;
namespace PlexRequests.UI.Models namespace PlexRequests.UI.Models
{ {
public class SearchTvShowViewModel public class SearchTvShowViewModel : SearchViewModel
{ {
public int Id { get; set; } public int Id { get; set; }
public string SeriesName { get; set; } public string SeriesName { get; set; }

View file

@ -0,0 +1,37 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: SearchTvShowViewModel.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 SearchViewModel
{
public bool Approved { get; set; }
public bool Requested { get; set; }
public bool Available { get; set; }
}
}

View file

@ -48,6 +48,10 @@ using PlexRequests.Services.Notification;
using PlexRequests.Store; using PlexRequests.Store;
using PlexRequests.UI.Helpers; using PlexRequests.UI.Helpers;
using PlexRequests.UI.Models; using PlexRequests.UI.Models;
using System.Threading.Tasks;
using TMDbLib.Objects.Search;
using PlexRequests.Api.Models.Tv;
using TMDbLib.Objects.General;
namespace PlexRequests.UI.Modules namespace PlexRequests.UI.Modules
{ {
@ -109,7 +113,8 @@ namespace PlexRequests.UI.Modules
private IHeadphonesApi HeadphonesApi { get; } private IHeadphonesApi HeadphonesApi { get; }
private static Logger Log = LogManager.GetCurrentClassLogger(); private static Logger Log = LogManager.GetCurrentClassLogger();
private bool IsAdmin { private bool IsAdmin
{
get get
{ {
return Context.CurrentUser.IsAuthenticated(); return Context.CurrentUser.IsAuthenticated();
@ -124,29 +129,150 @@ namespace PlexRequests.UI.Modules
return View["Search/Index", settings]; return View["Search/Index", settings];
} }
private Response UpcomingMovies()
{
Log.Trace("Loading upcoming movies");
return ProcessMovies(MovieSearchType.Upcoming, string.Empty);
}
private Response CurrentlyPlayingMovies()
{
Log.Trace("Loading currently playing movies");
return ProcessMovies(MovieSearchType.CurrentlyPlaying, string.Empty);
}
private Response SearchMovie(string searchTerm) private Response SearchMovie(string searchTerm)
{ {
Log.Trace("Searching for Movie {0}", searchTerm); Log.Trace("Searching for Movie {0}", searchTerm);
var movies = MovieApi.SearchMovie(searchTerm); return ProcessMovies(MovieSearchType.Search, searchTerm);
var result = movies.Result; }
return Response.AsJson(result);
private Response ProcessMovies(MovieSearchType searchType, string searchTerm)
{
List<Task> taskList = new List<Task>();
List<MovieResult> apiMovies = new List<MovieResult>();
taskList.Add(Task.Factory.StartNew<List<MovieResult>>(() =>
{
switch(searchType)
{
case MovieSearchType.Search:
return MovieApi.SearchMovie(searchTerm).Result.Select(x => new MovieResult()
{
Adult = x.Adult,
BackdropPath = x.BackdropPath,
GenreIds = x.GenreIds,
Id = x.Id,
OriginalLanguage = x.OriginalLanguage,
OriginalTitle = x.OriginalTitle,
Overview = x.Overview,
Popularity = x.Popularity,
PosterPath = x.PosterPath,
ReleaseDate = x.ReleaseDate,
Title = x.Title,
Video = x.Video,
VoteAverage = x.VoteAverage,
VoteCount = x.VoteCount
}).ToList();
case MovieSearchType.CurrentlyPlaying:
return MovieApi.GetCurrentPlayingMovies().Result.ToList();
case MovieSearchType.Upcoming:
return MovieApi.GetUpcomingMovies().Result.ToList();
default:
return new List<MovieResult>();
}
}).ContinueWith((t) =>
{
apiMovies = t.Result;
}));
Dictionary<int, RequestedModel> dbMovies = new Dictionary<int, RequestedModel>();
taskList.Add(Task.Factory.StartNew(() =>
{
return RequestService.GetAll().Where(x => x.Type == RequestType.Movie);
}).ContinueWith((t) =>
{
dbMovies = t.Result.ToDictionary(x => x.ProviderId);
}));
Task.WaitAll(taskList.ToArray());
List<SearchMovieViewModel> viewMovies = new List<SearchMovieViewModel>();
foreach (MovieResult movie in apiMovies)
{
var viewMovie = new SearchMovieViewModel()
{
Adult = movie.Adult,
BackdropPath = movie.BackdropPath,
GenreIds = movie.GenreIds,
Id = movie.Id,
OriginalLanguage = movie.OriginalLanguage,
OriginalTitle = movie.OriginalTitle,
Overview = movie.Overview,
Popularity = movie.Popularity,
PosterPath = movie.PosterPath,
ReleaseDate = movie.ReleaseDate,
Title = movie.Title,
Video = movie.Video,
VoteAverage = movie.VoteAverage,
VoteCount = movie.VoteCount
};
if (dbMovies.ContainsKey(movie.Id))
{
var dbm = dbMovies[movie.Id];
viewMovie.Requested = true;
viewMovie.Approved = dbm.Approved;
viewMovie.Available = dbm.Available;
}
viewMovies.Add(viewMovie);
}
return Response.AsJson(viewMovies);
} }
private Response SearchTvShow(string searchTerm) private Response SearchTvShow(string searchTerm)
{ {
Log.Trace("Searching for TV Show {0}", searchTerm); Log.Trace("Searching for TV Show {0}", searchTerm);
//var tvShow = TvApi.SearchTv(searchTerm, AuthToken);
var tvShow = new TvMazeApi().Search(searchTerm); List<Task> taskList = new List<Task>();
if (!tvShow.Any())
List<TvMazeSearch> apiTv = new List<TvMazeSearch>();
taskList.Add(Task.Factory.StartNew(() =>
{
return new TvMazeApi().Search(searchTerm);
}).ContinueWith((t) =>
{
apiTv = t.Result;
}));
Dictionary<int, RequestedModel> dbTv = new Dictionary<int, RequestedModel>();
taskList.Add(Task.Factory.StartNew(() =>
{
return RequestService.GetAll().Where(x => x.Type == RequestType.TvShow);
}).ContinueWith((t) =>
{
dbTv = t.Result.ToDictionary(x => x.ProviderId);
}));
Task.WaitAll(taskList.ToArray());
if (!apiTv.Any())
{ {
Log.Trace("TV Show data is null"); Log.Trace("TV Show data is null");
return Response.AsJson(""); return Response.AsJson("");
} }
var model = new List<SearchTvShowViewModel>();
foreach (var t in tvShow)
var viewTv = new List<SearchTvShowViewModel>();
foreach (var t in apiTv)
{ {
model.Add(new SearchTvShowViewModel var viewT = new SearchTvShowViewModel
{ {
// We are constructing the banner with the id: // We are constructing the banner with the id:
// http://thetvdb.com/banners/_cache/posters/ID-1.jpg // http://thetvdb.com/banners/_cache/posters/ID-1.jpg
@ -161,24 +287,56 @@ namespace PlexRequests.UI.Modules
Runtime = t.show.runtime.ToString(), Runtime = t.show.runtime.ToString(),
SeriesId = t.show.id, SeriesId = t.show.id,
SeriesName = t.show.name, SeriesName = t.show.name,
Status = t.show.status
};
Status = t.show.status, if (t.show.externals.thetvdb != null && dbTv.ContainsKey((int)t.show.externals.thetvdb))
}); {
var dbt = dbTv[(int)t.show.externals.thetvdb];
viewT.Requested = true;
viewT.Approved = dbt.Approved;
viewT.Available = dbt.Available;
}
viewTv.Add(viewT);
} }
Log.Trace("Returning TV Show results: "); Log.Trace("Returning TV Show results: ");
Log.Trace(model.DumpJson()); Log.Trace(viewTv.DumpJson());
return Response.AsJson(model); return Response.AsJson(viewTv);
} }
private Response SearchMusic(string searchTerm) private Response SearchMusic(string searchTerm)
{ {
var albums = MusicBrainzApi.SearchAlbum(searchTerm); List<Task> taskList = new List<Task>();
var releases = albums.releases ?? new List<Release>();
var model = new List<SearchMusicViewModel>(); List<Release> apiAlbums = new List<Release>();
foreach (var a in releases) taskList.Add(Task.Factory.StartNew(() =>
{ {
model.Add(new SearchMusicViewModel return MusicBrainzApi.SearchAlbum(searchTerm);
}).ContinueWith((t) =>
{
apiAlbums = t.Result.releases ?? new List<Release>();
}));
Dictionary<string, RequestedModel> dbAlbum = new Dictionary<string, RequestedModel>();
taskList.Add(Task.Factory.StartNew(() =>
{
return RequestService.GetAll().Where(x => x.Type == RequestType.Album);
}).ContinueWith((t) =>
{
dbAlbum = t.Result.ToDictionary(x => x.MusicBrainzId);
}));
Task.WaitAll(taskList.ToArray());
var viewAlbum = new List<SearchMusicViewModel>();
foreach (var a in apiAlbums)
{
var viewA = new SearchMusicViewModel
{ {
Title = a.title, Title = a.title,
Id = a.id, Id = a.id,
@ -188,27 +346,20 @@ namespace PlexRequests.UI.Modules
TrackCount = a.TrackCount, TrackCount = a.TrackCount,
ReleaseType = a.status, ReleaseType = a.status,
Country = a.country Country = a.country
}); };
if (!string.IsNullOrEmpty(a.id) && dbAlbum.ContainsKey(a.id))
{
var dba = dbAlbum[a.id];
viewA.Requested = true;
viewA.Approved = dba.Approved;
viewA.Available = dba.Available;
}
viewAlbum.Add(viewA);
} }
return Response.AsJson(model); return Response.AsJson(viewAlbum);
}
private Response UpcomingMovies() // TODO : Not used
{
var movies = MovieApi.GetUpcomingMovies();
var result = movies.Result;
Log.Trace("Movie Upcoming Results: ");
Log.Trace(result.DumpJson());
return Response.AsJson(result);
}
private Response CurrentlyPlayingMovies() // TODO : Not used
{
var movies = MovieApi.GetCurrentPlayingMovies();
var result = movies.Result;
Log.Trace("Movie Currently Playing Results: ");
Log.Trace(result.DumpJson());
return Response.AsJson(result);
} }
private Response RequestMovie(int movieId) private Response RequestMovie(int movieId)
@ -241,7 +392,7 @@ namespace PlexRequests.UI.Modules
try try
{ {
if (CheckIfTitleExistsInPlex(movieInfo.Title, movieInfo.ReleaseDate?.Year.ToString(),null, PlexType.Movie)) if (CheckIfTitleExistsInPlex(movieInfo.Title, movieInfo.ReleaseDate?.Year.ToString(), null, PlexType.Movie))
{ {
return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{fullMovieName} is already in Plex!" }); return Response.AsJson(new JsonResponseModel { Result = false, Message = $"{fullMovieName} is already in Plex!" });
} }
@ -502,7 +653,7 @@ namespace PlexRequests.UI.Modules
Log.Debug("This is a new request"); Log.Debug("This is a new request");
var albumInfo = MusicBrainzApi.GetAlbum(releaseId); var albumInfo = MusicBrainzApi.GetAlbum(releaseId);
DateTime release; DateTime release;
DateTimeHelper.CustomParse(albumInfo.ReleaseEvents?.FirstOrDefault()?.date, out release); DateTimeHelper.CustomParse(albumInfo.ReleaseEvents?.FirstOrDefault()?.date, out release);
@ -581,7 +732,7 @@ namespace PlexRequests.UI.Modules
Message = $"{model.Title} was successfully added!" Message = $"{model.Title} was successfully added!"
}); });
} }
var result = RequestService.AddRequest(model); var result = RequestService.AddRequest(model);
return Response.AsJson(new JsonResponseModel return Response.AsJson(new JsonResponseModel
{ {

View file

@ -169,8 +169,11 @@
<Compile Include="Helpers\TvSender.cs" /> <Compile Include="Helpers\TvSender.cs" />
<Compile Include="Helpers\ValidationHelper.cs" /> <Compile Include="Helpers\ValidationHelper.cs" />
<Compile Include="Models\DatatablesModel.cs" /> <Compile Include="Models\DatatablesModel.cs" />
<Compile Include="Models\MovieSearchType.cs" />
<Compile Include="Models\QualityModel.cs" /> <Compile Include="Models\QualityModel.cs" />
<Compile Include="Models\SearchViewModel.cs" />
<Compile Include="Models\SearchMusicViewModel.cs" /> <Compile Include="Models\SearchMusicViewModel.cs" />
<Compile Include="Models\SearchMovieViewModel.cs" />
<Compile Include="Validators\PushoverSettingsValidator.cs" /> <Compile Include="Validators\PushoverSettingsValidator.cs" />
<Compile Include="Validators\PushbulletSettingsValidator.cs" /> <Compile Include="Validators\PushbulletSettingsValidator.cs" />
<Compile Include="Validators\EmailNotificationSettingsValidator.cs" /> <Compile Include="Validators\EmailNotificationSettingsValidator.cs" />

View file

@ -124,21 +124,29 @@
<div class="col-sm-2 col-sm-push-3"> <div class="col-sm-2 col-sm-push-3">
<form method="POST" action="/search/request/{{type}}" id="form{{id}}"> <form method="POST" action="/search/request/{{type}}" id="form{{id}}">
<input name="{{type}}Id" type="text" value="{{id}}" hidden="hidden" /> <input name="{{type}}Id" type="text" value="{{id}}" hidden="hidden" />
{{#if_eq type "movie"}} {{#if_eq available true}}
<button id="{{id}}" style="text-align: right" class="btn btn-primary-outline requestMovie" type="submit"><i class="fa fa-plus"></i> Request</button> <button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> Available</button>
{{/if_eq}} {{else}}
{{#if_eq type "tv"}} {{#if_eq requested true}}
<div class="dropdown"> <button style="text-align: right" class="btn btn-primary-outline disabled" disabled><i class="fa fa-check"></i> Requested</button>
<button id="{{id}}" class="btn btn-primary-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> {{else}}
<i class="fa fa-plus"></i> Request {{#if_eq type "movie"}}
<span class="caret"></span> <button id="{{id}}" style="text-align: right" class="btn btn-primary-outline requestMovie" type="submit"><i class="fa fa-plus"></i> Request</button>
</button> {{/if_eq}}
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1"> {{#if_eq type "tv"}}
<li><a id="{{id}}" season-select="0" class="dropdownTv " href="#">All Seasons</a></li> <div class="dropdown">
<li><a id="{{id}}" season-select="1" class="dropdownTv" href="#">First Season</a></li> <button id="{{id}}" class="btn btn-primary-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<li><a id="{{id}}" season-select="2" class="dropdownTv" href="#">Latest Season</a></li> <i class="fa fa-plus"></i> Request
</ul> <span class="caret"></span>
</div> </button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a id="{{id}}" season-select="0" class="dropdownTv " href="#">All Seasons</a></li>
<li><a id="{{id}}" season-select="1" class="dropdownTv" href="#">First Season</a></li>
<li><a id="{{id}}" season-select="2" class="dropdownTv" href="#">Latest Season</a></li>
</ul>
</div>
{{/if_eq}}
{{/if_eq}}
{{/if_eq}} {{/if_eq}}
<br /> <br />
<br /> <br />
@ -181,8 +189,15 @@
<div class="col-sm-2 col-sm-push-3"> <div class="col-sm-2 col-sm-push-3">
<form method="POST" action="/search/request/{{type}}" id="form{{id}}"> <form method="POST" action="/search/request/{{type}}" id="form{{id}}">
<input name="{{type}}Id" type="text" value="{{id}}" hidden="hidden" /> <input name="{{type}}Id" type="text" value="{{id}}" hidden="hidden" />
{{#if_eq available true}}
<button id="{{id}}" style="text-align: right" class="btn btn-primary-outline requestAlbum" type="submit"><i class="fa fa-plus"></i> Request</button> <button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> Available</button>
{{else}}
{{#if_eq requested true}}
<button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> Requested</button>
{{else}}
<button id="{{id}}" style="text-align: right" class="btn btn-primary-outline requestAlbum" type="submit"><i class="fa fa-plus"></i> Request</button>
{{/if_eq}}
{{/if_eq}}
<br /> <br />
<small class="row">Track Count: {{trackCount}}</small> <small class="row">Track Count: {{trackCount}}</small>
<small class="row">Country: {{country}}</small> <small class="row">Country: {{country}}</small>