diff options
| author | Luke <luke.pulverenti@gmail.com> | 2015-12-18 11:48:04 -0500 |
|---|---|---|
| committer | Luke <luke.pulverenti@gmail.com> | 2015-12-18 11:48:04 -0500 |
| commit | e2041c049b39e1b4bcc5b4c91e92495f94b4f56b (patch) | |
| tree | 3311e963dcc0a5fc9494e56df6172d4c6bc4dedc | |
| parent | f9dca3b241926c3f25e9019993c287879f426114 (diff) | |
| parent | 73b1e227d35db3554a0176d1ca81a73f24cf60c3 (diff) | |
Merge pull request #1328 from MediaBrowser/master
fix tvdb lookup by imdb id
| -rw-r--r-- | MediaBrowser.Api/Playback/MediaInfoService.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Providers/TV/TvdbSeriesProvider.cs | 44 |
2 files changed, 41 insertions, 5 deletions
diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.cs index 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.cs index 5df5151caf..d63022900b 100644 --- a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs @@ -56,7 +56,7 @@ namespace MediaBrowser.Providers.TV private 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.TV throw 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.TV await 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"); |
