diff --git a/NzbDrone.Core.Test/EpisodeProviderTest.cs b/NzbDrone.Core.Test/EpisodeProviderTest.cs index 036c3dd76..7b109098a 100644 --- a/NzbDrone.Core.Test/EpisodeProviderTest.cs +++ b/NzbDrone.Core.Test/EpisodeProviderTest.cs @@ -65,7 +65,7 @@ namespace NzbDrone.Core.Test public void IsNeededTrue() { //Setup - var season = new Mock(); + var season = new Mock(); var series = new Mock(); //var history = new Mock(); //var quality = new Mock(); diff --git a/NzbDrone.Core.Test/IndexerProviderTest.cs b/NzbDrone.Core.Test/IndexerProviderTest.cs index 2f015ca18..a5bb4a85f 100644 --- a/NzbDrone.Core.Test/IndexerProviderTest.cs +++ b/NzbDrone.Core.Test/IndexerProviderTest.cs @@ -31,7 +31,7 @@ namespace NzbDrone.Core.Test list.Add(new Indexer { IndexerName = "Test4", RssUrl = "http://www.test4.com/rss.php", Enabled = false, Order = 2 }); var repo = new Mock(); - var config = new Mock(); + var config = new Mock(); repo.Setup(r => r.All()).Returns(list.AsQueryable()); var target = new IndexerProvider(repo.Object, config.Object); @@ -59,7 +59,7 @@ namespace NzbDrone.Core.Test list.Add(new Indexer { IndexerName = "Test4", RssUrl = "http://www.test4.com/rss.php", Enabled = false, Order = 2 }); var repo = new Mock(); - var config = new Mock(); + var config = new Mock(); repo.Setup(r => r.All()).Returns(list.AsQueryable()); var target = new IndexerProvider(repo.Object, config.Object); diff --git a/NzbDrone.Core.Test/MockLib.cs b/NzbDrone.Core.Test/MockLib.cs index cbd711fcb..7e9e56712 100644 --- a/NzbDrone.Core.Test/MockLib.cs +++ b/NzbDrone.Core.Test/MockLib.cs @@ -42,11 +42,11 @@ namespace NzbDrone.Core.Test return new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations); } - public static IConfigProvider StandardConfig + public static ConfigProvider StandardConfig { get { - var mock = new Mock(); + var mock = new Mock(); mock.SetupGet(c => c.SeriesRoot).Returns("C:\\"); return mock.Object; } diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserTest.cs index dad4cf4b1..3ef26d57a 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserTest.cs @@ -70,10 +70,10 @@ namespace NzbDrone.Core.Test } [Test] - [Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", 3, 1, 2, 3, 4, 5, 6)] - [Row("Two.and.a.Half.Me.103.104.720p.HDTV.X264-DIMENSION", 1, 3, 4)] - [Row("The.Kennedys.Part.1.and.Part.2.DSR.XviD-SYS", 1, 1, 2)] - public void episode_multipart_parse(string path, int season, params int[] episodes) + [Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", 3, new[] { 2, 3, 4, 5, 6 })] + [Row("Two.and.a.Half.Me.103.104.720p.HDTV.X264-DIMENSION", 1, new[] { 3, 4 })] + [Row("The.Kennedys.Part.1.and.Part.2.DSR.XviD-SYS", 1, new[] { 1, 2 })] + public void episode_multipart_parse(string path, int season, int[] episodes) { var result = Parser.ParseEpisodeInfo(path); Assert.AreEqual(season, result.SeasonNumber); diff --git a/NzbDrone.Core.Test/RssProviderTest.cs b/NzbDrone.Core.Test/RssProviderTest.cs index da70ce15b..e29c3dc2c 100644 --- a/NzbDrone.Core.Test/RssProviderTest.cs +++ b/NzbDrone.Core.Test/RssProviderTest.cs @@ -43,7 +43,7 @@ namespace NzbDrone.Core.Test public class MockFeedProvider : FeedProviderBase { - public MockFeedProvider(SeriesProvider seriesProvider, ISeasonProvider seasonProvider, EpisodeProvider episodeProvider, IConfigProvider configProvider, HttpProvider httpProvider) + public MockFeedProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider) : base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider) { } diff --git a/NzbDrone.Core.Test/SabControllerTest.cs b/NzbDrone.Core.Test/SabControllerTest.cs index 20e69a22c..fd402532e 100644 --- a/NzbDrone.Core.Test/SabControllerTest.cs +++ b/NzbDrone.Core.Test/SabControllerTest.cs @@ -32,7 +32,7 @@ namespace NzbDrone.Core.Test var mocker = new AutoMoqer(); - var fakeConfig = mocker.GetMock(); + var fakeConfig = mocker.GetMock(); fakeConfig.Setup(c => c.GetValue("SabHost", String.Empty, false)) .Returns(sabHost); fakeConfig.Setup(c => c.GetValue("SabPort", String.Empty, false)) @@ -73,7 +73,7 @@ namespace NzbDrone.Core.Test var mocker = new AutoMoqer(); - var fakeConfig = mocker.GetMock(); + var fakeConfig = mocker.GetMock(); fakeConfig.Setup(c => c.GetValue("SabHost", String.Empty, false)).Returns(sabHost); fakeConfig.Setup(c => c.GetValue("SabPort", String.Empty, false)).Returns(sabPort); fakeConfig.Setup(c => c.GetValue("SabApiKey", String.Empty, false)).Returns(apikey); @@ -105,7 +105,7 @@ namespace NzbDrone.Core.Test var mocker = new AutoMoqer(); - var fakeConfig = mocker.GetMock(); + var fakeConfig = mocker.GetMock(); fakeConfig.Setup(c => c.GetValue("SabHost", String.Empty, false)).Returns(sabHost); fakeConfig.Setup(c => c.GetValue("SabPort", String.Empty, false)).Returns(sabPort); fakeConfig.Setup(c => c.GetValue("SabApiKey", String.Empty, false)).Returns(apikey); @@ -135,7 +135,7 @@ namespace NzbDrone.Core.Test var mocker = new AutoMoqer(); - var fakeConfig = mocker.GetMock(); + var fakeConfig = mocker.GetMock(); fakeConfig.Setup(c => c.GetValue("SabHost", String.Empty, false)).Returns(sabHost); fakeConfig.Setup(c => c.GetValue("SabPort", String.Empty, false)).Returns(sabPort); fakeConfig.Setup(c => c.GetValue("SabApiKey", String.Empty, false)).Returns(apikey); @@ -165,7 +165,7 @@ namespace NzbDrone.Core.Test var mocker = new AutoMoqer(); - var fakeConfig = mocker.GetMock(); + var fakeConfig = mocker.GetMock(); fakeConfig.Setup(c => c.GetValue("SabHost", String.Empty, false)).Returns(sabHost); fakeConfig.Setup(c => c.GetValue("SabPort", String.Empty, false)).Returns(sabPort); fakeConfig.Setup(c => c.GetValue("SabApiKey", String.Empty, false)).Returns(apikey); diff --git a/NzbDrone.Core/CentralDispatch.cs b/NzbDrone.Core/CentralDispatch.cs index 4779bf7a9..0e8fbc300 100644 --- a/NzbDrone.Core/CentralDispatch.cs +++ b/NzbDrone.Core/CentralDispatch.cs @@ -61,7 +61,7 @@ namespace NzbDrone.Core _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); - _kernel.Bind().To().InSingletonScope(); + _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); @@ -72,13 +72,13 @@ namespace NzbDrone.Core _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); - _kernel.Bind().To().InSingletonScope(); - _kernel.Bind().To().InSingletonScope(); + _kernel.Bind().To().InSingletonScope(); + _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); - _kernel.Bind().To().InSingletonScope(); + _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToMethod(c => new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations)).InSingletonScope(); @@ -90,7 +90,7 @@ namespace NzbDrone.Core SetupDefaultQualityProfiles(_kernel.Get()); //Setup the default QualityProfiles on start-up //Get the Timers going - var config = _kernel.Get(); + var config = _kernel.Get(); var timer = _kernel.Get(); timer.SetRssSyncTimer(Convert.ToInt32(config.GetValue("SyncFrequency", "15", true))); timer.StartRssSyncTimer(); diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index ba6e5d6fd..80c4b2bb1 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -198,8 +198,6 @@ - - @@ -207,7 +205,6 @@ - @@ -223,7 +220,6 @@ - diff --git a/NzbDrone.Core/Providers/Core/ConfigProvider.cs b/NzbDrone.Core/Providers/Core/ConfigProvider.cs index dfd0c01c2..e8e48c4c8 100644 --- a/NzbDrone.Core/Providers/Core/ConfigProvider.cs +++ b/NzbDrone.Core/Providers/Core/ConfigProvider.cs @@ -5,7 +5,7 @@ using SubSonic.Repository; namespace NzbDrone.Core.Providers.Core { - public class ConfigProvider : IConfigProvider + public class ConfigProvider { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private readonly IRepository _sonicRepo; @@ -15,7 +15,11 @@ namespace NzbDrone.Core.Providers.Core _sonicRepo = dataRepository; } - public String ApiKey + public ConfigProvider() + { + } + + public virtual String ApiKey { get { return GetValue("ApiKey"); } @@ -23,154 +27,154 @@ namespace NzbDrone.Core.Providers.Core } - public String EpisodeNameFormat + public virtual String EpisodeNameFormat { get { return GetValue("EpisodeNameFormat"); } set { SetValue("EpisodeNameFormat", value); } } - public String SeriesRoot + public virtual String SeriesRoot { get { return GetValue("SeriesRoots"); } set { SetValue("SeriesRoots", value); } } - public String NzbMatrixUsername + public virtual String NzbMatrixUsername { get { return GetValue("NzbMatrixUsername"); } set { SetValue("NzbMatrixUsername", value); } } - public String NzbMatrixApiKey + public virtual String NzbMatrixApiKey { get { return GetValue("NzbMatrixApiKey"); } set { SetValue("NzbMatrixApiKey", value); } } - public String NzbsOrgUId + public virtual String NzbsOrgUId { get { return GetValue("NzbsOrgUId"); } set { SetValue("NzbsOrgUId", value); } } - public String NzbsOrgHash + public virtual String NzbsOrgHash { get { return GetValue("NzbsOrgHash"); } set { SetValue("NzbsOrgHash", value); } } - public String NzbsrusUId + public virtual String NzbsrusUId { get { return GetValue("NzbsrusUId"); } set { SetValue("NzbsrusUId", value); } } - public String NzbsrusHash + public virtual String NzbsrusHash { get { return GetValue("NzbsrusHash"); } set { SetValue("NzbsrusHash", value); } } - public String SyncFrequency + public virtual String SyncFrequency { get { return GetValue("SyncFrequency"); } set { SetValue("SyncFrequency", value); } } - public String DownloadPropers + public virtual String DownloadPropers { get { return GetValue("DownloadPropers"); } set { SetValue("DownloadPropers", value); } } - public String Retention + public virtual String Retention { get { return GetValue("Retention"); } set { SetValue("Retention", value); } } - public String SabHost + public virtual String SabHost { get { return GetValue("SabHost"); } set { SetValue("SabHost", value); } } - public String SabPort + public virtual String SabPort { get { return GetValue("SabPort"); } set { SetValue("SabPort", value); } } - public String SabApiKey + public virtual String SabApiKey { get { return GetValue("SabApiKey"); } set { SetValue("SabApiKey", value); } } - public String SabUsername + public virtual String SabUsername { get { return GetValue("SabUsername"); } set { SetValue("SabUsername", value); } } - public String SabPassword + public virtual String SabPassword { get { return GetValue("SabPassword"); } set { SetValue("SabPassword", value); } } - public String SabTvCategory + public virtual String SabTvCategory { get { return GetValue("SabTvCategory"); } set { SetValue("SabTvCategory", value); } } - public String SabTvPriority + public virtual String SabTvPriority { get { return GetValue("SabTvPriority"); } set { SetValue("SabTvPriority", value); } } - public String UseBlackhole + public virtual String UseBlackhole { get { return GetValue("UseBlackhole"); } set { SetValue("UseBlackhole", value); } } - public String BlackholeDirectory + public virtual String BlackholeDirectory { get { return GetValue("BlackholeDirectory"); } set { SetValue("BlackholeDirectory", value); } } - public bool UseSeasonFolder + public virtual bool UseSeasonFolder { get { return GetValueBoolean("Sorting_SeasonFolder", true); } set { SetValue("Sorting_SeasonFolder", value); } } - public int DefaultQualityProfile + public virtual int DefaultQualityProfile { get { return GetValueInt("DefaultQualityProfile", 1); } @@ -193,7 +197,7 @@ namespace NzbDrone.Core.Providers.Core return Convert.ToInt16(GetValue(key, defaultValue, false)); } - public string GetValue(string key, object defaultValue, bool makePermanent) + public virtual string GetValue(string key, object defaultValue, bool makePermanent) { string value; @@ -210,17 +214,17 @@ namespace NzbDrone.Core.Providers.Core return value; } - public void SetValue(string key, Boolean value) + public virtual void SetValue(string key, Boolean value) { SetValue(key, value.ToString()); } - public void SetValue(string key, int value) + public virtual void SetValue(string key, int value) { SetValue(key, value.ToString()); } - public void SetValue(string key, string value) + public virtual void SetValue(string key, string value) { if (String.IsNullOrEmpty(key)) throw new ArgumentOutOfRangeException("key"); diff --git a/NzbDrone.Core/Providers/Core/IConfigProvider.cs b/NzbDrone.Core/Providers/Core/IConfigProvider.cs deleted file mode 100644 index 536753af2..000000000 --- a/NzbDrone.Core/Providers/Core/IConfigProvider.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; - -namespace NzbDrone.Core.Providers.Core -{ - public interface IConfigProvider - { - String SeriesRoot { get; set; } - String EpisodeNameFormat { get; set; } - String NzbMatrixUsername { get; set; } - String NzbMatrixApiKey { get; set; } - String NzbsOrgUId { get; set; } - String NzbsOrgHash { get; set; } - String NzbsrusUId { get; set; } - String NzbsrusHash { get; set; } - String DownloadPropers { get; set; } - String Retention { get; set; } - String SabHost { get; set; } - String SabPort { get; set; } - String SabApiKey { get; set; } - String SabUsername { get; set; } - String SabPassword { get; set; } - String SabTvCategory { get; set; } - String UseBlackhole { get; set; } - String BlackholeDirectory { get; set; } - String SyncFrequency { get; set; } - String SabTvPriority { get; set; } - String ApiKey { get; set; } - bool UseSeasonFolder { get; set; } - int DefaultQualityProfile { get; set; } - - string GetValue(string key, object defaultValue, bool makePermanent); - void SetValue(string key, string value); - } -} \ No newline at end of file diff --git a/NzbDrone.Core/Providers/EpisodeProvider.cs b/NzbDrone.Core/Providers/EpisodeProvider.cs index d2f0c3cbe..18518c956 100644 --- a/NzbDrone.Core/Providers/EpisodeProvider.cs +++ b/NzbDrone.Core/Providers/EpisodeProvider.cs @@ -15,14 +15,14 @@ namespace NzbDrone.Core.Providers private readonly IRepository _sonicRepo; private readonly SeriesProvider _series; - private readonly ISeasonProvider _seasons; + private readonly SeasonProvider _seasons; private readonly TvDbProvider _tvDb; private readonly HistoryProvider _history; private readonly QualityProvider _quality; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); public EpisodeProvider(IRepository sonicRepo, SeriesProvider seriesProvider, - ISeasonProvider seasonProvider, TvDbProvider tvDbProvider, + SeasonProvider seasonProvider, TvDbProvider tvDbProvider, HistoryProvider history, QualityProvider quality) { _sonicRepo = sonicRepo; diff --git a/NzbDrone.Core/Providers/ExternalNotificationProvider.cs b/NzbDrone.Core/Providers/ExternalNotificationProvider.cs index 84cd9d078..e0d762512 100644 --- a/NzbDrone.Core/Providers/ExternalNotificationProvider.cs +++ b/NzbDrone.Core/Providers/ExternalNotificationProvider.cs @@ -12,12 +12,12 @@ namespace NzbDrone.Core.Providers { public class ExternalNotificationProvider { - private readonly IConfigProvider _configProvider; + private readonly ConfigProvider _configProvider; private readonly XbmcProvider _xbmcProvider; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public ExternalNotificationProvider(IConfigProvider configProvider, XbmcProvider xbmcProvider) + public ExternalNotificationProvider(ConfigProvider configProvider, XbmcProvider xbmcProvider) { _configProvider = configProvider; _xbmcProvider = xbmcProvider; diff --git a/NzbDrone.Core/Providers/Feed/FeedProviderBase.cs b/NzbDrone.Core/Providers/Feed/FeedProviderBase.cs index 89afdc922..c1d05a820 100644 --- a/NzbDrone.Core/Providers/Feed/FeedProviderBase.cs +++ b/NzbDrone.Core/Providers/Feed/FeedProviderBase.cs @@ -9,14 +9,14 @@ namespace NzbDrone.Core.Providers.Feed public abstract class FeedProviderBase { protected readonly SeriesProvider _seriesProvider; - protected readonly ISeasonProvider _seasonProvider; + protected readonly SeasonProvider _seasonProvider; protected readonly EpisodeProvider _episodeProvider; - protected readonly IConfigProvider _configProvider; + protected readonly ConfigProvider _configProvider; private readonly HttpProvider _httpProvider; protected static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public FeedProviderBase(SeriesProvider seriesProvider, ISeasonProvider seasonProvider, - EpisodeProvider episodeProvider, IConfigProvider configProvider, HttpProvider httpProvider) + public FeedProviderBase(SeriesProvider seriesProvider, SeasonProvider seasonProvider, + EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider) { _seriesProvider = seriesProvider; _seasonProvider = seasonProvider; diff --git a/NzbDrone.Core/Providers/Feed/NzbsOrgFeedProvider.cs b/NzbDrone.Core/Providers/Feed/NzbsOrgFeedProvider.cs index d98a69ef7..a5440c67a 100644 --- a/NzbDrone.Core/Providers/Feed/NzbsOrgFeedProvider.cs +++ b/NzbDrone.Core/Providers/Feed/NzbsOrgFeedProvider.cs @@ -9,7 +9,7 @@ namespace NzbDrone.Core.Providers.Feed { class NzbsOrgFeedProvider : FeedProviderBase { - public NzbsOrgFeedProvider(SeriesProvider seriesProvider, ISeasonProvider seasonProvider, EpisodeProvider episodeProvider, IConfigProvider configProvider, HttpProvider httpProvider) + public NzbsOrgFeedProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider) : base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider) { } diff --git a/NzbDrone.Core/Providers/IMediaFileProvider.cs b/NzbDrone.Core/Providers/IMediaFileProvider.cs deleted file mode 100644 index 3a499cd47..000000000 --- a/NzbDrone.Core/Providers/IMediaFileProvider.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Collections.Generic; -using NzbDrone.Core.Model; -using NzbDrone.Core.Repository; - -namespace NzbDrone.Core.Providers -{ - public interface IMediaFileProvider - { - /// - /// Scans the specified series folder for media files - /// - /// The series to be scanned - List Scan(Series series); - List Scan(Series series, string path); - EpisodeFile ImportFile(Series series, string filePath); - void CleanUp(List files); - void DeleteFromDb(int fileId); - void DeleteFromDisk(int fileId, string path); - void Update(EpisodeFile episodeFile); - EpisodeFile GetEpisodeFile(int episodeFileId); - List GetEpisodeFiles(); - } -} \ No newline at end of file diff --git a/NzbDrone.Core/Providers/ISeasonProvider.cs b/NzbDrone.Core/Providers/ISeasonProvider.cs deleted file mode 100644 index 4e4b27cb7..000000000 --- a/NzbDrone.Core/Providers/ISeasonProvider.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Generic; -using NzbDrone.Core.Model; -using NzbDrone.Core.Repository; - -namespace NzbDrone.Core.Providers -{ - public interface ISeasonProvider - { - Season GetSeason(int seasonId); - Season GetSeason(int seriesId, int seasonNumber); - List GetSeasons(int seriesId); - Season GetLatestSeason(int seriesId); - void EnsureSeason(int seriesId, int seasonId, int seasonNumber); - int SaveSeason(Season season); - bool IsIgnored(int seasonId); - bool IsIgnored(int seriesId, int seasonNumber); - void DeleteSeason(int seasonId); - } -} \ No newline at end of file diff --git a/NzbDrone.Core/Providers/ISyncProvider.cs b/NzbDrone.Core/Providers/ISyncProvider.cs deleted file mode 100644 index dbbdb3a64..000000000 --- a/NzbDrone.Core/Providers/ISyncProvider.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using NzbDrone.Core.Model; - -namespace NzbDrone.Core.Providers -{ - public interface ISyncProvider - { - - List GetUnmappedFolders(string path); - bool BeginUpdateNewSeries(); - } -} \ No newline at end of file diff --git a/NzbDrone.Core/Providers/IndexerProvider.cs b/NzbDrone.Core/Providers/IndexerProvider.cs index d890e2ca3..69e2efc7c 100644 --- a/NzbDrone.Core/Providers/IndexerProvider.cs +++ b/NzbDrone.Core/Providers/IndexerProvider.cs @@ -15,9 +15,9 @@ namespace NzbDrone.Core.Providers { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private readonly IRepository _sonicRepo; - private readonly IConfigProvider _configProvider; + private readonly ConfigProvider _configProvider; - public IndexerProvider(IRepository sonicRepo, IConfigProvider configProvider) + public IndexerProvider(IRepository sonicRepo, ConfigProvider configProvider) { _sonicRepo = sonicRepo; _configProvider = configProvider; diff --git a/NzbDrone.Core/Providers/MediaFileProvider.cs b/NzbDrone.Core/Providers/MediaFileProvider.cs index 73e76f84a..734fccb06 100644 --- a/NzbDrone.Core/Providers/MediaFileProvider.cs +++ b/NzbDrone.Core/Providers/MediaFileProvider.cs @@ -12,17 +12,17 @@ using SubSonic.Repository; namespace NzbDrone.Core.Providers { - public class MediaFileProvider : IMediaFileProvider + public class MediaFileProvider { private readonly IRepository _repository; - private readonly IConfigProvider _configProvider; + private readonly ConfigProvider _configProvider; private readonly DiskProvider _diskProvider; private readonly EpisodeProvider _episodeProvider; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly string[] MediaExtentions = new[] { "*.mkv", "*.avi", "*.wmv" }; - public MediaFileProvider(IRepository repository, IConfigProvider configProvider, DiskProvider diskProvider, EpisodeProvider episodeProvider) + public MediaFileProvider(IRepository repository, ConfigProvider configProvider, DiskProvider diskProvider, EpisodeProvider episodeProvider) { _repository = repository; _configProvider = configProvider; diff --git a/NzbDrone.Core/Providers/PostProcessingProvider.cs b/NzbDrone.Core/Providers/PostProcessingProvider.cs index b24d66fbf..b4ed878d8 100644 --- a/NzbDrone.Core/Providers/PostProcessingProvider.cs +++ b/NzbDrone.Core/Providers/PostProcessingProvider.cs @@ -12,11 +12,11 @@ namespace NzbDrone.Core.Providers public class PostProcessingProvider { private readonly SeriesProvider _seriesProvider; - private readonly IMediaFileProvider _mediaFileProvider; + private readonly MediaFileProvider _mediaFileProvider; private readonly RenameProvider _renameProvider; public PostProcessingProvider(SeriesProvider seriesProvider, - IMediaFileProvider mediaFileProvider, RenameProvider renameProvider) + MediaFileProvider mediaFileProvider, RenameProvider renameProvider) { _seriesProvider = seriesProvider; _mediaFileProvider = mediaFileProvider; diff --git a/NzbDrone.Core/Providers/RenameProvider.cs b/NzbDrone.Core/Providers/RenameProvider.cs index b35638d38..af07a7de0 100644 --- a/NzbDrone.Core/Providers/RenameProvider.cs +++ b/NzbDrone.Core/Providers/RenameProvider.cs @@ -15,11 +15,11 @@ namespace NzbDrone.Core.Providers public class RenameProvider { private readonly SeriesProvider _seriesProvider; - private readonly ISeasonProvider _seasonProvider; + private readonly SeasonProvider _seasonProvider; private readonly EpisodeProvider _episodeProvider; - private readonly IMediaFileProvider _mediaFileProvider; + private readonly MediaFileProvider _mediaFileProvider; private readonly DiskProvider _diskProvider; - private readonly IConfigProvider _configProvider; + private readonly ConfigProvider _configProvider; private readonly ExternalNotificationProvider _externalNotificationProvider; private Thread _renameThread; @@ -27,9 +27,9 @@ namespace NzbDrone.Core.Providers private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public RenameProvider(SeriesProvider seriesProvider, ISeasonProvider seasonProvider, - EpisodeProvider episodeProvider, IMediaFileProvider mediaFileProvider, - DiskProvider diskProvider, IConfigProvider configProvider, + public RenameProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, + EpisodeProvider episodeProvider, MediaFileProvider mediaFileProvider, + DiskProvider diskProvider, ConfigProvider configProvider, ExternalNotificationProvider extenalNotificationProvider) { _seriesProvider = seriesProvider; diff --git a/NzbDrone.Core/Providers/SabProvider.cs b/NzbDrone.Core/Providers/SabProvider.cs index d2889f24f..3f5078df9 100644 --- a/NzbDrone.Core/Providers/SabProvider.cs +++ b/NzbDrone.Core/Providers/SabProvider.cs @@ -9,12 +9,12 @@ namespace NzbDrone.Core.Providers { public class SabProvider { - private readonly IConfigProvider _config; + private readonly ConfigProvider _config; private readonly HttpProvider _http; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public SabProvider(IConfigProvider config, HttpProvider http) + public SabProvider(ConfigProvider config, HttpProvider http) { _config = config; _http = http; diff --git a/NzbDrone.Core/Providers/SeasonProvider.cs b/NzbDrone.Core/Providers/SeasonProvider.cs index dbd72ddbb..6b3e9f94b 100644 --- a/NzbDrone.Core/Providers/SeasonProvider.cs +++ b/NzbDrone.Core/Providers/SeasonProvider.cs @@ -8,7 +8,7 @@ using System.Linq; namespace NzbDrone.Core.Providers { - public class SeasonProvider : ISeasonProvider + public class SeasonProvider { private readonly IRepository _sonicRepo; private readonly SeriesProvider _seriesProvider; @@ -21,27 +21,32 @@ namespace NzbDrone.Core.Providers _seriesProvider = seriesProvider; } - public Season GetSeason(int seasonId) + public SeasonProvider() + { + + } + + public virtual Season GetSeason(int seasonId) { return _sonicRepo.Single(seasonId); } - public Season GetSeason(int seriesId, int seasonNumber) + public virtual Season GetSeason(int seriesId, int seasonNumber) { return _sonicRepo.Single(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber); } - public List GetSeasons(int seriesId) + public virtual List GetSeasons(int seriesId) { return _sonicRepo.All().Where(s => s.SeriesId == seriesId).ToList(); } - public Season GetLatestSeason(int seriesId) + public virtual Season GetLatestSeason(int seriesId) { return _sonicRepo.All().Where(s => s.SeriesId == seriesId).OrderBy(s => s.SeasonNumber).Last(); } - public void EnsureSeason(int seriesId, int seasonId, int seasonNumber) + public virtual void EnsureSeason(int seriesId, int seasonId, int seasonNumber) { if (_sonicRepo.Exists(s => s.SeasonId == seasonId)) return; @@ -58,12 +63,12 @@ namespace NzbDrone.Core.Providers _sonicRepo.Add(newSeason); } - public int SaveSeason(Season season) + public virtual int SaveSeason(Season season) { throw new NotImplementedException(); } - public bool IsIgnored(int seasonId) + public virtual bool IsIgnored(int seasonId) { if (_sonicRepo.Single(seasonId).Monitored) return false; @@ -72,7 +77,7 @@ namespace NzbDrone.Core.Providers return true; } - public bool IsIgnored(int seriesId, int seasonNumber) + public virtual bool IsIgnored(int seriesId, int seasonNumber) { var season = _sonicRepo.Single(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber); diff --git a/NzbDrone.Core/Providers/SeriesProvider.cs b/NzbDrone.Core/Providers/SeriesProvider.cs index 29838aaf1..75b44ddd5 100644 --- a/NzbDrone.Core/Providers/SeriesProvider.cs +++ b/NzbDrone.Core/Providers/SeriesProvider.cs @@ -19,13 +19,13 @@ namespace NzbDrone.Core.Providers //Trims all white spaces and separators from the end of the title. - private readonly IConfigProvider _config; + private readonly ConfigProvider _config; private readonly IRepository _sonioRepo; private readonly TvDbProvider _tvDb; private readonly QualityProvider _quality; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public SeriesProvider(IConfigProvider configProvider, + public SeriesProvider(ConfigProvider configProvider, IRepository dataRepository, TvDbProvider tvDbProvider, QualityProvider quality) { _config = configProvider; diff --git a/NzbDrone.Core/Providers/SyncProvider.cs b/NzbDrone.Core/Providers/SyncProvider.cs index c31f92974..c4379e85d 100644 --- a/NzbDrone.Core/Providers/SyncProvider.cs +++ b/NzbDrone.Core/Providers/SyncProvider.cs @@ -11,11 +11,11 @@ using NzbDrone.Core.Providers.Core; namespace NzbDrone.Core.Providers { - public class SyncProvider : ISyncProvider + public class SyncProvider { private readonly SeriesProvider _seriesProvider; private readonly EpisodeProvider _episodeProvider; - private readonly IMediaFileProvider _mediaFileProvider; + private readonly MediaFileProvider _mediaFileProvider; private readonly NotificationProvider _notificationProvider; private readonly DiskProvider _diskProvider; @@ -25,7 +25,7 @@ namespace NzbDrone.Core.Providers private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); public SyncProvider(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, - IMediaFileProvider mediaFileProvider, NotificationProvider notificationProvider, + MediaFileProvider mediaFileProvider, NotificationProvider notificationProvider, DiskProvider diskProvider) { _seriesProvider = seriesProvider; diff --git a/NzbDrone.Core/Providers/TimerProvider.cs b/NzbDrone.Core/Providers/TimerProvider.cs index 8700957ff..928e9abf3 100644 --- a/NzbDrone.Core/Providers/TimerProvider.cs +++ b/NzbDrone.Core/Providers/TimerProvider.cs @@ -12,16 +12,16 @@ namespace NzbDrone.Core.Providers { private readonly RssSyncProvider _rssSyncProvider; private readonly SeriesProvider _seriesProvider; - private readonly ISeasonProvider _seasonProvider; + private readonly SeasonProvider _seasonProvider; private readonly EpisodeProvider _episodeProvider; - private readonly IMediaFileProvider _mediaFileProvider; + private readonly MediaFileProvider _mediaFileProvider; private Timer _rssSyncTimer; private Timer _minuteTimer; private DateTime _rssSyncNextInterval; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public TimerProvider(RssSyncProvider rssSyncProvider, SeriesProvider seriesProvider, ISeasonProvider seasonProvider, EpisodeProvider episodeProvider, IMediaFileProvider mediaFileProvider) + public TimerProvider(RssSyncProvider rssSyncProvider, SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, MediaFileProvider mediaFileProvider) { _rssSyncProvider = rssSyncProvider; _seriesProvider = seriesProvider; diff --git a/NzbDrone.Core/Providers/XbmcProvider.cs b/NzbDrone.Core/Providers/XbmcProvider.cs index 072408b1f..851d1dd7c 100644 --- a/NzbDrone.Core/Providers/XbmcProvider.cs +++ b/NzbDrone.Core/Providers/XbmcProvider.cs @@ -12,12 +12,12 @@ namespace NzbDrone.Core.Providers { public class XbmcProvider { - private readonly IConfigProvider _configProvider; + private readonly ConfigProvider _configProvider; private readonly HttpProvider _httpProvider; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public XbmcProvider(IConfigProvider configProvider, HttpProvider httpProvider) + public XbmcProvider(ConfigProvider configProvider, HttpProvider httpProvider) { _configProvider = configProvider; _httpProvider = httpProvider; diff --git a/NzbDrone.Web/Controllers/AddSeriesController (x201's conflicted copy 2011-04-09).cs b/NzbDrone.Web/Controllers/AddSeriesController (x201's conflicted copy 2011-04-09).cs new file mode 100644 index 000000000..dbfa65355 --- /dev/null +++ b/NzbDrone.Web/Controllers/AddSeriesController (x201's conflicted copy 2011-04-09).cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using NzbDrone.Core.Providers; +using NzbDrone.Core.Providers.Core; +using NzbDrone.Web.Models; + +namespace NzbDrone.Web.Controllers +{ + public class AddSeriesController : Controller + { + public IConfigProvider ConfigProvider { get; set; } + private readonly SyncProvider _syncProvider; + private readonly RootDirProvider _rootFolderProvider; + private readonly IConfigProvider _configProvider; + private readonly QualityProvider _qualityProvider; + private readonly TvDbProvider _tvDbProvider; + private readonly SeriesProvider _seriesProvider; + + public AddSeriesController(SyncProvider syncProvider, RootDirProvider rootFolderProvider, IConfigProvider configProvider, + QualityProvider qualityProvider, TvDbProvider tvDbProvider, SeriesProvider seriesProvider) + { + ConfigProvider = configProvider; + _syncProvider = syncProvider; + _rootFolderProvider = rootFolderProvider; + _configProvider = configProvider; + _qualityProvider = qualityProvider; + _tvDbProvider = tvDbProvider; + _seriesProvider = seriesProvider; + } + + [HttpPost] + public JsonResult ScanNewSeries() + { + _syncProvider.BeginUpdateNewSeries(); + return new JsonResult(); + } + + public ActionResult AddNew() + { + ViewData["RootDirs"] = _rootFolderProvider.GetAll(); + ViewData["DirSep"] = Path.DirectorySeparatorChar; + + var profiles = _qualityProvider.GetAllProfiles(); + var selectList = new SelectList(profiles, "QualityProfileId", "Name"); + var defaultQuality = Convert.ToInt32(_configProvider.DefaultQualityProfile); + + var model = new AddNewSeriesModel + { + DirectorySeparatorChar = Path.DirectorySeparatorChar.ToString(), + RootDirectories = _rootFolderProvider.GetAll(), + QualityProfileId = defaultQuality, + QualitySelectList = selectList + }; + + return View(model); + } + + public ActionResult AddExisting() + { + var unmappedList = new List(); + + var profiles = _qualityProvider.GetAllProfiles(); + var defaultQuality = Convert.ToInt32(_configProvider.DefaultQualityProfile); + var selectList = new SelectList(profiles, "QualityProfileId", "Name", defaultQuality); + + ViewData["qualities"] = selectList; + + foreach (var folder in _rootFolderProvider.GetAll()) + { + unmappedList.AddRange(_syncProvider.GetUnmappedFolders(folder.Path)); + } + + return View(unmappedList); + } + + public ActionResult RenderPartial(string path) + { + + var suggestions = GetSuggestionList(new DirectoryInfo(path).Name); + + ViewData["guid"] = Guid.NewGuid(); + ViewData["path"] = path; + ViewData["javaPath"] = path.Replace(Path.DirectorySeparatorChar, '|').Replace(Path.VolumeSeparatorChar, '^'); + + var defaultQuality = _configProvider.DefaultQualityProfile; + var qualityProfiles = _qualityProvider.GetAllProfiles(); + + ViewData["quality"] = new SelectList( + qualityProfiles, + "QualityProfileId", + "Name", + defaultQuality); ; + + return PartialView("AddSeriesItem", suggestions); + + } + + public JsonResult AddSeries(string path, int seriesId, int qualityProfileId) + { + //Get TVDB Series Name + //Create new folder for series + //Add the new series to the Database + + _seriesProvider.AddSeries(path.Replace('|', Path.DirectorySeparatorChar).Replace('^', Path.VolumeSeparatorChar), seriesId, qualityProfileId); + ScanNewSeries(); + return new JsonResult() { Data = "ok" }; + } + + [HttpPost] + public ActionResult _textLookUp(string text, int? filterMode) + { + var suggestions = GetSuggestionList(text); + + return new JsonResult + { + JsonRequestBehavior = JsonRequestBehavior.AllowGet, + Data = suggestions + }; + } + + public SelectList GetSuggestionList(string searchString) + { + var dataVal = _tvDbProvider.SearchSeries(searchString); + //var bestResult = _tvDbProvider.GetBestMatch(dataVal.ToList(), searchString); + + return new SelectList(dataVal, "Id", "SeriesName", dataVal[0].Id); + } + + } +} diff --git a/NzbDrone.Web/Controllers/AddSeriesController.cs b/NzbDrone.Web/Controllers/AddSeriesController.cs index 985b257f8..8cfe4dbf3 100644 --- a/NzbDrone.Web/Controllers/AddSeriesController.cs +++ b/NzbDrone.Web/Controllers/AddSeriesController.cs @@ -12,18 +12,17 @@ namespace NzbDrone.Web.Controllers { public class AddSeriesController : Controller { - public IConfigProvider ConfigProvider { get; set; } - private readonly ISyncProvider _syncProvider; + + private readonly SyncProvider _syncProvider; private readonly RootDirProvider _rootFolderProvider; - private readonly IConfigProvider _configProvider; + private readonly ConfigProvider _configProvider; private readonly QualityProvider _qualityProvider; private readonly TvDbProvider _tvDbProvider; private readonly SeriesProvider _seriesProvider; - public AddSeriesController(ISyncProvider syncProvider, RootDirProvider rootFolderProvider, IConfigProvider configProvider, + public AddSeriesController(SyncProvider syncProvider, RootDirProvider rootFolderProvider, ConfigProvider configProvider, QualityProvider qualityProvider, TvDbProvider tvDbProvider, SeriesProvider seriesProvider) { - ConfigProvider = configProvider; _syncProvider = syncProvider; _rootFolderProvider = rootFolderProvider; _configProvider = configProvider; @@ -125,9 +124,14 @@ namespace NzbDrone.Web.Controllers public SelectList GetSuggestionList(string searchString) { var dataVal = _tvDbProvider.SearchSeries(searchString); - //var bestResult = _tvDbProvider.GetBestMatch(dataVal.ToList(), searchString); - return new SelectList(dataVal, "Id", "SeriesName", dataVal[0].Id); + int selectId = 0; + if (dataVal.Count != 0) + { + selectId = dataVal[0].Id; + } + + return new SelectList(dataVal, "Id", "SeriesName", selectId); } } diff --git a/NzbDrone.Web/Controllers/ApiController.cs b/NzbDrone.Web/Controllers/ApiController.cs index e6b670839..4346cb7bd 100644 --- a/NzbDrone.Web/Controllers/ApiController.cs +++ b/NzbDrone.Web/Controllers/ApiController.cs @@ -14,11 +14,11 @@ namespace NzbDrone.Web.Controllers public class ApiController : Controller { private readonly PostProcessingProvider _postProcessingProvider; - private readonly IConfigProvider _configProvider; + private readonly ConfigProvider _configProvider; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public ApiController(PostProcessingProvider postProcessingProvider, IConfigProvider configProvider) + public ApiController(PostProcessingProvider postProcessingProvider, ConfigProvider configProvider) { _postProcessingProvider = postProcessingProvider; _configProvider = configProvider; diff --git a/NzbDrone.Web/Controllers/SeriesController.cs b/NzbDrone.Web/Controllers/SeriesController.cs index d152b1ff9..34ee60cd7 100644 --- a/NzbDrone.Web/Controllers/SeriesController.cs +++ b/NzbDrone.Web/Controllers/SeriesController.cs @@ -23,19 +23,19 @@ namespace NzbDrone.Web.Controllers { private readonly SeriesProvider _seriesProvider; private readonly EpisodeProvider _episodeProvider; - private readonly ISyncProvider _syncProvider; + private readonly SyncProvider _syncProvider; private readonly RssSyncProvider _rssSyncProvider; private readonly QualityProvider _qualityProvider; - private readonly IMediaFileProvider _mediaFileProvider; + private readonly MediaFileProvider _mediaFileProvider; private readonly RenameProvider _renameProvider; private readonly RootDirProvider _rootDirProvider; private readonly TvDbProvider _tvDbProvider; // // GET: /Series/ - public SeriesController(ISyncProvider syncProvider, SeriesProvider seriesProvider, + public SeriesController(SyncProvider syncProvider, SeriesProvider seriesProvider, EpisodeProvider episodeProvider, RssSyncProvider rssSyncProvider, - QualityProvider qualityProvider, IMediaFileProvider mediaFileProvider, + QualityProvider qualityProvider, MediaFileProvider mediaFileProvider, RenameProvider renameProvider, RootDirProvider rootDirProvider, TvDbProvider tvDbProvider) { diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 1c74ee26b..ceed83c29 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -19,7 +19,7 @@ namespace NzbDrone.Web.Controllers [HandleError] public class SettingsController : Controller { - private IConfigProvider _configProvider; + private ConfigProvider _configProvider; private IndexerProvider _indexerProvider; private QualityProvider _qualityProvider; private RootDirProvider _rootDirProvider; @@ -28,7 +28,7 @@ namespace NzbDrone.Web.Controllers private const string SETTINGS_SAVED = "Settings Saved."; private const string SETTINGS_FAILED = "Error Saving Settings, please fix any errors"; - public SettingsController(IConfigProvider configProvider, IndexerProvider indexerProvider, + public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider, QualityProvider qualityProvider, RootDirProvider rootDirProvider) { _configProvider = configProvider;