fixes #425 - Support searching tmdb using imdb id

This commit is contained in:
Luke Pulverenti 2013-08-24 00:30:45 -04:00
parent e7d8e7fae0
commit 79a82ae671

View File

@ -247,8 +247,19 @@ namespace MediaBrowser.Providers.Movies
/// <returns>Task.</returns> /// <returns>Task.</returns>
private async Task FetchMovieData(BaseItem item, CancellationToken cancellationToken) private async Task FetchMovieData(BaseItem item, CancellationToken cancellationToken)
{ {
string id = item.GetProviderId(MetadataProviders.Tmdb) ?? await FindId(item, item.ProductionYear, cancellationToken).ConfigureAwait(false); var id = item.GetProviderId(MetadataProviders.Tmdb);
if (id != null)
if (string.IsNullOrEmpty(id))
{
id = item.GetProviderId(MetadataProviders.Imdb);
}
if (string.IsNullOrEmpty(id))
{
id = await FindId(item, cancellationToken).ConfigureAwait(false);
}
if (!string.IsNullOrEmpty(id))
{ {
Logger.Debug("MovieDbProvider - getting movie info with id: " + id); Logger.Debug("MovieDbProvider - getting movie info with id: " + id);
@ -290,19 +301,15 @@ namespace MediaBrowser.Providers.Movies
/// Finds the id. /// Finds the id.
/// </summary> /// </summary>
/// <param name="item">The item.</param> /// <param name="item">The item.</param>
/// <param name="productionYear">The production year.</param>
/// <param name="cancellationToken">The cancellation token</param> /// <param name="cancellationToken">The cancellation token</param>
/// <returns>Task{System.String}.</returns> /// <returns>Task{System.String}.</returns>
public async Task<string> FindId(BaseItem item, int? productionYear, CancellationToken cancellationToken) public async Task<string> FindId(BaseItem item, CancellationToken cancellationToken)
{ {
int? year; int? yearInName;
string name = item.Name; string name = item.Name;
ParseName(name, out name, out year); ParseName(name, out name, out yearInName);
if (year == null && productionYear != null) var year = item.ProductionYear ?? yearInName;
{
year = productionYear;
}
Logger.Info("MovieDbProvider: Finding id for movie: " + name); Logger.Info("MovieDbProvider: Finding id for movie: " + name);
string language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower(); string language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower();