mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
moved series/season/episodes to object db.
This commit is contained in:
parent
4504232956
commit
b5644bf660
@ -35,7 +35,7 @@ public static void InitializeAutomapper()
|
||||
.ForMember(dest => dest.QualityTypeId, opt => opt.MapFrom(src => src.Id));
|
||||
|
||||
//Series
|
||||
Mapper.CreateMap<Core.Episodes.Series, SeriesResource>()
|
||||
Mapper.CreateMap<Core.Tv.Series, SeriesResource>()
|
||||
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.SeriesId))
|
||||
.ForMember(dest => dest.CustomStartDate, opt => opt.ResolveUsing<NullableDatetimeToString>().FromMember(src => src.CustomStartDate))
|
||||
.ForMember(dest => dest.BacklogSetting, opt => opt.MapFrom(src => (Int32)src.BacklogSetting))
|
||||
|
@ -1,17 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using NzbDrone.Api.QualityProfiles;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
|
||||
namespace NzbDrone.Api.Resolvers
|
||||
{
|
||||
public class NextAiringResolver : ValueResolver<Core.Episodes.Series, DateTime?>
|
||||
public class NextAiringResolver : ValueResolver<Core.Tv.Series, DateTime?>
|
||||
{
|
||||
protected override DateTime? ResolveCore(Core.Episodes.Series source)
|
||||
protected override DateTime? ResolveCore(Core.Tv.Series source)
|
||||
{
|
||||
if(String.IsNullOrWhiteSpace(source.AirTime) || !source.NextAiring.HasValue)
|
||||
if (String.IsNullOrWhiteSpace(source.AirTime) || !source.NextAiring.HasValue)
|
||||
return source.NextAiring;
|
||||
|
||||
return source.NextAiring.Value.Add(Convert.ToDateTime(source.AirTime).TimeOfDay)
|
||||
|
@ -15,14 +15,14 @@ namespace NzbDrone.Api.Series
|
||||
{
|
||||
public class SeriesModule : NzbDroneApiModule
|
||||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private readonly JobController _jobProvider;
|
||||
|
||||
public SeriesModule(SeriesProvider seriesProvider,ISeriesRepository seriesRepository, JobController jobProvider)
|
||||
public SeriesModule(ISeriesService seriesService,ISeriesRepository seriesRepository, JobController jobProvider)
|
||||
: base("/Series")
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_seriesService = seriesService;
|
||||
_seriesRepository = seriesRepository;
|
||||
_jobProvider = jobProvider;
|
||||
Get["/"] = x => AllSeries();
|
||||
@ -58,7 +58,7 @@ private Response AddSeries()
|
||||
//(we can just create the folder and it won't blow up if it already exists)
|
||||
//We also need to remove any special characters from the filename before attempting to create it
|
||||
|
||||
_seriesProvider.AddSeries("", request.Path, request.SeriesId, request.QualityProfileId, null);
|
||||
_seriesService.AddSeries("", request.Path, request.SeriesId, request.QualityProfileId, null);
|
||||
_jobProvider.QueueJob(typeof(ImportNewSeriesJob));
|
||||
|
||||
return new Response { StatusCode = HttpStatusCode.Created };
|
||||
|
@ -32,6 +32,15 @@ public static Param<int> IsGreaterThan(this Param<int> param, int limit)
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<int> IsGreaterThanZero(this Param<int> param)
|
||||
{
|
||||
if (param.Value <= 0)
|
||||
throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsNotGt.Inject(param.Value, 0));
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public static Param<int> IsGreaterOrEqualTo(this Param<int> param, int limit)
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ public void IsAcceptableSize_true_single_episode_not_first_or_last_30_minute()
|
||||
|
||||
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(
|
||||
Mocker.GetMock<EpisodeService>().Setup(
|
||||
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(false);
|
||||
|
||||
@ -101,7 +101,7 @@ public void IsAcceptableSize_true_single_episode_not_first_or_last_60_minute()
|
||||
|
||||
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(
|
||||
Mocker.GetMock<EpisodeService>().Setup(
|
||||
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(false);
|
||||
|
||||
@ -122,7 +122,7 @@ public void IsAcceptableSize_false_single_episode_not_first_or_last_30_minute()
|
||||
|
||||
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(
|
||||
Mocker.GetMock<EpisodeService>().Setup(
|
||||
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(false);
|
||||
|
||||
@ -143,7 +143,7 @@ public void IsAcceptableSize_false_single_episode_not_first_or_last_60_minute()
|
||||
|
||||
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(
|
||||
Mocker.GetMock<EpisodeService>().Setup(
|
||||
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(false);
|
||||
|
||||
@ -164,7 +164,7 @@ public void IsAcceptableSize_true_multi_episode_not_first_or_last_30_minute()
|
||||
|
||||
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(
|
||||
Mocker.GetMock<EpisodeService>().Setup(
|
||||
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(false);
|
||||
|
||||
@ -185,7 +185,7 @@ public void IsAcceptableSize_true_multi_episode_not_first_or_last_60_minute()
|
||||
|
||||
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(
|
||||
Mocker.GetMock<EpisodeService>().Setup(
|
||||
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(false);
|
||||
|
||||
@ -206,7 +206,7 @@ public void IsAcceptableSize_false_multi_episode_not_first_or_last_30_minute()
|
||||
|
||||
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(
|
||||
Mocker.GetMock<EpisodeService>().Setup(
|
||||
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(false);
|
||||
|
||||
@ -227,7 +227,7 @@ public void IsAcceptableSize_false_multi_episode_not_first_or_last_60_minute()
|
||||
|
||||
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(
|
||||
Mocker.GetMock<EpisodeService>().Setup(
|
||||
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(false);
|
||||
|
||||
@ -248,7 +248,7 @@ public void IsAcceptableSize_true_single_episode_first_30_minute()
|
||||
|
||||
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(
|
||||
Mocker.GetMock<EpisodeService>().Setup(
|
||||
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(true);
|
||||
|
||||
@ -269,7 +269,7 @@ public void IsAcceptableSize_true_single_episode_first_60_minute()
|
||||
|
||||
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(
|
||||
Mocker.GetMock<EpisodeService>().Setup(
|
||||
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(true);
|
||||
|
||||
@ -290,7 +290,7 @@ public void IsAcceptableSize_false_single_episode_first_30_minute()
|
||||
|
||||
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(
|
||||
Mocker.GetMock<EpisodeService>().Setup(
|
||||
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(true);
|
||||
|
||||
@ -311,7 +311,7 @@ public void IsAcceptableSize_false_single_episode_first_60_minute()
|
||||
|
||||
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(
|
||||
Mocker.GetMock<EpisodeService>().Setup(
|
||||
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(true);
|
||||
|
||||
@ -333,7 +333,7 @@ public void IsAcceptableSize_true_unlimited_30_minute()
|
||||
|
||||
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(
|
||||
Mocker.GetMock<EpisodeService>().Setup(
|
||||
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(true);
|
||||
|
||||
@ -355,7 +355,7 @@ public void IsAcceptableSize_true_unlimited_60_minute()
|
||||
|
||||
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(
|
||||
Mocker.GetMock<EpisodeService>().Setup(
|
||||
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(true);
|
||||
|
||||
@ -378,7 +378,7 @@ public void IsAcceptableSize_should_treat_daily_series_as_single_episode()
|
||||
|
||||
Mocker.GetMock<QualityTypeProvider>().Setup(s => s.Get(1)).Returns(qualityType);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(
|
||||
Mocker.GetMock<EpisodeService>().Setup(
|
||||
s => s.IsFirstOrLastEpisodeOfSeason(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()))
|
||||
.Returns(true);
|
||||
|
||||
|
@ -59,11 +59,11 @@ public void Setup()
|
||||
var singleEpisodeList = new List<Episode> { firstEpisode };
|
||||
var doubleEpisodeList = new List<Episode> { firstEpisode, secondEpisode };
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(c => c.GetEpisodesByParseResult(parseResultSingle)).Returns(singleEpisodeList);
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(c => c.GetEpisodesByParseResult(parseResultMulti)).Returns(doubleEpisodeList);
|
||||
Mocker.GetMock<EpisodeService>().Setup(c => c.GetEpisodesByParseResult(parseResultSingle)).Returns(singleEpisodeList);
|
||||
Mocker.GetMock<EpisodeService>().Setup(c => c.GetEpisodesByParseResult(parseResultMulti)).Returns(doubleEpisodeList);
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(c => c.Get(parseResultMulti.CleanTitle)).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(c => c.Get(parseResultSingle.CleanTitle)).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(c => c.GetByTitle(parseResultMulti.CleanTitle)).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(c => c.GetByTitle(parseResultSingle.CleanTitle)).Returns(fakeSeries);
|
||||
}
|
||||
|
||||
private void WithFirstEpisodeIgnored()
|
||||
@ -96,7 +96,7 @@ public void not_monitored_series_should_be_skipped()
|
||||
public void not_in_db_should_be_skipped()
|
||||
{
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(p => p.Get(It.IsAny<String>()))
|
||||
.Setup(p => p.GetByTitle(It.IsAny<String>()))
|
||||
.Returns<Series>(null);
|
||||
|
||||
monitoredEpisodeSpecification.IsSatisfiedBy(parseResultMulti).Should().BeFalse();
|
||||
|
@ -39,10 +39,8 @@ public void SetUp()
|
||||
.Build();
|
||||
|
||||
_episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.SeriesId = _series.SeriesId)
|
||||
.With(e => e.Series = _series)
|
||||
.With(e => e.EpisodeFileId = _episodeFile.EpisodeFileId)
|
||||
.With(e => e.EpisodeFile = _episodeFile)
|
||||
.Build();
|
||||
}
|
||||
@ -51,7 +49,7 @@ public void SetUp()
|
||||
public void IsUpgradePossible_should_return_true_if_no_episode_file_exists()
|
||||
{
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.EpisodeFile = null)
|
||||
.Build();
|
||||
|
||||
//Act
|
||||
|
@ -23,13 +23,12 @@ public void no_grab_date(int offsetDays, bool hasEpisodes, bool ignored, Episode
|
||||
Episode episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.AirDate = DateTime.Now.AddDays(offsetDays))
|
||||
.With(e => e.Ignored = ignored)
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.GrabDate = null)
|
||||
.Build();
|
||||
|
||||
if (hasEpisodes)
|
||||
{
|
||||
episode.EpisodeFileId = 12;
|
||||
episode.EpisodeFile = new EpisodeFile();
|
||||
}
|
||||
|
||||
Assert.AreEqual(status, episode.Status);
|
||||
@ -43,14 +42,13 @@ public void old_grab_date(int offsetDays, bool hasEpisodes, bool ignored,
|
||||
{
|
||||
Episode episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Ignored = ignored)
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.GrabDate = DateTime.Now.AddDays(-2).AddHours(-1))
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(-2))
|
||||
.Build();
|
||||
|
||||
if (hasEpisodes)
|
||||
{
|
||||
episode.EpisodeFileId = 12;
|
||||
episode.EpisodeFile = new EpisodeFile();
|
||||
}
|
||||
|
||||
episode.Status.Should().Be(status);
|
||||
@ -67,13 +65,12 @@ public void recent_grab_date(int offsetDays, bool hasEpisodes, bool ignored,
|
||||
Episode episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.AirDate = DateTime.Now.AddDays(offsetDays))
|
||||
.With(e => e.Ignored = ignored)
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.GrabDate = DateTime.Now.AddHours(22))
|
||||
.Build();
|
||||
|
||||
if (hasEpisodes)
|
||||
{
|
||||
episode.EpisodeFileId = 12;
|
||||
episode.EpisodeFile = new EpisodeFile();
|
||||
}
|
||||
|
||||
Assert.AreEqual(status, episode.Status);
|
||||
@ -85,13 +82,12 @@ public void ignored_episode(int offsetDays, bool ignored, bool hasEpisodes, Epis
|
||||
Episode episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.AirDate = DateTime.Now.AddDays(offsetDays))
|
||||
.With(e => e.Ignored = ignored)
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.GrabDate = null)
|
||||
.Build();
|
||||
|
||||
if (hasEpisodes)
|
||||
{
|
||||
episode.EpisodeFileId = 12;
|
||||
episode.EpisodeFile = new EpisodeFile();
|
||||
}
|
||||
|
||||
Assert.AreEqual(status, episode.Status);
|
||||
@ -103,7 +99,6 @@ public void low_air_date()
|
||||
Episode episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.AirDate = DateTime.Now.AddDays(20))
|
||||
.With(e => e.Ignored = false)
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.GrabDate = null)
|
||||
.Build();
|
||||
|
||||
@ -120,14 +115,13 @@ public void episode_downloaded_post_download_status_is_used(bool hasEpisodes, bo
|
||||
{
|
||||
Episode episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Ignored = ignored)
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.GrabDate = DateTime.Now.AddHours(22))
|
||||
.With(e => e.PostDownloadStatus = postDownloadStatus)
|
||||
.Build();
|
||||
|
||||
if (hasEpisodes)
|
||||
{
|
||||
episode.EpisodeFileId = 12;
|
||||
episode.EpisodeFile = new EpisodeFile();
|
||||
}
|
||||
|
||||
Assert.AreEqual(status, episode.Status);
|
||||
|
@ -35,7 +35,7 @@ public void no_missing_epsiodes_should_not_trigger_any_search()
|
||||
WithStrictMocker();
|
||||
WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
//Act
|
||||
@ -67,7 +67,7 @@ public void individual_missing_episode()
|
||||
|
||||
WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<EpisodeSearchJob>()
|
||||
@ -99,7 +99,7 @@ public void individual_missing_episodes_only()
|
||||
|
||||
WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
//Act
|
||||
@ -129,10 +129,10 @@ public void series_season_missing_episodes_only_mismatch_count()
|
||||
|
||||
WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
|
||||
|
||||
//Act
|
||||
@ -163,10 +163,10 @@ public void series_season_missing_episodes_only()
|
||||
|
||||
WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(episodes.Select(e => e.EpisodeNumber).ToList());
|
||||
|
||||
//Act
|
||||
@ -205,10 +205,10 @@ public void multiple_missing_episodes()
|
||||
|
||||
WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.GetEpisodeNumbersBySeason(1, 1)).Returns(new List<int> { 1, 2, 3, 4, 5 });
|
||||
|
||||
//Act
|
||||
@ -246,7 +246,7 @@ public void GetMissingForEnabledSeries_should_only_return_episodes_for_monitored
|
||||
|
||||
WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
//Act
|
||||
@ -285,7 +285,7 @@ public void GetMissingForEnabledSeries_should_only_return_explicity_enabled_seri
|
||||
|
||||
//WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
//Act
|
||||
@ -325,7 +325,7 @@ public void GetMissingForEnabledSeries_should_return_explicity_enabled_and_inher
|
||||
|
||||
WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
//Act
|
||||
|
@ -152,14 +152,14 @@ public void AutoIgnoreSeason_new_series_should_not_ignore_any()
|
||||
.Setup(p => p.GetSeriesFiles(seriesId))
|
||||
.Returns(new List<EpisodeFile>());
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(p => p.GetSeasons(seriesId))
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.Setup(p => p.GetSeasonNumbers(seriesId))
|
||||
.Returns(new List<int> { 0, 1, 2, 3, 4 });
|
||||
|
||||
Mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
|
||||
|
||||
|
||||
Mocker.GetMock<SeasonProvider>().Verify(p => p.SetIgnore(seriesId, It.IsAny<int>(), It.IsAny<Boolean>()), Times.Never());
|
||||
Mocker.GetMock<ISeasonService>().Verify(p => p.SetIgnore(seriesId, It.IsAny<int>(), It.IsAny<Boolean>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -180,13 +180,13 @@ public void AutoIgnoreSeason_existing_should_not_ignore_currentseason()
|
||||
.Setup(p => p.GetSeriesFiles(seriesId))
|
||||
.Returns(episodesFiles);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(p => p.GetSeasons(seriesId))
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.Setup(p => p.GetSeasonNumbers(seriesId))
|
||||
.Returns(new List<int> { 0, 1, 2 });
|
||||
|
||||
Mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
|
||||
|
||||
Mocker.GetMock<SeasonProvider>().Verify(p => p.SetIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
|
||||
Mocker.GetMock<ISeasonService>().Verify(p => p.SetIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -206,15 +206,15 @@ public void AutoIgnoreSeason_existing_should_ignore_seasons_with_no_file()
|
||||
.Setup(p => p.GetSeriesFiles(seriesId))
|
||||
.Returns(episodesFiles);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(p => p.GetSeasons(seriesId))
|
||||
Mocker.GetMock<ISeasonRepository>()
|
||||
.Setup(p => p.GetSeasonNumbers(seriesId))
|
||||
.Returns(new List<int> { 0, 1, 2 });
|
||||
|
||||
Mocker.Resolve<ImportNewSeriesJob>().AutoIgnoreSeasons(seriesId);
|
||||
|
||||
Mocker.GetMock<SeasonProvider>().Verify(p => p.SetIgnore(seriesId, 0, true), Times.Once());
|
||||
Mocker.GetMock<SeasonProvider>().Verify(p => p.SetIgnore(seriesId, 1, true), Times.Never());
|
||||
Mocker.GetMock<SeasonProvider>().Verify(p => p.SetIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
|
||||
Mocker.GetMock<ISeasonService>().Verify(p => p.SetIgnore(seriesId, 0, true), Times.Once());
|
||||
Mocker.GetMock<ISeasonService>().Verify(p => p.SetIgnore(seriesId, 1, true), Times.Never());
|
||||
Mocker.GetMock<ISeasonService>().Verify(p => p.SetIgnore(seriesId, 2, It.IsAny<Boolean>()), Times.Never());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public void no_missing_epsiodes_should_not_trigger_any_search()
|
||||
//Setup
|
||||
var episodes = new List<Episode>();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
//Act
|
||||
@ -86,7 +86,7 @@ public void should_only_process_missing_episodes_from_the_last_30_days()
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(-35))
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<EpisodeSearchJob>().Setup(c => c.Start(It.IsAny<ProgressNotification>(), It.Is<object>(d => d.GetPropertyValue<int>("EpisodeId") >= 0)));
|
||||
@ -122,7 +122,7 @@ public void GetMissingForEnabledSeries_should_only_return_episodes_for_monitored
|
||||
|
||||
WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
//Act
|
||||
@ -161,7 +161,7 @@ public void GetMissingForEnabledSeries_should_only_return_explicity_enabled_seri
|
||||
|
||||
//WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
//Act
|
||||
@ -201,7 +201,7 @@ public void GetMissingForEnabledSeries_should_return_explicity_enabled_and_inher
|
||||
|
||||
WithEnableBacklogSearching();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
|
||||
|
||||
//Act
|
||||
|
@ -39,7 +39,7 @@ public void Setup()
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(-1))
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(c => c.GetEpisodesBySeason(1, 1)).Returns(_episodes);
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public void SeasonSearch_should_not_search_for_episodes_that_havent_aired_yet_or
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(2))
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(c => c.GetEpisodesBySeason(1, 1)).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<SearchProvider>()
|
||||
|
@ -25,10 +25,10 @@ public void SeriesSearch_success()
|
||||
|
||||
var notification = new ProgressNotification("Series Search");
|
||||
|
||||
Mocker.GetMock<SeasonProvider>()
|
||||
.Setup(c => c.GetSeasons(1)).Returns(seasons);
|
||||
Mocker.GetMock<SeasonRepository>()
|
||||
.Setup(c => c.GetSeasonNumbers(1)).Returns(seasons);
|
||||
|
||||
Mocker.GetMock<SeasonProvider>()
|
||||
Mocker.GetMock<SeasonRepository>()
|
||||
.Setup(c => c.IsIgnored(It.IsAny<int>(), It.IsAny<int>())).Returns(false);
|
||||
|
||||
Mocker.GetMock<SeasonSearchJob>()
|
||||
@ -52,8 +52,8 @@ public void SeriesSearch_no_seasons()
|
||||
|
||||
var notification = new ProgressNotification("Series Search");
|
||||
|
||||
Mocker.GetMock<SeasonProvider>()
|
||||
.Setup(c => c.GetSeasons(1)).Returns(seasons);
|
||||
Mocker.GetMock<SeasonRepository>()
|
||||
.Setup(c => c.GetSeasonNumbers(1)).Returns(seasons);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SeriesSearchJob>().Start(notification, new { SeriesId = 1 });
|
||||
@ -67,8 +67,8 @@ public void SeriesSearch_no_seasons()
|
||||
[Test]
|
||||
public void SeriesSearch_should_not_search_for_season_0()
|
||||
{
|
||||
Mocker.GetMock<SeasonProvider>()
|
||||
.Setup(c => c.GetSeasons(It.IsAny<int>()))
|
||||
Mocker.GetMock<SeasonRepository>()
|
||||
.Setup(c => c.GetSeasonNumbers(It.IsAny<int>()))
|
||||
.Returns(new List<int> { 0, 1, 2 });
|
||||
|
||||
Mocker.Resolve<SeriesSearchJob>().Start(MockNotification, new { SeriesId = 12 });
|
||||
|
@ -236,7 +236,6 @@
|
||||
<Compile Include="ProviderTests\LogProviderTests\LogProviderFixture.cs" />
|
||||
<Compile Include="ProviderTests\UpcomingEpisodesProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\MediaFileProviderTests\GetNewFilenameFixture.cs" />
|
||||
<Compile Include="dbBenchmark.cs" />
|
||||
<Compile Include="Framework\SqlCeTest.cs" />
|
||||
<Compile Include="DecisionEngineTests\MonitoredEpisodeSpecificationFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadProviderTests\DownloadProviderFixture.cs" />
|
||||
|
@ -88,7 +88,7 @@ public void should_move_file_if_a_conflict_is_found()
|
||||
var episode = Builder<Episode>.CreateListOfSize(1)
|
||||
.All()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.With(e => e.EpisodeFileId = episodeFile.EpisodeFileId)
|
||||
.With(e => e.EpisodeFile = episodeFile)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>().Setup(v => v.GetFileByPath(filename))
|
||||
@ -103,7 +103,7 @@ public void should_move_file_if_a_conflict_is_found()
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get(It.IsAny<int>()))
|
||||
.Returns(series);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(s => s.GetEpisodesByFileId(episodeFile.EpisodeFileId))
|
||||
Mocker.GetMock<EpisodeService>().Setup(s => s.GetEpisodesByFileId(episodeFile.EpisodeFileId))
|
||||
.Returns(episode);
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>().Setup(s => s.GetNewFilename(It.IsAny<IList<Episode>>(), series, QualityTypes.Unknown, false, It.IsAny<EpisodeFile>()))
|
||||
|
@ -49,7 +49,7 @@ public void should_delete_none_existing_files()
|
||||
.Setup(e => e.FileExists(It.IsAny<String>()))
|
||||
.Returns(false);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByFileId(It.IsAny<int>()))
|
||||
.Returns(new List<Episode>());
|
||||
|
||||
@ -63,7 +63,7 @@ public void should_delete_none_existing_files()
|
||||
//Assert
|
||||
Mocker.VerifyAllMocks();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Verify(e => e.GetEpisodesByFileId(It.IsAny<int>()), Times.Exactly(10));
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
@ -80,11 +80,11 @@ public void should_delete_none_existing_files_remove_links_to_episodes()
|
||||
.Setup(e => e.FileExists(It.IsAny<String>()))
|
||||
.Returns(false);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByFileId(It.IsAny<int>()))
|
||||
.Returns(new List<Episode> { new Episode { EpisodeFileId = 10 }, new Episode { EpisodeFileId = 10 } });
|
||||
.Returns(new List<Episode> { new Episode { EpisodeFile = new EpisodeFile { EpisodeFileId = 10 } }, new Episode { EpisodeFile = new EpisodeFile { EpisodeFileId = 10 } } });
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.UpdateEpisode(It.IsAny<Episode>()));
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
@ -100,11 +100,11 @@ public void should_delete_none_existing_files_remove_links_to_episodes()
|
||||
//Assert
|
||||
Mocker.VerifyAllMocks();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Verify(e => e.GetEpisodesByFileId(It.IsAny<int>()), Times.Exactly(10));
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Verify(e => e.UpdateEpisode(It.Is<Episode>(g=>g.EpisodeFileId == 0)), Times.Exactly(20));
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Verify(e => e.UpdateEpisode(It.Is<Episode>(g => g.EpisodeFileId == 0)), Times.Exactly(20));
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
.Verify(e => e.Delete(It.IsAny<int>()), Times.Exactly(10));
|
||||
|
@ -36,7 +36,7 @@ public void Setup()
|
||||
{
|
||||
_series = Builder<Series>
|
||||
.CreateNew()
|
||||
.With(s => s.IsDaily = false)
|
||||
.With(s => s.SeriesType = SeriesType.Standard)
|
||||
.Build();
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ public void With80MBFile()
|
||||
|
||||
public void WithDailySeries()
|
||||
{
|
||||
_series.IsDaily = true;
|
||||
_series.SeriesType = SeriesType.Daily;
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -67,7 +67,7 @@ public void import_new_file_should_succeed()
|
||||
.Setup(p => p.Exists(It.IsAny<String>()))
|
||||
.Returns(false);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
|
||||
|
||||
//Act
|
||||
@ -94,7 +94,7 @@ public void import_new_file_with_better_same_quality_should_succeed(QualityTypes
|
||||
|
||||
With80MBFile();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
|
||||
|
||||
//Act
|
||||
@ -124,7 +124,7 @@ public void import_new_file_episode_has_same_or_better_quality_should_skip(strin
|
||||
.Setup(p => p.Exists(It.IsAny<String>()))
|
||||
.Returns(false);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
|
||||
|
||||
//Act
|
||||
@ -194,7 +194,7 @@ public void import_file_with_no_episode_in_db_should_skip()
|
||||
.Setup(p => p.Exists(It.IsAny<String>()))
|
||||
.Returns(false);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(c => c.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>()))
|
||||
.Returns(new List<Episode>());
|
||||
|
||||
@ -225,7 +225,7 @@ public void import_new_file_episode_has_better_quality_than_existing(string file
|
||||
.Setup(p => p.Exists(It.IsAny<String>()))
|
||||
.Returns(false);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
|
||||
|
||||
//Act
|
||||
@ -257,7 +257,7 @@ public void import_new_multi_part_file_episode_has_equal_or_better_quality_than_
|
||||
.Setup(p => p.Exists(It.IsAny<String>()))
|
||||
.Returns(false);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
@ -290,7 +290,7 @@ public void skip_import_new_multi_part_file_episode_existing_has_better_quality(
|
||||
.Setup(p => p.Exists(It.IsAny<String>()))
|
||||
.Returns(false);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
@ -328,7 +328,7 @@ public void import_new_multi_part_file_episode_replace_two_files()
|
||||
.Setup(p => p.Exists(It.IsAny<String>()))
|
||||
.Returns(false);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode1, fakeEpisode2 });
|
||||
|
||||
//Act
|
||||
@ -348,8 +348,6 @@ public void should_import_new_episode_no_existing_episode_file()
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.EpisodeFile = null)
|
||||
.Build();
|
||||
|
||||
//Mocks
|
||||
@ -359,7 +357,7 @@ public void should_import_new_episode_no_existing_episode_file()
|
||||
.Setup(p => p.Exists(It.IsAny<String>()))
|
||||
.Returns(false);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode});
|
||||
|
||||
//Act
|
||||
@ -382,7 +380,7 @@ public void should_set_parseResult_SceneSource_if_not_in_series_Path()
|
||||
|
||||
With80MBFile();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(s => s.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>()))
|
||||
Mocker.GetMock<EpisodeService>().Setup(s => s.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>()))
|
||||
.Returns(new List<Episode>());
|
||||
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.IsChildOfPath(path, series.Path))
|
||||
@ -390,7 +388,7 @@ public void should_set_parseResult_SceneSource_if_not_in_series_Path()
|
||||
|
||||
Mocker.Resolve<DiskScanProvider>().ImportFile(series, path);
|
||||
|
||||
Mocker.Verify<EpisodeProvider>(s => s.GetEpisodesByParseResult(It.Is<EpisodeParseResult>(p => p.SceneSource)), Times.Once());
|
||||
Mocker.Verify<EpisodeService>(s => s.GetEpisodesByParseResult(It.Is<EpisodeParseResult>(p => p.SceneSource)), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -405,7 +403,7 @@ public void should_not_set_parseResult_SceneSource_if_in_series_Path()
|
||||
|
||||
With80MBFile();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Setup(s => s.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>()))
|
||||
Mocker.GetMock<EpisodeService>().Setup(s => s.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>()))
|
||||
.Returns(new List<Episode>());
|
||||
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.IsChildOfPath(path, series.Path))
|
||||
@ -413,7 +411,7 @@ public void should_not_set_parseResult_SceneSource_if_in_series_Path()
|
||||
|
||||
Mocker.Resolve<DiskScanProvider>().ImportFile(series, path);
|
||||
|
||||
Mocker.Verify<EpisodeProvider>(s => s.GetEpisodesByParseResult(It.Is<EpisodeParseResult>(p => p.SceneSource == false)), Times.Once());
|
||||
Mocker.Verify<EpisodeService>(s => s.GetEpisodesByParseResult(It.Is<EpisodeParseResult>(p => p.SceneSource == false)), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -440,8 +438,6 @@ public void should_return_null_if_file_size_is_under_70MB_and_runTime_under_3_mi
|
||||
public void should_import_if_file_size_is_under_70MB_but_runTime_over_3_minutes()
|
||||
{
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.EpisodeFile = null)
|
||||
.Build();
|
||||
|
||||
const string path = @"C:\Test\TV\30.rock.s01e01.pilot.avi";
|
||||
@ -458,7 +454,7 @@ public void should_import_if_file_size_is_under_70MB_but_runTime_over_3_minutes(
|
||||
.Setup(s => s.GetRunTime(path))
|
||||
.Returns(600);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
|
||||
|
||||
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(_series, path);
|
||||
@ -473,8 +469,6 @@ public void should_import_if_file_size_is_over_70MB_but_runTime_under_3_minutes(
|
||||
With80MBFile();
|
||||
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.EpisodeFile = null)
|
||||
.Build();
|
||||
|
||||
const string path = @"C:\Test\TV\30.rock.s01e01.pilot.avi";
|
||||
@ -487,7 +481,7 @@ public void should_import_if_file_size_is_over_70MB_but_runTime_under_3_minutes(
|
||||
.Setup(s => s.GetRunTime(path))
|
||||
.Returns(60);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
|
||||
|
||||
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(_series, path);
|
||||
@ -502,8 +496,6 @@ public void should_import_special_even_if_file_size_is_under_70MB_and_runTime_un
|
||||
With80MBFile();
|
||||
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.EpisodeFileId = 0)
|
||||
.With(e => e.EpisodeFile = null)
|
||||
.Build();
|
||||
|
||||
const string path = @"C:\Test\TV\30.rock.s00e01.pre-pilot.avi";
|
||||
@ -520,7 +512,7 @@ public void should_import_special_even_if_file_size_is_under_70MB_and_runTime_un
|
||||
.Setup(s => s.GetRunTime(path))
|
||||
.Returns(60);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(new List<Episode> { fakeEpisode });
|
||||
|
||||
var result = Mocker.Resolve<DiskScanProvider>().ImportFile(_series, path);
|
||||
@ -560,16 +552,16 @@ private static void VerifyFileImport(EpisodeFile result, AutoMoqer Mocker, Episo
|
||||
Mocker.GetMock<MediaFileProvider>().Verify(p => p.Add(It.IsAny<EpisodeFile>()), Times.Once());
|
||||
|
||||
//Get the count of episodes linked
|
||||
var count = Mocker.GetMock<EpisodeProvider>().Object.GetEpisodesByParseResult(null).Count;
|
||||
var count = Mocker.GetMock<EpisodeService>().Object.GetEpisodesByParseResult(null).Count;
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>().Verify(p => p.UpdateEpisode(It.Is<Episode>(e => e.EpisodeFileId == result.EpisodeFileId)), Times.Exactly(count));
|
||||
Mocker.GetMock<EpisodeService>().Verify(p => p.UpdateEpisode(It.Is<Episode>(e => e.EpisodeFileId == result.EpisodeFileId)), Times.Exactly(count));
|
||||
}
|
||||
|
||||
private static void VerifySkipImport(EpisodeFile result, AutoMoqer Mocker)
|
||||
{
|
||||
result.Should().BeNull();
|
||||
Mocker.GetMock<MediaFileProvider>().Verify(p => p.Add(It.IsAny<EpisodeFile>()), Times.Never());
|
||||
Mocker.GetMock<EpisodeProvider>().Verify(p => p.UpdateEpisode(It.IsAny<Episode>()), Times.Never());
|
||||
Mocker.GetMock<EpisodeService>().Verify(p => p.UpdateEpisode(It.IsAny<Episode>()), Times.Never());
|
||||
Mocker.GetMock<DiskProvider>().Verify(p => p.DeleteFile(It.IsAny<string>()), Times.Never());
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public void should_not_move_file_if_source_and_destination_are_the_same_path()
|
||||
.Setup(e => e.Get(fakeSeries.SeriesId))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByFileId(file.EpisodeFileId))
|
||||
.Returns(fakeEpisode);
|
||||
|
||||
@ -100,7 +100,7 @@ public void should_use_EpisodeFiles_quality()
|
||||
.Setup(e => e.Get(fakeSeries.SeriesId))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByFileId(file.EpisodeFileId))
|
||||
.Returns(fakeEpisode);
|
||||
|
||||
@ -163,7 +163,7 @@ public void should_log_error_and_return_null_when_source_file_does_not_exists()
|
||||
.Setup(e => e.Get(fakeSeries.SeriesId))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(e => e.GetEpisodesByFileId(file.EpisodeFileId))
|
||||
.Returns(fakeEpisode);
|
||||
|
||||
|
@ -22,8 +22,8 @@ public void series_should_update_the_last_scan_date()
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Update(It.Is<Series>(s => s.LastDiskSync != null))).Verifiable();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
.Setup(c => c.GetEpisodeBySeries(It.IsAny<long>()))
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(c => c.GetEpisodeBySeries(It.IsAny<int>()))
|
||||
.Returns(new List<Episode> { new Episode() });
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
|
@ -148,7 +148,7 @@ public void is_in_queue_should_find_if_exact_daily_episode_is_in_queue()
|
||||
{
|
||||
Quality = new QualityModel { Quality = QualityTypes.Bluray720p, Proper = false },
|
||||
AirDate = new DateTime(2011, 12, 01),
|
||||
Series = new Series { Title = "The Dailyshow", CleanTitle = Parser.NormalizeTitle("The Dailyshow"), IsDaily = true },
|
||||
Series = new Series { Title = "The Dailyshow", CleanTitle = Parser.NormalizeTitle("The Dailyshow"), SeriesType = SeriesType.Daily },
|
||||
};
|
||||
|
||||
|
||||
|
@ -41,12 +41,12 @@ private void SetDownloadClient(DownloadClientType clientType)
|
||||
private EpisodeParseResult SetupParseResult()
|
||||
{
|
||||
var episodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.TheFirst(1).With(s => s.EpisodeId = 12)
|
||||
.TheNext(1).With(s => s.EpisodeId = 99)
|
||||
.TheFirst(1).With(s => s.OID = 12)
|
||||
.TheNext(1).With(s => s.OID = 99)
|
||||
.All().With(s => s.SeriesId = 5)
|
||||
.Build().ToList();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(c => c.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>())).Returns(episodes);
|
||||
|
||||
return Builder<EpisodeParseResult>.CreateNew()
|
||||
@ -104,10 +104,10 @@ public void Download_report_should_send_to_sab_add_to_history_mark_as_grabbed()
|
||||
Mocker.GetMock<HistoryProvider>()
|
||||
.Verify(s => s.Add(It.Is<History>(h => h.EpisodeId == 99 && h.SeriesId == 5)), Times.Once());
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Verify(c => c.MarkEpisodeAsFetched(12));
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Verify(c => c.MarkEpisodeAsFetched(99));
|
||||
|
||||
Mocker.GetMock<ExternalNotificationProvider>()
|
||||
@ -139,10 +139,10 @@ public void should_download_nzb_to_blackhole_add_to_history_mark_as_grabbed()
|
||||
Mocker.GetMock<HistoryProvider>()
|
||||
.Verify(s => s.Add(It.Is<History>(h => h.EpisodeId == 99 && h.SeriesId == 5)), Times.Once());
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Verify(c => c.MarkEpisodeAsFetched(12));
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Verify(c => c.MarkEpisodeAsFetched(99));
|
||||
|
||||
Mocker.GetMock<ExternalNotificationProvider>()
|
||||
@ -165,7 +165,7 @@ public void Download_report_should_not_add_to_history_mark_as_grabbed_if_add_fai
|
||||
.Verify(s => s.Add(It.IsAny<History>()), Times.Never());
|
||||
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Verify(c => c.MarkEpisodeAsFetched(It.IsAny<int>()), Times.Never());
|
||||
|
||||
Mocker.GetMock<ExternalNotificationProvider>()
|
||||
@ -242,7 +242,7 @@ public string create_proper_sab_season_title(bool proper)
|
||||
public string create_proper_sab_daily_titles(bool proper)
|
||||
{
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(c => c.IsDaily = true)
|
||||
.With(c => c.SeriesType = SeriesType.Daily)
|
||||
.With(c => c.Title = "My Series Name")
|
||||
.Build();
|
||||
|
||||
|
@ -135,7 +135,7 @@ public void GetBestQualityInHistory_single_result()
|
||||
var history = Builder<History>.CreateNew()
|
||||
.With(h => h.Quality = QualityTypes.Bluray720p)
|
||||
.With(h => h.IsProper = true)
|
||||
.With(h => h.EpisodeId = historyEpisode.EpisodeId)
|
||||
.With(h => h.EpisodeId = historyEpisode.OID)
|
||||
.Build();
|
||||
|
||||
Db.Insert(history);
|
||||
@ -162,7 +162,7 @@ public void GetBestQualityInHistory_should_return_highest_result()
|
||||
var history = Builder<History>
|
||||
.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(h => h.EpisodeId = historyEpisode.EpisodeId)
|
||||
.With(h => h.EpisodeId = historyEpisode.OID)
|
||||
.With(h => h.SeriesId = historyEpisode.SeriesId)
|
||||
.TheFirst(1)
|
||||
.With(h => h.Quality = QualityTypes.DVD)
|
||||
@ -205,7 +205,7 @@ public void GetBestQualityInHistory_should_return_highest_weighted_result()
|
||||
var history = Builder<History>
|
||||
.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(h => h.EpisodeId = historyEpisode.EpisodeId)
|
||||
.With(h => h.EpisodeId = historyEpisode.OID)
|
||||
.With(h => h.SeriesId = historyEpisode.SeriesId)
|
||||
.TheFirst(1)
|
||||
.With(h => h.Quality = QualityTypes.DVD)
|
||||
@ -250,7 +250,7 @@ public void add_item()
|
||||
var history = new History
|
||||
{
|
||||
Date = DateTime.Now,
|
||||
EpisodeId = episode.EpisodeId,
|
||||
EpisodeId = episode.OID,
|
||||
SeriesId = episode.SeriesId,
|
||||
NzbTitle = "my title",
|
||||
Indexer = "Fake Indexer",
|
||||
|
@ -83,7 +83,7 @@ public void Scan_series_should_skip_series_with_no_episodes()
|
||||
{
|
||||
WithStrictMocker();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(c => c.GetEpisodeBySeries(12))
|
||||
.Returns(new List<Episode>());
|
||||
|
||||
|
@ -96,7 +96,6 @@ public void CleanUpDatabse_should_not_change_episodes_with_no_file_id()
|
||||
.All().With(c => c.GrabDate = DateTime.Now)
|
||||
.And(c => c.Ignored = false)
|
||||
.And(c => c.PostDownloadStatus = PostDownloadStatusType.NoError)
|
||||
.And(c => c.EpisodeFileId = 0)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(episodes);
|
||||
|
@ -765,7 +765,7 @@ public void should_use_airDate_if_series_isDaily()
|
||||
|
||||
var series = Builder<Series>
|
||||
.CreateNew()
|
||||
.With(s => s.IsDaily = true)
|
||||
.With(s => s.SeriesType = SeriesType.Daily)
|
||||
.With(s => s.Title = "The Daily Show with Jon Stewart")
|
||||
.Build();
|
||||
|
||||
@ -794,7 +794,7 @@ public void should_use_airDate_if_series_isDaily_no_episode_title()
|
||||
|
||||
var series = Builder<Series>
|
||||
.CreateNew()
|
||||
.With(s => s.IsDaily = true)
|
||||
.With(s => s.SeriesType = SeriesType.Daily)
|
||||
.With(s => s.Title = "The Daily Show with Jon Stewart")
|
||||
.Build();
|
||||
|
||||
@ -823,7 +823,7 @@ public void should_set_airdate_to_unknown_if_not_available()
|
||||
|
||||
var series = Builder<Series>
|
||||
.CreateNew()
|
||||
.With(s => s.IsDaily = true)
|
||||
.With(s => s.SeriesType = SeriesType.Daily)
|
||||
.With(s => s.Title = "The Daily Show with Jon Stewart")
|
||||
.Build();
|
||||
|
||||
|
@ -104,7 +104,7 @@ private void WithSingleEpisodeFile()
|
||||
.With(e => e.EpisodeNumber = 1)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.GetEpisodesByFileId(episodeFile.EpisodeFileId))
|
||||
.Returns(new List<Episode> { episode });
|
||||
}
|
||||
@ -117,7 +117,7 @@ private void WithMultiEpisodeFile()
|
||||
.With(e => e.SeasonNumber = 1)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.GetEpisodesByFileId(episodeFile.EpisodeFileId))
|
||||
.Returns(episodes.ToList());
|
||||
}
|
||||
|
@ -37,16 +37,14 @@ public void no_misnamed_files()
|
||||
.All()
|
||||
.With(e => e.Series = series)
|
||||
.TheFirst(1)
|
||||
.With(e => e.EpisodeFileId = 1)
|
||||
.With(e => e.EpisodeFile = episodeFiles[0])
|
||||
.TheNext(1)
|
||||
.With(e => e.EpisodeFileId = 2)
|
||||
.With(e => e.EpisodeFile = episodeFiles[1])
|
||||
.Build();
|
||||
|
||||
WithStrictMocker();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
@ -86,16 +84,14 @@ public void all_misnamed_files()
|
||||
.All()
|
||||
.With(e => e.Series = series)
|
||||
.TheFirst(1)
|
||||
.With(e => e.EpisodeFileId = 1)
|
||||
.With(e => e.EpisodeFile = episodeFiles[0])
|
||||
.TheNext(1)
|
||||
.With(e => e.EpisodeFileId = 2)
|
||||
.With(e => e.EpisodeFile = episodeFiles[1])
|
||||
.Build();
|
||||
|
||||
WithStrictMocker();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
@ -135,16 +131,14 @@ public void one_misnamed_file()
|
||||
.All()
|
||||
.With(e => e.Series = series)
|
||||
.TheFirst(1)
|
||||
.With(e => e.EpisodeFileId = 1)
|
||||
.With(e => e.EpisodeFile = episodeFiles[0])
|
||||
.TheNext(1)
|
||||
.With(e => e.EpisodeFileId = 2)
|
||||
.With(e => e.EpisodeFile = episodeFiles[1])
|
||||
.Build();
|
||||
|
||||
WithStrictMocker();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
@ -186,16 +180,14 @@ public void misnamed_multi_episode_file()
|
||||
.All()
|
||||
.With(e => e.Series = series)
|
||||
.TheFirst(2)
|
||||
.With(e => e.EpisodeFileId = 1)
|
||||
.With(e => e.EpisodeFile = episodeFiles[0])
|
||||
.TheNext(1)
|
||||
.With(e => e.EpisodeFileId = 2)
|
||||
.With(e => e.EpisodeFile = episodeFiles[1])
|
||||
.Build();
|
||||
|
||||
WithStrictMocker();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
@ -237,16 +229,14 @@ public void no_misnamed_multi_episode_file()
|
||||
.All()
|
||||
.With(e => e.Series = series)
|
||||
.TheFirst(2)
|
||||
.With(e => e.EpisodeFileId = 1)
|
||||
.With(e => e.EpisodeFile = episodeFiles[0])
|
||||
.TheNext(1)
|
||||
.With(e => e.EpisodeFileId = 2)
|
||||
.With(e => e.EpisodeFile = episodeFiles[1])
|
||||
.Build();
|
||||
|
||||
WithStrictMocker();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(c => c.EpisodesWithFiles()).Returns(episodes);
|
||||
|
||||
Mocker.GetMock<MediaFileProvider>()
|
||||
|
@ -48,7 +48,7 @@ private void WithRecentWrite()
|
||||
private void WithValidSeries()
|
||||
{
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get(It.IsAny<string>()))
|
||||
.Setup(c => c.GetByTitle(It.IsAny<string>()))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
@ -99,7 +99,7 @@ public void should_continue_processing_if_folder_is_tagged_and_not_fresh()
|
||||
droppedFolder.Create();
|
||||
|
||||
//Act
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get(It.IsAny<String>())).Returns<Series>(null).Verifiable();
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle(It.IsAny<String>())).Returns<Series>(null).Verifiable();
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
|
||||
|
||||
//Assert
|
||||
@ -115,7 +115,7 @@ public void should_search_for_series_using_title_without_status()
|
||||
|
||||
var droppedFolder = new DirectoryInfo(@"C:\Test\Unsorted TV\_unpack_The Office - S01E01 - Episode Title");
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get("office")).Returns<Series>(null).Verifiable();
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle("office")).Returns<Series>(null).Verifiable();
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
|
||||
@ -167,7 +167,7 @@ public void when_series_isnt_found_folder_should_be_tagged_as_unknown_series()
|
||||
var taggedFolder = @"C:\Test\Unsorted TV\_UnknownSeries_The Office - S01E01 - Episode Title";
|
||||
|
||||
//Act
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get("office")).Returns<Series>(null);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle("office")).Returns<Series>(null);
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder));
|
||||
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
|
||||
@ -193,7 +193,7 @@ public void when_no_files_are_imported_folder_should_be_tagged_with_parse_error(
|
||||
.Build();
|
||||
|
||||
//Act
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get("office")).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle("office")).Returns(fakeSeries);
|
||||
Mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(new List<EpisodeFile>());
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder));
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize + 10.Megabytes());
|
||||
@ -228,7 +228,7 @@ public void when_no_file_are_imported_and_folder_size_isnt_small_enought_folder_
|
||||
.Build().ToList();
|
||||
|
||||
//Act
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get("office")).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle("office")).Returns(fakeSeries);
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.MoveDirectory(droppedFolder.FullName, taggedFolder));
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize + 10.Megabytes());
|
||||
Mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles);
|
||||
@ -254,7 +254,7 @@ public void folder_shouldnt_be_tagged_with_same_tag_again(string path)
|
||||
WithOldWrite();
|
||||
|
||||
//Act
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get(It.IsAny<String>())).Returns<Series>(null);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle(It.IsAny<String>())).Returns<Series>(null);
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
|
||||
|
||||
//Assert
|
||||
@ -273,7 +273,7 @@ public void folder_should_not_be_tagged_if_existing_tag_is_diffrent()
|
||||
|
||||
var taggedFolder = TempFolder + @"\_UnknownSeries_The Office - S01E01 - Episode Title";
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get(It.IsAny<String>())).Returns<Series>(null);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle(It.IsAny<String>())).Returns<Series>(null);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
|
||||
@ -295,7 +295,7 @@ public void when_files_are_imported_and_folder_is_small_enough_dir_should_be_del
|
||||
|
||||
WithImportedFiles(droppedFolder.FullName);
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get("office")).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle("office")).Returns(fakeSeries);
|
||||
Mocker.GetMock<DiskScanProvider>().Setup(s => s.CleanUpDropFolder(droppedFolder.FullName));
|
||||
Mocker.GetMock<DiskScanProvider>().Setup(s => s.MoveEpisodeFile(It.IsAny<EpisodeFile>(), true)).Returns(new EpisodeFile());
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectorySize(droppedFolder.FullName)).Returns(Constants.IgnoreFileSize - 1.Megabytes());
|
||||
@ -322,7 +322,7 @@ public void all_imported_files_should_be_moved()
|
||||
var fakeEpisodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
|
||||
.Build().ToList();
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get(It.IsAny<string>())).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle(It.IsAny<string>())).Returns(fakeSeries);
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.FolderExists(fakeSeries.Path)).Returns(true);
|
||||
Mocker.GetMock<DiskScanProvider>().Setup(s => s.Scan(fakeSeries, droppedFolder.FullName)).Returns(fakeEpisodeFiles);
|
||||
|
||||
@ -346,7 +346,7 @@ public void should_logError_and_return_if_size_exceeds_free_space()
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get("rock"))
|
||||
.Setup(c => c.GetByTitle("rock"))
|
||||
.Returns(series);
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
@ -381,7 +381,7 @@ public void should_process_if_free_disk_space_exceeds_size()
|
||||
WithImportedFiles(downloadName.FullName);
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get("rock"))
|
||||
.Setup(c => c.GetByTitle("rock"))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
|
@ -62,7 +62,7 @@ public void ProcessDropFolder_should_only_process_folders_that_arent_known_serie
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get(It.IsAny<String>()))
|
||||
.Setup(c => c.GetByTitle(It.IsAny<String>()))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<DiskScanProvider>()
|
||||
@ -105,7 +105,7 @@ public void ProcessDropFolder_should_process_individual_video_files_in_drop_fold
|
||||
.Returns(files);
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get(It.IsAny<String>()))
|
||||
.Setup(c => c.GetByTitle(It.IsAny<String>()))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<DiskScanProvider>()
|
||||
|
@ -48,7 +48,7 @@ private void WithRecentWrite()
|
||||
private void WithValidSeries()
|
||||
{
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get(It.IsAny<string>()))
|
||||
.Setup(c => c.GetByTitle(It.IsAny<string>()))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
@ -96,11 +96,11 @@ public void should_continue_processing_if_not_fresh()
|
||||
var file = Path.Combine(TempFolder, "test.avi");
|
||||
|
||||
//Act
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get(It.IsAny<String>())).Returns<Series>(null).Verifiable();
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle(It.IsAny<String>())).Returns<Series>(null).Verifiable();
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessVideoFile(file);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<ISeriesRepository>().Verify(s => s.Get(It.IsAny<String>()), Times.Once());
|
||||
Mocker.GetMock<ISeriesRepository>().Verify(s => s.GetByTitle(It.IsAny<String>()), Times.Once());
|
||||
ExceptionVerification.IgnoreWarns();
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ public void should_return_if_series_is_not_found()
|
||||
var file = Path.Combine(TempFolder, "test.avi");
|
||||
|
||||
//Act
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get(It.IsAny<String>())).Returns<Series>(null);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle(It.IsAny<String>())).Returns<Series>(null);
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessVideoFile(file);
|
||||
|
||||
//Assert
|
||||
@ -150,7 +150,7 @@ public void should_logError_and_return_if_size_exceeds_free_space()
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get("rock"))
|
||||
.Setup(c => c.GetByTitle("rock"))
|
||||
.Returns(series);
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
@ -183,7 +183,7 @@ public void should_process_if_free_disk_space_exceeds_size()
|
||||
var downloadName = @"C:\Test\Drop\30.Rock.S01E01.Pilot.mkv";
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(c => c.Get("rock"))
|
||||
.Setup(c => c.GetByTitle("rock"))
|
||||
.Returns(fakeSeries);
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
|
@ -111,7 +111,7 @@ public void UpdateDailySeries_should_update_series_that_match_daily_series_list(
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(s => s.IsDaily = false)
|
||||
.With(s => s.SeriesType = SeriesType.Standard)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
@ -126,7 +126,7 @@ public void UpdateDailySeries_should_update_series_that_match_daily_series_list(
|
||||
//Assert
|
||||
var result = Db.Fetch<Series>();
|
||||
|
||||
result.Where(s => s.IsDaily).Should().HaveCount(5);
|
||||
result.Where(s => s.SeriesType == SeriesType.Daily).Should().HaveCount(5);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -136,7 +136,7 @@ public void UpdateDailySeries_should_update_series_should_skip_series_that_dont_
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(s => s.IsDaily = false)
|
||||
.With(s => s.SeriesType = SeriesType.Standard)
|
||||
.TheFirst(1)
|
||||
.With(s => s.SeriesId = 10)
|
||||
.TheNext(1)
|
||||
@ -157,8 +157,8 @@ public void UpdateDailySeries_should_update_series_should_skip_series_that_dont_
|
||||
//Assert
|
||||
var result = Db.Fetch<Series>();
|
||||
|
||||
result.Where(s => !s.IsDaily).Should().HaveCount(3);
|
||||
result.Where(s => s.IsDaily).Should().HaveCount(2);
|
||||
result.Where(s => s.SeriesType == SeriesType.Standard).Should().HaveCount(3);
|
||||
result.Where(s => s.SeriesType == SeriesType.Daily).Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -168,10 +168,10 @@ public void UpdateDailySeries_should_update_series_should_not_overwrite_existing
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(s => s.IsDaily = false)
|
||||
.With(s => s.SeriesType = SeriesType.Standard)
|
||||
.TheFirst(1)
|
||||
.With(s => s.SeriesId = 10)
|
||||
.With(s => s.IsDaily = true)
|
||||
.With(s => s.SeriesType = SeriesType.Daily)
|
||||
.TheNext(1)
|
||||
.With(s => s.SeriesId = 11)
|
||||
.TheNext(1)
|
||||
@ -190,8 +190,8 @@ public void UpdateDailySeries_should_update_series_should_not_overwrite_existing
|
||||
//Assert
|
||||
var result = Db.Fetch<Series>();
|
||||
|
||||
result.Where(s => s.IsDaily).Should().HaveCount(3);
|
||||
result.Where(s => !s.IsDaily).Should().HaveCount(2);
|
||||
result.Where(s => s.SeriesType == SeriesType.Daily).Should().HaveCount(3);
|
||||
result.Where(s => s.SeriesType == SeriesType.Standard).Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -43,7 +43,7 @@ public void Setup()
|
||||
.Build().ToList();
|
||||
|
||||
_searchHistory = Builder<SearchHistory>.CreateNew()
|
||||
.With(h => h.EpisodeId = _episode.EpisodeId)
|
||||
.With(h => h.EpisodeId = _episode.OID)
|
||||
.With(h => h.SeriesId - _series.SeriesId)
|
||||
.With(h => h.SearchHistoryItems = items)
|
||||
.Build();
|
||||
|
@ -51,7 +51,7 @@ public void Setup()
|
||||
.CreateListOfSize(1)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>()))
|
||||
.Returns(_episodes);
|
||||
}
|
||||
@ -59,19 +59,19 @@ public void Setup()
|
||||
private void WithMatchingSeries()
|
||||
{
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(s => s.Get(It.IsAny<string>())).Returns(_matchingSeries);
|
||||
.Setup(s => s.GetByTitle(It.IsAny<string>())).Returns(_matchingSeries);
|
||||
}
|
||||
|
||||
private void WithMisMatchedSeries()
|
||||
{
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(s => s.Get(It.IsAny<string>())).Returns(_mismatchedSeries);
|
||||
.Setup(s => s.GetByTitle(It.IsAny<string>())).Returns(_mismatchedSeries);
|
||||
}
|
||||
|
||||
private void WithNullSeries()
|
||||
{
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(s => s.Get(It.IsAny<string>())).Returns(_nullSeries);
|
||||
.Setup(s => s.GetByTitle(It.IsAny<string>())).Returns(_nullSeries);
|
||||
}
|
||||
|
||||
private void WithSuccessfulDownload()
|
||||
|
@ -17,10 +17,10 @@ public class TestSearch : SearchBase
|
||||
{
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public TestSearch(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, DownloadProvider downloadProvider,
|
||||
public TestSearch(ISeriesService seriesService, EpisodeService episodeService, DownloadProvider downloadProvider,
|
||||
IndexerProvider indexerProvider, SceneMappingProvider sceneMappingProvider,
|
||||
AllowedDownloadSpecification allowedDownloadSpecification, SearchHistoryProvider searchHistoryProvider,ISeriesRepository seriesRepository)
|
||||
: base(seriesProvider, seriesRepository, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
: base(seriesService, seriesRepository, episodeService, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
allowedDownloadSpecification, searchHistoryProvider)
|
||||
{
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public void Setup()
|
||||
.With(s => s.UtcOffset = -8)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<EpisodeProvider>()
|
||||
Mocker.GetMock<EpisodeService>()
|
||||
.Setup(s => s.GetEpisode(_series.SeriesId, 1, 1))
|
||||
.Returns(_episode);
|
||||
|
||||
|
@ -29,13 +29,13 @@ public void GetEpisodes_exists()
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
||||
.All().With(e => e.SeriesId = 1).With(e => e.EpisodeFileId = 0).Build();
|
||||
.All().With(e => e.SeriesId = 1).Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
var episode = Mocker.Resolve<EpisodeProvider>().GetEpisode(1);
|
||||
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1);
|
||||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
|
||||
@ -53,14 +53,13 @@ public void GetEpisodes_by_season_episode_exists()
|
||||
var fakeEpisodes = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = 1)
|
||||
.With(e => e.EpisodeNumber = 1)
|
||||
.And(e => e.SeasonNumber = 2)
|
||||
.With(e => e.EpisodeFileId = 0).Build();
|
||||
.And(e => e.SeasonNumber = 2).Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
var episode = Mocker.Resolve<EpisodeProvider>().GetEpisode(fakeSeries.SeriesId, 2, 1);
|
||||
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(fakeSeries.SeriesId, 2, 1);
|
||||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisodes);
|
||||
@ -73,7 +72,7 @@ public void GetEpisodes_by_season_episode_doesnt_exists()
|
||||
WithRealDb();
|
||||
|
||||
//Act
|
||||
var episode = Mocker.Resolve<EpisodeProvider>().GetEpisode(1, 1, 1);
|
||||
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1, 1, 1);
|
||||
|
||||
//Assert
|
||||
episode.Should().BeNull();
|
||||
@ -87,14 +86,14 @@ public void GetEpisode_with_EpisodeFile()
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = QualityTypes.SDTV).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
||||
.All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFileId = 1).With(e => e.EpisodeFile = fakeFile).Build();
|
||||
.All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFile = new EpisodeFile { EpisodeFileId = 1 }).With(e => e.EpisodeFile = fakeFile).Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
Db.Insert(fakeFile);
|
||||
|
||||
//Act
|
||||
var episode = Mocker.Resolve<EpisodeProvider>().GetEpisode(1);
|
||||
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1);
|
||||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
|
||||
@ -108,7 +107,7 @@ public void GetEpisodes_invalid_series()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
Mocker.Resolve<SeriesProvider>();
|
||||
Mocker.Resolve<SeriesService>();
|
||||
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
||||
.All().With(e => e.SeriesId = 1).Build();
|
||||
@ -118,9 +117,9 @@ public void GetEpisodes_invalid_series()
|
||||
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().GetEpisode(1);
|
||||
Mocker.Resolve<EpisodeService>().GetEpisode(1);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void GetEpisodesBySeason_success()
|
||||
{
|
||||
@ -139,7 +138,7 @@ public void GetEpisodesBySeason_success()
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
//Act
|
||||
var seasonEposodes = Mocker.Resolve<EpisodeProvider>().GetEpisodesBySeason(12, 2);
|
||||
var seasonEposodes = Mocker.Resolve<EpisodeService>().GetEpisodesBySeason(12, 2);
|
||||
|
||||
//Assert
|
||||
Db.Fetch<Episode>().Should().HaveCount(10);
|
||||
@ -172,10 +171,10 @@ public void RefreshEpisodeInfo_emptyRepo()
|
||||
.Returns(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
var actualCount = Mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList().Count;
|
||||
var actualCount = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList().Count;
|
||||
Mocker.GetMock<TvDbProvider>().VerifyAll();
|
||||
actualCount.Should().Be(episodeCount);
|
||||
}
|
||||
@ -207,10 +206,10 @@ public void RefreshEpisodeInfo_should_set_older_than_1900_to_null()
|
||||
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
var storedEpisodes = Mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList();
|
||||
var storedEpisodes = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
|
||||
storedEpisodes.Should().HaveCount(10);
|
||||
storedEpisodes.Where(e => e.AirDate == null).Should().HaveCount(7);
|
||||
storedEpisodes.Where(e => e.AirDate != null).Should().HaveCount(3);
|
||||
@ -247,10 +246,10 @@ public void RefreshEpisodeInfo_should_set_older_than_1900_to_null_for_existing_e
|
||||
.Returns(fakeTvDbEpisodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
var storedEpisodes = Mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList();
|
||||
var storedEpisodes = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
|
||||
storedEpisodes.Should().HaveCount(1);
|
||||
storedEpisodes.Where(e => e.AirDate == null).Should().HaveCount(1);
|
||||
}
|
||||
@ -285,10 +284,10 @@ public void RefreshEpisodeInfo_ignore_episode_zero()
|
||||
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
var result = Mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList();
|
||||
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
|
||||
Mocker.GetMock<TvDbProvider>().VerifyAll();
|
||||
result.Should().HaveCount(episodeCount);
|
||||
result.Where(e => e.EpisodeNumber == 0 && e.SeasonNumber == 15).Single().Ignored.Should().BeTrue();
|
||||
@ -324,10 +323,10 @@ public void RefreshEpisodeInfo_should_skip_future_episodes_with_no_title()
|
||||
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
var result = Mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList();
|
||||
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
|
||||
result.Should().HaveCount(episodeCount - 3);
|
||||
result.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.Title) || c.AirDate < DateTime.Now);
|
||||
}
|
||||
@ -346,7 +345,7 @@ public void RefreshEpisodeInfo_should_skip_older_than_1900_year_episodes_with_no
|
||||
.With(e => e.EpisodeName = "Something")
|
||||
.TheFirst(3)
|
||||
.With(e => e.EpisodeName = "")
|
||||
.With(e => e.FirstAired = new DateTime(1889,1,1))
|
||||
.With(e => e.FirstAired = new DateTime(1889, 1, 1))
|
||||
.Build())
|
||||
).With(c => c.Id = seriesId).Build();
|
||||
|
||||
@ -362,10 +361,10 @@ public void RefreshEpisodeInfo_should_skip_older_than_1900_year_episodes_with_no
|
||||
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
var result = Mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList();
|
||||
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
|
||||
result.Should().HaveCount(episodeCount - 3);
|
||||
result.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.Title) || c.AirDate < DateTime.Now);
|
||||
}
|
||||
@ -395,10 +394,10 @@ public void RefreshEpisodeInfo_should_add_future_episodes_with_title()
|
||||
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
var result = Mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList();
|
||||
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
|
||||
result.Should().HaveSameCount(fakeEpisodes.Episodes);
|
||||
}
|
||||
|
||||
@ -428,10 +427,10 @@ public void RefreshEpisodeInfo_should_add_old_episodes_with_no_title()
|
||||
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
var result = Mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList();
|
||||
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
|
||||
result.Should().HaveSameCount(fakeEpisodes.Episodes);
|
||||
}
|
||||
|
||||
@ -461,15 +460,15 @@ public void RefreshEpisodeInfo_ignore_season_zero()
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(fakeEpisodes);
|
||||
|
||||
Mocker.GetMock<SeasonProvider>()
|
||||
Mocker.GetMock<SeasonRepository>()
|
||||
.Setup(s => s.IsIgnored(seriesId, 0))
|
||||
.Returns(true);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
var result = Mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList();
|
||||
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
|
||||
Mocker.GetMock<TvDbProvider>().VerifyAll();
|
||||
result.Should().HaveCount(episodeCount);
|
||||
result.Where(e => e.Ignored).Should().HaveCount(episodeCount);
|
||||
@ -497,7 +496,7 @@ public void new_episodes_only_calls_Insert()
|
||||
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<IDatabase>().Verify(c => c.InsertMany(It.Is<IEnumerable<Episode>>(l => l.Count() == 5)), Times.Once());
|
||||
@ -531,7 +530,7 @@ public void existing_episodes_only_calls_Update()
|
||||
.Returns(currentEpisodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<IDatabase>().Verify(c => c.InsertMany(It.Is<IEnumerable<Episode>>(l => l.Count() == 0)), Times.Once());
|
||||
@ -564,7 +563,7 @@ public void should_try_to_get_existing_episode_using_tvdbid_first()
|
||||
.Returns(fakeTvDbResult);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
Mocker.VerifyAllMocks();
|
||||
@ -605,7 +604,7 @@ public void should_try_to_get_existing_episode_using_tvdbid_first_then_season_ep
|
||||
.Returns(new List<Episode> { localEpisode });
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
Mocker.VerifyAllMocks();
|
||||
@ -627,13 +626,13 @@ public void existing_episodes_keep_their_episodeId_file_id()
|
||||
{
|
||||
currentEpisodes.Add(new Episode
|
||||
{
|
||||
TvDbEpisodeId = tvDbEpisode.Id,
|
||||
EpisodeId = 99,
|
||||
EpisodeFileId = 69,
|
||||
Ignored = true,
|
||||
Series = fakeSeries,
|
||||
EpisodeNumber = tvDbEpisode.EpisodeNumber,
|
||||
SeasonNumber = tvDbEpisode.SeasonNumber
|
||||
TvDbEpisodeId = tvDbEpisode.Id,
|
||||
OID = 99,
|
||||
EpisodeFile = new EpisodeFile { EpisodeFileId = 69 },
|
||||
Ignored = true,
|
||||
Series = fakeSeries,
|
||||
EpisodeNumber = tvDbEpisode.EpisodeNumber,
|
||||
SeasonNumber = tvDbEpisode.SeasonNumber
|
||||
});
|
||||
}
|
||||
|
||||
@ -652,11 +651,11 @@ public void existing_episodes_keep_their_episodeId_file_id()
|
||||
.Callback<IEnumerable<Episode>>(ep => updatedEpisodes = ep.ToList());
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
updatedEpisodes.Should().HaveSameCount(tvdbSeries.Episodes);
|
||||
updatedEpisodes.Should().OnlyContain(c => c.EpisodeId == 99);
|
||||
updatedEpisodes.Should().OnlyContain(c => c.OID == 99);
|
||||
updatedEpisodes.Should().OnlyContain(c => c.EpisodeFileId == 69);
|
||||
updatedEpisodes.Should().OnlyContain(c => c.Ignored == true);
|
||||
}
|
||||
@ -677,8 +676,8 @@ public void existing_episodes_remote_their_episodeId_file_id_when_episode_number
|
||||
currentEpisodes.Add(new Episode
|
||||
{
|
||||
TvDbEpisodeId = tvDbEpisode.Id,
|
||||
EpisodeId = 99,
|
||||
EpisodeFileId = 69,
|
||||
OID = 99,
|
||||
EpisodeFile = new EpisodeFile { EpisodeFileId = 69 },
|
||||
Ignored = true,
|
||||
Series = fakeSeries,
|
||||
EpisodeNumber = tvDbEpisode.EpisodeNumber + 1,
|
||||
@ -701,7 +700,7 @@ public void existing_episodes_remote_their_episodeId_file_id_when_episode_number
|
||||
.Callback<IEnumerable<Episode>>(ep => updatedEpisodes = ep.ToList());
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
updatedEpisodes.Should().OnlyContain(c => c.EpisodeFileId == 0);
|
||||
@ -723,8 +722,8 @@ public void existing_episodes_remote_their_episodeId_file_id_when_season_number_
|
||||
currentEpisodes.Add(new Episode
|
||||
{
|
||||
TvDbEpisodeId = tvDbEpisode.Id,
|
||||
EpisodeId = 99,
|
||||
EpisodeFileId = 69,
|
||||
OID = 99,
|
||||
EpisodeFile = new EpisodeFile { EpisodeFileId = 69 },
|
||||
Ignored = true,
|
||||
Series = fakeSeries,
|
||||
EpisodeNumber = tvDbEpisode.EpisodeNumber,
|
||||
@ -747,7 +746,7 @@ public void existing_episodes_remote_their_episodeId_file_id_when_season_number_
|
||||
.Callback<IEnumerable<Episode>>(ep => updatedEpisodes = ep.ToList());
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
updatedEpisodes.Should().OnlyContain(c => c.EpisodeFileId == 0);
|
||||
@ -794,15 +793,15 @@ public void RefreshEpisodeInfo_should_ignore_new_episode_for_ignored_season()
|
||||
.Setup(c => c.GetSeries(seriesId, true, false))
|
||||
.Returns(tvdbSeries);
|
||||
|
||||
Mocker.GetMock<SeasonProvider>()
|
||||
Mocker.GetMock<SeasonRepository>()
|
||||
.Setup(s => s.IsIgnored(seriesId, It.IsAny<int>()))
|
||||
.Returns(true);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
var result = Mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList();
|
||||
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
|
||||
Mocker.GetMock<TvDbProvider>().VerifyAll();
|
||||
result.Should().HaveCount(episodeCount);
|
||||
result.Where(e => e.Ignored).Should().HaveCount(episodeCount);
|
||||
@ -820,15 +819,18 @@ public void Add_daily_show_episodes()
|
||||
|
||||
Db.Insert(Builder<QualityProfile>.CreateNew().Build());
|
||||
|
||||
var seriesRepo = Mocker.Resolve<ISeriesRepository>();
|
||||
|
||||
const int tvDbSeriesId = 71256;
|
||||
//act
|
||||
var seriesProvider = Mocker.Resolve<SeriesProvider>();
|
||||
var seriesProvider = Mocker.Resolve<SeriesService>();
|
||||
|
||||
seriesProvider.AddSeries("Test Series","c:\\test\\", tvDbSeriesId, 1, null);
|
||||
seriesProvider.AddSeries("Test Series", "c:\\test\\", tvDbSeriesId, 1, null);
|
||||
|
||||
var episodeProvider = Mocker.Resolve<EpisodeProvider>();
|
||||
episodeProvider.RefreshEpisodeInfo(seriesProvider.ge(tvDbSeriesId));
|
||||
|
||||
|
||||
var episodeProvider = Mocker.Resolve<EpisodeService>();
|
||||
episodeProvider.RefreshEpisodeInfo(seriesRepo.Get(tvDbSeriesId));
|
||||
|
||||
//assert
|
||||
var episodes = episodeProvider.GetEpisodeBySeries(tvDbSeriesId);
|
||||
@ -841,7 +843,7 @@ public void GetEpisode_by_Season_Episode_none_existing()
|
||||
WithRealDb();
|
||||
|
||||
//Act
|
||||
var episode = Mocker.Resolve<EpisodeProvider>().GetEpisode(1, 1, 1);
|
||||
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1, 1, 1);
|
||||
|
||||
//Assert
|
||||
episode.Should().BeNull();
|
||||
@ -855,14 +857,14 @@ public void GetEpisode_by_Season_Episode_with_EpisodeFile()
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = QualityTypes.SDTV).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
||||
.All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFileId = 1).With(e => e.EpisodeFile = fakeFile).Build();
|
||||
.All().With(e => e.SeriesId = 1).TheFirst(1).With(c => c.EpisodeFile = new EpisodeFile { EpisodeFileId = 1 }).With(e => e.EpisodeFile = fakeFile).Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
Db.Insert(fakeFile);
|
||||
|
||||
//Act
|
||||
var episode = Mocker.Resolve<EpisodeProvider>().GetEpisode(1, 1, 1);
|
||||
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1, 1, 1);
|
||||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
|
||||
@ -877,13 +879,13 @@ public void GetEpisode_by_Season_Episode_without_EpisodeFile()
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
||||
.All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFileId = 0).Build();
|
||||
.All().With(e => e.SeriesId = 1).TheFirst(1).Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
var episode = Mocker.Resolve<EpisodeProvider>().GetEpisode(1, 1, 1);
|
||||
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1, 1, 1);
|
||||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisodes.First());
|
||||
@ -899,14 +901,14 @@ public void GetEpisode_by_AirDate_with_EpisodeFile()
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = QualityTypes.SDTV).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
||||
.All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFileId = 1).With(e => e.EpisodeFile = fakeFile).Build();
|
||||
.All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFile = new EpisodeFile { EpisodeFileId = 1 }).With(e => e.EpisodeFile = fakeFile).Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
Db.Insert(fakeFile);
|
||||
|
||||
//Act
|
||||
var episode = Mocker.Resolve<EpisodeProvider>().GetEpisode(1, fakeEpisodes[0].AirDate.Value);
|
||||
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1, fakeEpisodes[0].AirDate.Value);
|
||||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
|
||||
@ -921,13 +923,13 @@ public void GetEpisode_by_AirDate_without_EpisodeFile()
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
||||
.All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFileId = 0).Build();
|
||||
.All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFile = new EpisodeFile { EpisodeFileId = 1 }).Build();
|
||||
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
//Act
|
||||
var episode = Mocker.Resolve<EpisodeProvider>().GetEpisode(1, fakeEpisodes[0].AirDate.Value);
|
||||
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1, fakeEpisodes[0].AirDate.Value);
|
||||
|
||||
//Assert
|
||||
episode.ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisodes.First());
|
||||
@ -947,11 +949,11 @@ public void MarkEpisodeAsFetched()
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().MarkEpisodeAsFetched(2);
|
||||
Mocker.Resolve<EpisodeService>().MarkEpisodeAsFetched(2);
|
||||
var episodes = Db.Fetch<Episode>();
|
||||
|
||||
//Assert
|
||||
episodes.Where(e => e.EpisodeId == 2).Single().GrabDate.Should().BeWithin(TimeSpan.FromSeconds(5)).Before(
|
||||
episodes.Where(e => e.OID == 2).Single().GrabDate.Should().BeWithin(TimeSpan.FromSeconds(5)).Before(
|
||||
DateTime.Now);
|
||||
|
||||
episodes.Where(e => e.GrabDate == null).Should().HaveCount(4);
|
||||
@ -979,12 +981,12 @@ public void AddEpisode_episode_is_ignored_when_full_season_is_ignored()
|
||||
.With(e => e.Ignored = false)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<SeasonProvider>()
|
||||
Mocker.GetMock<SeasonRepository>()
|
||||
.Setup(s => s.IsIgnored(newEpisode.SeriesId, newEpisode.SeasonNumber))
|
||||
.Returns(true);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().AddEpisode(newEpisode);
|
||||
Mocker.Resolve<EpisodeService>().AddEpisode(newEpisode);
|
||||
|
||||
//Assert
|
||||
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
||||
@ -1018,7 +1020,7 @@ public void AddEpisode_episode_is_not_ignored_when_full_season_is_not_ignored()
|
||||
.Build();
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().AddEpisode(newEpisode);
|
||||
Mocker.Resolve<EpisodeService>().AddEpisode(newEpisode);
|
||||
|
||||
//Assert
|
||||
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
||||
@ -1054,7 +1056,7 @@ public void AddEpisode_episode_is_not_ignored_when_not_full_season_is_not_ignore
|
||||
.Build();
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().AddEpisode(newEpisode);
|
||||
Mocker.Resolve<EpisodeService>().AddEpisode(newEpisode);
|
||||
|
||||
//Assert
|
||||
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
||||
@ -1080,7 +1082,7 @@ public void IgnoreEpisode_Ignore()
|
||||
episodes.ForEach(c => Db.Insert(c));
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().SetEpisodeIgnore(1, true);
|
||||
Mocker.Resolve<EpisodeService>().SetEpisodeIgnore(1, true);
|
||||
|
||||
//Assert
|
||||
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
||||
@ -1106,7 +1108,7 @@ public void IgnoreEpisode_RemoveIgnore()
|
||||
episodes.ForEach(c => Db.Insert(c));
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().SetEpisodeIgnore(1, false);
|
||||
Mocker.Resolve<EpisodeService>().SetEpisodeIgnore(1, false);
|
||||
|
||||
//Assert
|
||||
var episodesInDb = Db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
||||
@ -1133,7 +1135,6 @@ public void EpisodesWithoutFiles_no_specials()
|
||||
.With(c => c.AirDate = DateTime.Today.AddDays(-4))
|
||||
.With(c => c.Ignored = true)
|
||||
.TheFirst(2)
|
||||
.With(c => c.EpisodeFileId = 0)
|
||||
.Section(1, 2)
|
||||
.With(c => c.Ignored = false)
|
||||
.Build().ToList();
|
||||
@ -1143,7 +1144,6 @@ public void EpisodesWithoutFiles_no_specials()
|
||||
.With(c => c.SeriesId = 10)
|
||||
.With(c => c.SeasonNumber = 0)
|
||||
.With(c => c.AirDate = DateTime.Today.AddDays(-4))
|
||||
.With(c => c.EpisodeFileId = 0)
|
||||
.With(c => c.Ignored = false)
|
||||
.TheFirst(1).With(c => c.Ignored = true)
|
||||
.Build().ToList();
|
||||
@ -1153,7 +1153,7 @@ public void EpisodesWithoutFiles_no_specials()
|
||||
Db.InsertMany(specials);
|
||||
|
||||
//Act
|
||||
var missingFiles = Mocker.Resolve<EpisodeProvider>().EpisodesWithoutFiles(false);
|
||||
var missingFiles = Mocker.Resolve<EpisodeService>().EpisodesWithoutFiles(false);
|
||||
|
||||
//Assert
|
||||
missingFiles.Should().HaveCount(1);
|
||||
@ -1178,7 +1178,6 @@ public void EpisodesWithoutFiles_with_specials()
|
||||
.With(c => c.AirDate = DateTime.Today.AddDays(-4))
|
||||
.With(c => c.Ignored = true)
|
||||
.TheFirst(2)
|
||||
.With(c => c.EpisodeFileId = 0)
|
||||
.Section(1, 2)
|
||||
.With(c => c.Ignored = false)
|
||||
.Build().ToList();
|
||||
@ -1188,7 +1187,6 @@ public void EpisodesWithoutFiles_with_specials()
|
||||
.With(c => c.SeriesId = 10)
|
||||
.With(c => c.SeasonNumber = 0)
|
||||
.With(c => c.AirDate = DateTime.Today.AddDays(-4))
|
||||
.With(c => c.EpisodeFileId = 0)
|
||||
.With(c => c.Ignored = false)
|
||||
.TheFirst(1)
|
||||
.With(c => c.Ignored = true)
|
||||
@ -1199,7 +1197,7 @@ public void EpisodesWithoutFiles_with_specials()
|
||||
Db.InsertMany(specials);
|
||||
|
||||
//Act
|
||||
var missingFiles = Mocker.Resolve<EpisodeProvider>().EpisodesWithoutFiles(true);
|
||||
var missingFiles = Mocker.Resolve<EpisodeService>().EpisodesWithoutFiles(true);
|
||||
|
||||
//Assert
|
||||
missingFiles.Should().HaveCount(2);
|
||||
@ -1229,7 +1227,6 @@ public void EpisodesWithFiles_success()
|
||||
.With(c => c.AirDate = DateTime.Today.AddDays(-4))
|
||||
.With(c => c.Ignored = true)
|
||||
.With(c => c.EpisodeFile = episodeFile)
|
||||
.With(c => c.EpisodeFileId = episodeFile.EpisodeFileId)
|
||||
.Build().ToList();
|
||||
|
||||
Db.Insert(series);
|
||||
@ -1237,7 +1234,7 @@ public void EpisodesWithFiles_success()
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
//Act
|
||||
var withFiles = Mocker.Resolve<EpisodeProvider>().EpisodesWithFiles();
|
||||
var withFiles = Mocker.Resolve<EpisodeService>().EpisodesWithFiles();
|
||||
|
||||
//Assert
|
||||
withFiles.Should().HaveCount(2);
|
||||
@ -1268,14 +1265,13 @@ public void EpisodesWithFiles_no_files()
|
||||
.With(c => c.SeasonNumber = 1)
|
||||
.With(c => c.AirDate = DateTime.Today.AddDays(-4))
|
||||
.With(c => c.Ignored = true)
|
||||
.With(c => c.EpisodeFileId = 0)
|
||||
.Build().ToList();
|
||||
|
||||
Db.Insert(series);
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
//Act
|
||||
var withFiles = Mocker.Resolve<EpisodeProvider>().EpisodesWithFiles();
|
||||
var withFiles = Mocker.Resolve<EpisodeService>().EpisodesWithFiles();
|
||||
|
||||
//Assert
|
||||
withFiles.Should().HaveCount(0);
|
||||
@ -1296,14 +1292,14 @@ public void GetEpisodesByFileId_multi_episodes()
|
||||
.All()
|
||||
.With(c => c.SeriesId = 10)
|
||||
.With(c => c.SeasonNumber = 1)
|
||||
.With(c => c.EpisodeFileId = 12345)
|
||||
.With(c => c.EpisodeFile = new EpisodeFile { EpisodeFileId = 12345 })
|
||||
.Build();
|
||||
|
||||
Db.Insert(series);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
var episodes = Mocker.Resolve<EpisodeProvider>().GetEpisodesByFileId(12345);
|
||||
var episodes = Mocker.Resolve<EpisodeService>().GetEpisodesByFileId(12345);
|
||||
|
||||
//Assert
|
||||
episodes.Should().HaveCount(2);
|
||||
@ -1322,14 +1318,14 @@ public void GetEpisodesByFileId_single_episode()
|
||||
var fakeEpisode = Builder<Episode>.CreateNew()
|
||||
.With(c => c.SeriesId = 10)
|
||||
.With(c => c.SeasonNumber = 1)
|
||||
.With(c => c.EpisodeFileId = 12345)
|
||||
.With(c => c.EpisodeFile = new EpisodeFile { EpisodeFileId = 12345 })
|
||||
.Build();
|
||||
|
||||
Db.Insert(series);
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
//Act
|
||||
var episodes = Mocker.Resolve<EpisodeProvider>().GetEpisodesByFileId(12345);
|
||||
var episodes = Mocker.Resolve<EpisodeService>().GetEpisodesByFileId(12345);
|
||||
|
||||
//Assert
|
||||
episodes.Should().HaveCount(1);
|
||||
@ -1351,7 +1347,7 @@ public void IsFirstOrLastEpisodeInSeason_false()
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<EpisodeProvider>().IsFirstOrLastEpisodeOfSeason(10, 1, 5);
|
||||
var result = Mocker.Resolve<EpisodeService>().IsFirstOrLastEpisodeOfSeason(10, 1, 5);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
@ -1371,7 +1367,7 @@ public void IsFirstOrLastEpisodeInSeason_true_first()
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<EpisodeProvider>().IsFirstOrLastEpisodeOfSeason(10, 1, 1);
|
||||
var result = Mocker.Resolve<EpisodeService>().IsFirstOrLastEpisodeOfSeason(10, 1, 1);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
@ -1391,7 +1387,7 @@ public void IsFirstOrLastEpisodeInSeason_true_last()
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<EpisodeProvider>().IsFirstOrLastEpisodeOfSeason(10, 1, 10);
|
||||
var result = Mocker.Resolve<EpisodeService>().IsFirstOrLastEpisodeOfSeason(10, 1, 10);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
@ -1422,10 +1418,10 @@ public void SetPostDownloadStatus(string folderName, PostDownloadStatusType post
|
||||
Db.Insert(fakeSeries);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get("officeus")).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle("officeus")).Returns(fakeSeries);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().SetPostDownloadStatus(fakeEpisodes.Select(e => e.EpisodeId).ToList(), postDownloadStatus);
|
||||
Mocker.Resolve<EpisodeService>().SetPostDownloadStatus(fakeEpisodes.Select(e => e.OID).ToList(), postDownloadStatus);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
@ -1454,10 +1450,10 @@ public void SetPostDownloadStatus_Invalid_EpisodeId()
|
||||
Db.Insert(fakeSeries);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.Get("officeus")).Returns(fakeSeries);
|
||||
Mocker.GetMock<ISeriesRepository>().Setup(s => s.GetByTitle("officeus")).Returns(fakeSeries);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().SetPostDownloadStatus(new List<int> { 300 }, postDownloadStatus);
|
||||
Mocker.Resolve<EpisodeService>().SetPostDownloadStatus(new List<int> { 300 }, postDownloadStatus);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
@ -1468,7 +1464,7 @@ public void SetPostDownloadStatus_Invalid_EpisodeId()
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void SetPostDownloadStatus_should_throw_if_episode_list_is_empty()
|
||||
{
|
||||
Mocker.Resolve<EpisodeProvider>().SetPostDownloadStatus(new List<int>(), PostDownloadStatusType.Failed);
|
||||
Mocker.Resolve<EpisodeService>().SetPostDownloadStatus(new List<int>(), PostDownloadStatusType.Failed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -1508,10 +1504,10 @@ public void RefreshEpisodeInfo_should_ignore_episode_zero_except_if_season_one()
|
||||
.Returns(tvdbSeries);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
|
||||
Mocker.Resolve<EpisodeService>().RefreshEpisodeInfo(fakeSeries);
|
||||
|
||||
//Assert
|
||||
var result = Mocker.Resolve<EpisodeProvider>().GetEpisodeBySeries(seriesId).ToList();
|
||||
var result = Mocker.Resolve<EpisodeService>().GetEpisodeBySeries(seriesId).ToList();
|
||||
result.Should().HaveCount(episodeCount);
|
||||
result.Where(e => e.Ignored).Should().HaveCount(episodeCount - 1);
|
||||
result.Single(e => e.SeasonNumber == 1).Ignored.Should().BeFalse();
|
||||
@ -1525,14 +1521,14 @@ public void GetEpisode_with_EpisodeFile_should_have_quality_set_properly()
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.EpisodeFileId).With(c => c.Quality = QualityTypes.WEBDL1080p).Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
||||
.All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFileId = 1).With(e => e.EpisodeFile = fakeFile).Build();
|
||||
.All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFile = new EpisodeFile { EpisodeFileId = 1 }).With(e => e.EpisodeFile = fakeFile).Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.InsertMany(fakeEpisodes);
|
||||
Db.Insert(fakeFile);
|
||||
|
||||
//Act
|
||||
var episode = Mocker.Resolve<EpisodeProvider>().GetEpisode(1);
|
||||
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1);
|
||||
|
||||
//Assert
|
||||
episode.EpisodeFile.Quality.Should().Be(QualityTypes.WEBDL1080p);
|
||||
|
@ -45,7 +45,7 @@ public void Delete_None_Valid_TvDbEpisodeId()
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
Mocker.Resolve<EpisodeService>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
@ -81,7 +81,7 @@ public void Delete_None_TvDbEpisodeId_is_zero()
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
Mocker.Resolve<EpisodeService>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
@ -115,7 +115,7 @@ public void Delete_None_TvDbEpisodeId_is_null()
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
Mocker.Resolve<EpisodeService>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
@ -153,7 +153,7 @@ public void Delete_TvDbId()
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
Mocker.Resolve<EpisodeService>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
@ -206,7 +206,7 @@ public void Delete_TvDbId_multiple_series()
|
||||
Db.Insert(otherFakeEpisode);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
Mocker.Resolve<EpisodeService>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Episode>();
|
||||
@ -220,7 +220,7 @@ public void should_not_do_anything_if_episode_list_is_empty()
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
|
||||
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, new List<TvdbEpisode>());
|
||||
Mocker.Resolve<EpisodeService>().DeleteEpisodesNotInTvdb(fakeSeries, new List<TvdbEpisode>());
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EpisodeProviderTest_GetEpisodesByParseResult : SqlCeTest
|
||||
{
|
||||
private EpisodeProvider episodeProvider;
|
||||
private EpisodeService episodeService;
|
||||
|
||||
private Series fakeSeries;
|
||||
private Series fakeDailySeries;
|
||||
@ -32,7 +32,7 @@ public void Setup()
|
||||
fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
|
||||
fakeDailySeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.IsDaily = true)
|
||||
.With(c => c.SeriesType = SeriesType.Daily)
|
||||
.Build();
|
||||
|
||||
fakeEpisode = Builder<Episode>.CreateNew()
|
||||
@ -55,7 +55,7 @@ public void Setup()
|
||||
|
||||
WithRealDb();
|
||||
|
||||
episodeProvider = Mocker.Resolve<EpisodeProvider>();
|
||||
episodeService = Mocker.Resolve<EpisodeService>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -71,7 +71,7 @@ public void existing_single_episode_should_return_single_existing_episode()
|
||||
EpisodeNumbers = new List<int> { fakeEpisode.EpisodeNumber }
|
||||
};
|
||||
|
||||
var ep = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
var ep = episodeService.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
ep.Should().HaveCount(1);
|
||||
parseResult.EpisodeTitle.Should().Be(fakeEpisode.Title);
|
||||
@ -89,7 +89,7 @@ public void single_none_existing_episode_should_return_nothing_and_add_nothing()
|
||||
EpisodeNumbers = new List<int> { 10 }
|
||||
};
|
||||
|
||||
var episode = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
var episode = episodeService.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
episode.Should().BeEmpty();
|
||||
Db.Fetch<Episode>().Should().HaveCount(0);
|
||||
@ -105,7 +105,7 @@ public void single_none_existing_series_should_return_nothing_and_add_nothing()
|
||||
EpisodeNumbers = new List<int> { 10 }
|
||||
};
|
||||
|
||||
var episode = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
var episode = episodeService.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
episode.Should().BeEmpty();
|
||||
Db.Fetch<Episode>().Should().HaveCount(0);
|
||||
@ -126,7 +126,7 @@ public void existing_multi_episode_should_return_all_episodes()
|
||||
EpisodeNumbers = new List<int> { fakeEpisode.EpisodeNumber, fakeEpisode2.EpisodeNumber }
|
||||
};
|
||||
|
||||
var ep = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
var ep = episodeService.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
ep.Should().HaveCount(2);
|
||||
Db.Fetch<Episode>().Should().HaveCount(2);
|
||||
@ -149,7 +149,7 @@ public void none_existing_multi_episode_should_not_return_or_add_anything()
|
||||
EpisodeNumbers = new List<int> { fakeEpisode.EpisodeNumber, fakeEpisode2.EpisodeNumber }
|
||||
};
|
||||
|
||||
var ep = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
var ep = episodeService.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
ep.Should().BeEmpty();
|
||||
Db.Fetch<Episode>().Should().BeEmpty();
|
||||
@ -160,7 +160,7 @@ public void none_existing_multi_episode_should_not_return_or_add_anything()
|
||||
public void GetEpisodeParseResult_should_return_empty_list_if_episode_list_is_null()
|
||||
{
|
||||
//Act
|
||||
var episodes = episodeProvider.GetEpisodesByParseResult(new EpisodeParseResult());
|
||||
var episodes = episodeService.GetEpisodesByParseResult(new EpisodeParseResult());
|
||||
//Assert
|
||||
episodes.Should().NotBeNull();
|
||||
episodes.Should().BeEmpty();
|
||||
@ -170,7 +170,7 @@ public void GetEpisodeParseResult_should_return_empty_list_if_episode_list_is_nu
|
||||
public void GetEpisodeParseResult_should_return_empty_list_if_episode_list_is_empty()
|
||||
{
|
||||
//Act
|
||||
var episodes = episodeProvider.GetEpisodesByParseResult(new EpisodeParseResult { EpisodeNumbers = new List<int>() });
|
||||
var episodes = episodeService.GetEpisodesByParseResult(new EpisodeParseResult { EpisodeNumbers = new List<int>() });
|
||||
//Assert
|
||||
episodes.Should().NotBeNull();
|
||||
episodes.Should().BeEmpty();
|
||||
@ -184,7 +184,7 @@ public void should_return_single_episode_when_air_date_is_provided()
|
||||
Db.Insert(fakeDailyEpisode);
|
||||
|
||||
//Act
|
||||
var episodes = episodeProvider.GetEpisodesByParseResult(new EpisodeParseResult { AirDate = DateTime.Today, Series = fakeDailySeries });
|
||||
var episodes = episodeService.GetEpisodesByParseResult(new EpisodeParseResult { AirDate = DateTime.Today, Series = fakeDailySeries });
|
||||
|
||||
//Assert
|
||||
episodes.Should().HaveCount(1);
|
||||
@ -196,7 +196,7 @@ public void should_return_single_episode_when_air_date_is_provided()
|
||||
[Test]
|
||||
public void should_not_add_episode_when_episode_doesnt_exist()
|
||||
{
|
||||
var episodes = episodeProvider.GetEpisodesByParseResult(new EpisodeParseResult { AirDate = DateTime.Today, Series = fakeDailySeries });
|
||||
var episodes = episodeService.GetEpisodesByParseResult(new EpisodeParseResult { AirDate = DateTime.Today, Series = fakeDailySeries });
|
||||
|
||||
//Assert
|
||||
episodes.Should().HaveCount(0);
|
||||
@ -218,7 +218,7 @@ public void GetEpisodeParseResult_should_return_single_title_for_multiple_episod
|
||||
EpisodeNumbers = new List<int> { fakeEpisode.EpisodeNumber, fakeEpisode2.EpisodeNumber }
|
||||
};
|
||||
|
||||
var ep = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
var ep = episodeService.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
ep.Should().HaveCount(2);
|
||||
Db.Fetch<Episode>().Should().HaveCount(2);
|
||||
@ -242,7 +242,7 @@ public void GetEpisodeParseResult_should_return_single_title_for_single_episode(
|
||||
EpisodeNumbers = new List<int> { fakeEpisode.EpisodeNumber }
|
||||
};
|
||||
|
||||
var ep = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
var ep = episodeService.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
ep.Should().HaveCount(1);
|
||||
Db.Fetch<Episode>().Should().HaveCount(1);
|
||||
@ -261,7 +261,7 @@ public void GetEpisodeParseResult_should_return_nothing_when_series_is_not_daily
|
||||
AirDate = DateTime.Today
|
||||
};
|
||||
|
||||
var ep = episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
var ep = episodeService.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
ep.Should().BeEmpty();
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
|
@ -52,14 +52,14 @@ public void WithSceneNumbering()
|
||||
[Test]
|
||||
public void should_return_null_if_no_episodes_in_db()
|
||||
{
|
||||
Mocker.Resolve<EpisodeProvider>().GetEpisodeBySceneNumbering(_series.SeriesId, 1, 1).Should().BeNull();
|
||||
Mocker.Resolve<EpisodeService>().GetEpisodeBySceneNumbering(_series.SeriesId, 1, 1).Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_null_if_no_matching_episode_is_found()
|
||||
{
|
||||
WithNullSceneNumbering();
|
||||
Mocker.Resolve<EpisodeProvider>().GetEpisodeBySceneNumbering(_series.SeriesId, 1, 1).Should().BeNull();
|
||||
Mocker.Resolve<EpisodeService>().GetEpisodeBySceneNumbering(_series.SeriesId, 1, 1).Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -67,10 +67,10 @@ public void should_return_episode_if_matching_episode_is_found()
|
||||
{
|
||||
WithSceneNumbering();
|
||||
|
||||
var result = Mocker.Resolve<EpisodeProvider>()
|
||||
var result = Mocker.Resolve<EpisodeService>()
|
||||
.GetEpisodeBySceneNumbering(_series.SeriesId, _episode.SceneSeasonNumber, _episode.SceneEpisodeNumber);
|
||||
|
||||
result.EpisodeId.Should().Be(_episode.EpisodeId);
|
||||
result.OID.Should().Be(_episode.OID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public void SetIgnore_should_update_ignored_status(bool ignoreFlag)
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.All()
|
||||
.With(c => c.SeriesId = fakeSeason.SeriesId)
|
||||
.With(c => c.SeasonNumber = fakeSeason.SeasonId)
|
||||
.With(c => c.SeasonNumber = fakeSeason.OID)
|
||||
.With(c => c.Ignored = !ignoreFlag)
|
||||
.Build().ToList();
|
||||
|
||||
@ -42,7 +42,7 @@ public void SetIgnore_should_update_ignored_status(bool ignoreFlag)
|
||||
var id = Db.Insert(fakeSeason);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SeasonProvider>().SetIgnore(fakeSeason.SeriesId, fakeSeason.SeasonNumber, ignoreFlag);
|
||||
Mocker.Resolve<ISeasonService>().SetIgnore(fakeSeason.SeriesId, fakeSeason.SeasonNumber, ignoreFlag);
|
||||
|
||||
//Assert
|
||||
var season = Db.SingleOrDefault<Season>(id);
|
||||
@ -65,7 +65,7 @@ public void IsIgnored_should_return_ignored_status_of_season(bool ignoreFlag)
|
||||
Db.Insert(fakeSeason);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SeasonProvider>().IsIgnored(fakeSeason.SeriesId, fakeSeason.SeasonNumber);
|
||||
var result = Mocker.Resolve<SeasonRepository>().IsIgnored(fakeSeason.SeriesId, fakeSeason.SeasonNumber);
|
||||
|
||||
//Assert
|
||||
result.Should().Be(ignoreFlag);
|
||||
@ -74,7 +74,7 @@ public void IsIgnored_should_return_ignored_status_of_season(bool ignoreFlag)
|
||||
[Test]
|
||||
public void IsIgnored_should_throw_an_exception_if_not_in_db()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => Mocker.Resolve<SeasonProvider>().IsIgnored(10, 0));
|
||||
Assert.Throws<InvalidOperationException>(() => Mocker.Resolve<SeasonRepository>().IsIgnored(10, 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -98,7 +98,7 @@ public void All_should_return_seasons_with_episodes()
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SeasonProvider>().All(seriesId);
|
||||
var result = Mocker.Resolve<SeasonRepository>().GetSeasonBySeries(seriesId);
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(1);
|
||||
@ -135,7 +135,7 @@ public void All_should_return_all_seasons_with_episodes()
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SeasonProvider>().All(seriesId);
|
||||
var result = Mocker.Resolve<SeasonRepository>().GetSeasonBySeries(seriesId);
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(5);
|
||||
@ -147,46 +147,7 @@ public void All_should_return_all_seasons_with_episodes()
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EnsureSeason_should_add_all_seasons_for_new_series()
|
||||
{
|
||||
var seasons = new[] { 0, 1, 2, 3, 4, 5 };
|
||||
Mocker.Resolve<SeasonProvider>().EnsureSeasons(12, seasons);
|
||||
|
||||
Mocker.Resolve<SeasonProvider>().GetSeasons(12).SequenceEqual(seasons);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EnsureSeason_should_add_missing_seasons()
|
||||
{
|
||||
var seasonsA = new[] { 0, 1, 2, 3 };
|
||||
var seasonsB = new[] { 0, 1, 2, 3, 4, 5 };
|
||||
Mocker.Resolve<SeasonProvider>().EnsureSeasons(12, seasonsA);
|
||||
Mocker.Resolve<SeasonProvider>().GetSeasons(12).SequenceEqual(seasonsA);
|
||||
|
||||
Mocker.Resolve<SeasonProvider>().EnsureSeasons(12, seasonsB);
|
||||
Mocker.Resolve<SeasonProvider>().GetSeasons(12).SequenceEqual(seasonsB);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void EnsureSeason_marks_season_zero_as_ignored()
|
||||
{
|
||||
var seasons = new[] { 0, 1, 2, 3 };
|
||||
|
||||
Mocker.Resolve<SeasonProvider>().EnsureSeasons(12, seasons);
|
||||
Db.Fetch<Season>().Should().Contain(c => c.SeasonNumber == 0 && c.Ignored);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void EnsureSeason_none_zero_seasons_arent_ignored()
|
||||
{
|
||||
var seasons = new[] { 1, 2, 3 };
|
||||
|
||||
Mocker.Resolve<SeasonProvider>().EnsureSeasons(12, seasons);
|
||||
Db.Fetch<Season>().Should().OnlyContain(c => c.Ignored == false);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void GetSeason_should_return_seasons_for_specified_series_only()
|
||||
@ -194,18 +155,15 @@ public void GetSeason_should_return_seasons_for_specified_series_only()
|
||||
var seriesA = new[] { 1, 2, 3 };
|
||||
var seriesB = new[] { 4, 5, 6 };
|
||||
|
||||
Mocker.Resolve<SeasonProvider>().EnsureSeasons(1, seriesA);
|
||||
Mocker.Resolve<SeasonProvider>().EnsureSeasons(2, seriesB);
|
||||
|
||||
Mocker.Resolve<SeasonProvider>().GetSeasons(1).Should().Equal(seriesA);
|
||||
Mocker.Resolve<SeasonProvider>().GetSeasons(2).Should().Equal(seriesB);
|
||||
Mocker.Resolve<SeasonRepository>().GetSeasonNumbers(1).Should().Equal(seriesA);
|
||||
Mocker.Resolve<SeasonRepository>().GetSeasonNumbers(2).Should().Equal(seriesB);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void GetSeason_should_return_emptylist_if_series_doesnt_exist()
|
||||
{
|
||||
Mocker.Resolve<SeasonProvider>().GetSeasons(1).Should().BeEmpty();
|
||||
Mocker.Resolve<SeasonRepository>().GetSeasonNumbers(1).Should().BeEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
Binary file not shown.
@ -1,244 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Test
|
||||
{
|
||||
[TestFixture]
|
||||
[Explicit]
|
||||
[Category("Benchmark")]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class DbBenchmark : SqlCeTest
|
||||
{
|
||||
const int Episodes_Per_Season = 20;
|
||||
private readonly List<int> seasonsNumbers = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
private readonly List<int> seriesIds = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
|
||||
private readonly List<Episode> episodes = new List<Episode>();
|
||||
private readonly List<EpisodeFile> files = new List<EpisodeFile>();
|
||||
private IDatabase db;
|
||||
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
int currentFileId = 0;
|
||||
|
||||
|
||||
var qulityProfile = new QualityProfile
|
||||
{
|
||||
Name = "TestProfile",
|
||||
Allowed = new List<QualityTypes> { QualityTypes.DVD, QualityTypes.Bluray1080p },
|
||||
Cutoff = QualityTypes.DVD
|
||||
};
|
||||
Db.Insert(qulityProfile);
|
||||
|
||||
foreach (var _seriesId in seriesIds)
|
||||
{
|
||||
int seriesId = _seriesId;
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.SeriesId = seriesId)
|
||||
.With(s => s.Monitored = true)
|
||||
.Build();
|
||||
|
||||
Db.Insert(series);
|
||||
|
||||
foreach (var _seasonNumber in seasonsNumbers)
|
||||
{
|
||||
for (int i = 1; i <= Episodes_Per_Season; i++)
|
||||
{
|
||||
var epFileId = 0;
|
||||
|
||||
if (i < 10)
|
||||
{
|
||||
var epFile = Builder<EpisodeFile>.CreateNew()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.And(e => e.SeasonNumber = _seasonNumber)
|
||||
.And(e => e.Path = Guid.NewGuid().ToString())
|
||||
.Build();
|
||||
|
||||
files.Add(epFile);
|
||||
|
||||
currentFileId++;
|
||||
epFileId = currentFileId;
|
||||
|
||||
}
|
||||
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.SeriesId = seriesId)
|
||||
.And(e => e.SeasonNumber = _seasonNumber)
|
||||
.And(e => e.EpisodeNumber = i)
|
||||
.And(e => e.Ignored = false)
|
||||
.And(e => e.TvDbEpisodeId = episodes.Count + 1)
|
||||
.And(e => e.EpisodeFileId = epFileId)
|
||||
.And(e => e.AirDate = DateTime.Today.AddDays(-20))
|
||||
.Build();
|
||||
|
||||
episodes.Add(episode);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Db.InsertMany(episodes);
|
||||
Db.InsertMany(files);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void get_episode_by_series_seasons_episode_x5000()
|
||||
{
|
||||
|
||||
Mocker.SetConstant(db);
|
||||
Mocker.Resolve<SeriesProvider>();
|
||||
|
||||
var epProvider = Mocker.Resolve<EpisodeProvider>();
|
||||
|
||||
Thread.Sleep(1000);
|
||||
|
||||
var random = new Random();
|
||||
Console.WriteLine("Starting Test");
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
for (int i = 0; i < 5000; i++)
|
||||
{
|
||||
var ep = epProvider.GetEpisode(6, random.Next(2, 5), random.Next(2, Episodes_Per_Season - 10));
|
||||
ep.Series.Should().NotBeNull();
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
|
||||
Console.WriteLine("Took " + sw.Elapsed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void get_episode_by_series_seasons_x1000()
|
||||
{
|
||||
|
||||
Mocker.SetConstant(db);
|
||||
Mocker.Resolve<SeriesProvider>();
|
||||
|
||||
var epProvider = Mocker.Resolve<EpisodeProvider>();
|
||||
|
||||
|
||||
Thread.Sleep(1000);
|
||||
|
||||
|
||||
var random = new Random();
|
||||
Console.WriteLine("Starting Test");
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
epProvider.GetEpisodesBySeason(6, random.Next(2, 5)).Should().NotBeNull();
|
||||
}
|
||||
|
||||
|
||||
sw.Stop();
|
||||
|
||||
Console.WriteLine("Took " + sw.Elapsed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void get_episode_file_count_x100()
|
||||
{
|
||||
|
||||
Mocker.SetConstant(db);
|
||||
Mocker.Resolve<SeriesProvider>();
|
||||
Mocker.Resolve<EpisodeProvider>();
|
||||
var mediaProvider = Mocker.Resolve<MediaFileProvider>();
|
||||
|
||||
|
||||
Thread.Sleep(1000);
|
||||
|
||||
|
||||
var random = new Random();
|
||||
Console.WriteLine("Starting Test");
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
mediaProvider.GetEpisodeFilesCount(random.Next(1, 5)).Should().NotBeNull();
|
||||
}
|
||||
|
||||
|
||||
sw.Stop();
|
||||
|
||||
Console.WriteLine("Took " + sw.Elapsed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void get_episode_file_count_x1000()
|
||||
{
|
||||
|
||||
Mocker.SetConstant(db);
|
||||
Mocker.Resolve<SeriesProvider>();
|
||||
Mocker.Resolve<EpisodeProvider>();
|
||||
var mediaProvider = Mocker.Resolve<MediaFileProvider>();
|
||||
|
||||
|
||||
Thread.Sleep(1000);
|
||||
|
||||
|
||||
var random = new Random();
|
||||
Console.WriteLine("Starting Test");
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
mediaProvider.GetEpisodeFilesCount(random.Next(1, 5)).Should().NotBeNull();
|
||||
}
|
||||
|
||||
|
||||
sw.Stop();
|
||||
|
||||
Console.WriteLine("Took " + sw.Elapsed);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void get_season_count_x500()
|
||||
{
|
||||
|
||||
Mocker.SetConstant(db);
|
||||
var provider = Mocker.Resolve<EpisodeProvider>();
|
||||
|
||||
|
||||
Thread.Sleep(1000);
|
||||
|
||||
|
||||
var random = new Random();
|
||||
Console.WriteLine("Starting Test");
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
provider.GetSeasons(random.Next(1, 10)).Should().HaveSameCount(seasonsNumbers);
|
||||
}
|
||||
|
||||
|
||||
sw.Stop();
|
||||
|
||||
Console.WriteLine("Took " + sw.Elapsed);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -11,6 +11,8 @@ public interface IBasicRepository<TModel>
|
||||
TModel Update(TModel model);
|
||||
TModel Upsert(TModel model);
|
||||
void Delete(int id);
|
||||
IList<TModel> InsertMany(IList<TModel> model);
|
||||
IList<TModel> UpdateMany(IList<TModel> model);
|
||||
}
|
||||
|
||||
public class BasicRepository<TModel> : IBasicRepository<TModel> where TModel : ModelBase, new()
|
||||
@ -44,6 +46,16 @@ public TModel Update(TModel model)
|
||||
return ObjectDatabase.Update(model);
|
||||
}
|
||||
|
||||
public IList<TModel> InsertMany(IList<TModel> model)
|
||||
{
|
||||
return ObjectDatabase.InsertMany(model);
|
||||
}
|
||||
|
||||
public IList<TModel> UpdateMany(IList<TModel> model)
|
||||
{
|
||||
return ObjectDatabase.UpdateMany(model);
|
||||
}
|
||||
|
||||
public TModel Upsert(TModel model)
|
||||
{
|
||||
if(model.OID == 0)
|
||||
|
@ -22,7 +22,7 @@ public Season MapIt(Season season, Episode episode, EpisodeFile episodeFile)
|
||||
episode.EpisodeFile = (episode.EpisodeFileId == 0 ? null : episodeFile);
|
||||
|
||||
// Is this the same season as the current one we're processing
|
||||
if (_current != null && _current.SeasonId == season.SeasonId)
|
||||
if (_current != null && _current.OID == season.OID)
|
||||
{
|
||||
// Yes, just add this post to the current author's collection of posts
|
||||
_current.Episodes.Add(episode);
|
||||
|
@ -10,13 +10,13 @@ namespace NzbDrone.Core.DecisionEngine
|
||||
public class AcceptableSizeSpecification
|
||||
{
|
||||
private readonly QualityTypeProvider _qualityTypeProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public AcceptableSizeSpecification(QualityTypeProvider qualityTypeProvider, EpisodeProvider episodeProvider)
|
||||
public AcceptableSizeSpecification(QualityTypeProvider qualityTypeProvider, EpisodeService episodeService)
|
||||
{
|
||||
_qualityTypeProvider = qualityTypeProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
}
|
||||
|
||||
public AcceptableSizeSpecification()
|
||||
@ -56,7 +56,7 @@ public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
||||
//Check if there was only one episode parsed
|
||||
//and it is the first or last episode of the season
|
||||
if (subject.EpisodeNumbers != null && subject.EpisodeNumbers.Count == 1 &&
|
||||
_episodeProvider.IsFirstOrLastEpisodeOfSeason(series.SeriesId,
|
||||
_episodeService.IsFirstOrLastEpisodeOfSeason(series.SeriesId,
|
||||
subject.SeasonNumber, subject.EpisodeNumbers[0]))
|
||||
{
|
||||
maxSize = maxSize * 2;
|
||||
|
@ -8,15 +8,13 @@ namespace NzbDrone.Core.DecisionEngine
|
||||
{
|
||||
public class MonitoredEpisodeSpecification
|
||||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public MonitoredEpisodeSpecification(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, ISeriesRepository seriesRepository)
|
||||
public MonitoredEpisodeSpecification(EpisodeService episodeService, ISeriesRepository seriesRepository)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
@ -27,7 +25,7 @@ public MonitoredEpisodeSpecification()
|
||||
|
||||
public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
||||
{
|
||||
var series = _seriesRepository.Get(subject.CleanTitle);
|
||||
var series = _seriesRepository.GetByTitle(subject.CleanTitle);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
@ -43,7 +41,7 @@ public virtual bool IsSatisfiedBy(EpisodeParseResult subject)
|
||||
return false;
|
||||
}
|
||||
|
||||
var episodes = _episodeProvider.GetEpisodesByParseResult(subject);
|
||||
var episodes = _episodeService.GetEpisodesByParseResult(subject);
|
||||
subject.Episodes = episodes;
|
||||
|
||||
//return monitored if any of the episodes are monitored
|
||||
|
@ -8,14 +8,14 @@ namespace NzbDrone.Core.DecisionEngine
|
||||
{
|
||||
public class UpgradeHistorySpecification
|
||||
{
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly HistoryProvider _historyProvider;
|
||||
private readonly QualityUpgradeSpecification _qualityUpgradeSpecification;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public UpgradeHistorySpecification(EpisodeProvider episodeProvider, HistoryProvider historyProvider, QualityUpgradeSpecification qualityUpgradeSpecification)
|
||||
public UpgradeHistorySpecification(EpisodeService episodeService, HistoryProvider historyProvider, QualityUpgradeSpecification qualityUpgradeSpecification)
|
||||
{
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
_historyProvider = historyProvider;
|
||||
_qualityUpgradeSpecification = qualityUpgradeSpecification;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ protected override void AttachToComponentRegistration(IComponentRegistry registr
|
||||
{
|
||||
registration.Preparing += OnComponentPreparing;
|
||||
}
|
||||
|
||||
static void OnComponentPreparing(object sender, PreparingEventArgs e)
|
||||
{
|
||||
e.Parameters = e.Parameters.Union(new[]
|
||||
@ -19,7 +20,7 @@ static void OnComponentPreparing(object sender, PreparingEventArgs e)
|
||||
new ResolvedParameter((p, i) => p.ParameterType == typeof(Logger), (p,i)=> GetLogger(p.Member.DeclaringType))
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private static object GetLogger(Type type)
|
||||
{
|
||||
const string STRING_TO_REMOVE = "NzbDrone";
|
||||
|
@ -13,17 +13,17 @@ namespace NzbDrone.Core.Jobs
|
||||
{
|
||||
public class BacklogSearchJob : IJob
|
||||
{
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly EpisodeSearchJob _episodeSearchJob;
|
||||
private readonly SeasonSearchJob _seasonSearchJob;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public BacklogSearchJob(EpisodeProvider episodeProvider, EpisodeSearchJob episodeSearchJob,
|
||||
public BacklogSearchJob(EpisodeService episodeService, EpisodeSearchJob episodeSearchJob,
|
||||
SeasonSearchJob seasonSearchJob, ConfigProvider configProvider)
|
||||
{
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
_episodeSearchJob = episodeSearchJob;
|
||||
_seasonSearchJob = seasonSearchJob;
|
||||
_configProvider = configProvider;
|
||||
@ -60,7 +60,7 @@ public void Start(ProgressNotification notification, dynamic options)
|
||||
var seriesId = group.Key.SeriesId;
|
||||
var seasonNumber = group.Key.SeasonNumber;
|
||||
|
||||
var countInDb = _episodeProvider.GetEpisodeNumbersBySeason(seriesId, seasonNumber).Count;
|
||||
var countInDb = _episodeService.GetEpisodeNumbersBySeason(seriesId, seasonNumber).Count;
|
||||
|
||||
//Todo: Download a full season if more than n% is missing?
|
||||
|
||||
@ -83,7 +83,7 @@ public void Start(ProgressNotification notification, dynamic options)
|
||||
//Process the list of remaining episodes, 1 by 1
|
||||
foreach (var episode in individualEpisodes)
|
||||
{
|
||||
_episodeSearchJob.Start(notification, new { EpisodeId = episode.EpisodeId});
|
||||
_episodeSearchJob.Start(notification, new { EpisodeId = episode.OID});
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public List<Episode> GetMissingForEnabledSeries()
|
||||
if (!_configProvider.EnableBacklogSearching)
|
||||
{
|
||||
Logger.Trace("Backlog searching is not enabled, only running for explicitly enabled series.");
|
||||
return _episodeProvider.EpisodesWithoutFiles(true).Where(e =>
|
||||
return _episodeService.EpisodesWithoutFiles(true).Where(e =>
|
||||
e.Series.BacklogSetting == BacklogSettingType.Enable &&
|
||||
e.Series.Monitored
|
||||
).ToList();
|
||||
@ -101,7 +101,7 @@ public List<Episode> GetMissingForEnabledSeries()
|
||||
else
|
||||
{
|
||||
Logger.Trace("Backlog searching is enabled, skipping explicity disabled series.");
|
||||
return _episodeProvider.EpisodesWithoutFiles(true).Where(e =>
|
||||
return _episodeService.EpisodesWithoutFiles(true).Where(e =>
|
||||
e.Series.BacklogSetting != BacklogSettingType.Disable &&
|
||||
e.Series.Monitored
|
||||
).ToList();
|
||||
|
@ -13,16 +13,18 @@ namespace NzbDrone.Core.Jobs
|
||||
{
|
||||
public class BannerDownloadJob : IJob
|
||||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly BannerProvider _bannerProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private const string BANNER_URL_PREFIX = "http://www.thetvdb.com/banners/";
|
||||
|
||||
public BannerDownloadJob(SeriesProvider seriesProvider, BannerProvider bannerProvider)
|
||||
public BannerDownloadJob(ISeriesService seriesService, BannerProvider bannerProvider, ISeriesRepository seriesRepository)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_seriesService = seriesService;
|
||||
_bannerProvider = bannerProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
public BannerDownloadJob()
|
||||
@ -45,7 +47,7 @@ public virtual void Start(ProgressNotification notification, dynamic options)
|
||||
|
||||
if (options != null)
|
||||
{
|
||||
Series series = _seriesProvider.Get(options.SeriesId);
|
||||
Series series = _seriesRepository.Get(options.SeriesId);
|
||||
|
||||
if (series != null && !String.IsNullOrEmpty(series.BannerUrl))
|
||||
{
|
||||
@ -55,7 +57,7 @@ public virtual void Start(ProgressNotification notification, dynamic options)
|
||||
return;
|
||||
}
|
||||
|
||||
var seriesInDb = _seriesProvider.All();
|
||||
var seriesInDb = _seriesRepository.All();
|
||||
|
||||
foreach (var series in seriesInDb.Where(s => !String.IsNullOrEmpty(s.BannerUrl)))
|
||||
{
|
||||
|
@ -13,16 +13,16 @@ public class ConvertEpisodeJob : IJob
|
||||
{
|
||||
private readonly HandbrakeProvider _handbrakeProvider;
|
||||
private readonly AtomicParsleyProvider _atomicParsleyProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public ConvertEpisodeJob(HandbrakeProvider handbrakeProvider, AtomicParsleyProvider atomicParsleyProvider,
|
||||
EpisodeProvider episodeProvider)
|
||||
EpisodeService episodeService)
|
||||
{
|
||||
_handbrakeProvider = handbrakeProvider;
|
||||
_atomicParsleyProvider = atomicParsleyProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
}
|
||||
|
||||
public string Name
|
||||
@ -41,7 +41,7 @@ public void Start(ProgressNotification notification, dynamic options)
|
||||
if (options == null || options.EpisodeId <= 0)
|
||||
throw new ArgumentNullException(options);
|
||||
|
||||
Episode episode = _episodeProvider.GetEpisode(options.EpisodeId);
|
||||
Episode episode = _episodeService.GetEpisode(options.EpisodeId);
|
||||
notification.CurrentMessage = String.Format("Starting Conversion for {0}", episode);
|
||||
var outputFile = _handbrakeProvider.ConvertFile(episode, notification);
|
||||
|
||||
|
@ -10,15 +10,17 @@ namespace NzbDrone.Core.Jobs
|
||||
{
|
||||
public class DeleteSeriesJob : IJob
|
||||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly RecycleBinProvider _recycleBinProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public DeleteSeriesJob(SeriesProvider seriesProvider, RecycleBinProvider recycleBinProvider)
|
||||
public DeleteSeriesJob(ISeriesService seriesService, RecycleBinProvider recycleBinProvider, ISeriesRepository seriesRepository)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_seriesService = seriesService;
|
||||
_recycleBinProvider = recycleBinProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
public string Name
|
||||
@ -46,12 +48,12 @@ private void DeleteSeries(ProgressNotification notification, int seriesId, bool
|
||||
{
|
||||
Logger.Trace("Deleting Series [{0}]", seriesId);
|
||||
|
||||
var series = _seriesProvider.Get(seriesId);
|
||||
var series = _seriesRepository.Get(seriesId);
|
||||
var title = series.Title;
|
||||
|
||||
notification.CurrentMessage = String.Format("Deleting '{0}' from database", title);
|
||||
|
||||
_seriesProvider.DeleteSeries(seriesId);
|
||||
_seriesRepository.Delete(seriesId);
|
||||
|
||||
notification.CurrentMessage = String.Format("Successfully deleted '{0}' from database", title);
|
||||
|
||||
|
@ -13,17 +13,19 @@ namespace NzbDrone.Core.Jobs
|
||||
{
|
||||
public class DiskScanJob : IJob
|
||||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly DiskScanProvider _diskScanProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public DiskScanJob(SeriesProvider seriesProvider, DiskScanProvider diskScanProvider,
|
||||
ConfigProvider configProvider)
|
||||
public DiskScanJob(ISeriesService seriesService, DiskScanProvider diskScanProvider,
|
||||
ConfigProvider configProvider, ISeriesRepository seriesRepository)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_seriesService = seriesService;
|
||||
_diskScanProvider = diskScanProvider;
|
||||
_configProvider = configProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
public DiskScanJob()
|
||||
@ -46,14 +48,14 @@ public virtual void Start(ProgressNotification notification, dynamic options)
|
||||
if (options == null || options.SeriesId == 0)
|
||||
{
|
||||
if (_configProvider.IgnoreArticlesWhenSortingSeries)
|
||||
seriesToScan = _seriesProvider.All().OrderBy(o => o.Title.IgnoreArticles()).ToList();
|
||||
seriesToScan = _seriesRepository.All().OrderBy(o => o.Title.IgnoreArticles()).ToList();
|
||||
|
||||
else
|
||||
seriesToScan = _seriesProvider.All().OrderBy(o => o.Title).ToList();
|
||||
seriesToScan = _seriesRepository.All().OrderBy(o => o.Title).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
seriesToScan = new List<Series>() { _seriesProvider.Get(options.SeriesId) };
|
||||
seriesToScan = new List<Series>() { _seriesRepository.Get(options.SeriesId) };
|
||||
}
|
||||
|
||||
foreach (var series in seriesToScan)
|
||||
|
@ -12,18 +12,18 @@ namespace NzbDrone.Core.Jobs
|
||||
{
|
||||
public class EpisodeSearchJob : IJob
|
||||
{
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly UpgradePossibleSpecification _upgradePossibleSpecification;
|
||||
private readonly EpisodeSearch _episodeSearch;
|
||||
private readonly DailyEpisodeSearch _dailyEpisodeSearch;
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public EpisodeSearchJob(EpisodeProvider episodeProvider, UpgradePossibleSpecification upgradePossibleSpecification,
|
||||
public EpisodeSearchJob(EpisodeService episodeService, UpgradePossibleSpecification upgradePossibleSpecification,
|
||||
EpisodeSearch episodeSearch, DailyEpisodeSearch dailyEpisodeSearch)
|
||||
{
|
||||
if(dailyEpisodeSearch == null) throw new ArgumentNullException("dailyEpisodeSearch");
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
_upgradePossibleSpecification = upgradePossibleSpecification;
|
||||
_episodeSearch = episodeSearch;
|
||||
_dailyEpisodeSearch = dailyEpisodeSearch;
|
||||
@ -49,7 +49,7 @@ public virtual void Start(ProgressNotification notification, dynamic options)
|
||||
if (options == null || options.EpisodeId <= 0)
|
||||
throw new ArgumentException("options");
|
||||
|
||||
Episode episode = _episodeProvider.GetEpisode(options.EpisodeId);
|
||||
Episode episode = _episodeService.GetEpisode(options.EpisodeId);
|
||||
|
||||
if (episode == null)
|
||||
{
|
||||
@ -64,7 +64,7 @@ public virtual void Start(ProgressNotification notification, dynamic options)
|
||||
return;
|
||||
}
|
||||
|
||||
if (episode.Series.IsDaily)
|
||||
if (episode.Series.SeriesType == SeriesType.Daily)
|
||||
{
|
||||
if (!episode.AirDate.HasValue)
|
||||
{
|
||||
|
@ -15,32 +15,36 @@ namespace NzbDrone.Core.Jobs
|
||||
/// </summary>
|
||||
public class ImportNewSeriesJob : IJob
|
||||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly MediaFileProvider _mediaFileProvider;
|
||||
private readonly UpdateInfoJob _updateInfoJob;
|
||||
private readonly DiskScanJob _diskScanJob;
|
||||
private readonly BannerDownloadJob _bannerDownloadJob;
|
||||
private readonly SeasonProvider _seasonProvider;
|
||||
private readonly ISeasonRepository _seasonRepository;
|
||||
private readonly XemUpdateJob _xemUpdateJob;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private readonly ISeasonService _seasonService;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private List<int> _attemptedSeries;
|
||||
|
||||
public ImportNewSeriesJob(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
|
||||
public ImportNewSeriesJob(ISeriesService seriesService, EpisodeService episodeService,
|
||||
MediaFileProvider mediaFileProvider, UpdateInfoJob updateInfoJob,
|
||||
DiskScanJob diskScanJob, BannerDownloadJob bannerDownloadJob,
|
||||
SeasonProvider seasonProvider, XemUpdateJob xemUpdateJob)
|
||||
ISeasonRepository seasonRepository, XemUpdateJob xemUpdateJob, ISeriesRepository seriesRepository,ISeasonService seasonService)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_seriesService = seriesService;
|
||||
_episodeService = episodeService;
|
||||
_mediaFileProvider = mediaFileProvider;
|
||||
_updateInfoJob = updateInfoJob;
|
||||
_diskScanJob = diskScanJob;
|
||||
_bannerDownloadJob = bannerDownloadJob;
|
||||
_seasonProvider = seasonProvider;
|
||||
_seasonRepository = seasonRepository;
|
||||
_xemUpdateJob = xemUpdateJob;
|
||||
_seriesRepository = seriesRepository;
|
||||
_seasonService = seasonService;
|
||||
}
|
||||
|
||||
public string Name
|
||||
@ -61,7 +65,7 @@ public void Start(ProgressNotification notification, dynamic options)
|
||||
|
||||
private void ScanSeries(ProgressNotification notification)
|
||||
{
|
||||
var syncList = _seriesProvider.All().Where(s => s.LastInfoSync == null && !_attemptedSeries.Contains(s.SeriesId)).ToList();
|
||||
var syncList = _seriesRepository.All().Where(s => s.LastInfoSync == null && !_attemptedSeries.Contains(s.SeriesId)).ToList();
|
||||
if (syncList.Count == 0)
|
||||
{
|
||||
return;
|
||||
@ -77,7 +81,7 @@ private void ScanSeries(ProgressNotification notification)
|
||||
_updateInfoJob.Start(notification, new { SeriesId = currentSeries.SeriesId });
|
||||
_diskScanJob.Start(notification, new { SeriesId = currentSeries.SeriesId });
|
||||
|
||||
var updatedSeries = _seriesProvider.Get(currentSeries.SeriesId);
|
||||
var updatedSeries = _seriesRepository.Get(currentSeries.SeriesId);
|
||||
AutoIgnoreSeasons(updatedSeries.SeriesId);
|
||||
|
||||
//Download the banner for the new series
|
||||
@ -105,14 +109,14 @@ public void AutoIgnoreSeasons(int seriesId)
|
||||
|
||||
if (episodeFiles.Count() != 0)
|
||||
{
|
||||
var seasons = _episodeProvider.GetSeasons(seriesId);
|
||||
var seasons = _seasonRepository.GetSeasonNumbers(seriesId);
|
||||
var currentSeasons = seasons.Max();
|
||||
|
||||
foreach (var season in seasons)
|
||||
{
|
||||
if (season != currentSeasons && !episodeFiles.Any(e => e.SeasonNumber == season))
|
||||
{
|
||||
_seasonProvider.SetIgnore(seriesId, season, true);
|
||||
_seasonService.SetIgnore(seriesId, season, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public IList<JobDefinition> GetPendingJobs()
|
||||
public void Init()
|
||||
{
|
||||
var currentJobs = All();
|
||||
_logger.Debug("Initializing jobs. Available: {0} Existing:{1}", _jobs.Count(), currentJobs.Count);
|
||||
_logger.Debug("Initializing jobs. Available: {0} Existing:{1}", _jobs.Count(), currentJobs.Count());
|
||||
|
||||
foreach (var currentJob in currentJobs)
|
||||
{
|
||||
|
@ -13,16 +13,16 @@ namespace NzbDrone.Core.Jobs
|
||||
{
|
||||
public class PastWeekBacklogSearchJob : IJob
|
||||
{
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly EpisodeSearchJob _episodeSearchJob;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public PastWeekBacklogSearchJob(EpisodeProvider episodeProvider, EpisodeSearchJob episodeSearchJob,
|
||||
public PastWeekBacklogSearchJob(EpisodeService episodeService, EpisodeSearchJob episodeSearchJob,
|
||||
ConfigProvider configProvider)
|
||||
{
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
_episodeSearchJob = episodeSearchJob;
|
||||
_configProvider = configProvider;
|
||||
}
|
||||
@ -44,13 +44,13 @@ public void Start(ProgressNotification notification, dynamic options)
|
||||
Logger.Debug("Processing missing episodes from the past week, count: {0}", missingEpisodes.Count);
|
||||
foreach (var episode in missingEpisodes)
|
||||
{
|
||||
_episodeSearchJob.Start(notification, new { EpisodeId = episode.EpisodeId });
|
||||
_episodeSearchJob.Start(notification, new { EpisodeId = episode.OID });
|
||||
}
|
||||
}
|
||||
|
||||
public List<Episode> GetMissingForEnabledSeries()
|
||||
{
|
||||
return _episodeProvider.EpisodesWithoutFiles(true).Where(e =>
|
||||
return _episodeService.EpisodesWithoutFiles(true).Where(e =>
|
||||
e.AirDate >= DateTime.Today.AddDays(-7) &&
|
||||
e.Series.Monitored
|
||||
).ToList();
|
||||
|
@ -13,16 +13,16 @@ namespace NzbDrone.Core.Jobs
|
||||
{
|
||||
public class RecentBacklogSearchJob : IJob
|
||||
{
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly EpisodeSearchJob _episodeSearchJob;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public RecentBacklogSearchJob(EpisodeProvider episodeProvider, EpisodeSearchJob episodeSearchJob,
|
||||
public RecentBacklogSearchJob(EpisodeService episodeService, EpisodeSearchJob episodeSearchJob,
|
||||
ConfigProvider configProvider)
|
||||
{
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
_episodeSearchJob = episodeSearchJob;
|
||||
_configProvider = configProvider;
|
||||
}
|
||||
@ -44,7 +44,7 @@ public void Start(ProgressNotification notification, dynamic options)
|
||||
Logger.Debug("Processing missing episodes from the last 30 days, count: {0}", missingEpisodes.Count);
|
||||
foreach (var episode in missingEpisodes)
|
||||
{
|
||||
_episodeSearchJob.Start(notification, new { EpisodeId = episode.EpisodeId });
|
||||
_episodeSearchJob.Start(notification, new { EpisodeId = episode.OID });
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ public List<Episode> GetMissingForEnabledSeries()
|
||||
if (!_configProvider.EnableBacklogSearching)
|
||||
{
|
||||
Logger.Trace("Backlog searching is not enabled, only running for explicitly enabled series.");
|
||||
return _episodeProvider.EpisodesWithoutFiles(true).Where(e =>
|
||||
return _episodeService.EpisodesWithoutFiles(true).Where(e =>
|
||||
e.AirDate >= DateTime.Today.AddDays(-30) &&
|
||||
e.Series.BacklogSetting == BacklogSettingType.Enable &&
|
||||
e.Series.Monitored
|
||||
@ -62,8 +62,8 @@ public List<Episode> GetMissingForEnabledSeries()
|
||||
|
||||
else
|
||||
{
|
||||
Logger.Trace("Backlog searching is enabled, skipping explicity disabled series.");
|
||||
return _episodeProvider.EpisodesWithoutFiles(true).Where(e =>
|
||||
Logger.Trace("Backlog searching is enabled, skipping explicitly disabled series.");
|
||||
return _episodeService.EpisodesWithoutFiles(true).Where(e =>
|
||||
e.AirDate >= DateTime.Today.AddDays(-30) &&
|
||||
e.Series.BacklogSetting != BacklogSettingType.Disable &&
|
||||
e.Series.Monitored
|
||||
|
@ -12,17 +12,19 @@ namespace NzbDrone.Core.Jobs
|
||||
public class RefreshEpisodeMetadata : IJob
|
||||
{
|
||||
private readonly MediaFileProvider _mediaFileProvider;
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly MetadataProvider _metadataProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public RefreshEpisodeMetadata(MediaFileProvider mediaFileProvider, SeriesProvider seriesProvider,
|
||||
MetadataProvider metadataProvider)
|
||||
public RefreshEpisodeMetadata(MediaFileProvider mediaFileProvider, ISeriesService seriesService,
|
||||
MetadataProvider metadataProvider,ISeriesRepository seriesRepository)
|
||||
{
|
||||
_mediaFileProvider = mediaFileProvider;
|
||||
_seriesProvider = seriesProvider;
|
||||
_seriesService = seriesService;
|
||||
_metadataProvider = metadataProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
public string Name
|
||||
@ -40,10 +42,10 @@ public void Start(ProgressNotification notification, dynamic options)
|
||||
List<Series> seriesToRefresh;
|
||||
|
||||
if (options == null || options.SeriesId <= 0)
|
||||
seriesToRefresh = _seriesProvider.All().ToList();
|
||||
seriesToRefresh = _seriesRepository.All().ToList();
|
||||
|
||||
else
|
||||
seriesToRefresh = new List<Series> { _seriesProvider.Get(options.SeriesId) };
|
||||
seriesToRefresh = new List<Series> { _seriesRepository.Get(options.SeriesId) };
|
||||
|
||||
foreach(var series in seriesToRefresh)
|
||||
{
|
||||
|
@ -13,20 +13,20 @@ public class RenameSeasonJob : IJob
|
||||
private readonly MediaFileProvider _mediaFileProvider;
|
||||
private readonly DiskScanProvider _diskScanProvider;
|
||||
private readonly ExternalNotificationProvider _externalNotificationProvider;
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly MetadataProvider _metadataProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public RenameSeasonJob(MediaFileProvider mediaFileProvider, DiskScanProvider diskScanProvider,
|
||||
ExternalNotificationProvider externalNotificationProvider, SeriesProvider seriesProvider,
|
||||
ExternalNotificationProvider externalNotificationProvider, ISeriesService seriesService,
|
||||
MetadataProvider metadataProvider,ISeriesRepository seriesRepository)
|
||||
{
|
||||
_mediaFileProvider = mediaFileProvider;
|
||||
_diskScanProvider = diskScanProvider;
|
||||
_externalNotificationProvider = externalNotificationProvider;
|
||||
_seriesProvider = seriesProvider;
|
||||
_seriesService = seriesService;
|
||||
_metadataProvider = metadataProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
@ -14,20 +14,20 @@ public class RenameSeriesJob : IJob
|
||||
private readonly MediaFileProvider _mediaFileProvider;
|
||||
private readonly DiskScanProvider _diskScanProvider;
|
||||
private readonly ExternalNotificationProvider _externalNotificationProvider;
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly MetadataProvider _metadataProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public RenameSeriesJob(MediaFileProvider mediaFileProvider, DiskScanProvider diskScanProvider,
|
||||
ExternalNotificationProvider externalNotificationProvider, SeriesProvider seriesProvider,
|
||||
ExternalNotificationProvider externalNotificationProvider, ISeriesService seriesService,
|
||||
MetadataProvider metadataProvider,ISeriesRepository seriesRepository)
|
||||
{
|
||||
_mediaFileProvider = mediaFileProvider;
|
||||
_diskScanProvider = diskScanProvider;
|
||||
_externalNotificationProvider = externalNotificationProvider;
|
||||
_seriesProvider = seriesProvider;
|
||||
_seriesService = seriesService;
|
||||
_metadataProvider = metadataProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
@ -13,16 +13,16 @@ public class SeasonSearchJob : IJob
|
||||
{
|
||||
private readonly SearchProvider _searchProvider;
|
||||
private readonly EpisodeSearchJob _episodeSearchJob;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public SeasonSearchJob(SearchProvider searchProvider, EpisodeSearchJob episodeSearchJob,
|
||||
EpisodeProvider episodeProvider)
|
||||
EpisodeService episodeService)
|
||||
{
|
||||
_searchProvider = searchProvider;
|
||||
_episodeSearchJob = episodeSearchJob;
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
}
|
||||
|
||||
public SeasonSearchJob()
|
||||
@ -57,7 +57,7 @@ public virtual void Start(ProgressNotification notification, dynamic options)
|
||||
// return;
|
||||
|
||||
Logger.Debug("Getting episodes from database for series: {0} and season: {1}", options.SeriesId, options.SeasonNumber);
|
||||
List<Episode> episodes = _episodeProvider.GetEpisodesBySeason(options.SeriesId, options.SeasonNumber);
|
||||
List<Episode> episodes = _episodeService.GetEpisodesBySeason(options.SeriesId, options.SeasonNumber);
|
||||
|
||||
if (episodes == null || episodes.Count == 0)
|
||||
{
|
||||
@ -68,11 +68,11 @@ public virtual void Start(ProgressNotification notification, dynamic options)
|
||||
if (episodes.Count == successes.Count)
|
||||
return;
|
||||
|
||||
var missingEpisodes = episodes.Select(e => e.EpisodeId).Except(successes).ToList();
|
||||
var missingEpisodes = episodes.Select(e => e.OID).Except(successes).ToList();
|
||||
|
||||
foreach (var episode in episodes.Where(e => !e.Ignored && missingEpisodes.Contains(e.EpisodeId)).OrderBy(o => o.EpisodeNumber))
|
||||
foreach (var episode in episodes.Where(e => !e.Ignored && missingEpisodes.Contains(e.OID)).OrderBy(o => o.EpisodeNumber))
|
||||
{
|
||||
_episodeSearchJob.Start(notification, new { EpisodeId = episode.EpisodeId });
|
||||
_episodeSearchJob.Start(notification, new { EpisodeId = episode.OID });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,15 +12,14 @@ namespace NzbDrone.Core.Jobs
|
||||
public class SeriesSearchJob : IJob
|
||||
{
|
||||
private readonly SeasonSearchJob _seasonSearchJob;
|
||||
private readonly SeasonProvider _seasonProvider;
|
||||
private readonly ISeasonRepository _seasonRepository;
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public SeriesSearchJob(SeasonSearchJob seasonSearchJob,
|
||||
SeasonProvider seasonProvider)
|
||||
public SeriesSearchJob(SeasonSearchJob seasonSearchJob, ISeasonRepository seasonRepository)
|
||||
{
|
||||
_seasonSearchJob = seasonSearchJob;
|
||||
_seasonProvider = seasonProvider;
|
||||
_seasonRepository = seasonRepository;
|
||||
}
|
||||
|
||||
public string Name
|
||||
@ -39,11 +38,11 @@ public void Start(ProgressNotification notification, dynamic options)
|
||||
throw new ArgumentException("options.SeriesId");
|
||||
|
||||
logger.Debug("Getting seasons from database for series: {0}", options.SeriesId);
|
||||
IList<int> seasons = _seasonProvider.GetSeasons(options.SeriesId);
|
||||
IList<int> seasons = _seasonRepository.GetSeasonBySeries(options.SeriesId);
|
||||
|
||||
foreach (var season in seasons.Where(s => s > 0))
|
||||
{
|
||||
if (!_seasonProvider.IsIgnored(options.SeriesId, season))
|
||||
if (!_seasonRepository.IsIgnored(options.SeriesId, season))
|
||||
{
|
||||
_seasonSearchJob.Start(notification, new { SeriesId = options.SeriesId, SeasonNumber = season });
|
||||
}
|
||||
|
@ -13,18 +13,18 @@ namespace NzbDrone.Core.Jobs
|
||||
{
|
||||
public class UpdateInfoJob : IJob
|
||||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly ReferenceDataProvider _referenceDataProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public UpdateInfoJob(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
|
||||
public UpdateInfoJob(ISeriesService seriesService, EpisodeService episodeService,
|
||||
ReferenceDataProvider referenceDataProvider, ConfigProvider configProvider, ISeriesRepository seriesRepository)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_seriesService = seriesService;
|
||||
_episodeService = episodeService;
|
||||
_referenceDataProvider = referenceDataProvider;
|
||||
_configProvider = configProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
@ -69,8 +69,8 @@ public virtual void Start(ProgressNotification notification, dynamic options)
|
||||
try
|
||||
{
|
||||
notification.CurrentMessage = "Updating " + series.Title;
|
||||
_seriesProvider.UpdateSeriesInfo(series.SeriesId);
|
||||
_episodeProvider.RefreshEpisodeInfo(series);
|
||||
_seriesService.UpdateSeriesInfo(series.SeriesId);
|
||||
_episodeService.RefreshEpisodeInfo(series);
|
||||
notification.CurrentMessage = "Update completed for " + series.Title;
|
||||
}
|
||||
|
||||
|
@ -302,6 +302,8 @@
|
||||
<Compile Include="Model\JobQueueItem.cs" />
|
||||
<Compile Include="Model\LanguageType.cs" />
|
||||
<Compile Include="Model\MisnamedEpisodeModel.cs" />
|
||||
<Compile Include="Tv\EpisodeService.cs" />
|
||||
<Compile Include="Tv\SeasonRepository.cs" />
|
||||
<Compile Include="Tv\SeriesRepository.cs" />
|
||||
<Compile Include="Tv\QualityModel.cs" />
|
||||
<Compile Include="Model\Sabnzbd\SabAddResponse.cs" />
|
||||
@ -354,7 +356,7 @@
|
||||
<Compile Include="Providers\Search\PartialSeasonSearch.cs" />
|
||||
<Compile Include="Providers\Search\EpisodeSearch.cs" />
|
||||
<Compile Include="Providers\Search\SearchBase.cs" />
|
||||
<Compile Include="Tv\SeasonProvider.cs" />
|
||||
<Compile Include="Tv\SeasonService.cs" />
|
||||
<Compile Include="Jobs\RecentBacklogSearchJob.cs" />
|
||||
<Compile Include="Instrumentation\TrimLogsJob.cs" />
|
||||
<Compile Include="Jobs\JobController.cs" />
|
||||
@ -455,7 +457,7 @@
|
||||
<Compile Include="Providers\DownloadProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Tv\EpisodeProvider.cs">
|
||||
<Compile Include="Tv\EpisodeRepository.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Providers\ExternalNotificationProvider.cs">
|
||||
|
@ -16,9 +16,9 @@ public class DiskScanProvider
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly string[] mediaExtentions = new[] { ".mkv", ".avi", ".wmv", ".mp4", ".mpg", ".mpeg", ".xvid", ".flv", ".mov", ".rm", ".rmvb", ".divx", ".dvr-ms", ".ts", ".ogm", ".m4v", ".strm" };
|
||||
private readonly DiskProvider _diskProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly MediaFileProvider _mediaFileProvider;
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly ExternalNotificationProvider _externalNotificationProvider;
|
||||
private readonly DownloadProvider _downloadProvider;
|
||||
private readonly SignalRProvider _signalRProvider;
|
||||
@ -27,15 +27,15 @@ public class DiskScanProvider
|
||||
private readonly MediaInfoProvider _mediaInfoProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
public DiskScanProvider(DiskProvider diskProvider, EpisodeProvider episodeProvider,
|
||||
SeriesProvider seriesProvider, MediaFileProvider mediaFileProvider,
|
||||
public DiskScanProvider(DiskProvider diskProvider, EpisodeService episodeService,
|
||||
ISeriesService seriesService, MediaFileProvider mediaFileProvider,
|
||||
ExternalNotificationProvider externalNotificationProvider, DownloadProvider downloadProvider,
|
||||
SignalRProvider signalRProvider, ConfigProvider configProvider,
|
||||
RecycleBinProvider recycleBinProvider, MediaInfoProvider mediaInfoProvider,ISeriesRepository seriesRepository)
|
||||
RecycleBinProvider recycleBinProvider, MediaInfoProvider mediaInfoProvider, ISeriesRepository seriesRepository)
|
||||
{
|
||||
_diskProvider = diskProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_seriesProvider = seriesProvider;
|
||||
_episodeService = episodeService;
|
||||
_seriesService = seriesService;
|
||||
_mediaFileProvider = mediaFileProvider;
|
||||
_externalNotificationProvider = externalNotificationProvider;
|
||||
_downloadProvider = downloadProvider;
|
||||
@ -74,7 +74,7 @@ public virtual List<EpisodeFile> Scan(Series series, string path)
|
||||
return new List<EpisodeFile>();
|
||||
}
|
||||
|
||||
if (_episodeProvider.GetEpisodeBySeries(series.SeriesId).Count == 0)
|
||||
if (_episodeService.GetEpisodeBySeries(series.SeriesId).Count == 0)
|
||||
{
|
||||
Logger.Debug("Series {0} has no episodes. skipping", series.Title);
|
||||
return new List<EpisodeFile>();
|
||||
@ -122,7 +122,7 @@ public virtual EpisodeFile ImportFile(Series series, string filePath)
|
||||
var size = _diskProvider.GetSize(filePath);
|
||||
var runTime = _mediaInfoProvider.GetRunTime(filePath);
|
||||
|
||||
if(series.IsDaily || parseResult.SeasonNumber > 0)
|
||||
if (series.SeriesType == SeriesType.Daily || parseResult.SeasonNumber > 0)
|
||||
{
|
||||
if (size < Constants.IgnoreFileSize && runTime < 180)
|
||||
{
|
||||
@ -137,7 +137,7 @@ public virtual EpisodeFile ImportFile(Series series, string filePath)
|
||||
parseResult.SeriesTitle = series.Title; //replaces the nasty path as title to help with logging
|
||||
parseResult.Series = series;
|
||||
|
||||
var episodes = _episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
var episodes = _episodeService.GetEpisodesByParseResult(parseResult);
|
||||
|
||||
if (episodes.Count <= 0)
|
||||
{
|
||||
@ -173,14 +173,14 @@ public virtual EpisodeFile ImportFile(Series series, string filePath)
|
||||
|
||||
//Todo: We shouldn't actually import the file until we confirm its the only one we want.
|
||||
//Todo: Separate episodeFile creation from importing (pass file to import to import)
|
||||
var fileId = _mediaFileProvider.Add(episodeFile);
|
||||
_mediaFileProvider.Add(episodeFile);
|
||||
|
||||
//Link file to all episodes
|
||||
foreach (var ep in episodes)
|
||||
{
|
||||
ep.EpisodeFileId = fileId;
|
||||
ep.EpisodeFile = episodeFile;
|
||||
ep.PostDownloadStatus = PostDownloadStatusType.NoError;
|
||||
_episodeProvider.UpdateEpisode(ep);
|
||||
_episodeService.UpdateEpisode(ep);
|
||||
Logger.Debug("Linking [{0}] > [{1}]", filePath, ep);
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ public virtual EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, bool newDown
|
||||
throw new ArgumentNullException("episodeFile");
|
||||
|
||||
var series = _seriesRepository.Get(episodeFile.SeriesId);
|
||||
var episodes = _episodeProvider.GetEpisodesByFileId(episodeFile.EpisodeFileId);
|
||||
var episodes = _episodeService.GetEpisodesByFileId(episodeFile.EpisodeFileId);
|
||||
string newFileName = _mediaFileProvider.GetNewFilename(episodes, series, episodeFile.Quality, episodeFile.Proper, episodeFile);
|
||||
var newFile = _mediaFileProvider.CalculateFilePath(series, episodes.First().SeasonNumber, newFileName, Path.GetExtension(episodeFile.Path));
|
||||
|
||||
@ -204,7 +204,7 @@ public virtual EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, bool newDown
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!_diskProvider.FileExists(episodeFile.Path))
|
||||
if (!_diskProvider.FileExists(episodeFile.Path))
|
||||
{
|
||||
Logger.Error("Episode file path does not exist, {0}", episodeFile.Path);
|
||||
return null;
|
||||
@ -231,7 +231,7 @@ public virtual EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, bool newDown
|
||||
|
||||
var parseResult = Parser.ParsePath(episodeFile.Path);
|
||||
parseResult.Series = series;
|
||||
parseResult.Quality = new QualityModel{ Quality = episodeFile.Quality, Proper = episodeFile.Proper };
|
||||
parseResult.Quality = new QualityModel { Quality = episodeFile.Quality, Proper = episodeFile.Proper };
|
||||
parseResult.Episodes = episodes;
|
||||
|
||||
var message = _downloadProvider.GetDownloadTitle(parseResult);
|
||||
@ -239,9 +239,9 @@ public virtual EpisodeFile MoveEpisodeFile(EpisodeFile episodeFile, bool newDown
|
||||
if (newDownload)
|
||||
{
|
||||
_externalNotificationProvider.OnDownload(message, series);
|
||||
|
||||
foreach(var episode in episodes)
|
||||
_signalRProvider.UpdateEpisodeStatus(episode.EpisodeId, EpisodeStatusType.Ready, parseResult.Quality);
|
||||
|
||||
foreach (var episode in episodes)
|
||||
_signalRProvider.UpdateEpisodeStatus(episode.OID, EpisodeStatusType.Ready, parseResult.Quality);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -261,19 +261,19 @@ public virtual void CleanUp(IList<EpisodeFile> files)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(!_diskProvider.FileExists(episodeFile.Path))
|
||||
if (!_diskProvider.FileExists(episodeFile.Path))
|
||||
{
|
||||
Logger.Trace("File [{0}] no longer exists on disk. removing from db", episodeFile.Path);
|
||||
|
||||
//Set the EpisodeFileId for each episode attached to this file to 0
|
||||
foreach(var episode in _episodeProvider.GetEpisodesByFileId(episodeFile.EpisodeFileId))
|
||||
foreach (var episode in _episodeService.GetEpisodesByFileId(episodeFile.EpisodeFileId))
|
||||
{
|
||||
Logger.Trace("Setting EpisodeFileId for Episode: [{0}] to 0", episode.EpisodeId);
|
||||
episode.EpisodeFileId = 0;
|
||||
Logger.Trace("Detaching episode {0} from file.", episode.OID);
|
||||
episode.EpisodeFile = null;
|
||||
episode.Ignored = _configProvider.AutoIgnorePreviouslyDownloadedEpisodes;
|
||||
episode.GrabDate = null;
|
||||
episode.PostDownloadStatus = PostDownloadStatusType.Unknown;
|
||||
_episodeProvider.UpdateEpisode(episode);
|
||||
_episodeService.UpdateEpisode(episode);
|
||||
}
|
||||
|
||||
//Delete it from the DB
|
||||
@ -295,7 +295,7 @@ public virtual void CleanUpDropFolder(string path)
|
||||
|
||||
var filesOnDisk = GetVideoFiles(path);
|
||||
|
||||
foreach(var file in filesOnDisk)
|
||||
foreach (var file in filesOnDisk)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -11,6 +11,7 @@
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Nzbget;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Providers.DownloadClients
|
||||
{
|
||||
@ -41,7 +42,7 @@ public virtual bool IsInQueue(EpisodeParseResult newParseResult)
|
||||
var matchingTitleWithQuality = matchigTitle.Where(q => q.ParseResult.Quality >= newParseResult.Quality);
|
||||
|
||||
|
||||
if (newParseResult.Series.IsDaily)
|
||||
if (newParseResult.Series.SeriesType == SeriesType.Daily)
|
||||
{
|
||||
return matchingTitleWithQuality.Any(q => q.ParseResult.AirDate.Value.Date == newParseResult.AirDate.Value.Date);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Sabnzbd;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Providers.DownloadClients
|
||||
{
|
||||
@ -40,7 +41,7 @@ public virtual bool IsInQueue(EpisodeParseResult newParseResult)
|
||||
|
||||
var matchingTitleWithQuality = matchigTitle.Where(q => q.ParseResult.Quality >= newParseResult.Quality);
|
||||
|
||||
if (newParseResult.Series.IsDaily)
|
||||
if (newParseResult.Series.SeriesType == SeriesType.Daily)
|
||||
{
|
||||
return matchingTitleWithQuality.Any(q => q.ParseResult.AirDate.Value.Date == newParseResult.AirDate.Value.Date);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class DownloadProvider
|
||||
{
|
||||
private readonly SabProvider _sabProvider;
|
||||
private readonly HistoryProvider _historyProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly ExternalNotificationProvider _externalNotificationProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private readonly BlackholeProvider _blackholeProvider;
|
||||
@ -25,14 +25,14 @@ public class DownloadProvider
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public DownloadProvider(SabProvider sabProvider, HistoryProvider historyProvider,
|
||||
EpisodeProvider episodeProvider, ExternalNotificationProvider externalNotificationProvider,
|
||||
EpisodeService episodeService, ExternalNotificationProvider externalNotificationProvider,
|
||||
ConfigProvider configProvider, BlackholeProvider blackholeProvider,
|
||||
SignalRProvider signalRProvider, PneumaticProvider pneumaticProvider,
|
||||
NzbgetProvider nzbgetProvider)
|
||||
{
|
||||
_sabProvider = sabProvider;
|
||||
_historyProvider = historyProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
_externalNotificationProvider = externalNotificationProvider;
|
||||
_configProvider = configProvider;
|
||||
_blackholeProvider = blackholeProvider;
|
||||
@ -66,16 +66,16 @@ public virtual bool DownloadReport(EpisodeParseResult parseResult)
|
||||
IsProper = parseResult.Quality.Proper,
|
||||
Quality = parseResult.Quality.Quality,
|
||||
NzbTitle = parseResult.OriginalString,
|
||||
EpisodeId = episode.EpisodeId,
|
||||
EpisodeId = episode.OID,
|
||||
SeriesId = episode.SeriesId,
|
||||
NzbInfoUrl = parseResult.NzbInfoUrl,
|
||||
ReleaseGroup = parseResult.ReleaseGroup,
|
||||
};
|
||||
|
||||
_historyProvider.Add(history);
|
||||
_episodeProvider.MarkEpisodeAsFetched(episode.EpisodeId);
|
||||
_episodeService.MarkEpisodeAsFetched(episode.OID);
|
||||
|
||||
_signalRProvider.UpdateEpisodeStatus(episode.EpisodeId, EpisodeStatusType.Downloading, null);
|
||||
_signalRProvider.UpdateEpisodeStatus(episode.OID, EpisodeStatusType.Downloading, null);
|
||||
}
|
||||
|
||||
_externalNotificationProvider.OnGrab(downloadTitle);
|
||||
@ -124,7 +124,7 @@ public virtual String GetDownloadTitle(EpisodeParseResult parseResult)
|
||||
return seasonResult;
|
||||
}
|
||||
|
||||
if (parseResult.Series.IsDaily)
|
||||
if (parseResult.Series.SeriesType == SeriesType.Daily)
|
||||
{
|
||||
var dailyResult = String.Format("{0} - {1:yyyy-MM-dd} - {2} [{3}]", seriesTitle,
|
||||
parseResult.AirDate, parseResult.Episodes.First().Title, parseResult.Quality.Quality);
|
||||
|
@ -18,11 +18,11 @@ public class MediaFileProvider
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private readonly IDatabase _database;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
|
||||
public MediaFileProvider(EpisodeProvider episodeProvider, ConfigProvider configProvider, IDatabase database)
|
||||
public MediaFileProvider(EpisodeService episodeService, ConfigProvider configProvider, IDatabase database)
|
||||
{
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
_configProvider = configProvider;
|
||||
_database = database;
|
||||
}
|
||||
@ -78,7 +78,7 @@ public virtual IList<EpisodeFile> GetSeasonFiles(int seriesId, int seasonNumber)
|
||||
|
||||
public virtual Tuple<int, int> GetEpisodeFilesCount(int seriesId)
|
||||
{
|
||||
var allEpisodes = _episodeProvider.GetEpisodeBySeries(seriesId).ToList();
|
||||
var allEpisodes = _episodeService.GetEpisodeBySeries(seriesId).ToList();
|
||||
|
||||
var episodeTotal = allEpisodes.Where(e => !e.Ignored && e.AirDate != null && e.AirDate <= DateTime.Today).ToList();
|
||||
var avilableEpisodes = episodeTotal.Where(e => e.EpisodeFileId > 0).ToList();
|
||||
@ -173,7 +173,7 @@ public virtual string GetNewFilename(IList<Episode> episodes, Series series, Qua
|
||||
result += series.Title + separatorStyle.Pattern;
|
||||
}
|
||||
|
||||
if(!series.IsDaily)
|
||||
if (series.SeriesType == SeriesType.Standard)
|
||||
{
|
||||
result += numberStyle.Pattern.Replace("%0e",
|
||||
String.Format("{0:00}", sortedEpisodes.First().EpisodeNumber));
|
||||
|
@ -15,15 +15,15 @@ public abstract class MetadataBase
|
||||
protected readonly ConfigProvider _configProvider;
|
||||
protected readonly DiskProvider _diskProvider;
|
||||
protected readonly BannerProvider _bannerProvider;
|
||||
protected readonly EpisodeProvider _episodeProvider;
|
||||
protected readonly EpisodeService _episodeService;
|
||||
|
||||
protected MetadataBase(ConfigProvider configProvider, DiskProvider diskProvider,
|
||||
BannerProvider bannerProvider, EpisodeProvider episodeProvider)
|
||||
BannerProvider bannerProvider, EpisodeService episodeService)
|
||||
{
|
||||
_configProvider = configProvider;
|
||||
_diskProvider = diskProvider;
|
||||
_bannerProvider = bannerProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
_logger = LogManager.GetLogger(GetType().ToString());
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,8 @@ namespace NzbDrone.Core.Providers.Metadata
|
||||
public class Xbmc : MetadataBase
|
||||
{
|
||||
public Xbmc(ConfigProvider configProvider, DiskProvider diskProvider,
|
||||
BannerProvider bannerProvider, EpisodeProvider episodeProvider)
|
||||
: base(configProvider, diskProvider, bannerProvider, episodeProvider)
|
||||
BannerProvider bannerProvider, EpisodeService episodeService)
|
||||
: base(configProvider, diskProvider, bannerProvider, episodeService)
|
||||
{
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ public override void CreateForSeries(Series series, TvdbSeries tvDbSeries)
|
||||
public override void CreateForEpisodeFile(EpisodeFile episodeFile, TvdbSeries tvDbSeries)
|
||||
{
|
||||
//Create filename.tbn and filename.nfo
|
||||
var episodes = _episodeProvider.GetEpisodesByFileId(episodeFile.EpisodeFileId);
|
||||
var episodes = _episodeService.GetEpisodesByFileId(episodeFile.EpisodeFileId);
|
||||
|
||||
if (!episodes.Any())
|
||||
{
|
||||
|
@ -14,21 +14,21 @@ namespace NzbDrone.Core.Providers
|
||||
public class MisnamedProvider
|
||||
{
|
||||
private readonly MediaFileProvider _mediaFileProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public MisnamedProvider(MediaFileProvider mediaFileProvider, EpisodeProvider episodeProvider)
|
||||
public MisnamedProvider(MediaFileProvider mediaFileProvider, EpisodeService episodeService)
|
||||
{
|
||||
_mediaFileProvider = mediaFileProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
}
|
||||
|
||||
public virtual List<MisnamedEpisodeModel> MisnamedFiles(int pageNumber, int pageSize, out int totalItems)
|
||||
{
|
||||
var misnamedFiles = new List<MisnamedEpisodeModel>();
|
||||
|
||||
var episodesWithFiles = _episodeProvider.EpisodesWithFiles().GroupBy(e => e.EpisodeFileId).ToList();
|
||||
var episodesWithFiles = _episodeService.EpisodesWithFiles().GroupBy(e => e.EpisodeFileId).ToList();
|
||||
totalItems = episodesWithFiles.Count();
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
|
@ -16,16 +16,16 @@ public class PostDownloadProvider
|
||||
private static readonly Regex StatusRegex = new Regex(@"^_[\w_]*_", RegexOptions.Compiled);
|
||||
private readonly DiskProvider _diskProvider;
|
||||
private readonly DiskScanProvider _diskScanProvider;
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly MetadataProvider _metadataProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
public PostDownloadProvider(DiskProvider diskProvider, DiskScanProvider diskScanProvider,
|
||||
SeriesProvider seriesProvider, MetadataProvider metadataProvider,ISeriesRepository seriesRepository)
|
||||
ISeriesService seriesService, MetadataProvider metadataProvider,ISeriesRepository seriesRepository)
|
||||
{
|
||||
_diskProvider = diskProvider;
|
||||
_diskScanProvider = diskScanProvider;
|
||||
_seriesProvider = seriesProvider;
|
||||
_seriesService = seriesService;
|
||||
_metadataProvider = metadataProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
@ -79,7 +79,7 @@ public virtual void ProcessDownload(DirectoryInfo subfolderInfo)
|
||||
}
|
||||
|
||||
string seriesName = Parser.ParseSeriesName(RemoveStatusFromFolderName(subfolderInfo.Name));
|
||||
var series = _seriesRepository.Get(seriesName);
|
||||
var series = _seriesRepository.GetByTitle(seriesName);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
@ -149,7 +149,7 @@ public virtual void ProcessVideoFile(string videoFile)
|
||||
}
|
||||
|
||||
var seriesName = Parser.ParseSeriesName(Path.GetFileNameWithoutExtension(videoFile));
|
||||
var series = _seriesRepository.Get(seriesName);
|
||||
var series = _seriesRepository.GetByTitle(seriesName);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
|
@ -18,10 +18,10 @@ public class DailyEpisodeSearch : SearchBase
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public DailyEpisodeSearch(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, DownloadProvider downloadProvider, IndexerProvider indexerProvider,
|
||||
public DailyEpisodeSearch(ISeriesService seriesService, EpisodeService episodeService, DownloadProvider downloadProvider, IndexerProvider indexerProvider,
|
||||
SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification,
|
||||
SearchHistoryProvider searchHistoryProvider, ISeriesRepository seriesRepository)
|
||||
: base(seriesProvider, seriesRepository, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
: base(seriesService, seriesRepository, episodeService, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
allowedDownloadSpecification, searchHistoryProvider)
|
||||
{
|
||||
_seriesRepository = seriesRepository;
|
||||
|
@ -17,10 +17,10 @@ public class EpisodeSearch : SearchBase
|
||||
{
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public EpisodeSearch(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, DownloadProvider downloadProvider, IndexerProvider indexerProvider,
|
||||
public EpisodeSearch(ISeriesService seriesService, EpisodeService episodeService, DownloadProvider downloadProvider, IndexerProvider indexerProvider,
|
||||
SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification,
|
||||
SearchHistoryProvider searchHistoryProvider, ISeriesRepository seriesRepository)
|
||||
: base(seriesProvider,seriesRepository, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
: base(seriesService,seriesRepository, episodeService, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
allowedDownloadSpecification, searchHistoryProvider)
|
||||
{
|
||||
}
|
||||
|
@ -17,10 +17,10 @@ public class PartialSeasonSearch : SearchBase
|
||||
{
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public PartialSeasonSearch(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, DownloadProvider downloadProvider, IndexerProvider indexerProvider,
|
||||
public PartialSeasonSearch(ISeriesService seriesService, EpisodeService episodeService, DownloadProvider downloadProvider, IndexerProvider indexerProvider,
|
||||
SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification,
|
||||
SearchHistoryProvider searchHistoryProvider,ISeriesRepository seriesRepository)
|
||||
: base(seriesProvider, seriesRepository, episodeProvider, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
: base(seriesService, seriesRepository, episodeService, downloadProvider, indexerProvider, sceneMappingProvider,
|
||||
allowedDownloadSpecification, searchHistoryProvider)
|
||||
{
|
||||
}
|
||||
|
@ -1,23 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Search;
|
||||
|
||||
namespace NzbDrone.Core.Providers.Search
|
||||
{
|
||||
public abstract class SearchBase
|
||||
{
|
||||
protected readonly SeriesProvider _seriesProvider;
|
||||
protected readonly ISeriesService _seriesService;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
protected readonly EpisodeProvider _episodeProvider;
|
||||
protected readonly EpisodeService _episodeService;
|
||||
protected readonly DownloadProvider _downloadProvider;
|
||||
protected readonly IndexerProvider _indexerProvider;
|
||||
protected readonly SceneMappingProvider _sceneMappingProvider;
|
||||
@ -26,14 +24,14 @@ public abstract class SearchBase
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
protected SearchBase(SeriesProvider seriesProvider,ISeriesRepository seriesRepository, EpisodeProvider episodeProvider, DownloadProvider downloadProvider,
|
||||
protected SearchBase(ISeriesService seriesService,ISeriesRepository seriesRepository, EpisodeService episodeService, DownloadProvider downloadProvider,
|
||||
IndexerProvider indexerProvider, SceneMappingProvider sceneMappingProvider,
|
||||
AllowedDownloadSpecification allowedDownloadSpecification,
|
||||
SearchHistoryProvider searchHistoryProvider)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_seriesService = seriesService;
|
||||
_seriesRepository = seriesRepository;
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
_downloadProvider = downloadProvider;
|
||||
_indexerProvider = indexerProvider;
|
||||
_sceneMappingProvider = sceneMappingProvider;
|
||||
@ -107,7 +105,7 @@ public virtual SearchHistory ProcessReports(Series series, dynamic options, List
|
||||
items.Add(item);
|
||||
|
||||
logger.Trace("Analysing report " + episodeParseResult);
|
||||
episodeParseResult.Series = _seriesRepository.Get(episodeParseResult.CleanTitle);
|
||||
episodeParseResult.Series = _seriesRepository.GetByTitle(episodeParseResult.CleanTitle);
|
||||
|
||||
if(episodeParseResult.Series == null || episodeParseResult.Series.SeriesId != series.SeriesId)
|
||||
{
|
||||
@ -115,9 +113,9 @@ public virtual SearchHistory ProcessReports(Series series, dynamic options, List
|
||||
continue;
|
||||
}
|
||||
|
||||
episodeParseResult.Episodes = _episodeProvider.GetEpisodesByParseResult(episodeParseResult);
|
||||
episodeParseResult.Episodes = _episodeService.GetEpisodesByParseResult(episodeParseResult);
|
||||
|
||||
if (searchResult.Successes.Intersect(episodeParseResult.Episodes.Select(e => e.EpisodeId)).Any())
|
||||
if (searchResult.Successes.Intersect(episodeParseResult.Episodes.Select(e => e.OID)).Any())
|
||||
{
|
||||
item.SearchError = ReportRejectionType.Skipped;
|
||||
continue;
|
||||
@ -132,7 +130,7 @@ public virtual SearchHistory ProcessReports(Series series, dynamic options, List
|
||||
if(item.SearchError == ReportRejectionType.None)
|
||||
{
|
||||
if(DownloadReport(notification, episodeParseResult, item))
|
||||
searchResult.Successes.AddRange(episodeParseResult.Episodes.Select(e => e.EpisodeId));
|
||||
searchResult.Successes.AddRange(episodeParseResult.Episodes.Select(e => e.OID));
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
|
@ -13,20 +13,20 @@ namespace NzbDrone.Core.Providers
|
||||
public class SearchHistoryProvider
|
||||
{
|
||||
private readonly IDatabase _database;
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly DownloadProvider _downloadProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public SearchHistoryProvider(IDatabase database, SeriesProvider seriesProvider,
|
||||
DownloadProvider downloadProvider, EpisodeProvider episodeProvider, ISeriesRepository seriesRepository)
|
||||
public SearchHistoryProvider(IDatabase database, ISeriesService seriesService,
|
||||
DownloadProvider downloadProvider, EpisodeService episodeService, ISeriesRepository seriesRepository)
|
||||
{
|
||||
_database = database;
|
||||
_seriesProvider = seriesProvider;
|
||||
_seriesService = seriesService;
|
||||
_downloadProvider = downloadProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ public virtual void ForceDownload(int itemId)
|
||||
parseResult.NzbUrl = item.NzbUrl;
|
||||
parseResult.Series = series;
|
||||
parseResult.Indexer = item.Indexer;
|
||||
parseResult.Episodes = _episodeProvider.GetEpisodesByParseResult(parseResult);
|
||||
parseResult.Episodes = _episodeService.GetEpisodesByParseResult(parseResult);
|
||||
parseResult.SceneSource = true;
|
||||
|
||||
logger.Info("Forcing Download of: {0}", item.ReportTitle);
|
||||
|
@ -16,18 +16,18 @@ namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class SearchProvider
|
||||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly PartialSeasonSearch _partialSeasonSearch;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public SearchProvider(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
|
||||
public SearchProvider(ISeriesService seriesService, EpisodeService episodeService,
|
||||
PartialSeasonSearch partialSeasonSearch,ISeriesRepository seriesRepository)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_seriesService = seriesService;
|
||||
_episodeService = episodeService;
|
||||
_partialSeasonSearch = partialSeasonSearch;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
@ -46,14 +46,14 @@ public virtual List<int> SeasonSearch(ProgressNotification notification, int ser
|
||||
return new List<int>();
|
||||
}
|
||||
|
||||
if (series.IsDaily)
|
||||
if (series.SeriesType == SeriesType.Daily)
|
||||
{
|
||||
logger.Trace("Daily series detected, skipping season search: {0}", series.Title);
|
||||
return new List<int>();
|
||||
}
|
||||
|
||||
logger.Debug("Getting episodes from database for series: {0} and season: {1}", seriesId, seasonNumber);
|
||||
var episodes = _episodeProvider.GetEpisodesBySeason(seriesId, seasonNumber);
|
||||
var episodes = _episodeService.GetEpisodesBySeason(seriesId, seasonNumber);
|
||||
|
||||
if (episodes == null || episodes.Count == 0)
|
||||
{
|
||||
@ -75,13 +75,13 @@ public virtual List<int> PartialSeasonSearch(ProgressNotification notification,
|
||||
return new List<int>();
|
||||
}
|
||||
|
||||
if (series.IsDaily)
|
||||
if (series.SeriesType == SeriesType.Daily)
|
||||
{
|
||||
logger.Trace("Daily series detected, skipping season search: {0}", series.Title);
|
||||
return new List<int>();
|
||||
}
|
||||
|
||||
var episodes = _episodeProvider.GetEpisodesBySeason(seriesId, seasonNumber);
|
||||
var episodes = _episodeService.GetEpisodesBySeason(seriesId, seasonNumber);
|
||||
|
||||
if (episodes == null || episodes.Count == 0)
|
||||
{
|
||||
|
@ -13,16 +13,16 @@ public class TvRageMappingProvider
|
||||
{
|
||||
private readonly SceneMappingProvider _sceneMappingProvider;
|
||||
private readonly TvRageProvider _tvRageProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public TvRageMappingProvider(SceneMappingProvider sceneMappingProvider,
|
||||
TvRageProvider tvRageProvider, EpisodeProvider episodeProvider)
|
||||
TvRageProvider tvRageProvider, EpisodeService episodeService)
|
||||
{
|
||||
_sceneMappingProvider = sceneMappingProvider;
|
||||
_tvRageProvider = tvRageProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_episodeService = episodeService;
|
||||
}
|
||||
|
||||
public TvRageMappingProvider()
|
||||
@ -31,7 +31,7 @@ public TvRageMappingProvider()
|
||||
|
||||
public Series FindMatchingTvRageSeries(Series series)
|
||||
{
|
||||
var firstEpisode = _episodeProvider.GetEpisode(series.SeriesId, 1, 1);
|
||||
var firstEpisode = _episodeService.GetEpisode(series.SeriesId, 1, 1);
|
||||
|
||||
var cleanName = _sceneMappingProvider.GetCleanName(series.SeriesId);
|
||||
var results = _tvRageProvider.SearchSeries(series.Title);
|
||||
|
@ -10,18 +10,18 @@ namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class XemProvider
|
||||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly EpisodeService _episodeService;
|
||||
private readonly XemCommunicationProvider _xemCommunicationProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public XemProvider(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
|
||||
public XemProvider(ISeriesService seriesService, EpisodeService episodeService,
|
||||
XemCommunicationProvider xemCommunicationProvider,ISeriesRepository seriesRepository)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_seriesService = seriesService;
|
||||
_episodeService = episodeService;
|
||||
_xemCommunicationProvider = xemCommunicationProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
@ -89,7 +89,7 @@ public virtual void PerformUpdate(Series series)
|
||||
return;
|
||||
}
|
||||
|
||||
var episodes = _episodeProvider.GetEpisodeBySeries(series.SeriesId);
|
||||
var episodes = _episodeService.GetEpisodeBySeries(series.SeriesId);
|
||||
|
||||
foreach (var mapping in mappings)
|
||||
{
|
||||
@ -110,7 +110,7 @@ public virtual void PerformUpdate(Series series)
|
||||
}
|
||||
|
||||
_logger.Trace("Committing scene numbering mappings to database for: {0}", series.Title);
|
||||
_episodeProvider.UpdateEpisodes(episodesToUpdate);
|
||||
_episodeService.UpdateEpisodes(episodesToUpdate);
|
||||
|
||||
_logger.Trace("Setting UseSceneMapping for {0}", series.Title);
|
||||
series.UseSceneNumbering = true;
|
||||
|
@ -25,14 +25,14 @@ public class RootFolderService : IRootFolderService
|
||||
private readonly IBasicRepository<RootFolder> _rootFolderRepository;
|
||||
private readonly DiskProvider _diskProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
|
||||
public RootFolderService(IBasicRepository<RootFolder> rootFolderRepository, SeriesProvider seriesProvider, DiskProvider diskProvider,ISeriesRepository seriesRepository)
|
||||
public RootFolderService(IBasicRepository<RootFolder> rootFolderRepository, ISeriesService seriesService, DiskProvider diskProvider,ISeriesRepository seriesRepository)
|
||||
{
|
||||
_rootFolderRepository = rootFolderRepository;
|
||||
_diskProvider = diskProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
_seriesProvider = seriesProvider;
|
||||
_seriesService = seriesService;
|
||||
}
|
||||
|
||||
public virtual List<RootFolder> All()
|
||||
|
@ -1,17 +1,15 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Model;
|
||||
|
||||
namespace NzbDrone.Core.Tv
|
||||
{
|
||||
public class Episode
|
||||
public class Episode : ModelBase
|
||||
{
|
||||
public int EpisodeId { get; set; }
|
||||
|
||||
public int? TvDbEpisodeId { get; set; }
|
||||
|
||||
public int SeriesId { get; set; }
|
||||
public int EpisodeFileId { get; set; }
|
||||
public int SeasonNumber { get; set; }
|
||||
public int EpisodeNumber { get; set; }
|
||||
public string Title { get; set; }
|
||||
@ -25,6 +23,23 @@ public class Episode
|
||||
|
||||
public DateTime? GrabDate { get; set; }
|
||||
|
||||
|
||||
public bool HasFile
|
||||
{
|
||||
get { return EpisodeFile != null; }
|
||||
}
|
||||
|
||||
public int EpisodeFileId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!HasFile) return 0;
|
||||
return EpisodeFile.EpisodeFileId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public EpisodeStatusType Status
|
||||
{
|
||||
get
|
||||
@ -64,7 +79,7 @@ public override string ToString()
|
||||
{
|
||||
string seriesTitle = Series == null ? "[NULL]" : Series.Title;
|
||||
|
||||
if (Series != null && Series.IsDaily && AirDate.HasValue)
|
||||
if (Series != null && Series.SeriesType == SeriesType.Daily && AirDate.HasValue)
|
||||
return string.Format("{0} - {1:yyyy-MM-dd}", seriesTitle, AirDate.Value);
|
||||
|
||||
return string.Format("{0} - S{1:00}E{2:00}", seriesTitle, SeasonNumber, EpisodeNumber);
|
||||
|
@ -1,476 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using PetaPoco;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Tv
|
||||
{
|
||||
public class EpisodeProvider
|
||||
{
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private readonly TvDbProvider _tvDbProvider;
|
||||
private readonly SeasonProvider _seasonProvider;
|
||||
private readonly IDatabase _database;
|
||||
|
||||
public EpisodeProvider(IDatabase database, TvDbProvider tvDbProviderProvider,
|
||||
SeasonProvider seasonProvider)
|
||||
{
|
||||
_tvDbProvider = tvDbProviderProvider;
|
||||
_seasonProvider = seasonProvider;
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public EpisodeProvider()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void AddEpisode(Episode episode)
|
||||
{
|
||||
//If Season is ignored ignore this episode
|
||||
episode.Ignored = _seasonProvider.IsIgnored(episode.SeriesId, episode.SeasonNumber);
|
||||
|
||||
_database.Insert(episode);
|
||||
}
|
||||
|
||||
public virtual Episode GetEpisode(long id)
|
||||
{
|
||||
var episode = _database.Fetch<Episode, Series, EpisodeFile>(@"SELECT * FROM Episodes
|
||||
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
|
||||
LEFT JOIN EpisodeFiles ON Episodes.EpisodeFileId = EpisodeFiles.EpisodeFileId
|
||||
WHERE EpisodeId = @0", id).Single();
|
||||
|
||||
if (episode.EpisodeFileId == 0)
|
||||
episode.EpisodeFile = null;
|
||||
|
||||
return episode;
|
||||
}
|
||||
|
||||
public virtual Episode GetEpisode(int seriesId, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
var episode = _database.Fetch<Episode, Series, EpisodeFile>(@"SELECT * FROM Episodes
|
||||
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
|
||||
LEFT JOIN EpisodeFiles ON Episodes.EpisodeFileId = EpisodeFiles.EpisodeFileId
|
||||
WHERE Episodes.SeriesId = @0 AND Episodes.SeasonNumber = @1 AND Episodes.EpisodeNumber = @2", seriesId, seasonNumber, episodeNumber).SingleOrDefault();
|
||||
|
||||
if (episode == null)
|
||||
return null;
|
||||
|
||||
if (episode.EpisodeFileId == 0)
|
||||
episode.EpisodeFile = null;
|
||||
|
||||
return episode;
|
||||
}
|
||||
|
||||
public virtual Episode GetEpisode(int seriesId, DateTime date)
|
||||
{
|
||||
var episode = _database.Fetch<Episode, Series, EpisodeFile>(@"SELECT * FROM Episodes
|
||||
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
|
||||
LEFT JOIN EpisodeFiles ON Episodes.EpisodeFileId = EpisodeFiles.EpisodeFileId
|
||||
WHERE Episodes.SeriesId = @0 AND AirDate = @1", seriesId, date.Date).SingleOrDefault();
|
||||
|
||||
if (episode == null)
|
||||
return null;
|
||||
|
||||
if (episode.EpisodeFileId == 0)
|
||||
episode.EpisodeFile = null;
|
||||
|
||||
return episode;
|
||||
}
|
||||
|
||||
public virtual IList<Episode> GetEpisodeBySeries(long seriesId)
|
||||
{
|
||||
var episodes = _database.Fetch<Episode, Series, EpisodeFile>(@"SELECT * FROM Episodes
|
||||
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
|
||||
LEFT JOIN EpisodeFiles ON Episodes.EpisodeFileId = EpisodeFiles.EpisodeFileId
|
||||
WHERE Episodes.SeriesId = @0", seriesId);
|
||||
|
||||
foreach (var episode in episodes)
|
||||
{
|
||||
if (episode.EpisodeFileId == 0)
|
||||
episode.EpisodeFile = null;
|
||||
}
|
||||
|
||||
return episodes;
|
||||
}
|
||||
|
||||
public virtual IList<Episode> GetEpisodesBySeason(long seriesId, int seasonNumber)
|
||||
{
|
||||
var episodes = _database.Fetch<Episode, Series, EpisodeFile>(@"SELECT * FROM Episodes
|
||||
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
|
||||
LEFT JOIN EpisodeFiles ON Episodes.EpisodeFileId = EpisodeFiles.EpisodeFileId
|
||||
WHERE Episodes.SeriesId = @0 AND Episodes.SeasonNumber = @1", seriesId, seasonNumber);
|
||||
|
||||
foreach (var episode in episodes)
|
||||
{
|
||||
if (episode.EpisodeFileId == 0)
|
||||
episode.EpisodeFile = null;
|
||||
}
|
||||
|
||||
return episodes;
|
||||
}
|
||||
|
||||
public virtual void MarkEpisodeAsFetched(int episodeId)
|
||||
{
|
||||
logger.Trace("Marking episode {0} as fetched.", episodeId);
|
||||
_database.Execute("UPDATE Episodes SET GrabDate=@0 WHERE EpisodeId=@1", DateTime.Now, episodeId);
|
||||
}
|
||||
|
||||
public virtual IList<Episode> GetEpisodesByParseResult(EpisodeParseResult parseResult)
|
||||
{
|
||||
//Disabling auto add, need to make it a lot more conservative.
|
||||
var autoAddNew = false;
|
||||
|
||||
var result = new List<Episode>();
|
||||
|
||||
if (parseResult.AirDate.HasValue)
|
||||
{
|
||||
if (!parseResult.Series.IsDaily)
|
||||
{
|
||||
//Todo: Collect this as a Series we want to treat as a daily series, or possible parsing error
|
||||
logger.Warn("Found daily-style episode for non-daily series: {0}. {1}", parseResult.Series.Title, parseResult.OriginalString);
|
||||
return new List<Episode>();
|
||||
}
|
||||
|
||||
var episodeInfo = GetEpisode(parseResult.Series.SeriesId, parseResult.AirDate.Value);
|
||||
|
||||
if (episodeInfo == null && autoAddNew)
|
||||
{
|
||||
logger.Info("Episode {0} doesn't exist in db. adding it now. {1}", parseResult, parseResult.OriginalString);
|
||||
episodeInfo = new Episode
|
||||
{
|
||||
SeriesId = parseResult.Series.SeriesId,
|
||||
AirDate = parseResult.AirDate.Value,
|
||||
Title = "TBD",
|
||||
Overview = String.Empty
|
||||
};
|
||||
|
||||
var episodesInSeries = GetEpisodeBySeries(parseResult.Series.SeriesId);
|
||||
|
||||
//Find the current season number
|
||||
var maxSeasonNumber = episodesInSeries.Select(s => s.SeasonNumber).MaxOrDefault();
|
||||
|
||||
//Set the season number
|
||||
episodeInfo.SeasonNumber = (maxSeasonNumber == 0) ? 1 : maxSeasonNumber;
|
||||
|
||||
//Find the latest episode number
|
||||
var maxEpisodeNumber = episodesInSeries
|
||||
.Where(w => w.SeasonNumber == episodeInfo.SeasonNumber)
|
||||
.Select(s => s.EpisodeNumber).MaxOrDefault();
|
||||
|
||||
//Set the episode number to max + 1
|
||||
episodeInfo.EpisodeNumber = maxEpisodeNumber + 1;
|
||||
|
||||
AddEpisode(episodeInfo);
|
||||
}
|
||||
if (episodeInfo != null)
|
||||
{
|
||||
result.Add(episodeInfo);
|
||||
parseResult.EpisodeTitle = episodeInfo.Title;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
if (parseResult.EpisodeNumbers == null)
|
||||
return result;
|
||||
|
||||
//Set it to empty before looping through the episode numbers
|
||||
parseResult.EpisodeTitle = String.Empty;
|
||||
|
||||
foreach (var episodeNumber in parseResult.EpisodeNumbers)
|
||||
{
|
||||
Episode episodeInfo = null;
|
||||
|
||||
if (parseResult.SceneSource && parseResult.Series.UseSceneNumbering)
|
||||
episodeInfo = GetEpisodeBySceneNumbering(parseResult.Series.SeriesId, parseResult.SeasonNumber, episodeNumber);
|
||||
|
||||
if (episodeInfo == null)
|
||||
{
|
||||
episodeInfo = GetEpisode(parseResult.Series.SeriesId, parseResult.SeasonNumber, episodeNumber);
|
||||
if (episodeInfo == null && parseResult.AirDate != null)
|
||||
{
|
||||
episodeInfo = GetEpisode(parseResult.Series.SeriesId, parseResult.AirDate.Value);
|
||||
}
|
||||
}
|
||||
|
||||
//if still null we should add the temp episode
|
||||
if (episodeInfo == null && autoAddNew)
|
||||
{
|
||||
logger.Info("Episode {0} doesn't exist in db. adding it now. {1}", parseResult, parseResult.OriginalString);
|
||||
episodeInfo = new Episode
|
||||
{
|
||||
SeriesId = parseResult.Series.SeriesId,
|
||||
AirDate = DateTime.Now.Date,
|
||||
EpisodeNumber = episodeNumber,
|
||||
SeasonNumber = parseResult.SeasonNumber,
|
||||
Title = "TBD",
|
||||
Overview = String.Empty,
|
||||
};
|
||||
|
||||
if (parseResult.EpisodeNumbers.Count == 1 && parseResult.EpisodeNumbers.First() == 0)
|
||||
episodeInfo.Ignored = true;
|
||||
|
||||
AddEpisode(episodeInfo);
|
||||
}
|
||||
|
||||
if (episodeInfo != null)
|
||||
{
|
||||
result.Add(episodeInfo);
|
||||
|
||||
if (parseResult.Series.UseSceneNumbering)
|
||||
{
|
||||
logger.Info("Using Scene to TVDB Mapping for: {0} - Scene: {1}x{2:00} - TVDB: {3}x{4:00}",
|
||||
parseResult.Series.Title,
|
||||
episodeInfo.SceneSeasonNumber,
|
||||
episodeInfo.SceneEpisodeNumber,
|
||||
episodeInfo.SeasonNumber,
|
||||
episodeInfo.EpisodeNumber);
|
||||
}
|
||||
|
||||
if (parseResult.EpisodeNumbers.Count == 1)
|
||||
{
|
||||
parseResult.EpisodeTitle = episodeInfo.Title.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
parseResult.EpisodeTitle = Parser.CleanupEpisodeTitle(episodeInfo.Title);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Debug("Unable to find {0}", parseResult);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual IList<Episode> EpisodesWithoutFiles(bool includeSpecials)
|
||||
{
|
||||
var episodes = _database.Query<Episode, Series>(@"SELECT Episodes.*, Series.* FROM Episodes
|
||||
INNER JOIN Series
|
||||
ON Episodes.SeriesId = Series.SeriesId
|
||||
WHERE (EpisodeFileId=0 OR EpisodeFileId=NULL) AND Ignored = 0 AND AirDate<=@0",
|
||||
DateTime.Now.Date);
|
||||
if (!includeSpecials)
|
||||
return episodes.Where(e => e.SeasonNumber > 0).ToList();
|
||||
|
||||
return episodes.ToList();
|
||||
}
|
||||
|
||||
public virtual IList<Episode> GetEpisodesByFileId(int episodeFileId)
|
||||
{
|
||||
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
|
||||
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
|
||||
WHERE EpisodeFileId = @0", episodeFileId);
|
||||
}
|
||||
|
||||
public virtual IList<Episode> EpisodesWithFiles()
|
||||
{
|
||||
var episodes = _database.Fetch<Episode, Series, EpisodeFile>(@"SELECT Episodes.*, Series.*, EpisodeFiles.* FROM Episodes
|
||||
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
|
||||
INNER JOIN EpisodeFiles ON Episodes.EpisodeFileId = EpisodeFiles.EpisodeFileId");
|
||||
|
||||
return episodes;
|
||||
}
|
||||
|
||||
public virtual void RefreshEpisodeInfo(Series series)
|
||||
{
|
||||
logger.Trace("Starting episode info refresh for series: {0}", series.Title.WithDefault(series.SeriesId));
|
||||
var successCount = 0;
|
||||
var failCount = 0;
|
||||
|
||||
var tvdbEpisodes = _tvDbProvider.GetSeries(series.SeriesId, true)
|
||||
.Episodes
|
||||
.Where(episode => !string.IsNullOrWhiteSpace(episode.EpisodeName) ||
|
||||
(episode.FirstAired < DateTime.Now.AddDays(2) && episode.FirstAired.Year > 1900))
|
||||
.ToList();
|
||||
|
||||
var seriesEpisodes = GetEpisodeBySeries(series.SeriesId);
|
||||
var updateList = new List<Episode>();
|
||||
var newList = new List<Episode>();
|
||||
|
||||
_seasonProvider.EnsureSeasons(series.SeriesId, tvdbEpisodes.Select(c => c.SeasonNumber).Distinct());
|
||||
|
||||
foreach (var episode in tvdbEpisodes.OrderBy(e => e.SeasonNumber).ThenBy(e => e.EpisodeNumber))
|
||||
{
|
||||
try
|
||||
{
|
||||
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);
|
||||
|
||||
//not found, try using season/episode number
|
||||
if (episodeToUpdate == null)
|
||||
{
|
||||
episodeToUpdate = seriesEpisodes.SingleOrDefault(e => e.SeasonNumber == episode.SeasonNumber && e.EpisodeNumber == episode.EpisodeNumber);
|
||||
}
|
||||
|
||||
if (episodeToUpdate == null)
|
||||
{
|
||||
episodeToUpdate = new Episode();
|
||||
newList.Add(episodeToUpdate);
|
||||
|
||||
//If it is Episode Zero Ignore it (specials, sneak peeks.)
|
||||
if (episode.EpisodeNumber == 0 && episode.SeasonNumber != 1)
|
||||
{
|
||||
episodeToUpdate.Ignored = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
episodeToUpdate.Ignored = _seasonProvider.IsIgnored(series.SeriesId, episode.SeasonNumber);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updateList.Add(episodeToUpdate);
|
||||
}
|
||||
|
||||
if ((episodeToUpdate.EpisodeNumber != episode.EpisodeNumber ||
|
||||
episodeToUpdate.SeasonNumber != episode.SeasonNumber) &&
|
||||
episodeToUpdate.EpisodeFileId > 0)
|
||||
{
|
||||
logger.Info("Unlinking episode file because TheTVDB changed the epsiode number...");
|
||||
|
||||
_database.Delete<EpisodeFile>(episodeToUpdate.EpisodeFileId);
|
||||
episodeToUpdate.EpisodeFileId = 0;
|
||||
}
|
||||
|
||||
episodeToUpdate.SeriesId = series.SeriesId;
|
||||
episodeToUpdate.TvDbEpisodeId = episode.Id;
|
||||
episodeToUpdate.EpisodeNumber = episode.EpisodeNumber;
|
||||
episodeToUpdate.SeasonNumber = episode.SeasonNumber;
|
||||
episodeToUpdate.AbsoluteEpisodeNumber = episode.AbsoluteNumber;
|
||||
episodeToUpdate.Title = episode.EpisodeName;
|
||||
|
||||
episodeToUpdate.Overview = episode.Overview.Truncate(3500);
|
||||
|
||||
if (episode.FirstAired.Year > 1900)
|
||||
episodeToUpdate.AirDate = episode.FirstAired.Date;
|
||||
else
|
||||
episodeToUpdate.AirDate = null;
|
||||
|
||||
successCount++;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.FatalException(String.Format("An error has occurred while updating episode info for series {0}", series.Title), e);
|
||||
failCount++;
|
||||
}
|
||||
}
|
||||
|
||||
_database.InsertMany(newList);
|
||||
_database.UpdateMany(updateList);
|
||||
|
||||
if (failCount != 0)
|
||||
{
|
||||
logger.Info("Finished episode refresh for series: {0}. Successful: {1} - Failed: {2} ",
|
||||
series.Title, successCount, failCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Info("Finished episode refresh for series: {0}.", series.Title);
|
||||
}
|
||||
|
||||
DeleteEpisodesNotInTvdb(series, tvdbEpisodes);
|
||||
}
|
||||
|
||||
public virtual void UpdateEpisode(Episode episode)
|
||||
{
|
||||
_database.Update(episode);
|
||||
}
|
||||
|
||||
public virtual IList<int> GetSeasons(int seriesId)
|
||||
{
|
||||
return _database.Fetch<Int32>("SELECT DISTINCT SeasonNumber FROM Episodes WHERE SeriesId=@0", seriesId).OrderBy(c => c).ToList();
|
||||
}
|
||||
|
||||
public virtual IList<int> GetEpisodeNumbersBySeason(int seriesId, int seasonNumber)
|
||||
{
|
||||
return _database.Fetch<int>("SELECT EpisodeNumber FROM Episodes WHERE SeriesId=@0 AND SeasonNumber=@1", seriesId, seasonNumber).OrderBy(c => c).ToList();
|
||||
}
|
||||
|
||||
public virtual void SetEpisodeIgnore(int episodeId, bool isIgnored)
|
||||
{
|
||||
_database.Execute(@"UPDATE Episodes SET Ignored = @0
|
||||
WHERE EpisodeId = @1",
|
||||
isIgnored, episodeId);
|
||||
|
||||
logger.Info("Ignore flag for Episode:{0} was set to {1}", episodeId, isIgnored);
|
||||
}
|
||||
|
||||
public virtual bool IsFirstOrLastEpisodeOfSeason(int seriesId, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
var episodes = GetEpisodesBySeason(seriesId, seasonNumber).OrderBy(e => e.EpisodeNumber);
|
||||
|
||||
if (!episodes.Any())
|
||||
return false;
|
||||
|
||||
//Ensure that this is either the first episode
|
||||
//or is the last episode in a season that has 10 or more episodes
|
||||
if (episodes.First().EpisodeNumber == episodeNumber || (episodes.Count() >= 10 && episodes.Last().EpisodeNumber == episodeNumber))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void DeleteEpisodesNotInTvdb(Series series, IList<TvdbEpisode> tvdbEpisodes)
|
||||
{
|
||||
logger.Trace("Starting deletion of episodes that no longer exist in TVDB: {0}", series.Title.WithDefault(series.SeriesId));
|
||||
|
||||
if (!tvdbEpisodes.Any()) return;
|
||||
|
||||
//Delete Episodes not matching TvDbIds for this series
|
||||
var tvDbIds = tvdbEpisodes.Select(e => e.Id);
|
||||
var tvDbIdString = String.Join(", ", tvDbIds);
|
||||
|
||||
var tvDbIdQuery = String.Format("DELETE FROM Episodes WHERE SeriesId = {0} AND TvDbEpisodeId > 0 AND TvDbEpisodeId NOT IN ({1})",
|
||||
series.SeriesId, tvDbIdString);
|
||||
|
||||
_database.Execute(tvDbIdQuery);
|
||||
|
||||
logger.Trace("Deleted episodes that no longer exist in TVDB for {0}", series.SeriesId);
|
||||
}
|
||||
|
||||
public virtual void SetPostDownloadStatus(List<int> episodeIds, PostDownloadStatusType postDownloadStatus)
|
||||
{
|
||||
if (episodeIds.Count == 0) throw new ArgumentException("episodeIds should contain one or more episode ids.");
|
||||
|
||||
var episodeIdString = String.Join(", ", episodeIds);
|
||||
|
||||
var episodeIdQuery = String.Format(@"UPDATE Episodes SET PostDownloadStatus = {0}
|
||||
WHERE EpisodeId IN ({1})", (int)postDownloadStatus, episodeIdString);
|
||||
|
||||
logger.Trace("Updating PostDownloadStatus for all episodeIds in {0}", episodeIdString);
|
||||
_database.Execute(episodeIdQuery);
|
||||
}
|
||||
|
||||
public virtual void UpdateEpisodes(List<Episode> episodes)
|
||||
{
|
||||
_database.UpdateMany(episodes);
|
||||
}
|
||||
|
||||
public virtual Episode GetEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
var episode = _database.Fetch<Episode, Series, EpisodeFile>(@"SELECT * FROM Episodes
|
||||
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
|
||||
LEFT JOIN EpisodeFiles ON Episodes.EpisodeFileId = EpisodeFiles.EpisodeFileId
|
||||
WHERE Episodes.SeriesId = @0 AND Episodes.SceneSeasonNumber = @1 AND Episodes.SceneEpisodeNumber = @2", seriesId, seasonNumber, episodeNumber).SingleOrDefault();
|
||||
|
||||
if (episode == null)
|
||||
return null;
|
||||
|
||||
if (episode.EpisodeFileId == 0)
|
||||
episode.EpisodeFile = null;
|
||||
|
||||
return episode;
|
||||
}
|
||||
}
|
||||
} |