diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index 254780bb9..3ffcefaf7 100644
--- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -190,7 +190,6 @@
-
@@ -220,7 +219,6 @@
-
diff --git a/NzbDrone.Core.Test/ProviderTests/SearchHistoryProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SearchHistoryProviderTest.cs
deleted file mode 100644
index 3507df51c..000000000
--- a/NzbDrone.Core.Test/ProviderTests/SearchHistoryProviderTest.cs
+++ /dev/null
@@ -1,362 +0,0 @@
-using System;
-using System.IO;
-using System.Linq;
-using System.Net;
-using FizzWare.NBuilder;
-using FluentAssertions;
-using Moq;
-using NUnit.Framework;
-using NzbDrone.Common;
-using NzbDrone.Core.Download;
-using NzbDrone.Core.Tv;
-using NzbDrone.Core.Model;
-using NzbDrone.Core.Model.Notification;
-using NzbDrone.Core.Providers;
-using NzbDrone.Core.Repository;
-using NzbDrone.Core.Repository.Quality;
-using NzbDrone.Core.Repository.Search;
-using NzbDrone.Core.Test.Framework;
-using NzbDrone.Test.Common.AutoMoq;
-using NzbDrone.Test.Common;
-
-namespace NzbDrone.Core.Test.ProviderTests
-{
- [TestFixture]
- // ReSharper disable InconsistentNaming
- public class SearchHistoryProviderTest : SqlCeTest
- {
- private SearchHistory _searchHistory;
- private Series _series;
- private Episode _episode;
-
- [SetUp]
- public void Setup()
- {
- _series = Builder.CreateNew()
- .Build();
-
- _episode = Builder.CreateNew()
- .Build();
-
- var items = Builder.CreateListOfSize(10)
- .All()
- .With(c => c.Quality = QualityTypes.SDTV)
- .Build().ToList();
-
- _searchHistory = Builder.CreateNew()
- .With(h => h.EpisodeId = _episode.OID)
- .With(h => h.SeriesId - _series.OID)
- .With(h => h.SearchHistoryItems = items)
- .Build();
- }
-
- private void WithUnsuccessfulSearch()
- {
- foreach(var item in _searchHistory.SearchHistoryItems)
- {
- item.Success = false;
- }
- }
-
- private void WithSuccessfulSearch()
- {
- foreach(var item in _searchHistory.SearchHistoryItems)
- {
- item.Success = false;
- }
-
- var i = _searchHistory.SearchHistoryItems.Last();
- i.Success = true;
- i.SearchError = ReportRejectionType.None;
- }
-
- private void WithExpiredHistory()
- {
- var history = Builder.CreateListOfSize(10)
- .All()
- .With(h => h.SearchTime = DateTime.Now.AddDays(-10))
- .Build();
-
- foreach(var searchHistory in history)
- {
- var items = Builder.CreateListOfSize(10)
- .All()
- .With(c => c.Quality = QualityTypes.SDTV)
- .With(i => i.Id == searchHistory.Id)
- .Build();
-
- Db.InsertMany(items);
- }
-
- Db.InsertMany(history);
- }
-
- private void WithValidHistory()
- {
- var history = Builder.CreateListOfSize(10)
- .All()
- .With(h => h.SearchTime = DateTime.Now)
- .Build();
-
- foreach (var searchHistory in history)
- {
- var items = Builder.CreateListOfSize(10)
- .All()
- .With(c => c.Quality = QualityTypes.SDTV)
- .With(i => i.Id == searchHistory.Id)
- .Build();
-
- Db.InsertMany(items);
- }
-
- Db.InsertMany(history);
- }
-
- [Test]
- public void Add_should_add_history_and_history_items()
- {
- WithRealDb();
-
- Mocker.Resolve().Add(_searchHistory);
-
- Db.Fetch().Should().HaveCount(1);
- Db.Fetch().Should().HaveCount(10);
- }
-
- [Test]
- public void Add_should_add_return_id()
- {
- WithRealDb();
-
- var result = Mocker.Resolve().Add(_searchHistory);
-
- result.Should().NotBe(0);
- }
-
- [Test]
- public void Delete_should_delete_history_and_history_items()
- {
- WithRealDb();
-
- Mocker.Resolve().Add(_searchHistory);
-
- var history = Db.Fetch();
-
- Mocker.Resolve().Delete(history.First().Id);
-
- Db.Fetch().Should().HaveCount(0);
- Db.Fetch().Should().HaveCount(0);
- }
-
- [Test]
- public void AllSearchHistory_should_return_all_items()
- {
- WithRealDb();
- Db.Insert(_series);
- Db.Insert(_episode);
-
- Mocker.Resolve().Add(_searchHistory);
-
- var result = Mocker.Resolve().AllSearchHistory();
-
- result.Count.Should().Be(1);
- }
-
- [Test]
- public void AllSearchHistory_should_have_series_title()
- {
- WithRealDb();
- Db.Insert(_series);
- Db.Insert(_episode);
-
- Mocker.Resolve().Add(_searchHistory);
-
- var result = Mocker.Resolve().AllSearchHistory();
-
- result.Count.Should().Be(1);
- result.First().SeriesTitle.Should().Be(_series.Title);
- }
-
- [Test]
- public void AllSearchHistory_should_have_episode_information()
- {
- WithRealDb();
- Db.Insert(_series);
- Db.Insert(_episode);
-
- Mocker.Resolve().Add(_searchHistory);
-
- var result = Mocker.Resolve().AllSearchHistory();
-
- result.Count.Should().Be(1);
- result.First().EpisodeTitle.Should().Be(_episode.Title);
- result.First().EpisodeNumber.Should().Be(_episode.EpisodeNumber);
- result.First().SeasonNumber.Should().Be(_episode.SeasonNumber);
- }
-
- [Test]
- public void AllSearchHistory_should_have_totalItems_count()
- {
- WithRealDb();
- Db.Insert(_series);
- Db.Insert(_episode);
-
- Mocker.Resolve().Add(_searchHistory);
-
- var result = Mocker.Resolve().AllSearchHistory();
-
- result.Count.Should().Be(1);
- result.First().TotalItems.Should().Be(_searchHistory.SearchHistoryItems.Count);
- }
-
- [Test]
- public void AllSearchHistory_should_have_successfulCount_equal_zero_when_all_failed()
- {
- WithRealDb();
- Db.Insert(_series);
- Db.Insert(_episode);
-
- WithUnsuccessfulSearch();
-
- Mocker.Resolve().Add(_searchHistory);
-
- var result = Mocker.Resolve().AllSearchHistory();
-
- result.Count.Should().Be(1);
- result.First().SuccessfulCount.Should().Be(0);
- }
-
- [Test]
- public void AllSearchHistory_should_have_successfulCount_equal_one_when_one_was_downloaded()
- {
- WithRealDb();
- Db.Insert(_series);
- Db.Insert(_episode);
-
- WithSuccessfulSearch();
-
- Mocker.Resolve().Add(_searchHistory);
-
- var result = Mocker.Resolve().AllSearchHistory();
-
- result.Count.Should().Be(1);
- result.First().SuccessfulCount.Should().Be(1);
- }
-
- [Test]
- public void GetSearchHistory_should_return_searchHistory_with_items()
- {
- WithRealDb();
- Db.Insert(_series);
- Db.Insert(_episode);
-
- WithSuccessfulSearch();
- var id = Mocker.Resolve().Add(_searchHistory);
-
- var result = Mocker.Resolve().GetSearchHistory(id);
-
- result.SearchHistoryItems.Should().HaveCount(_searchHistory.SearchHistoryItems.Count);
- }
-
- [Test]
- public void GetSearchHistory_should_have_episodeDetails()
- {
- WithRealDb();
- Db.Insert(_series);
- Db.Insert(_episode);
-
- WithSuccessfulSearch();
- var id = Mocker.Resolve().Add(_searchHistory);
-
- var result = Mocker.Resolve().GetSearchHistory(id);
-
- result.EpisodeNumber.Should().Be(_episode.EpisodeNumber);
- result.SeasonNumber.Should().Be(_episode.SeasonNumber);
- result.EpisodeTitle.Should().Be(_episode.Title);
- result.AirDate.Should().Be(_episode.AirDate.Value);
- }
-
- [Test]
- public void GetSearchHistory_should_not_have_episode_info_if_it_was_a_full_season_search()
- {
- WithRealDb();
- Db.Insert(_series);
-
- _searchHistory.EpisodeId = 0;
- var id = Mocker.Resolve().Add(_searchHistory);
-
- var result = Mocker.Resolve().GetSearchHistory(id);
-
- result.EpisodeNumber.Should().Be(null);
- result.SeasonNumber.Should().Be(_searchHistory.SeasonNumber);
- result.EpisodeTitle.Should().Be(null);
- }
-
- [Test]
- public void ForceDownload_should_download_report()
- {
- WithRealDb();
- Db.Insert(_series);
- Db.Insert(_episode);
-
- var reportTitle = String.Format("{0} - S{1:00}E{2:00}", _series.Title, _episode.SeasonNumber, _episode.EpisodeNumber);
- _searchHistory.SearchHistoryItems.First().ReportTitle = reportTitle;
-
- Mocker.Resolve().Add(_searchHistory);
- var items = Db.Fetch();
-
- Mocker.Resolve().ForceDownload(items.First().Id);
-
- Mocker.GetMock().Verify(v => v.DownloadReport(It.IsAny()), Times.Once());
- }
-
- [Test]
- public void Cleanup_should_not_blowup_if_there_is_nothing_to_delete()
- {
- WithRealDb();
-
- Mocker.Resolve().Cleanup();
- Db.Fetch().Should().HaveCount(0);
- }
-
- [Test]
- public void Cleanup_should_delete_searchHistory_older_than_1_week()
- {
- WithRealDb();
- WithExpiredHistory();
-
- Mocker.Resolve().Cleanup();
- Db.Fetch().Should().HaveCount(0);
- }
-
- [Test]
- public void Cleanup_should_delete_searchHistoryItems_older_than_1_week()
- {
- WithRealDb();
- WithExpiredHistory();
-
- Mocker.Resolve().Cleanup();
- Db.Fetch().Should().HaveCount(0);
- }
-
- [Test]
- public void Cleanup_should_not_delete_searchHistory_younger_than_1_week()
- {
- WithRealDb();
- WithValidHistory();
-
- Mocker.Resolve().Cleanup();
- Db.Fetch().Should().HaveCount(10);
- }
-
- [Test]
- public void Cleanup_should_not_delete_searchHistoryItems_younger_than_1_week()
- {
- WithRealDb();
- WithValidHistory();
-
- Mocker.Resolve().Cleanup();
- Db.Fetch().Should().HaveCount(100);
- }
- }
-}
\ No newline at end of file
diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs
index 15bcb0bc0..19a0cddc7 100644
--- a/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs
+++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs
@@ -21,9 +21,9 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests
public TestSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider,
IIndexerService indexerService, SceneMappingProvider sceneMappingProvider,
- AllowedDownloadSpecification allowedDownloadSpecification, SearchHistoryProvider searchHistoryProvider,ISeriesRepository seriesRepository)
+ AllowedDownloadSpecification allowedDownloadSpecification, ISeriesRepository seriesRepository)
: base(seriesService, seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingProvider,
- allowedDownloadSpecification, searchHistoryProvider)
+ allowedDownloadSpecification)
{
}
diff --git a/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest_DeleteInvalidEpisodes.cs b/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest_DeleteInvalidEpisodes.cs
deleted file mode 100644
index 8d7892e51..000000000
--- a/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest_DeleteInvalidEpisodes.cs
+++ /dev/null
@@ -1,226 +0,0 @@
-// ReSharper disable RedundantUsingDirective
-
-using System.Collections.Generic;
-using System.Linq;
-using FizzWare.NBuilder;
-using FluentAssertions;
-using NUnit.Framework;
-using NzbDrone.Core.Tv;
-using NzbDrone.Core.Test.Framework;
-using TvdbLib.Data;
-
-namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
-{
- [TestFixture]
- // ReSharper disable InconsistentNaming
- public class EpisodeProviderTest_DeleteInvalidEpisodes : SqlCeTest
- {
- [Test]
- public void Delete_None_Valid_TvDbEpisodeId()
- {
- //Setup
- const int seriesId = 71663;
- const int episodeCount = 10;
-
- var tvDbSeries = Builder.CreateListOfSize(episodeCount).
- All()
- .With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
- .Build();
-
-
- var fakeSeries = Builder.CreateNew()
- .With(c => c.OID = seriesId)
- .Build();
-
- var fakeEpisode = Builder.CreateNew()
- .With(e => e.SeriesId = seriesId)
- .With(e => e.TvDbEpisodeId = tvDbSeries.First().Id)
- .Build();
-
-
-
- WithRealDb();
-
- Db.Insert(fakeSeries);
- Db.Insert(fakeEpisode);
-
- //Act
- Mocker.Resolve().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
-
- //Assert
- var result = Db.Fetch();
- result.Should().HaveCount(1);
- }
-
- [Test]
- public void Delete_None_TvDbEpisodeId_is_zero()
- {
- //Setup
- const int seriesId = 71663;
- const int episodeCount = 10;
-
- var tvDbSeries = Builder.CreateListOfSize(episodeCount).
- All()
- .With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
- .Build();
-
- var fakeSeries = Builder.CreateNew()
- .With(c => c.OID = seriesId)
- .Build();
-
- var fakeEpisode = Builder.CreateNew()
- .With(e => e.SeriesId = seriesId)
- .With(e => e.TvDbEpisodeId = 0)
- .Build();
-
-
-
- WithRealDb();
-
- Db.Insert(fakeSeries);
- Db.Insert(fakeEpisode);
-
- //Act
- Mocker.Resolve().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
-
- //Assert
- var result = Db.Fetch();
- result.Should().HaveCount(1);
- }
-
- [Test]
- public void Delete_None_TvDbEpisodeId_is_null()
- {
- //Setup
- const int seriesId = 71663;
- const int episodeCount = 10;
-
- var tvDbSeries = Builder.CreateListOfSize(episodeCount).
- All()
- .With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
- .Build();
-
- var fakeSeries = Builder.CreateNew()
- .With(c => c.OID = seriesId)
- .Build();
-
- var fakeEpisode = Builder.CreateNew()
- .With(e => e.SeriesId = seriesId)
- .With(e => e.TvDbEpisodeId = 0)
- .Build();
-
- WithRealDb();
-
- Db.Insert(fakeSeries);
- Db.Insert(fakeEpisode);
-
- //Act
- Mocker.Resolve().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
-
- //Assert
- var result = Db.Fetch();
- result.Should().HaveCount(1);
- }
-
- [Test]
- public void Delete_TvDbId()
- {
- //Setup
- const int seriesId = 71663;
- const int episodeCount = 10;
-
- var tvDbSeries = Builder.CreateListOfSize(episodeCount).
- All()
- .With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
- .Build();
-
- var fakeSeries = Builder.CreateNew()
- .With(c => c.OID = seriesId)
- .Build();
-
- var fakeEpisode = Builder.CreateNew()
- .With(e => e.SeriesId = seriesId)
- .With(e => e.SeasonNumber = 20)
- .With(e => e.EpisodeNumber = 20)
- .With(e => e.TvDbEpisodeId = 300)
- .Build();
-
-
-
- WithRealDb();
-
- Db.Insert(fakeSeries);
- Db.Insert(fakeEpisode);
-
- //Act
- Mocker.Resolve().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
-
- //Assert
- var result = Db.Fetch();
- result.Should().HaveCount(0);
- }
-
- //Other series, by season/episode + by tvdbid
- [Test]
- public void Delete_TvDbId_multiple_series()
- {
- //Setup
- const int seriesId = 71663;
- const int episodeCount = 10;
-
- var tvDbSeries = Builder.CreateListOfSize(episodeCount).
- All()
- .With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
- .Build();
-
- var fakeSeries = Builder.CreateNew()
- .With(c => c.OID = seriesId)
- .Build();
-
- var fakeEpisode = Builder.CreateNew()
- .With(e => e.SeriesId = seriesId)
- .With(e => e.SeasonNumber = 20)
- .With(e => e.EpisodeNumber = 20)
- .With(e => e.TvDbEpisodeId = 300)
- .Build();
-
- //Other Series
- var otherFakeSeries = Builder.CreateNew()
- .With(c => c.OID = 12345)
- .Build();
-
- var otherFakeEpisode = Builder.CreateNew()
- .With(e => e.SeriesId = 12345)
- .With(e => e.SeasonNumber = 20)
- .With(e => e.EpisodeNumber = 20)
- .With(e => e.TvDbEpisodeId = 300)
- .Build();
-
-
-
- WithRealDb();
-
- Db.Insert(fakeSeries);
- Db.Insert(fakeEpisode);
- Db.Insert(otherFakeSeries);
- Db.Insert(otherFakeEpisode);
-
- //Act
- Mocker.Resolve().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
-
- //Assert
- var result = Db.Fetch();
- result.Should().HaveCount(1);
- }
-
- [Test]
- public void should_not_do_anything_if_episode_list_is_empty()
- {
- WithStrictMocker();
-
- var fakeSeries = Builder.CreateNew().Build();
-
- Mocker.Resolve().DeleteEpisodesNotInTvdb(fakeSeries, new List());
- }
- }
-}
\ No newline at end of file
diff --git a/NzbDrone.Core/Helpers/SabnzbdPriorityTypeConverter.cs b/NzbDrone.Core/Helpers/SabnzbdPriorityTypeConverter.cs
index 40b157e2d..9281fc09c 100644
--- a/NzbDrone.Core/Helpers/SabnzbdPriorityTypeConverter.cs
+++ b/NzbDrone.Core/Helpers/SabnzbdPriorityTypeConverter.cs
@@ -1,7 +1,5 @@
using System;
-using System.Collections.Generic;
using System.Linq;
-using System.Text;
using Newtonsoft.Json;
using NzbDrone.Core.Model.Sabnzbd;
diff --git a/NzbDrone.Core/Helpers/SabnzbdQueueTimeConverter.cs b/NzbDrone.Core/Helpers/SabnzbdQueueTimeConverter.cs
index 4a60fec0e..2a33f374c 100644
--- a/NzbDrone.Core/Helpers/SabnzbdQueueTimeConverter.cs
+++ b/NzbDrone.Core/Helpers/SabnzbdQueueTimeConverter.cs
@@ -1,7 +1,5 @@
using System;
-using System.Collections.Generic;
using System.Linq;
-using System.Text;
using Newtonsoft.Json;
namespace NzbDrone.Core.Helpers
diff --git a/NzbDrone.Core/Helpers/SortHelper.cs b/NzbDrone.Core/Helpers/SortHelper.cs
index bee13809c..bc4f5d11a 100644
--- a/NzbDrone.Core/Helpers/SortHelper.cs
+++ b/NzbDrone.Core/Helpers/SortHelper.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
namespace NzbDrone.Core.Helpers
{
diff --git a/NzbDrone.Core/Jobs/SearchHistoryCleanupJob.cs b/NzbDrone.Core/Jobs/SearchHistoryCleanupJob.cs
deleted file mode 100644
index 8802c9ba1..000000000
--- a/NzbDrone.Core/Jobs/SearchHistoryCleanupJob.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using NLog;
-using NzbDrone.Core.Helpers;
-using NzbDrone.Core.Model.Notification;
-using NzbDrone.Core.Providers;
-using NzbDrone.Core.Providers.Core;
-using NzbDrone.Core.Repository;
-
-namespace NzbDrone.Core.Jobs
-{
- public class SearchHistoryCleanupJob : IJob
- {
- private readonly SearchHistoryProvider _searchHistoryProvider;
- private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
-
- public SearchHistoryCleanupJob(SearchHistoryProvider searchHistoryProvider)
- {
- _searchHistoryProvider = searchHistoryProvider;
- }
-
- public SearchHistoryCleanupJob()
- {
- }
-
- public string Name
- {
- get { return "Search History Cleanup"; }
- }
-
- public TimeSpan DefaultInterval
- {
- get { return TimeSpan.FromHours(24); }
- }
-
- public virtual void Start(ProgressNotification notification, dynamic options)
- {
- Logger.Info("Running search history cleanup.");
- _searchHistoryProvider.Cleanup();
- }
- }
-}
diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj
index f25fec41a..2a37c9e53 100644
--- a/NzbDrone.Core/NzbDrone.Core.csproj
+++ b/NzbDrone.Core/NzbDrone.Core.csproj
@@ -284,7 +284,6 @@
-
@@ -358,7 +357,6 @@
-
@@ -387,7 +385,6 @@
-
diff --git a/NzbDrone.Core/Providers/MetadataProvider.cs b/NzbDrone.Core/Providers/MetadataProvider.cs
index c95ba6f15..10b32118f 100644
--- a/NzbDrone.Core/Providers/MetadataProvider.cs
+++ b/NzbDrone.Core/Providers/MetadataProvider.cs
@@ -2,9 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
-using NzbDrone.Core.Datastore;
using NzbDrone.Core.Tv;
-using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Metadata;
using NzbDrone.Core.Repository;
using PetaPoco;
diff --git a/NzbDrone.Core/Providers/Search/DailyEpisodeSearch.cs b/NzbDrone.Core/Providers/Search/DailyEpisodeSearch.cs
index b0eaf26da..0ce9da971 100644
--- a/NzbDrone.Core/Providers/Search/DailyEpisodeSearch.cs
+++ b/NzbDrone.Core/Providers/Search/DailyEpisodeSearch.cs
@@ -22,9 +22,9 @@ namespace NzbDrone.Core.Providers.Search
public DailyEpisodeSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService,
SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification,
- SearchHistoryProvider searchHistoryProvider, ISeriesRepository seriesRepository)
+ ISeriesRepository seriesRepository)
: base(seriesService, seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingProvider,
- allowedDownloadSpecification, searchHistoryProvider)
+ allowedDownloadSpecification)
{
_seriesRepository = seriesRepository;
}
diff --git a/NzbDrone.Core/Providers/Search/EpisodeSearch.cs b/NzbDrone.Core/Providers/Search/EpisodeSearch.cs
index e32abc65e..217735d5a 100644
--- a/NzbDrone.Core/Providers/Search/EpisodeSearch.cs
+++ b/NzbDrone.Core/Providers/Search/EpisodeSearch.cs
@@ -21,9 +21,9 @@ namespace NzbDrone.Core.Providers.Search
public EpisodeSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService,
SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification,
- SearchHistoryProvider searchHistoryProvider, ISeriesRepository seriesRepository)
+ ISeriesRepository seriesRepository)
: base(seriesService,seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingProvider,
- allowedDownloadSpecification, searchHistoryProvider)
+ allowedDownloadSpecification)
{
}
diff --git a/NzbDrone.Core/Providers/Search/PartialSeasonSearch.cs b/NzbDrone.Core/Providers/Search/PartialSeasonSearch.cs
index 573586685..a03cc7821 100644
--- a/NzbDrone.Core/Providers/Search/PartialSeasonSearch.cs
+++ b/NzbDrone.Core/Providers/Search/PartialSeasonSearch.cs
@@ -21,9 +21,9 @@ namespace NzbDrone.Core.Providers.Search
public PartialSeasonSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService,
SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification,
- SearchHistoryProvider searchHistoryProvider,ISeriesRepository seriesRepository)
+ ISeriesRepository seriesRepository)
: base(seriesService, seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingProvider,
- allowedDownloadSpecification, searchHistoryProvider)
+ allowedDownloadSpecification)
{
}
diff --git a/NzbDrone.Core/Providers/Search/SearchBase.cs b/NzbDrone.Core/Providers/Search/SearchBase.cs
index 82da86285..26ceba1c5 100644
--- a/NzbDrone.Core/Providers/Search/SearchBase.cs
+++ b/NzbDrone.Core/Providers/Search/SearchBase.cs
@@ -23,14 +23,12 @@ namespace NzbDrone.Core.Providers.Search
protected readonly IIndexerService _indexerService;
protected readonly SceneMappingProvider _sceneMappingProvider;
protected readonly AllowedDownloadSpecification _allowedDownloadSpecification;
- protected readonly SearchHistoryProvider _searchHistoryProvider;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
protected SearchBase(ISeriesService seriesService,ISeriesRepository seriesRepository, IEpisodeService episodeService, DownloadProvider downloadProvider,
IIndexerService indexerService, SceneMappingProvider sceneMappingProvider,
- AllowedDownloadSpecification allowedDownloadSpecification,
- SearchHistoryProvider searchHistoryProvider)
+ AllowedDownloadSpecification allowedDownloadSpecification)
{
_seriesService = seriesService;
_seriesRepository = seriesRepository;
@@ -39,7 +37,6 @@ namespace NzbDrone.Core.Providers.Search
_indexerService = indexerService;
_sceneMappingProvider = sceneMappingProvider;
_allowedDownloadSpecification = allowedDownloadSpecification;
- _searchHistoryProvider = searchHistoryProvider;
}
protected SearchBase()
@@ -71,7 +68,6 @@ namespace NzbDrone.Core.Providers.Search
notification.CurrentMessage = "Processing search results";
ProcessReports(series, options, reports, searchResult, notification);
- _searchHistoryProvider.Add(searchResult);
if(searchResult.Successes.Any())
return searchResult.Successes;
diff --git a/NzbDrone.Core/Providers/SearchHistoryProvider.cs b/NzbDrone.Core/Providers/SearchHistoryProvider.cs
deleted file mode 100644
index aa706d5f1..000000000
--- a/NzbDrone.Core/Providers/SearchHistoryProvider.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using NLog;
-using NzbDrone.Core.Download;
-using NzbDrone.Core.Tv;
-using NzbDrone.Core.Repository;
-using NzbDrone.Core.Repository.Search;
-using PetaPoco;
-
-namespace NzbDrone.Core.Providers
-{
- public class SearchHistoryProvider
- {
- private readonly IDatabase _database;
- private readonly ISeriesService _seriesService;
- private readonly DownloadProvider _downloadProvider;
- private readonly IEpisodeService _episodeService;
- private readonly ISeriesRepository _seriesRepository;
-
- private static readonly Logger logger = LogManager.GetCurrentClassLogger();
-
- public SearchHistoryProvider(IDatabase database, ISeriesService seriesService,
- DownloadProvider downloadProvider, IEpisodeService episodeService, ISeriesRepository seriesRepository)
- {
- _database = database;
- _seriesService = seriesService;
- _downloadProvider = downloadProvider;
- _episodeService = episodeService;
- _seriesRepository = seriesRepository;
- }
-
- public SearchHistoryProvider()
- {
-
- }
-
- public virtual int Add(SearchHistory searchHistory)
- {
- logger.Trace("Adding new search result");
- searchHistory.SuccessfulDownload = searchHistory.SearchHistoryItems.Any(s => s.Success);
- var id = Convert.ToInt32(_database.Insert(searchHistory));
-
- searchHistory.SearchHistoryItems.ForEach(s => s.SearchHistoryId = id);
- logger.Trace("Adding search result items");
- _database.InsertMany(searchHistory.SearchHistoryItems);
-
- return id;
- }
-
- public virtual void Delete(int id)
- {
- logger.Trace("Deleting search result items attached to: {0}", id);
- _database.Execute("DELETE FROM SearchHistoryItems WHERE SearchHistoryId = @0", id);
-
- logger.Trace("Deleting search result: {0}", id);
- _database.Delete(id);
- }
-
- public virtual List AllSearchHistory()
- {
- var sql = @"SELECT SearchHistory.Id, SearchHistory.SeriesId, SearchHistory.SeasonNumber,
- SearchHistory.EpisodeId, SearchHistory.SearchTime,
- Series.Title as SeriesTitle, Series.IsDaily,
- Episodes.EpisodeNumber, Episodes.SeasonNumber, Episodes.Title as EpisodeTitle,
- Episodes.AirDate,
- Count(SearchHistoryItems.Id) as TotalItems,
- SUM(CASE WHEN SearchHistoryItems.Success = 1 THEN 1 ELSE 0 END) as SuccessfulCount
- FROM SearchHistory
- INNER JOIN Series
- ON Series.SeriesId = SearchHistory.SeriesId
- LEFT JOIN Episodes
- ON Episodes.EpisodeId = SearchHistory.EpisodeId
- LEFT JOIN SearchHistoryItems
- ON SearchHistoryItems.SearchHistoryId = SearchHistory.Id
- GROUP BY SearchHistory.Id, SearchHistory.SeriesId, SearchHistory.SeasonNumber,
- SearchHistory.EpisodeId, SearchHistory.SearchTime,
- Series.Title, Series.IsDaily,
- Episodes.EpisodeNumber, Episodes.SeasonNumber, Episodes.Title,
- Episodes.AirDate";
-
- return _database.Fetch(sql);
- }
-
- public virtual SearchHistory GetSearchHistory(int id)
- {
- var sql = @"SELECT SearchHistory.Id, SearchHistory.SeriesId, SearchHistory.SeasonNumber,
- SearchHistory.EpisodeId, SearchHistory.SearchTime,
- Series.Title as SeriesTitle, Series.IsDaily,
- Episodes.EpisodeNumber, Episodes.SeasonNumber, Episodes.Title as EpisodeTitle,
- Episodes.AirDate
- FROM SearchHistory
- INNER JOIN Series
- ON Series.SeriesId = SearchHistory.SeriesId
- LEFT JOIN Episodes
- ON Episodes.EpisodeId = SearchHistory.EpisodeId
- WHERE SearchHistory.Id = @0";
-
- var result = _database.Single(sql, id);
- result.SearchHistoryItems = _database.Fetch("WHERE SearchHistoryId = @0", id);
-
- return result;
- }
-
- public virtual void ForceDownload(int itemId)
- {
- var item = _database.Single(itemId);
- logger.Info("Starting Force Download of: {0}", item.ReportTitle);
- var searchResult = _database.Single(item.SearchHistoryId);
- var series = _seriesRepository.Get(searchResult.SeriesId);
-
- var parseResult = Parser.ParseTitle(item.ReportTitle);
- parseResult.NzbUrl = item.NzbUrl;
- parseResult.Series = series;
- parseResult.Indexer = item.Indexer;
- parseResult.Episodes = _episodeService.GetEpisodesByParseResult(parseResult);
- parseResult.SceneSource = true;
-
- logger.Info("Forcing Download of: {0}", item.ReportTitle);
- _downloadProvider.DownloadReport(parseResult);
- }
-
- public virtual void Cleanup()
- {
- var ids = _database.Fetch("SELECT Id FROM SearchHistory WHERE SearchTime < @0", DateTime.Now.AddDays(-7));
-
- if (ids.Any())
- {
- logger.Trace("Deleting old search items");
- _database.Execute("DELETE FROM SearchHistoryItems WHERE SearchHistoryId IN (@0)", ids);
-
- logger.Trace("Deleting old search results");
- _database.Execute("DELETE FROM SearchHistory WHERE Id IN (@0)", ids);
- }
- }
- }
-}
diff --git a/NzbDrone.Core/Providers/StatsProvider.cs b/NzbDrone.Core/Providers/StatsProvider.cs
deleted file mode 100644
index a9bec3e00..000000000
--- a/NzbDrone.Core/Providers/StatsProvider.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System;
-using System.Linq;
-using NzbDrone.Core.Tv;
-using NzbDrone.Core.Model;
-using PetaPoco;
-
-namespace NzbDrone.Core.Providers
-{
- public class StatsProvider
- {
- private readonly IDatabase _database;
-
- public StatsProvider(IDatabase database)
- {
- _database = database;
- }
-
- public StatsProvider()
- {
- }
-
- public virtual StatsModel GetStats()
- {
- var series = _database.Fetch();
- var episodes = _database.Fetch();
- var history = _database.Fetch("WHERE Date >= @0", DateTime.Today.AddDays(-30));
-
- var stats = new StatsModel();
- stats.SeriesTotal = series.Count;
- stats.SeriesContinuing = series.Count(s => s.Status == "Continuing");
- stats.SeriesEnded = series.Count(s => s.Status == "Ended");
- stats.EpisodesTotal = episodes.Count;
- stats.EpisodesOnDisk = episodes.Count(e => e.EpisodeFileId > 0);
- stats.EpisodesMissing = episodes.Count(e => e.Ignored == false && e.EpisodeFileId == 0);
- stats.DownloadedLastMonth = history.Count;
- stats.DownloadLastWeek = history.Count(h => h.Date >= DateTime.Today.AddDays(-7));
-
- return stats;
- }
- }
-}
diff --git a/NzbDrone.Core/Providers/TvDbProvider.cs b/NzbDrone.Core/Providers/TvDbProvider.cs
index cbcc748d7..996d1ada1 100644
--- a/NzbDrone.Core/Providers/TvDbProvider.cs
+++ b/NzbDrone.Core/Providers/TvDbProvider.cs
@@ -1,7 +1,9 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Common;
+using NzbDrone.Core.Tv;
using NzbDrone.Core.Tvdb;
using TvdbLib;
using TvdbLib.Cache;
@@ -61,10 +63,40 @@ namespace NzbDrone.Core.Providers
.GroupBy(e => e.SeriesId.ToString("000000") + e.SeasonNumber.ToString("000") + e.EpisodeNumber.ToString("000"))
.Select(e => e.First());
- result.Episodes = episodes.ToList();
+ result.Episodes = episodes.Where(episode => !string.IsNullOrWhiteSpace(episode.EpisodeName) || (episode.FirstAired < DateTime.Now.AddDays(2) && episode.FirstAired.Year > 1900)).ToList();
return result;
}
}
+
+ public virtual IList GetEpisodes(int tvDbSeriesId)
+ {
+ var series = GetSeries(tvDbSeriesId, true);
+
+ var episodes = new List();
+
+ foreach (var tvDbEpisode in series.Episodes)
+ {
+ var episode = new Episode();
+
+ episode.TvDbEpisodeId = tvDbEpisode.Id;
+ episode.EpisodeNumber = tvDbEpisode.EpisodeNumber;
+ episode.SeasonNumber = tvDbEpisode.SeasonNumber;
+ episode.AbsoluteEpisodeNumber = tvDbEpisode.AbsoluteNumber;
+ episode.Title = tvDbEpisode.EpisodeName;
+ episode.Overview = tvDbEpisode.Overview;
+
+ if (tvDbEpisode.FirstAired.Year > 1900)
+ {
+ episode.AirDate = tvDbEpisode.FirstAired.Date;
+ }
+ else
+ {
+ episode.AirDate = null;
+ }
+ }
+
+ return episodes;
+ }
}
}
\ No newline at end of file
diff --git a/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs b/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs
index 2586668b3..99fcfc801 100644
--- a/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs
+++ b/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs
@@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Tv;
-using NzbDrone.Core.Model;
-using NzbDrone.Core.Repository;
using PetaPoco;
namespace NzbDrone.Core.Providers
diff --git a/NzbDrone.Core/Tv/EpisodeService.cs b/NzbDrone.Core/Tv/EpisodeService.cs
index 7b470543d..737dc7801 100644
--- a/NzbDrone.Core/Tv/EpisodeService.cs
+++ b/NzbDrone.Core/Tv/EpisodeService.cs
@@ -28,7 +28,6 @@ namespace NzbDrone.Core.Tv
IList GetEpisodeNumbersBySeason(int seriesId, int seasonNumber);
void SetEpisodeIgnore(int episodeId, bool isIgnored);
bool IsFirstOrLastEpisodeOfSeason(int seriesId, int seasonNumber, int episodeNumber);
- void DeleteEpisodesNotInTvdb(Series series, IList tvdbEpisodes);
void SetPostDownloadStatus(List episodeIds, PostDownloadStatusType postDownloadStatus);
void UpdateEpisodes(List episodes);
Episode GetEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber);
@@ -181,11 +180,8 @@ namespace NzbDrone.Core.Tv
var successCount = 0;
var failCount = 0;
- var tvdbEpisodes = _tvDbProvider.GetSeries(series.OID, true)
- .Episodes
- .Where(episode => !string.IsNullOrWhiteSpace(episode.EpisodeName) ||
- (episode.FirstAired < DateTime.Now.AddDays(2) && episode.FirstAired.Year > 1900))
- .ToList();
+ var tvdbEpisodes = _tvDbProvider.GetEpisodes(series.OID);
+
var seriesEpisodes = GetEpisodeBySeries(series.OID);
var updateList = new List();
@@ -198,7 +194,7 @@ namespace NzbDrone.Core.Tv
logger.Trace("Updating info for [{0}] - S{1:00}E{2:00}", series.Title, episode.SeasonNumber, episode.EpisodeNumber);
//first check using tvdbId, this should cover cases when and episode number in a season is changed
- var episodeToUpdate = seriesEpisodes.SingleOrDefault(e => e.TvDbEpisodeId == episode.Id);
+ var episodeToUpdate = seriesEpisodes.SingleOrDefault(e => e.TvDbEpisodeId == episode.TvDbEpisodeId);
//not found, try using season/episode number
if (episodeToUpdate == null)
@@ -230,30 +226,20 @@ namespace NzbDrone.Core.Tv
episodeToUpdate.SeasonNumber != episode.SeasonNumber) &&
episodeToUpdate.EpisodeFileId > 0)
{
- logger.Info("Unlinking episode file because TheTVDB changed the epsiode number...");
+ logger.Info("Unlinking episode file because TheTVDB changed the episode number...");
episodeToUpdate.EpisodeFile = null;
}
episodeToUpdate.SeriesId = series.OID;
episodeToUpdate.Series = series;
- episodeToUpdate.TvDbEpisodeId = episode.Id;
+ episodeToUpdate.TvDbEpisodeId = episode.TvDbEpisodeId;
episodeToUpdate.EpisodeNumber = episode.EpisodeNumber;
episodeToUpdate.SeasonNumber = episode.SeasonNumber;
- episodeToUpdate.AbsoluteEpisodeNumber = episode.AbsoluteNumber;
- episodeToUpdate.Title = episode.EpisodeName;
-
- episodeToUpdate.Overview = episode.Overview.Truncate(3500);
+ episodeToUpdate.AbsoluteEpisodeNumber = episode.AbsoluteEpisodeNumber;
+ episodeToUpdate.Title = episode.Title;
- if(episode.FirstAired.Year > 1900)
- {
- episodeToUpdate.AirDate = episode.FirstAired.Date;
-
- if (!String.IsNullOrWhiteSpace(series.AirTime))
- episodeToUpdate.AirDate = episodeToUpdate.AirDate.Value.Add(Convert.ToDateTime(series.AirTime).TimeOfDay)
- .AddHours(series.UtcOffset * -1);
- }
- else
- episodeToUpdate.AirDate = null;
+ episodeToUpdate.Overview = episode.Overview;
+ episodeToUpdate.AirDate = episode.AirDate;
successCount++;
}
@@ -314,19 +300,12 @@ namespace NzbDrone.Core.Tv
return false;
}
- public virtual void DeleteEpisodesNotInTvdb(Series series, IList tvdbEpisodes)
+ private void DeleteEpisodesNotInTvdb(Series series, IEnumerable tvdbEpisodes)
{
logger.Trace("Starting deletion of episodes that no longer exist in TVDB: {0}", series.Title.WithDefault(series.OID));
-
- if (!tvdbEpisodes.Any()) return;
-
- var seriesEpisodeIds = _episodeRepository.GetEpisodes(series.OID).Select(c => c.TvDbEpisodeId);
-
- var toBeDeleted = seriesEpisodeIds.Except(tvdbEpisodes.Select(e => e.Id));
-
- foreach (var id in toBeDeleted)
+ foreach (var episode in tvdbEpisodes)
{
- _episodeRepository.Delete(id);
+ _episodeRepository.Delete(episode.OID);
}
logger.Trace("Deleted episodes that no longer exist in TVDB for {0}", series.OID);