Merge pull request #456 from Radarr/patch/lang

Change lang in UI to what profile / lang they choose when they add a …
pull/459/head
Devin Buhl 8 years ago committed by GitHub
commit 4b1e4eecfb

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.MetadataSource
@ -7,6 +8,6 @@ namespace NzbDrone.Core.MetadataSource
public interface IProvideMovieInfo
{
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 System.Text.RegularExpressions;
using System.Text;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Profiles;
namespace NzbDrone.Core.MetadataSource.SkyHook
{
@ -67,25 +69,39 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
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()
.SetSegment("route", "movie")
.SetSegment("id", TmdbId.ToString())
.SetSegment("secondaryRoute", "")
.AddQueryParam("append_to_response", "alternative_titles,release_dates,videos")
.AddQueryParam("country", "US")
.AddQueryParam("language", langCode.ToUpper())
// .AddQueryParam("country", "US")
.Build();
request.AllowAutoRedirect = true;
request.SuppressHttpError = true;
var response = _httpClient.Get<MovieResourceRoot>(request);
var resource = response.Resource;
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.ImdbId = resource.imdb_id;
movie.Title = resource.title;
@ -106,10 +122,10 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
movie.Images.Add(_configService.GetCoverForURL(resource.backdrop_path, MediaCoverTypes.Banner));
movie.Runtime = resource.runtime;
foreach(Title title in resource.alternative_titles.titles)
{
movie.AlternativeTitles.Add(title.title);
}
//foreach(Title title in resource.alternative_titles.titles)
//{
// movie.AlternativeTitles.Add(title.title);
//}
foreach(ReleaseDates releaseDates in resource.release_dates.results)
{
@ -149,7 +165,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
{
movie.Status = MovieStatusType.Announced;
}
if (resource.videos != null)
{
foreach (Video video in resource.videos.results)

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

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

Loading…
Cancel
Save