The Free Software Media System - Server Backend & API
fix tvdb lookup by imdb id
Luke Pulverenti73b1e227d35d
diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.csindex 5a2c286d5c..3b577ac01e 100644--- a/MediaBrowser.Api/Playback/MediaInfoService.cs+++ b/MediaBrowser.Api/Playback/MediaInfoService.cs@@ -156,7 +156,7 @@ namespace MediaBrowser.Api.Playback{var mediaSourceId = request.MediaSourceId;- SetDeviceSpecificData(request.Id, info, profile, authInfo, request.MaxStreamingBitrate, request.StartTimeTicks ?? 0, mediaSourceId, request.AudioStreamIndex, request.SubtitleStreamIndex);+ SetDeviceSpecificData(request.Id, info, profile, authInfo, request.MaxStreamingBitrate ?? profile.MaxStreamingBitrate, request.StartTimeTicks ?? 0, mediaSourceId, request.AudioStreamIndex, request.SubtitleStreamIndex);}return ToOptimizedResult(info);diff --git a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesProvider.csindex 5df5151caf..d63022900b 100644--- a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs+++ b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs@@ -56,7 +56,7 @@ namespace MediaBrowser.Providers.TVprivate const string SeriesSearchUrl = "http://www.thetvdb.com/api/GetSeries.php?seriesname={0}&language={1}";private const string SeriesGetZip = "http://www.thetvdb.com/api/{0}/series/{1}/all/{2}.zip";- private const string SeriesGetZipByImdbId = "http://www.thetvdb.com/api/{0}/GetSeriesByRemoteID.php?imdbid={1}&language={2}";+ private const string GetSeriesByImdbId = "http://www.thetvdb.com/api/GetSeriesByRemoteID.php?imdbid={0}&language={1}";public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken){@@ -219,9 +219,12 @@ namespace MediaBrowser.Providers.TVthrow new ArgumentNullException("seriesId");}- var url = string.Equals(idType, "tvdb", StringComparison.OrdinalIgnoreCase) ?- string.Format(SeriesGetZip, TVUtils.TvdbApiKey, seriesId, preferredMetadataLanguage) :- string.Format(SeriesGetZipByImdbId, TVUtils.TvdbApiKey, seriesId, preferredMetadataLanguage);+ if (!string.Equals(idType, "tvdb", StringComparison.OrdinalIgnoreCase))+ {+ seriesId = await GetSeriesByRemoteId(seriesId, idType, preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);+ }++ var url = string.Format(SeriesGetZip, TVUtils.TvdbApiKey, seriesId, preferredMetadataLanguage);using (var zipStream = await _httpClient.Get(new HttpRequestOptions{@@ -262,6 +265,39 @@ namespace MediaBrowser.Providers.TVawait ExtractEpisodes(seriesDataPath, downloadLangaugeXmlFile, lastTvDbUpdateTime).ConfigureAwait(false);}+ private async Task<string> GetSeriesByRemoteId(string id, string idType, string language, CancellationToken cancellationToken)+ {+ var url = string.Format(GetSeriesByImdbId, id, language);++ using (var result = await _httpClient.Get(new HttpRequestOptions+ {+ Url = url,+ ResourcePool = TvDbResourcePool,+ CancellationToken = cancellationToken++ }).ConfigureAwait(false))+ {+ var doc = new XmlDocument();+ doc.Load(result);++ if (doc.HasChildNodes)+ {+ var node = doc.SelectSingleNode("//Series/seriesid");++ if (node != null)+ {+ var idResult = node.InnerText;++ _logger.Info("Tvdb GetSeriesByRemoteId produced id of {0}", idResult ?? string.Empty);++ return idResult;+ }+ }+ }++ return null;+ }+public TvdbOptions GetTvDbOptions(){return _config.GetConfiguration<TvdbOptions>("tvdb");