mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-20 21:55:03 -04:00
Async HttpClient and list lookup
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Cloud;
|
||||
using NzbDrone.Common.Extensions;
|
||||
@@ -14,7 +15,6 @@ using NzbDrone.Core.MetadataSource.SkyHook.Resource;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Movies.AlternativeTitles;
|
||||
using NzbDrone.Core.Movies.Credits;
|
||||
using NzbDrone.Core.NetImport.ImportExclusions;
|
||||
using NzbDrone.Core.NetImport.TMDb;
|
||||
using NzbDrone.Core.Parser;
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||
return new HashSet<int>(response.Resource.Results.Select(c => c.id));
|
||||
}
|
||||
|
||||
public Tuple<Movie, List<Credit>> GetMovieInfo(int tmdbId)
|
||||
public async Task<Tuple<Movie, List<Credit>>> GetMovieInfoAsync(int tmdbId)
|
||||
{
|
||||
var httpRequest = _radarrMetadata.Create()
|
||||
.SetSegment("route", "movie")
|
||||
@@ -75,7 +75,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||
httpRequest.AllowAutoRedirect = true;
|
||||
httpRequest.SuppressHttpError = true;
|
||||
|
||||
var httpResponse = _httpClient.Get<MovieResource>(httpRequest);
|
||||
var httpResponse = await _httpClient.GetAsync<MovieResource>(httpRequest);
|
||||
|
||||
if (httpResponse.HasHttpError)
|
||||
{
|
||||
@@ -98,6 +98,11 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||
return new Tuple<Movie, List<Credit>>(movie, credits.ToList());
|
||||
}
|
||||
|
||||
public Tuple<Movie, List<Credit>> GetMovieInfo(int tmdbId)
|
||||
{
|
||||
return GetMovieInfoAsync(tmdbId).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public Movie GetMovieByImdbId(string imdbId)
|
||||
{
|
||||
var httpRequest = _radarrMetadata.Create()
|
||||
@@ -236,14 +241,14 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||
return title;
|
||||
}
|
||||
|
||||
public Movie MapMovieToTmdbMovie(Movie movie)
|
||||
public async Task<Movie> MapMovieToTmdbMovieAsync(Movie movie)
|
||||
{
|
||||
try
|
||||
{
|
||||
Movie newMovie = movie;
|
||||
if (movie.TmdbId > 0)
|
||||
{
|
||||
newMovie = GetMovieInfo(movie.TmdbId).Item1;
|
||||
newMovie = (await GetMovieInfoAsync(movie.TmdbId)).Item1;
|
||||
}
|
||||
else if (movie.ImdbId.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
@@ -283,6 +288,11 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||
}
|
||||
}
|
||||
|
||||
public Movie MapMovieToTmdbMovie(Movie movie)
|
||||
{
|
||||
return MapMovieToTmdbMovieAsync(movie).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public List<Movie> SearchForNewMovie(string title)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user