New: Dont Use Profile Language for Metadata Pull

pull/2/head
Qstick 5 years ago
parent d6f15af6b6
commit f332f8d7cd

@ -28,7 +28,7 @@ namespace NzbDrone.Api.Movies
int tmdbId = -1; int tmdbId = -1;
if (int.TryParse(Request.Query.tmdbId, out tmdbId)) if (int.TryParse(Request.Query.tmdbId, out tmdbId))
{ {
var result = _movieInfo.GetMovieInfo(tmdbId, null, true).Item1; var result = _movieInfo.GetMovieInfo(tmdbId, true).Item1;
return result.ToResource(); return result.ToResource();
} }

@ -24,7 +24,7 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook
[TestCase(70981, "Prometheus")] [TestCase(70981, "Prometheus")]
public void should_be_able_to_get_movie_detail(int tmdbId, string title) public void should_be_able_to_get_movie_detail(int tmdbId, string title)
{ {
var details = Subject.GetMovieInfo(tmdbId, null, false).Item1; var details = Subject.GetMovieInfo(tmdbId, false).Item1;
ValidateMovie(details); ValidateMovie(details);

@ -33,14 +33,14 @@ namespace NzbDrone.Core.Test.MovieTests
.Returns(_movie); .Returns(_movie);
Mocker.GetMock<IProvideMovieInfo>() Mocker.GetMock<IProvideMovieInfo>()
.Setup(s => s.GetMovieInfo(It.IsAny<int>(), It.IsAny<Profile>(), It.IsAny<bool>())) .Setup(s => s.GetMovieInfo(It.IsAny<int>(), It.IsAny<bool>()))
.Callback<int, Profile, bool>((i, p, b) => { throw new MovieNotFoundException(i); }); .Callback<int, bool>((i, b) => { throw new MovieNotFoundException(i); });
} }
private void GivenNewMovieInfo(Movie movie) private void GivenNewMovieInfo(Movie movie)
{ {
Mocker.GetMock<IProvideMovieInfo>() Mocker.GetMock<IProvideMovieInfo>()
.Setup(s => s.GetMovieInfo(_movie.TmdbId, It.IsAny<Profile>(), It.IsAny<bool>())) .Setup(s => s.GetMovieInfo(_movie.TmdbId, It.IsAny<bool>()))
.Returns(new Tuple<Movie, List<Credit>>(movie, new List<Credit>())); .Returns(new Tuple<Movie, List<Credit>>(movie, new List<Credit>()));
} }

@ -1,15 +1,14 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Core.Movies; using NzbDrone.Core.Movies;
using NzbDrone.Core.Movies.Credits; using NzbDrone.Core.Movies.Credits;
using NzbDrone.Core.Profiles;
namespace NzbDrone.Core.MetadataSource namespace NzbDrone.Core.MetadataSource
{ {
public interface IProvideMovieInfo public interface IProvideMovieInfo
{ {
Movie GetMovieInfo(string imdbId); Movie GetMovieInfo(string imdbId);
Tuple<Movie, List<Credit>> GetMovieInfo(int tmdbId, Profile profile, bool hasPreDBEntry); Tuple<Movie, List<Credit>> GetMovieInfo(int tmdbId, bool hasPreDBEntry);
HashSet<int> GetChangedMovies(DateTime startTime); HashSet<int> GetChangedMovies(DateTime startTime);
} }
} }

