mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 13:53:19 -07:00
Additional movie information
This commit is contained in:
parent
1ddb6c7f01
commit
16c94f2414
7 changed files with 316 additions and 14 deletions
|
@ -32,6 +32,8 @@ namespace Ombi.Api
|
|||
public abstract class MovieBase
|
||||
{
|
||||
private static readonly string Encrypted = "0T3QNSseexLO7n7UPiJvl70Y+KKnvbeTlsusl7Kwq0hPH0BHOuFNGwksNCjkwqWedyDdI/MJeUR4wtL4bIl0Z+//uHXEaYM/4H2pjeLbH5EWdUe5TTj1AhaIR5PQweamvcienRyFD/3YPCC/+qL5mHkKXBkPumMod3Zb/4yN0Ik=";
|
||||
protected string ApiKey = StringCipher.Decrypt(Encrypted, "ApiKey");
|
||||
private string _apiKey;
|
||||
|
||||
protected string ApiKey => _apiKey ?? (_apiKey = StringCipher.Decrypt(Encrypted, "ApiKey"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,12 +25,17 @@
|
|||
// ************************************************************************/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using NLog.Fluent;
|
||||
using Ombi.Api.Models.Movie;
|
||||
using RestSharp;
|
||||
using TMDbLib.Client;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Movies;
|
||||
using TMDbLib.Objects.Search;
|
||||
using Movie = TMDbLib.Objects.Movies.Movie;
|
||||
|
||||
namespace Ombi.Api
|
||||
{
|
||||
|
@ -39,9 +44,12 @@ namespace Ombi.Api
|
|||
public TheMovieDbApi()
|
||||
{
|
||||
Client = new TMDbClient(ApiKey);
|
||||
Api = new ApiRequest();
|
||||
}
|
||||
|
||||
private ApiRequest Api { get; }
|
||||
public TMDbClient Client { get; set; }
|
||||
private const string BaseUrl = "https://api.themoviedb.org/3/";
|
||||
public async Task<List<SearchMovie>> SearchMovie(string searchTerm)
|
||||
{
|
||||
var results = await Client.SearchMovie(searchTerm);
|
||||
|
@ -56,7 +64,27 @@ namespace Ombi.Api
|
|||
public async Task<List<MovieResult>> GetUpcomingMovies()
|
||||
{
|
||||
var movies = await Client.GetMovieList(MovieListType.Upcoming);
|
||||
return movies?.Results ?? new List<MovieResult>();
|
||||
return movies?.Results ?? new List<MovieResult>();
|
||||
}
|
||||
|
||||
public TmdbMovieDetails GetMovieInformationWithVideos(int tmdbId)
|
||||
{
|
||||
var request = new RestRequest { Resource = "movie/{movieId}", Method = Method.GET };
|
||||
request.AddUrlSegment("movieId", tmdbId.ToString());
|
||||
request.AddQueryParameter("api_key", ApiKey);
|
||||
request.AddQueryParameter("append_to_response", "videos"); // Get the videos
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
var obj = Api.ExecuteJson<TmdbMovieDetails>(request, new Uri(BaseUrl));
|
||||
return obj;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Movie> GetMovieInformation(int tmdbId)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue