2013-03-07 06:45:36 +03:00
|
|
|
using System;
|
2013-01-13 11:24:48 +03:00
|
|
|
using System.Collections.Generic;
|
2013-03-07 06:45:36 +03:00
|
|
|
using System.Linq;
|
2013-01-13 11:24:48 +03:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using NLog;
|
2013-03-07 06:45:36 +03:00
|
|
|
using NzbDrone.Core.DecisionEngine;
|
2013-02-24 22:18:48 +03:00
|
|
|
using NzbDrone.Core.Download;
|
2013-03-07 06:45:36 +03:00
|
|
|
using NzbDrone.Core.IndexerSearch;
|
2013-02-21 10:07:34 +03:00
|
|
|
using NzbDrone.Core.Indexers;
|
2013-03-07 06:45:36 +03:00
|
|
|
using NzbDrone.Core.Model;
|
2013-03-02 21:25:39 +03:00
|
|
|
using NzbDrone.Core.ReferenceData;
|
2013-02-19 09:01:03 +03:00
|
|
|
using NzbDrone.Core.Tv;
|
2013-01-13 11:24:48 +03:00
|
|
|
|
2013-03-07 06:45:36 +03:00
|
|
|
namespace NzbDrone.Core.Test.IndexerSearchTests
|
2013-01-13 11:24:48 +03:00
|
|
|
{
|
2013-03-07 07:34:56 +03:00
|
|
|
public class TestSearch : IndexerSearchBase
|
2013-01-13 11:24:48 +03:00
|
|
|
{
|
|
|
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
2013-03-27 06:44:52 +03:00
|
|
|
public TestSearch(IEpisodeService episodeService, IDownloadProvider downloadProvider,
|
2013-03-07 06:45:36 +03:00
|
|
|
IIndexerService indexerService, ISceneMappingService sceneMappingService,
|
2013-03-27 06:44:52 +03:00
|
|
|
IDownloadDirector downloadDirector, ISeriesRepository seriesRepository)
|
2013-03-07 04:51:47 +03:00
|
|
|
: base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
|
|
|
downloadDirector)
|
2013-01-13 11:24:48 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-03-07 06:45:36 +03:00
|
|
|
public override List<EpisodeParseResult> PerformSearch(Series series, List<Episode> episodes, Model.Notification.ProgressNotification notification)
|
2013-01-13 11:24:48 +03:00
|
|
|
{
|
2013-03-07 06:45:36 +03:00
|
|
|
var episode = episodes.Single();
|
2013-01-13 11:24:48 +03:00
|
|
|
|
|
|
|
var reports = new List<EpisodeParseResult>();
|
|
|
|
var title = GetSearchTitle(series);
|
|
|
|
|
2013-03-07 06:45:36 +03:00
|
|
|
var seasonNumber = episode.SeasonNumber;
|
|
|
|
var episodeNumber = episode.EpisodeNumber;
|
2013-01-13 11:24:48 +03:00
|
|
|
|
2013-02-21 10:07:34 +03:00
|
|
|
Parallel.ForEach(_indexerService.GetEnabledIndexers(), indexer =>
|
2013-01-13 11:24:48 +03: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 06:45:36 +03:00
|
|
|
series.Title, episode.SeasonNumber, episode.EpisodeNumber, indexer.Name), e);
|
2013-01-13 11:24:48 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return reports;
|
|
|
|
}
|
|
|
|
|
2013-03-07 04:51:47 +03:00
|
|
|
public override bool IsEpisodeMatch(Series series, dynamic options, EpisodeParseResult episodeParseResult)
|
2013-01-13 11:24:48 +03:00
|
|
|
{
|
2013-03-07 04:51:47 +03:00
|
|
|
return true;
|
2013-01-13 11:24:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|