Added GetSeasonFiles to MediaFileProvider
This commit is contained in:
parent
4ac4ba5067
commit
6c4f19b365
|
@ -300,12 +300,38 @@ namespace NzbDrone.Core.Test
|
||||||
.Setup(c => c.GetAllSeries())
|
.Setup(c => c.GetAllSeries())
|
||||||
.Returns(Builder<Series>.CreateListOfSize(2)
|
.Returns(Builder<Series>.CreateListOfSize(2)
|
||||||
.WhereTheFirst(1).Has(c => c.LastInfoSync = DateTime.Now).Build().AsQueryable());
|
.WhereTheFirst(1).Has(c => c.LastInfoSync = DateTime.Now).Build().AsQueryable());
|
||||||
mocker.GetMock<MediaFileProvider>( MockBehavior.Strict)
|
mocker.GetMock<MediaFileProvider>(MockBehavior.Strict)
|
||||||
.Setup(c=>c.Scan(It.Is<Series>(s=>s.LastInfoSync != null))).Returns(new List<EpisodeFile>()).Verifiable();
|
.Setup(c => c.Scan(It.Is<Series>(s => s.LastInfoSync != null))).Returns(new List<EpisodeFile>()).Verifiable();
|
||||||
|
|
||||||
mocker.Resolve<MediaFileScanJob>().Start(new ProgressNotification("test"), 0);
|
mocker.Resolve<MediaFileScanJob>().Start(new ProgressNotification("test"), 0);
|
||||||
|
|
||||||
mocker.VerifyAllMocks();
|
mocker.VerifyAllMocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void get_season_files()
|
||||||
|
{
|
||||||
|
var episodes = Builder<Episode>.CreateListOfSize(20)
|
||||||
|
.WhereTheFirst(8)
|
||||||
|
.Has(c => c.EpisodeFile = new EpisodeFile())
|
||||||
|
.AndTheRemaining()
|
||||||
|
.Has(c => c.EpisodeFile = null)
|
||||||
|
.Build().ToList();
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
mocker.GetMock<SeasonProvider>()
|
||||||
|
.Setup(c => c.GetSeason(12))
|
||||||
|
.Returns(Builder<Season>.CreateNew().With(c => c.Episodes = episodes).Build())
|
||||||
|
.Verifiable();
|
||||||
|
|
||||||
|
|
||||||
|
var result = mocker.Resolve<MediaFileProvider>().GetSeasonFiles(12);
|
||||||
|
|
||||||
|
Assert.Count(8, result);
|
||||||
|
Assert.DoesNotContain(result, null);
|
||||||
|
mocker.VerifyAllMocks();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,14 +11,16 @@ namespace NzbDrone.Core.Providers.Jobs
|
||||||
private readonly SeriesProvider _seriesProvider;
|
private readonly SeriesProvider _seriesProvider;
|
||||||
private readonly EpisodeProvider _episodeProvider;
|
private readonly EpisodeProvider _episodeProvider;
|
||||||
private readonly MediaFileProvider _mediaFileProvider;
|
private readonly MediaFileProvider _mediaFileProvider;
|
||||||
|
private readonly SeasonProvider _seasonProvider;
|
||||||
|
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public NewSeriesUpdate(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, MediaFileProvider mediaFileProvider)
|
public NewSeriesUpdate(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, MediaFileProvider mediaFileProvider, SeasonProvider seasonProvider)
|
||||||
{
|
{
|
||||||
_seriesProvider = seriesProvider;
|
_seriesProvider = seriesProvider;
|
||||||
_episodeProvider = episodeProvider;
|
_episodeProvider = episodeProvider;
|
||||||
_mediaFileProvider = mediaFileProvider;
|
_mediaFileProvider = mediaFileProvider;
|
||||||
|
_seasonProvider = seasonProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
|
@ -48,11 +50,12 @@ namespace NzbDrone.Core.Providers.Jobs
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
notification.CurrentMessage = String.Format("Searching for '{0}'", new DirectoryInfo(currentSeries.Path).Name);
|
notification.CurrentMessage = String.Format("Searching for '{0}'",
|
||||||
|
new DirectoryInfo(currentSeries.Path).Name);
|
||||||
var updatedSeries = _seriesProvider.UpdateSeriesInfo(currentSeries.SeriesId);
|
var updatedSeries = _seriesProvider.UpdateSeriesInfo(currentSeries.SeriesId);
|
||||||
|
|
||||||
notification.CurrentMessage = String.Format("Downloading episode info for '{0}'",
|
notification.CurrentMessage = String.Format("Downloading episode info for '{0}'",
|
||||||
updatedSeries.Title);
|
updatedSeries.Title);
|
||||||
_episodeProvider.RefreshEpisodeInfo(updatedSeries.SeriesId);
|
_episodeProvider.RefreshEpisodeInfo(updatedSeries.SeriesId);
|
||||||
|
|
||||||
notification.CurrentMessage = String.Format("Scanning disk for '{0}' files", updatedSeries.Title);
|
notification.CurrentMessage = String.Format("Scanning disk for '{0}' files", updatedSeries.Title);
|
||||||
|
|
|
@ -16,15 +16,17 @@ namespace NzbDrone.Core.Providers
|
||||||
private readonly DiskProvider _diskProvider;
|
private readonly DiskProvider _diskProvider;
|
||||||
private readonly EpisodeProvider _episodeProvider;
|
private readonly EpisodeProvider _episodeProvider;
|
||||||
private readonly SeriesProvider _seriesProvider;
|
private readonly SeriesProvider _seriesProvider;
|
||||||
|
private readonly SeasonProvider _seasonProvider;
|
||||||
private readonly IRepository _repository;
|
private readonly IRepository _repository;
|
||||||
|
|
||||||
public MediaFileProvider(IRepository repository, DiskProvider diskProvider,
|
public MediaFileProvider(IRepository repository, DiskProvider diskProvider,
|
||||||
EpisodeProvider episodeProvider, SeriesProvider seriesProvider)
|
EpisodeProvider episodeProvider, SeriesProvider seriesProvider, SeasonProvider seasonProvider)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
_episodeProvider = episodeProvider;
|
_episodeProvider = episodeProvider;
|
||||||
_seriesProvider = seriesProvider;
|
_seriesProvider = seriesProvider;
|
||||||
|
_seasonProvider = seasonProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MediaFileProvider() { }
|
public MediaFileProvider() { }
|
||||||
|
@ -180,6 +182,13 @@ namespace NzbDrone.Core.Providers
|
||||||
return _repository.All<EpisodeFile>().ToList();
|
return _repository.All<EpisodeFile>().ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual List<EpisodeFile> GetSeasonFiles(int seasonId)
|
||||||
|
{
|
||||||
|
var res = _seasonProvider.GetSeason(seasonId).Episodes.Where(c => c.EpisodeFile != null).Select(c => c.EpisodeFile);
|
||||||
|
|
||||||
|
return res.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
private List<string> GetMediaFileList(string path)
|
private List<string> GetMediaFileList(string path)
|
||||||
{
|
{
|
||||||
Logger.Debug("Scanning '{0}' for episodes", path);
|
Logger.Debug("Scanning '{0}' for episodes", path);
|
||||||
|
|
|
@ -18,9 +18,9 @@ namespace NzbDrone.Core.Repository
|
||||||
public DayOfWeek? LastDiskSync { get; set; }
|
public DayOfWeek? LastDiskSync { get; set; }
|
||||||
|
|
||||||
[SubSonicToManyRelation]
|
[SubSonicToManyRelation]
|
||||||
public virtual List<Episode> Episodes { get; protected set; }
|
public virtual List<Episode> Episodes { get; set; }
|
||||||
|
|
||||||
[SubSonicToOneRelation(ThisClassContainsJoinKey = true)]
|
[SubSonicToOneRelation(ThisClassContainsJoinKey = true)]
|
||||||
public virtual Series Series { get; protected set; }
|
public virtual Series Series { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue