aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-12-18 11:43:42 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-12-18 11:43:42 -0500
commit73b1e227d35db3554a0176d1ca81a73f24cf60c3 (patch)
treefef336b2bd927251e46a509fe4e9a89e4308aa9f
parent791c6cbce154b9fe8485290deb5668be565ea606 (diff)
fix tvdb lookup by imdb id
-rw-r--r--MediaBrowser.Api/Playback/MediaInfoService.cs2
-rw-r--r--MediaBrowser.Providers/TV/TvdbSeriesProvider.cs44
2 files changed, 41 insertions, 5 deletions
diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.cs
index 5a2c286d5..3b577ac01 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 5df5151ca..d63022900 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");