From c0cf5ea0c9993b453b75cc45a60a76454c33334b Mon Sep 17 00:00:00 2001 From: softworkz Date: Thu, 24 Mar 2016 15:42:06 +0100 Subject: [PATCH] MovieDbEpisodeProvider: Implement GetSearchResults to allow usage from auto-organize --- .../TV/TheMovieDb/MovieDbEpisodeProvider.cs | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbEpisodeProvider.cs index 6a98fcf61..42254f360 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbEpisodeProvider.cs @@ -28,9 +28,36 @@ namespace MediaBrowser.Providers.TV : base(httpClient, configurationManager, jsonSerializer, fileSystem, localization, logManager) { } - public Task> GetSearchResults(EpisodeInfo searchInfo, CancellationToken cancellationToken) + public async Task> GetSearchResults(EpisodeInfo searchInfo, CancellationToken cancellationToken) { - return Task.FromResult>(new List()); + var list = new List(); + + // The search query must either provide an episode number or date + if (!searchInfo.IndexNumber.HasValue || !searchInfo.ParentIndexNumber.HasValue) + { + return list; + } + + var metadataResult = await GetMetadata(searchInfo, cancellationToken); + + if (metadataResult.HasMetadata) + { + var item = metadataResult.Item; + + list.Add(new RemoteSearchResult + { + IndexNumber = item.IndexNumber, + Name = item.Name, + ParentIndexNumber = item.ParentIndexNumber, + PremiereDate = item.PremiereDate, + ProductionYear = item.ProductionYear, + ProviderIds = item.ProviderIds, + SearchProviderName = Name, + IndexNumberEnd = item.IndexNumberEnd + }); + } + + return list; } public async Task> GetMetadata(EpisodeInfo info, CancellationToken cancellationToken)