From 1c301f2c54eb2cf8d7bff07162f689873ae83eef Mon Sep 17 00:00:00 2001 From: tidusjar Date: Tue, 4 Apr 2017 23:07:13 +0100 Subject: [PATCH] #865 --- Ombi/Ombi.Api/Api.cs | 29 +++++++ Ombi/Ombi.Api/ApiHelper.cs | 78 +++++++++++++++++++ Ombi/Ombi.Api/Ombi.Api.csproj | 11 +++ Ombi/Ombi.Core/MovieProcessor.cs | 8 ++ Ombi/Ombi.Core/Ombi.Core.csproj | 7 ++ Ombi/Ombi.TheMovieDbApi/IMovieDbApi.cs | 33 ++++++++ .../Models/BelongsToCollection.cs | 10 +++ Ombi/Ombi.TheMovieDbApi/Models/Genre.cs | 8 ++ .../Models/MovieResponse.cs | 58 ++++++++++++++ .../Models/ProductionCompanies.cs | 8 ++ .../Models/ProductionCountries.cs | 8 ++ .../Ombi.TheMovieDbApi/Models/SearchResult.cs | 46 +++++++++++ .../Models/SpokenLanguages.cs | 8 ++ .../Models/TheMovieDbContainer.cs | 39 ++++++++++ .../Ombi.TheMovieDbApi.csproj | 11 +++ Ombi/Ombi.TheMovieDbApi/TheMovieDbApi.cs | 39 ++++++++++ Ombi/Ombi.sln | 24 ++++++ Ombi/Ombi/Controllers/BaseApiController.cs | 2 +- Ombi/Ombi/Controllers/SearchController.cs | 11 ++- Ombi/Ombi/Ombi.csproj | 4 + Ombi/Ombi/app/app.module.ts | 4 +- .../app/search/interfaces/IMovieResult.ts | 16 ++++ Ombi/Ombi/app/search/search.component.html | 2 +- Ombi/Ombi/app/search/search.component.ts | 35 ++++++++- Ombi/Ombi/app/services/search.service.ts | 16 ++++ Ombi/Ombi/app/services/service.helpers.ts | 15 ++++ 26 files changed, 520 insertions(+), 10 deletions(-) create mode 100644 Ombi/Ombi.Api/Api.cs create mode 100644 Ombi/Ombi.Api/ApiHelper.cs create mode 100644 Ombi/Ombi.Api/Ombi.Api.csproj create mode 100644 Ombi/Ombi.Core/MovieProcessor.cs create mode 100644 Ombi/Ombi.Core/Ombi.Core.csproj create mode 100644 Ombi/Ombi.TheMovieDbApi/IMovieDbApi.cs create mode 100644 Ombi/Ombi.TheMovieDbApi/Models/BelongsToCollection.cs create mode 100644 Ombi/Ombi.TheMovieDbApi/Models/Genre.cs create mode 100644 Ombi/Ombi.TheMovieDbApi/Models/MovieResponse.cs create mode 100644 Ombi/Ombi.TheMovieDbApi/Models/ProductionCompanies.cs create mode 100644 Ombi/Ombi.TheMovieDbApi/Models/ProductionCountries.cs create mode 100644 Ombi/Ombi.TheMovieDbApi/Models/SearchResult.cs create mode 100644 Ombi/Ombi.TheMovieDbApi/Models/SpokenLanguages.cs create mode 100644 Ombi/Ombi.TheMovieDbApi/Models/TheMovieDbContainer.cs create mode 100644 Ombi/Ombi.TheMovieDbApi/Ombi.TheMovieDbApi.csproj create mode 100644 Ombi/Ombi.TheMovieDbApi/TheMovieDbApi.cs create mode 100644 Ombi/Ombi/app/search/interfaces/IMovieResult.ts create mode 100644 Ombi/Ombi/app/services/search.service.ts create mode 100644 Ombi/Ombi/app/services/service.helpers.ts diff --git a/Ombi/Ombi.Api/Api.cs b/Ombi/Ombi.Api/Api.cs new file mode 100644 index 000000000..adeb34bfc --- /dev/null +++ b/Ombi/Ombi.Api/Api.cs @@ -0,0 +1,29 @@ +using System; +using System.IO; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace Ombi.Api +{ + public class Api + { + public static JsonSerializerSettings Settings = new JsonSerializerSettings + { + NullValueHandling = NullValueHandling.Ignore + }; + public async Task Get(Uri uri) + { + var h = new HttpClient(); + var response = await h.GetAsync(uri); + + if (!response.IsSuccessStatusCode) + { + // Logging + } + var receiveString = await response.Content.ReadAsStringAsync(); + return JsonConvert.DeserializeObject(receiveString, Settings); + } + } +} diff --git a/Ombi/Ombi.Api/ApiHelper.cs b/Ombi/Ombi.Api/ApiHelper.cs new file mode 100644 index 000000000..61050909e --- /dev/null +++ b/Ombi/Ombi.Api/ApiHelper.cs @@ -0,0 +1,78 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2017 Jamie Rees +// File: ApiHelper.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; + +namespace Ombi.Api +{ + public static class ApiHelper + { + public static Uri ChangePath(this Uri uri, string path, params string[] args) + { + var builder = new UriBuilder(uri); + + if (args != null && args.Length > 0) + { + builder.Path = builder.Path + string.Format(path, args); + } + else + { + builder.Path += path; + } + return builder.Uri; + } + public static Uri ChangePath(this Uri uri, string path) + { + return ChangePath(uri, path, null); + } + + public static Uri AddQueryParameter(this Uri uri, string parameter, string value) + { + if (string.IsNullOrEmpty(parameter) || string.IsNullOrEmpty(value)) return uri; + var builder = new UriBuilder(uri); + var startingTag = string.Empty; + var hasQuery = false; + if (string.IsNullOrEmpty(builder.Query)) + { + startingTag = "?"; + } + else + { + hasQuery = true; + startingTag = builder.Query.Contains("?") ? "&" : "?"; + } + + builder.Query = hasQuery + ? $"{builder.Query}{startingTag}{parameter}={value}" + : $"{startingTag}{parameter}={value}"; + return builder.Uri; + } + + + + } +} \ No newline at end of file diff --git a/Ombi/Ombi.Api/Ombi.Api.csproj b/Ombi/Ombi.Api/Ombi.Api.csproj new file mode 100644 index 000000000..498e443c1 --- /dev/null +++ b/Ombi/Ombi.Api/Ombi.Api.csproj @@ -0,0 +1,11 @@ + + + + netstandard1.4 + + + + + + + \ No newline at end of file diff --git a/Ombi/Ombi.Core/MovieProcessor.cs b/Ombi/Ombi.Core/MovieProcessor.cs new file mode 100644 index 000000000..b2816009f --- /dev/null +++ b/Ombi/Ombi.Core/MovieProcessor.cs @@ -0,0 +1,8 @@ +using System; + +namespace Ombi.Core +{ + public class MovieProcessor + { + } +} diff --git a/Ombi/Ombi.Core/Ombi.Core.csproj b/Ombi/Ombi.Core/Ombi.Core.csproj new file mode 100644 index 000000000..954020d10 --- /dev/null +++ b/Ombi/Ombi.Core/Ombi.Core.csproj @@ -0,0 +1,7 @@ + + + + netstandard1.4 + + + \ No newline at end of file diff --git a/Ombi/Ombi.TheMovieDbApi/IMovieDbApi.cs b/Ombi/Ombi.TheMovieDbApi/IMovieDbApi.cs new file mode 100644 index 000000000..3be66d0c1 --- /dev/null +++ b/Ombi/Ombi.TheMovieDbApi/IMovieDbApi.cs @@ -0,0 +1,33 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2017 Jamie Rees +// File: IMovieDbApi.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 Ombi.TheMovieDbApi +{ + public interface IMovieDbApi + { + + } +} \ No newline at end of file diff --git a/Ombi/Ombi.TheMovieDbApi/Models/BelongsToCollection.cs b/Ombi/Ombi.TheMovieDbApi/Models/BelongsToCollection.cs new file mode 100644 index 000000000..abbc69fef --- /dev/null +++ b/Ombi/Ombi.TheMovieDbApi/Models/BelongsToCollection.cs @@ -0,0 +1,10 @@ +namespace Ombi.TheMovieDbApi.Models +{ + public class BelongsToCollection + { + public int id { get; set; } + public string name { get; set; } + public string poster_path { get; set; } + public string backdrop_path { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.TheMovieDbApi/Models/Genre.cs b/Ombi/Ombi.TheMovieDbApi/Models/Genre.cs new file mode 100644 index 000000000..f07d3b3da --- /dev/null +++ b/Ombi/Ombi.TheMovieDbApi/Models/Genre.cs @@ -0,0 +1,8 @@ +namespace Ombi.TheMovieDbApi.Models +{ + public class Genre + { + public int id { get; set; } + public string name { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.TheMovieDbApi/Models/MovieResponse.cs b/Ombi/Ombi.TheMovieDbApi/Models/MovieResponse.cs new file mode 100644 index 000000000..f619f647a --- /dev/null +++ b/Ombi/Ombi.TheMovieDbApi/Models/MovieResponse.cs @@ -0,0 +1,58 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2017 Jamie Rees +// File: MovieResponse.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 Ombi.TheMovieDbApi.Models +{ + + public class MovieResponse + { + public bool adult { get; set; } + public string backdrop_path { get; set; } + public BelongsToCollection belongs_to_collection { get; set; } + public int budget { get; set; } + public Genre[] genres { get; set; } + public string homepage { get; set; } + public int id { get; set; } + public string imdb_id { get; set; } + public string original_language { get; set; } + public string original_title { get; set; } + public string overview { get; set; } + public float popularity { get; set; } + public string poster_path { get; set; } + public ProductionCompanies[] production_companies { get; set; } + public ProductionCountries[] production_countries { get; set; } + public string release_date { get; set; } + public int revenue { get; set; } + public int runtime { get; set; } + public SpokenLanguages[] spoken_languages { get; set; } + public string status { get; set; } + public string tagline { get; set; } + public string title { get; set; } + public bool video { get; set; } + public float vote_average { get; set; } + public int vote_count { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.TheMovieDbApi/Models/ProductionCompanies.cs b/Ombi/Ombi.TheMovieDbApi/Models/ProductionCompanies.cs new file mode 100644 index 000000000..5acd5471c --- /dev/null +++ b/Ombi/Ombi.TheMovieDbApi/Models/ProductionCompanies.cs @@ -0,0 +1,8 @@ +namespace Ombi.TheMovieDbApi.Models +{ + public class ProductionCompanies + { + public string name { get; set; } + public int id { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.TheMovieDbApi/Models/ProductionCountries.cs b/Ombi/Ombi.TheMovieDbApi/Models/ProductionCountries.cs new file mode 100644 index 000000000..db9fa47e5 --- /dev/null +++ b/Ombi/Ombi.TheMovieDbApi/Models/ProductionCountries.cs @@ -0,0 +1,8 @@ +namespace Ombi.TheMovieDbApi.Models +{ + public class ProductionCountries + { + public string iso_3166_1 { get; set; } + public string name { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.TheMovieDbApi/Models/SearchResult.cs b/Ombi/Ombi.TheMovieDbApi/Models/SearchResult.cs new file mode 100644 index 000000000..81d8115f6 --- /dev/null +++ b/Ombi/Ombi.TheMovieDbApi/Models/SearchResult.cs @@ -0,0 +1,46 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2017 Jamie Rees +// File: SearchResult.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 Ombi.TheMovieDbApi.Models +{ + public class SearchResult + { + public string poster_path { get; set; } + public bool adult { get; set; } + public string overview { get; set; } + public string release_date { get; set; } + public int?[] genre_ids { get; set; } + public int id { get; set; } + public string original_title { get; set; } + public string original_language { get; set; } + public string title { get; set; } + public string backdrop_path { get; set; } + public float popularity { get; set; } + public int vote_count { get; set; } + public bool video { get; set; } + public float vote_average { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.TheMovieDbApi/Models/SpokenLanguages.cs b/Ombi/Ombi.TheMovieDbApi/Models/SpokenLanguages.cs new file mode 100644 index 000000000..01863de18 --- /dev/null +++ b/Ombi/Ombi.TheMovieDbApi/Models/SpokenLanguages.cs @@ -0,0 +1,8 @@ +namespace Ombi.TheMovieDbApi.Models +{ + public class SpokenLanguages + { + public string iso_639_1 { get; set; } + public string name { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.TheMovieDbApi/Models/TheMovieDbContainer.cs b/Ombi/Ombi.TheMovieDbApi/Models/TheMovieDbContainer.cs new file mode 100644 index 000000000..72f58dd02 --- /dev/null +++ b/Ombi/Ombi.TheMovieDbApi/Models/TheMovieDbContainer.cs @@ -0,0 +1,39 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2017 Jamie Rees +// File: TheMovieDbContainer.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.Collections.Generic; + +namespace Ombi.TheMovieDbApi.Models +{ + public class TheMovieDbContainer + { + public int page { get; set; } + public List results { get; set; } + public int total_results { get; set; } + public int total_pages { get; set; } + } +} \ No newline at end of file diff --git a/Ombi/Ombi.TheMovieDbApi/Ombi.TheMovieDbApi.csproj b/Ombi/Ombi.TheMovieDbApi/Ombi.TheMovieDbApi.csproj new file mode 100644 index 000000000..3197c51cf --- /dev/null +++ b/Ombi/Ombi.TheMovieDbApi/Ombi.TheMovieDbApi.csproj @@ -0,0 +1,11 @@ + + + + netstandard1.4 + + + + + + + \ No newline at end of file diff --git a/Ombi/Ombi.TheMovieDbApi/TheMovieDbApi.cs b/Ombi/Ombi.TheMovieDbApi/TheMovieDbApi.cs new file mode 100644 index 000000000..eada2c583 --- /dev/null +++ b/Ombi/Ombi.TheMovieDbApi/TheMovieDbApi.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Ombi.Api; +using Ombi.TheMovieDbApi.Models; + +namespace Ombi.TheMovieDbApi +{ + public class TheMovieDbApi + { + public TheMovieDbApi() + { + Api = new Api.Api(); + } + private const string ApiToken = "b8eabaf5608b88d0298aa189dd90bf00"; + private static readonly Uri BaseUri = new Uri("https://api.themoviedb.org/3/"); + public Api.Api Api { get; } + + public async Task GetMovieInformation(int movieId) + { + var url = BaseUri.ChangePath("movie/{0}", movieId.ToString()); + AddHeaders(url); + return await Api.Get(url); + } + + public async Task> SearchMovie(string searchTerm) + { + var url = BaseUri.ChangePath("search/movie/"); + url = AddHeaders(url); + url = url.AddQueryParameter("query", searchTerm); + return await Api.Get>(url); + } + + private Uri AddHeaders(Uri url) + { + return url.AddQueryParameter("api_key", ApiToken); + } + } +} diff --git a/Ombi/Ombi.sln b/Ombi/Ombi.sln index f387bc6a5..d4488bfca 100644 --- a/Ombi/Ombi.sln +++ b/Ombi/Ombi.sln @@ -12,6 +12,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Build\publish.bat = Build\publish.bat EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Core", "Ombi.Core\Ombi.Core.csproj", "{F56E79C7-791D-4668-A0EC-29E3BBC8D24B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Api", "Api", "{9293CA11-360A-4C20-A674-B9E794431BF5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.TheMovieDbApi", "Ombi.TheMovieDbApi\Ombi.TheMovieDbApi.csproj", "{132DA282-5894-4570-8916-D8C18ED2CE84}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api", "Ombi.Api\Ombi.Api.csproj", "{EA31F915-31F9-4318-B521-1500CDF40DDF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -22,8 +30,24 @@ Global {C987AA67-AFE1-468F-ACD3-EAD5A48E1F6A}.Debug|Any CPU.Build.0 = Debug|Any CPU {C987AA67-AFE1-468F-ACD3-EAD5A48E1F6A}.Release|Any CPU.ActiveCfg = Release|Any CPU {C987AA67-AFE1-468F-ACD3-EAD5A48E1F6A}.Release|Any CPU.Build.0 = Release|Any CPU + {F56E79C7-791D-4668-A0EC-29E3BBC8D24B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F56E79C7-791D-4668-A0EC-29E3BBC8D24B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F56E79C7-791D-4668-A0EC-29E3BBC8D24B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F56E79C7-791D-4668-A0EC-29E3BBC8D24B}.Release|Any CPU.Build.0 = Release|Any CPU + {132DA282-5894-4570-8916-D8C18ED2CE84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {132DA282-5894-4570-8916-D8C18ED2CE84}.Debug|Any CPU.Build.0 = Debug|Any CPU + {132DA282-5894-4570-8916-D8C18ED2CE84}.Release|Any CPU.ActiveCfg = Release|Any CPU + {132DA282-5894-4570-8916-D8C18ED2CE84}.Release|Any CPU.Build.0 = Release|Any CPU + {EA31F915-31F9-4318-B521-1500CDF40DDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EA31F915-31F9-4318-B521-1500CDF40DDF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EA31F915-31F9-4318-B521-1500CDF40DDF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EA31F915-31F9-4318-B521-1500CDF40DDF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {132DA282-5894-4570-8916-D8C18ED2CE84} = {9293CA11-360A-4C20-A674-B9E794431BF5} + {EA31F915-31F9-4318-B521-1500CDF40DDF} = {9293CA11-360A-4C20-A674-B9E794431BF5} + EndGlobalSection EndGlobal diff --git a/Ombi/Ombi/Controllers/BaseApiController.cs b/Ombi/Ombi/Controllers/BaseApiController.cs index 8a81b0277..f122c578b 100644 --- a/Ombi/Ombi/Controllers/BaseApiController.cs +++ b/Ombi/Ombi/Controllers/BaseApiController.cs @@ -29,8 +29,8 @@ using Microsoft.AspNetCore.Mvc; namespace Ombi.Controllers { + [Route("api/[controller]")] public class BaseApiController : Controller { - overr } } \ No newline at end of file diff --git a/Ombi/Ombi/Controllers/SearchController.cs b/Ombi/Ombi/Controllers/SearchController.cs index 2bc01ef96..fbe718ff3 100644 --- a/Ombi/Ombi/Controllers/SearchController.cs +++ b/Ombi/Ombi/Controllers/SearchController.cs @@ -3,15 +3,18 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; +using Ombi.TheMovieDbApi.Models; namespace Ombi.Controllers { - public class SearchController : Controller + public class SearchController : BaseApiController { - [Route()] - public IActionResult Index() + [HttpGet("movie/{searchTerm}")] + public async Task> SearchMovie(string searchTerm) { - return View(); + var api = new TheMovieDbApi.TheMovieDbApi(); + var result = await api.SearchMovie(searchTerm); + return result.results; } diff --git a/Ombi/Ombi/Ombi.csproj b/Ombi/Ombi/Ombi.csproj index c64595c28..112a28415 100644 --- a/Ombi/Ombi/Ombi.csproj +++ b/Ombi/Ombi/Ombi.csproj @@ -19,4 +19,8 @@ + + + + diff --git a/Ombi/Ombi/app/app.module.ts b/Ombi/Ombi/app/app.module.ts index 830f47cd8..8741b8fb9 100644 --- a/Ombi/Ombi/app/app.module.ts +++ b/Ombi/Ombi/app/app.module.ts @@ -11,6 +11,8 @@ import { HttpModule } from '@angular/http'; import { SearchComponent } from './search/search.component'; import { PageNotFoundComponent } from './errors/not-found.component'; +// Services +import { SearchService } from './services/search.service'; import { ButtonModule } from 'primeng/primeng'; import { MenubarModule } from 'primeng/components/menubar/menubar'; @@ -38,7 +40,7 @@ const routes: Routes = [ SearchComponent ], providers: [ - //Services + SearchService ], bootstrap: [AppComponent] }) diff --git a/Ombi/Ombi/app/search/interfaces/IMovieResult.ts b/Ombi/Ombi/app/search/interfaces/IMovieResult.ts new file mode 100644 index 000000000..141515fcd --- /dev/null +++ b/Ombi/Ombi/app/search/interfaces/IMovieResult.ts @@ -0,0 +1,16 @@ +export interface IMovieResult { + poster_path: string, + adult: boolean, + overview: string, + release_date: string, + genre_ids: number[], + id: number, + original_title: string, + original_language: string, + title: string, + backdrop_path: string, + popularity: number, + vote_count: number, + video: boolean, + vote_average:number +} \ No newline at end of file diff --git a/Ombi/Ombi/app/search/search.component.html b/Ombi/Ombi/app/search/search.component.html index e93d20a77..e1f2f2e93 100644 --- a/Ombi/Ombi/app/search/search.component.html +++ b/Ombi/Ombi/app/search/search.component.html @@ -33,7 +33,7 @@
- +