From b74d091833935779f76083c4098338858fd54602 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 24 Jan 2016 23:12:47 -0500 Subject: [PATCH] fix pt-br from tvdb --- MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs | 4 +--- MediaBrowser.Providers/TV/TvdbSeriesProvider.cs | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs index d03920742..392033048 100644 --- a/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs @@ -169,10 +169,8 @@ namespace MediaBrowser.Providers.TV /// /// Gets the episode XML files. /// - /// The season number. - /// The episode number. - /// The ending episode number. /// The series data path. + /// The search information. /// List{FileInfo}. internal List GetEpisodeXmlNodes(string seriesDataPath, EpisodeInfo searchInfo) { diff --git a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs index 00bc032ca..313ca9074 100644 --- a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs @@ -58,6 +58,17 @@ namespace MediaBrowser.Providers.TV private const string SeriesGetZip = "http://www.thetvdb.com/api/{0}/series/{1}/all/{2}.zip"; private const string GetSeriesByImdbId = "http://www.thetvdb.com/api/GetSeriesByRemoteID.php?imdbid={0}&language={1}"; + private string NormalizeLanguage(string language) + { + if (string.IsNullOrWhiteSpace(language)) + { + return language; + } + + // pt-br is just pt to tvdb + return language.Split('-')[0].ToLower(); + } + public async Task> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken) { if (IsValidSeries(searchInfo.ProviderIds)) @@ -270,7 +281,7 @@ namespace MediaBrowser.Providers.TV private async Task GetSeriesByRemoteId(string id, string idType, string language, CancellationToken cancellationToken) { - var url = string.Format(GetSeriesByImdbId, id, language); + var url = string.Format(GetSeriesByImdbId, id, NormalizeLanguage(language)); using (var result = await _httpClient.Get(new HttpRequestOptions { @@ -455,7 +466,7 @@ namespace MediaBrowser.Providers.TV private async Task> FindSeriesInternal(string name, string language, CancellationToken cancellationToken) { - var url = string.Format(SeriesSearchUrl, WebUtility.UrlEncode(name), language.ToLower()); + var url = string.Format(SeriesSearchUrl, WebUtility.UrlEncode(name), NormalizeLanguage(language)); var doc = new XmlDocument(); using (var results = await _httpClient.Get(new HttpRequestOptions