@ -20,7 +20,6 @@ using NzbDrone.Core.Movies.AlternativeTitles;
using NzbDrone.Core.Movies.Credits; using NzbDrone.Core.Movies.Credits;
using NzbDrone.Core.NetImport.ImportExclusions; using NzbDrone.Core.NetImport.ImportExclusions;
using NzbDrone.Core.Parser; using NzbDrone.Core.Parser;
using NzbDrone.Core.Profiles;
namespace NzbDrone.Core.MetadataSource.SkyHook namespace NzbDrone.Core.MetadataSource.SkyHook
{ {
@ -79,9 +78,9 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
return new HashSet<int>(response.Resource.results.Select(c => c.id)); return new HashSet<int>(response.Resource.results.Select(c => c.id));
} }
public Tuple<Movie, List<Credit>> GetMovieInfo(int tmdbId, Profile profile, bool hasPreDBEntry) public Tuple<Movie, List<Credit>> GetMovieInfo(int tmdbId, bool hasPreDBEntry)
{ {
var langCode = profile != null ? IsoLanguages.Get(profile.Language)?.TwoLetterCode ?? "en" : "en"; var langCode = "en";
var request = _movieBuilder.Create() var request = _movieBuilder.Create()
.SetSegment("api", "3") .SetSegment("api", "3")
@ -143,15 +142,6 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
var movie = new Movie(); var movie = new Movie();
var altTitles = new List<AlternativeTitle>(); var altTitles = new List<AlternativeTitle>();
if (langCode != "en")
{
var iso = IsoLanguages.Find(resource.original_language);
if (iso != null)
{
altTitles.Add(new AlternativeTitle(resource.original_title, SourceType.TMDB, tmdbId, iso.Language));
}
}
foreach (var alternativeTitle in resource.alternative_titles.titles) foreach (var alternativeTitle in resource.alternative_titles.titles)
{ {
if (alternativeTitle.iso_3166_1.ToLower() == langCode) if (alternativeTitle.iso_3166_1.ToLower() == langCode)
@ -498,7 +488,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
try try
{ {
return new List<Movie> { GetMovieInfo(tmdbid, null, false).Item1 }; return new List<Movie> { GetMovieInfo(tmdbid, false).Item1 };
} }
catch (MovieNotFoundException) catch (MovieNotFoundException)
{ {
@ -735,7 +725,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
Movie newMovie = movie; Movie newMovie = movie;
if (movie.TmdbId > 0) if (movie.TmdbId > 0)
{ {
newMovie = GetMovieInfo(movie.TmdbId, null, false).Item1; newMovie = GetMovieInfo(movie.TmdbId, false).Item1;
} }
else if (movie.ImdbId.IsNotNullOrWhiteSpace()) else if (movie.ImdbId.IsNotNullOrWhiteSpace())
{ {

@ -26,7 +26,6 @@ namespace NzbDrone.Core.Movies
private readonly IAlternativeTitleService _titleService; private readonly IAlternativeTitleService _titleService;
private readonly ICreditService _creditService; private readonly ICreditService _creditService;
private readonly IEventAggregator _eventAggregator; private readonly IEventAggregator _eventAggregator;
private readonly IManageCommandQueue _commandQueueManager;
private readonly IDiskScanService _diskScanService; private readonly IDiskScanService _diskScanService;
private readonly ICheckIfMovieShouldBeRefreshed _checkIfMovieShouldBeRefreshed; private readonly ICheckIfMovieShouldBeRefreshed _checkIfMovieShouldBeRefreshed;
private readonly IConfigService _configService; private readonly IConfigService _configService;
@ -42,7 +41,6 @@ namespace NzbDrone.Core.Movies
IDiskScanService diskScanService, IDiskScanService diskScanService,
IRadarrAPIClient apiClient, IRadarrAPIClient apiClient,
ICheckIfMovieShouldBeRefreshed checkIfMovieShouldBeRefreshed, ICheckIfMovieShouldBeRefreshed checkIfMovieShouldBeRefreshed,
IManageCommandQueue commandQueue,
IConfigService configService, IConfigService configService,
Logger logger) Logger logger)
{ {
@ -52,7 +50,6 @@ namespace NzbDrone.Core.Movies
_creditService = creditService; _creditService = creditService;
_eventAggregator = eventAggregator; _eventAggregator = eventAggregator;
_apiClient = apiClient; _apiClient = apiClient;
_commandQueueManager = commandQueue;
_diskScanService = diskScanService; _diskScanService = diskScanService;
_checkIfMovieShouldBeRefreshed = checkIfMovieShouldBeRefreshed; _checkIfMovieShouldBeRefreshed = checkIfMovieShouldBeRefreshed;
_configService = configService; _configService = configService;
@ -68,7 +65,7 @@ namespace NzbDrone.Core.Movies
try try
{ {
var tuple = _movieInfo.GetMovieInfo(movie.TmdbId, movie.Profile, movie.HasPreDBEntry); var tuple = _movieInfo.GetMovieInfo(movie.TmdbId, movie.HasPreDBEntry);
movieInfo = tuple.Item1; movieInfo = tuple.Item1;
credits = tuple.Item2; credits = tuple.Item2;
} }
@ -87,7 +84,7 @@ namespace NzbDrone.Core.Movies
if (movie.TmdbId != movieInfo.TmdbId) if (movie.TmdbId != movieInfo.TmdbId)
{ {
_logger.Warn("Movie '{0}' (TmdbId {1}) was replaced with '{2}' (TmdbId {3}), because the original was a duplicate.", movie.Title, movie.TmdbId, movieInfo.Title, movieInfo.TmdbId); _logger.Warn("Movie '{0}' (Tmdbid {1}) was replaced with '{2}' (Tmdbid {3}), because the original was a duplicate.", movie.Title, movie.TmdbId, movieInfo.Title, movieInfo.TmdbId);
movie.TmdbId = movieInfo.TmdbId; movie.TmdbId = movieInfo.TmdbId;
} }

@ -32,7 +32,7 @@ namespace Radarr.Api.V3.Movies
int tmdbId = -1; int tmdbId = -1;
if (int.TryParse(Request.Query.tmdbId, out tmdbId)) if (int.TryParse(Request.Query.tmdbId, out tmdbId))
{ {
var result = _movieInfo.GetMovieInfo(tmdbId, null, true).Item1; var result = _movieInfo.GetMovieInfo(tmdbId, true).Item1;
return result.ToResource(); return result.ToResource();
} }

Loading…
Cancel
Save