2013-03-07 03:45:36 +00:00
|
|
|
using System;
|
2013-01-13 08:24:48 +00:00
|
|
|
using System.Collections.Generic;
|
2013-03-07 03:45:36 +00:00
|
|
|
using System.Linq;
|
2013-01-13 08:24:48 +00:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using NLog;
|
2013-03-07 03:45:36 +00:00
|
|
|
using NzbDrone.Core.DecisionEngine;
|
2013-02-24 19:18:48 +00:00
|
|
|
using NzbDrone.Core.Download;
|
2013-03-07 03:45:36 +00:00
|
|
|
using NzbDrone.Core.IndexerSearch;
|
2013-02-21 07:07:34 +00:00
|
|
|
using NzbDrone.Core.Indexers;
|
2013-03-07 03:45:36 +00:00
|
|
|
using NzbDrone.Core.Model;
|
2013-03-02 18:25:39 +00:00
|
|
|
using NzbDrone.Core.ReferenceData;
|
2013-02-19 06:01:03 +00:00
|
|
|
using NzbDrone.Core.Tv;
|
2013-01-13 08:24:48 +00:00
|
|
|
|
2013-03-07 03:45:36 +00:00
|
|
|
namespace NzbDrone.Core.Test.IndexerSearchTests
|
2013-01-13 08:24:48 +00:00
|
|
|
{
|
2013-03-07 04:34:56 +00:00
|
|
|
public class TestSearch : IndexerSearchBase
|
2013-01-13 08:24:48 +00:00
|
|
|
{
|
|
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
2013-03-27 03:44:52 +00:00
|
|
|
public TestSearch(IEpisodeService episodeService, IDownloadProvider downloadProvider,
|
2013-03-07 03:45:36 +00:00
|
|
|
IIndexerService indexerService, ISceneMappingService sceneMappingService,
|
2013-03-27 03:44:52 +00:00
|
|
|
IDownloadDirector downloadDirector, ISeriesRepository seriesRepository)
|
2013-03-07 01:51:47 +00:00
|
|
|
: base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
|
|
|
downloadDirector)
|
2013-01-13 08:24:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-03-07 03:45:36 +00:00
|
|
|
public override List<EpisodeParseResult> PerformSearch(Series series, List<Episode> episodes, Model.Notification.ProgressNotification notification)
|
2013-01-13 08:24:48 +00:00
|
|
|
{
|
2013-03-07 03:45:36 +00:00
|
|
|
var episode = episodes.Single();
|
2013-01-13 08:24:48 +00:00
|
|
|
|
|
|
|
var reports = new List<EpisodeParseResult>();
|
|
|
|
var title = GetSearchTitle(series);
|
|
|
|
|
2013-03-07 03:45:36 +00:00
|
|
|
var seasonNumber = episode.SeasonNumber;
|
|
|
|
var episodeNumber = episode.EpisodeNumber;
|
2013-01-13 08:24:48 +00:00
|
|
|
|
2013-02-21 07:07:34 +00:00
|
|
|
Parallel.ForEach(_indexerService.GetEnabledIndexers(), indexer =>
|
2013-01-13 08:24:48 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
reports.AddRange(indexer.FetchEpisode(title, seasonNumber, episodeNumber));
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
logger.ErrorException(String.Format("An error has occurred while searching for {0}-S{1:00}E{2:00} from: {3}",
|
2013-03-07 03:45:36 +00:00
|
|
|
series.Title, episode.SeasonNumber, episode.EpisodeNumber, indexer.Name), e);
|
2013-01-13 08:24:48 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return reports;
|
|
|
|
}
|
|
|
|
|
2013-03-07 01:51:47 +00:00
|
|
|
public override bool IsEpisodeMatch(Series series, dynamic options, EpisodeParseResult episodeParseResult)
|
2013-01-13 08:24:48 +00:00
|
|
|
{
|
2013-03-07 01:51:47 +00:00
|
|
|
return true;
|
2013-01-13 08:24:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|