Change lang in UI to what profile / lang they choose when they add a movie

Devin Buhl 8 years ago
parent 2b25ce237f
commit 8e452f8b6d

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
namespace NzbDrone.Core.MetadataSource namespace NzbDrone.Core.MetadataSource
@ -7,6 +8,6 @@ namespace NzbDrone.Core.MetadataSource
public interface IProvideMovieInfo public interface IProvideMovieInfo
{ {
Movie GetMovieInfo(string ImdbId); Movie GetMovieInfo(string ImdbId);
Movie GetMovieInfo(int TmdbId); Movie GetMovieInfo(int TmdbId, Profile profile);
} }
} }

@ -14,6 +14,8 @@ using NzbDrone.Core.Tv;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Text; using System.Text;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Profiles;
namespace NzbDrone.Core.MetadataSource.SkyHook namespace NzbDrone.Core.MetadataSource.SkyHook
{ {
@ -67,25 +69,39 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
return new Tuple<Series, List<Episode>>(series, episodes.ToList()); return new Tuple<Series, List<Episode>>(series, episodes.ToList());
} }
public Movie GetMovieInfo(int TmdbId) public Movie GetMovieInfo(int TmdbId, Profile profile = null)
{ {
var langCode = profile != null ? IsoLanguages.Get(profile.Language).TwoLetterCode : "us";
var request = _movieBuilder.Create() var request = _movieBuilder.Create()
.SetSegment("route", "movie") .SetSegment("route", "movie")
.SetSegment("id", TmdbId.ToString()) .SetSegment("id", TmdbId.ToString())
.SetSegment("secondaryRoute", "") .SetSegment("secondaryRoute", "")
.AddQueryParam("append_to_response", "alternative_titles,release_dates,videos") .AddQueryParam("append_to_response", "alternative_titles,release_dates,videos")
.AddQueryParam("country", "US") .AddQueryParam("language", langCode.ToUpper())
// .AddQueryParam("country", "US")
.Build(); .Build();
request.AllowAutoRedirect = true; request.AllowAutoRedirect = true;
request.SuppressHttpError = true; request.SuppressHttpError = true;
var response = _httpClient.Get<MovieResourceRoot>(request); var response = _httpClient.Get<MovieResourceRoot>(request);
var resource = response.Resource; var resource = response.Resource;
var movie = new Movie(); var movie = new Movie();
foreach (var alternativeTitle in resource.alternative_titles.titles)
{
if (alternativeTitle.iso_3166_1.ToLower() == langCode)
{
movie.AlternativeTitles.Add(alternativeTitle.title);
}
else if (alternativeTitle.iso_3166_1.ToLower() == "us")
{
movie.AlternativeTitles.Add(alternativeTitle.title);
}
}
movie.TmdbId = TmdbId; movie.TmdbId = TmdbId;
movie.ImdbId = resource.imdb_id; movie.ImdbId = resource.imdb_id;
movie.Title = resource.title; movie.Title = resource.title;
@ -106,10 +122,10 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
movie.Images.Add(_configService.GetCoverForURL(resource.backdrop_path, MediaCoverTypes.Banner)); movie.Images.Add(_configService.GetCoverForURL(resource.backdrop_path, MediaCoverTypes.Banner));
movie.Runtime = resource.runtime; movie.Runtime = resource.runtime;
foreach(Title title in resource.alternative_titles.titles) //foreach(Title title in resource.alternative_titles.titles)
{ //{
movie.AlternativeTitles.Add(title.title); // movie.AlternativeTitles.Add(title.title);
} //}
foreach(ReleaseDates releaseDates in resource.release_dates.results) foreach(ReleaseDates releaseDates in resource.release_dates.results)
{ {

@ -12,5 +12,6 @@
ThreeLetterCode = threeLetterCode; ThreeLetterCode = threeLetterCode;
Language = language; Language = language;
} }
} }
} }

@ -51,7 +51,7 @@ namespace NzbDrone.Core.Tv
try try
{ {
movieInfo = _movieInfo.GetMovieInfo(movie.TmdbId); movieInfo = _movieInfo.GetMovieInfo(movie.TmdbId, movie.Profile);
} }
catch (MovieNotFoundException) catch (MovieNotFoundException)
{ {

Loading…
Cancel
Save