mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
Merge branch 'master' of git://github.com/kayone/NzbDrone
Conflicts: NzbDrone.Core.Test/ParserTest.cs
This commit is contained in:
commit
76a9a0c6f0
@ -152,8 +152,8 @@ public void import_existing_season_file()
|
||||
.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(true).Verifiable();
|
||||
|
||||
//mocker.GetMock<EpisodeProvider>()
|
||||
// .Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns(fakeEpisode)
|
||||
// .Verifiable();
|
||||
// .Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns(fakeEpisode)
|
||||
// .Verifiable();
|
||||
|
||||
mocker.GetMock<DiskProvider>()
|
||||
.Setup(e => e.GetSize(fileName)).Returns(size).Verifiable();
|
||||
@ -224,18 +224,17 @@ public void import_existing_file()
|
||||
mocker.GetMock<IRepository>(MockBehavior.Strict)
|
||||
.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(true).Verifiable();
|
||||
mocker.GetMock<EpisodeProvider>(MockBehavior.Strict);
|
||||
mocker.GetMock<DiskProvider>(MockBehavior.Strict);
|
||||
mocker.GetMock<DiskProvider>()
|
||||
.Setup(e => e.GetSize(fileName)).Returns(500000).Verifiable();
|
||||
|
||||
|
||||
//Act
|
||||
var result = mocker.Resolve<MediaFileProvider>().ImportFile(fakeSeries, fileName);
|
||||
|
||||
//Assert
|
||||
mocker.GetMock<IRepository>().VerifyAll();
|
||||
mocker.GetMock<EpisodeProvider>().VerifyAll();
|
||||
mocker.GetMock<DiskProvider>(MockBehavior.Strict).VerifyAll();
|
||||
Assert.IsNull(result);
|
||||
mocker.GetMock<IRepository>().Verify(r => r.Add(result), Times.Never());
|
||||
mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -262,7 +261,8 @@ public void import_file_with_no_episode()
|
||||
.Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns<Episode>(null).
|
||||
Verifiable();
|
||||
|
||||
mocker.GetMock<DiskProvider>(MockBehavior.Strict);
|
||||
mocker.GetMock<DiskProvider>(MockBehavior.Strict)
|
||||
.Setup(e => e.GetSize(fileName)).Returns(90000000000);
|
||||
|
||||
|
||||
//Act
|
||||
|
@ -112,15 +112,15 @@ public void episode_multipart_parse(string postTitle, string title, int season,
|
||||
[Row("The Tonight Show With Jay Leno 2011 04 15 1080i HDTV DD5 1 MPEG2 TrollHD", "The Tonight Show With Jay Leno", 2011, 04, 15)]
|
||||
[Row("The.Daily.Show.2010.10.11.Johnny.Knoxville.iTouch-MW", "The.Daily.Show", 2010, 10, 11)]
|
||||
[Row("The Daily Show - 2011-04-12 - Gov. Deval Patrick", "The.Daily.Show", 2011, 04, 12)]
|
||||
[Row("2011.01.10 - Denis Leary - HD TV.mkv", 2011, 1, 10)]
|
||||
[Row("2011.03.13 - Denis Leary - HD TV.mkv", 2011, 3, 13)]
|
||||
[Row("2011.01.10 - Denis Leary - HD TV.mkv","", 2011, 1, 10)]
|
||||
[Row("2011.03.13 - Denis Leary - HD TV.mkv", "", 2011, 3, 13)]
|
||||
public void episode_daily_parse(string postTitle, string title, int year, int month, int day)
|
||||
{
|
||||
var result = Parser.ParseEpisodeInfo(postTitle);
|
||||
var airDate = new DateTime(year, month, day);
|
||||
Assert.AreEqual(Parser.NormalizeTitle(title), result.CleanTitle);
|
||||
Assert.AreEqual(airDate, result.AirDate);
|
||||
Assert.IsEmpty(result.Episodes);
|
||||
Assert.IsNull(result.Episodes);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -10,16 +10,16 @@ namespace NzbDrone.Core.Providers.Core
|
||||
public class ConfigProvider
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly IRepository _sonicRepo;
|
||||
private readonly IRepository _repository;
|
||||
|
||||
public ConfigProvider(IRepository dataRepository)
|
||||
public ConfigProvider(IRepository repository)
|
||||
{
|
||||
_sonicRepo = dataRepository;
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
public IList<Config> All()
|
||||
{
|
||||
return _sonicRepo.All<Config>().ToList();
|
||||
return _repository.All<Config>().ToList();
|
||||
}
|
||||
|
||||
public ConfigProvider()
|
||||
@ -220,7 +220,7 @@ public virtual string GetValue(string key, object defaultValue, bool makePermane
|
||||
{
|
||||
string value;
|
||||
|
||||
var dbValue = _sonicRepo.Single<Config>(key);
|
||||
var dbValue = _repository.Single<Config>(key);
|
||||
|
||||
if (dbValue != null && !String.IsNullOrEmpty(dbValue.Value))
|
||||
return dbValue.Value;
|
||||
@ -252,11 +252,11 @@ public virtual void SetValue(string key, string value)
|
||||
|
||||
Logger.Debug("Writing Setting to file. Key:'{0}' Value:'{1}'", key, value);
|
||||
|
||||
var dbValue = _sonicRepo.Single<Config>(key);
|
||||
var dbValue = _repository.Single<Config>(key);
|
||||
|
||||
if (dbValue == null)
|
||||
{
|
||||
_sonicRepo.Add(new Config
|
||||
_repository.Add(new Config
|
||||
{
|
||||
Key = key,
|
||||
Value = value
|
||||
@ -265,7 +265,7 @@ public virtual void SetValue(string key, string value)
|
||||
else
|
||||
{
|
||||
dbValue.Value = value;
|
||||
_sonicRepo.Update(dbValue);
|
||||
_repository.Update(dbValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,21 +12,15 @@ namespace NzbDrone.Core.Providers
|
||||
public class EpisodeProvider
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly QualityProvider _qualityProvider;
|
||||
private readonly SeasonProvider _seasons;
|
||||
private readonly SeriesProvider _series;
|
||||
private readonly IRepository _sonicRepo;
|
||||
private readonly TvDbProvider _tvDb;
|
||||
private readonly SeasonProvider _seasonsProvider;
|
||||
private readonly IRepository _repository;
|
||||
private readonly TvDbProvider _tvDbProvider;
|
||||
|
||||
public EpisodeProvider(IRepository sonicRepo, SeriesProvider seriesProvider,
|
||||
SeasonProvider seasonProvider, TvDbProvider tvDbProvider,
|
||||
QualityProvider qualityProvider)
|
||||
public EpisodeProvider(IRepository repository, SeasonProvider seasonProviderProvider, TvDbProvider tvDbProviderProvider)
|
||||
{
|
||||
_sonicRepo = sonicRepo;
|
||||
_series = seriesProvider;
|
||||
_tvDb = tvDbProvider;
|
||||
_seasons = seasonProvider;
|
||||
_qualityProvider = qualityProvider;
|
||||
_repository = repository;
|
||||
_tvDbProvider = tvDbProviderProvider;
|
||||
_seasonsProvider = seasonProviderProvider;
|
||||
}
|
||||
|
||||
public EpisodeProvider()
|
||||
@ -35,36 +29,36 @@ public EpisodeProvider()
|
||||
|
||||
public virtual Episode GetEpisode(long id)
|
||||
{
|
||||
return _sonicRepo.Single<Episode>(id);
|
||||
return _repository.Single<Episode>(id);
|
||||
}
|
||||
|
||||
public virtual Episode GetEpisode(int seriesId, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
return
|
||||
_sonicRepo.Single<Episode>(
|
||||
_repository.Single<Episode>(
|
||||
c => c.SeriesId == seriesId && c.SeasonNumber == seasonNumber && c.EpisodeNumber == episodeNumber);
|
||||
}
|
||||
|
||||
public virtual Episode GetEpisode(int seriesId, DateTime date)
|
||||
{
|
||||
return
|
||||
_sonicRepo.Single<Episode>(
|
||||
_repository.Single<Episode>(
|
||||
c => c.SeriesId == seriesId && c.AirDate == date.Date);
|
||||
}
|
||||
|
||||
public virtual IList<Episode> GetEpisodeBySeries(long seriesId)
|
||||
{
|
||||
return _sonicRepo.Find<Episode>(e => e.SeriesId == seriesId);
|
||||
return _repository.Find<Episode>(e => e.SeriesId == seriesId);
|
||||
}
|
||||
|
||||
public virtual IList<Episode> GetEpisodeBySeason(long seasonId)
|
||||
{
|
||||
return _sonicRepo.Find<Episode>(e => e.SeasonId == seasonId);
|
||||
return _repository.Find<Episode>(e => e.SeasonId == seasonId);
|
||||
}
|
||||
|
||||
public virtual IList<Episode> GetEpisodeByParseResult(EpisodeParseResult parseResult)
|
||||
{
|
||||
var seasonEpisodes = _sonicRepo.All<Episode>().Where(e =>
|
||||
var seasonEpisodes = _repository.All<Episode>().Where(e =>
|
||||
e.SeriesId == parseResult.SeriesId &&
|
||||
e.SeasonNumber == parseResult.SeasonNumber).ToList();
|
||||
|
||||
@ -102,7 +96,7 @@ public virtual bool IsNeeded(EpisodeParseResult parsedReport)
|
||||
Language = "en"
|
||||
};
|
||||
|
||||
_sonicRepo.Add(episodeInfo);
|
||||
_repository.Add(episodeInfo);
|
||||
|
||||
}
|
||||
|
||||
@ -151,7 +145,7 @@ public virtual void RefreshEpisodeInfo(int seriesId)
|
||||
Logger.Info("Starting episode info refresh for series:{0}", seriesId);
|
||||
int successCount = 0;
|
||||
int failCount = 0;
|
||||
var targetSeries = _tvDb.GetSeries(seriesId, true);
|
||||
var targetSeries = _tvDbProvider.GetSeries(seriesId, true);
|
||||
|
||||
var updateList = new List<Episode>();
|
||||
var newList = new List<Episode>();
|
||||
@ -159,7 +153,7 @@ public virtual void RefreshEpisodeInfo(int seriesId)
|
||||
Logger.Debug("Updating season info for series:{0}", targetSeries.SeriesName);
|
||||
targetSeries.Episodes.Select(e => new { e.SeasonId, e.SeasonNumber })
|
||||
.Distinct().ToList()
|
||||
.ForEach(s => _seasons.EnsureSeason(seriesId, s.SeasonId, s.SeasonNumber));
|
||||
.ForEach(s => _seasonsProvider.EnsureSeason(seriesId, s.SeasonId, s.SeasonNumber));
|
||||
|
||||
foreach (var episode in targetSeries.Episodes)
|
||||
{
|
||||
@ -214,8 +208,8 @@ public virtual void RefreshEpisodeInfo(int seriesId)
|
||||
}
|
||||
}
|
||||
|
||||
_sonicRepo.AddMany(newList);
|
||||
_sonicRepo.UpdateMany(updateList);
|
||||
_repository.AddMany(newList);
|
||||
_repository.UpdateMany(updateList);
|
||||
|
||||
Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ",
|
||||
targetSeries.SeriesName, successCount, failCount);
|
||||
@ -223,12 +217,12 @@ public virtual void RefreshEpisodeInfo(int seriesId)
|
||||
|
||||
public virtual void DeleteEpisode(int episodeId)
|
||||
{
|
||||
_sonicRepo.Delete<Episode>(episodeId);
|
||||
_repository.Delete<Episode>(episodeId);
|
||||
}
|
||||
|
||||
public virtual void UpdateEpisode(Episode episode)
|
||||
{
|
||||
_sonicRepo.Update(episode);
|
||||
_repository.Update(episode);
|
||||
}
|
||||
}
|
||||
} |