1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-25 12:12:58 +01:00

ReSharper code cleanup

This commit is contained in:
kay.one 2011-04-09 19:44:01 -07:00
parent 8cade435d1
commit e896af5cd0
138 changed files with 2368 additions and 2218 deletions

70
NzbDrone.5.1.ReSharper Normal file
View File

@ -0,0 +1,70 @@
<Configuration>
<CodeStyleSettings>
<ExternalPath IsNull="False">
</ExternalPath>
<Sharing>SOLUTION</Sharing>
<CSharp>
<FormatSettings>
<MODIFIERS_ORDER IsNull="False">
<Item>public</Item>
<Item>protected</Item>
<Item>internal</Item>
<Item>private</Item>
<Item>new</Item>
<Item>abstract</Item>
<Item>virtual</Item>
<Item>override</Item>
<Item>sealed</Item>
<Item>static</Item>
<Item>readonly</Item>
<Item>extern</Item>
<Item>unsafe</Item>
<Item>volatile</Item>
</MODIFIERS_ORDER>
</FormatSettings>
<UsingsSettings />
<Naming2>
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
</Naming2>
</CSharp>
<VB>
<FormatSettings />
<ImportsSettings />
<Naming2>
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
</Naming2>
</VB>
<Web>
<Naming2 />
</Web>
<Xaml>
<Naming2 />
</Xaml>
<XML>
<FormatSettings />
</XML>
<GenerateMemberBody />
<Naming2>
<EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
<EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateStaticReadonly" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" />
<PredefinedRule Inspect="True" Prefix="I" Suffix="" Style="AaBb" ElementKind="Interfaces" />
<PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="LocalConstants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Parameters" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PublicFields" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
<PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Constants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AA_BB" ElementKind="PrivateConstants" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
</Naming2>
</CodeStyleSettings>
</Configuration>

View File

@ -14,9 +14,9 @@ namespace AutoMoq
{ {
public class AutoMoqer public class AutoMoqer
{ {
internal Type ResolveType;
private IUnityContainer container; private IUnityContainer container;
private IDictionary<Type, object> registeredMocks; private IDictionary<Type, object> registeredMocks;
internal Type ResolveType = null;
public AutoMoqer() public AutoMoqer()
{ {
@ -67,6 +67,45 @@ namespace AutoMoq
SetMock(instance.GetType(), null); SetMock(instance.GetType(), null);
} }
public ISetup<T> Setup<T>(Expression<Action<T>> expression) where T : class
{
return GetMock<T>().Setup(expression);
}
public ISetup<T, TResult> Setup<T, TResult>(Expression<Func<T, TResult>> expression) where T : class
{
return GetMock<T>().Setup(expression);
}
public void Verify<T>(Expression<Action<T>> expression) where T : class
{
GetMock<T>().Verify(expression);
}
public void Verify<T>(Expression<Action<T>> expression, string failMessage) where T : class
{
GetMock<T>().Verify(expression, failMessage);
}
public void Verify<T>(Expression<Action<T>> expression, Times times) where T : class
{
GetMock<T>().Verify(expression, times);
}
public void Verify<T>(Expression<Action<T>> expression, Times times, string failMessage) where T : class
{
GetMock<T>().Verify(expression, times, failMessage);
}
public void VerifyAllMocks()
{
foreach (var registeredMock in registeredMocks)
{
var mock = registeredMock.Value as Mock;
mock.VerifyAll();
}
}
#region private methods #region private methods
private void SetupAutoMoqer(IUnityContainer container) private void SetupAutoMoqer(IUnityContainer container)
@ -107,45 +146,5 @@ namespace AutoMoq
} }
#endregion #endregion
public ISetup<T> Setup<T>(Expression<Action<T>> expression) where T : class
{
return GetMock<T>().Setup(expression);
}
public ISetup<T, TResult> Setup<T, TResult>(Expression<Func<T, TResult>> expression) where T : class
{
return GetMock<T>().Setup(expression);
}
public void Verify<T>(Expression<Action<T>> expression) where T : class
{
GetMock<T>().Verify(expression);
}
public void Verify<T>(Expression<Action<T>> expression, string failMessage) where T : class
{
GetMock<T>().Verify(expression, failMessage);
}
public void Verify<T>(Expression<Action<T>> expression, Times times) where T : class
{
GetMock<T>().Verify(expression, times);
}
public void Verify<T>(Expression<Action<T>> expression, Times times, string failMessage) where T : class
{
GetMock<T>().Verify(expression, times, failMessage);
}
public void VerifyAllMocks()
{
foreach (var registeredMock in registeredMocks)
{
var mock = registeredMock.Value as Mock;
mock.VerifyAll();
}
}
} }
} }

View File

@ -1,22 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using AutoMoq; using AutoMoq;
using FizzWare.NBuilder;
using Gallio.Framework;
using MbUnit.Framework; using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq; using Moq;
using Ninject;
using Ninject.Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using SubSonic.Repository;
using TvdbLib.Data;
using SubSonic.Extensions;
namespace NzbDrone.Core.Test namespace NzbDrone.Core.Test
{ {
@ -117,7 +102,7 @@ namespace NzbDrone.Core.Test
//Arrange //Arrange
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
var constant = new VirtualDependency() { PropValue = Guid.NewGuid().ToString() }; var constant = new VirtualDependency {PropValue = Guid.NewGuid().ToString()};
mocker.SetConstant(constant); mocker.SetConstant(constant);
@ -127,7 +112,6 @@ namespace NzbDrone.Core.Test
//Assert //Assert
Assert.AreEqual(constant.PropValue, result); Assert.AreEqual(constant.PropValue, result);
} }
} }
public class ConcreteClass public class ConcreteClass
@ -138,24 +122,27 @@ namespace NzbDrone.Core.Test
} }
} }
public class Dependency : IDependency { } public class Dependency : IDependency
{
}
public interface IDependency { } public interface IDependency
{
}
public class ClassWithDependencies public class ClassWithDependencies
{ {
public IDependency Dependency { get; set; }
public ClassWithDependencies(IDependency dependency) public ClassWithDependencies(IDependency dependency)
{ {
Dependency = dependency; Dependency = dependency;
} }
public IDependency Dependency { get; set; }
} }
public class ClassWithVirtualDependencies public class ClassWithVirtualDependencies
{ {
private readonly VirtualDependency _virtualDependency; private readonly VirtualDependency _virtualDependency;
public IDependency Dependency { get; set; }
public ClassWithVirtualDependencies(IDependency dependency, VirtualDependency virtualDependency) public ClassWithVirtualDependencies(IDependency dependency, VirtualDependency virtualDependency)
{ {
@ -163,6 +150,8 @@ namespace NzbDrone.Core.Test
Dependency = dependency; Dependency = dependency;
} }
public IDependency Dependency { get; set; }
public string CallVirtualChild() public string CallVirtualChild()
{ {
return _virtualDependency.VirtualMethod(); return _virtualDependency.VirtualMethod();
@ -178,19 +167,20 @@ namespace NzbDrone.Core.Test
{ {
private readonly IDependency _dependency; private readonly IDependency _dependency;
public string PropValue { get; set; } public VirtualDependency()
{
public VirtualDependency() { } }
public VirtualDependency(IDependency dependency) public VirtualDependency(IDependency dependency)
{ {
_dependency = dependency; _dependency = dependency;
} }
public string PropValue { get; set; }
public virtual string VirtualMethod() public virtual string VirtualMethod()
{ {
return "hello"; return "hello";
} }
} }
} }

View File

@ -10,9 +10,9 @@ namespace AutoMoq.Unity
{ {
internal class AutoMockingBuilderStrategy : BuilderStrategy internal class AutoMockingBuilderStrategy : BuilderStrategy
{ {
private readonly IUnityContainer container;
private readonly MockFactory mockFactory; private readonly MockFactory mockFactory;
private readonly IEnumerable<Type> registeredTypes; private readonly IEnumerable<Type> registeredTypes;
private readonly IUnityContainer container;
public AutoMockingBuilderStrategy(IEnumerable<Type> registeredTypes, IUnityContainer container) public AutoMockingBuilderStrategy(IEnumerable<Type> registeredTypes, IUnityContainer container)
{ {
@ -45,7 +45,7 @@ namespace AutoMoq.Unity
private static Type GetTheTypeFromTheBuilderContext(IBuilderContext context) private static Type GetTheTypeFromTheBuilderContext(IBuilderContext context)
{ {
return ((NamedTypeBuildKey)context.OriginalBuildKey).Type; return (context.OriginalBuildKey).Type;
} }
private bool TypeIsNotRegistered(Type type) private bool TypeIsNotRegistered(Type type)

View File

@ -1,12 +1,6 @@
using System; using AutoMoq;
using System.Collections.Generic;
using System.Text;
using AutoMoq;
using Gallio.Framework;
using MbUnit.Framework; using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq; using Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using SubSonic.Repository; using SubSonic.Repository;
@ -60,7 +54,8 @@ namespace NzbDrone.Core.Test
//Assert //Assert
mocker.GetMock<IRepository>().Verify(); mocker.GetMock<IRepository>().Verify();
mocker.GetMock<IRepository>().Verify(r => r.Update(It.IsAny<Config>()), Times.Never()); mocker.GetMock<IRepository>().Verify(r => r.Update(It.IsAny<Config>()), Times.Never());
mocker.GetMock<IRepository>().Verify(r => r.Add(It.Is<Config>(c => c.Key == key && c.Value == value)), Times.Once()); mocker.GetMock<IRepository>().Verify(r => r.Add(It.Is<Config>(c => c.Key == key && c.Value == value)),
Times.Once());
} }
} }
} }

View File

@ -1,22 +1,15 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using System.Text;
using AutoMoq; using AutoMoq;
using FizzWare.NBuilder; using FizzWare.NBuilder;
using Gallio.Framework;
using MbUnit.Framework; using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq; using Moq;
using Ninject;
using Ninject.Moq;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
using SubSonic.Repository; using SubSonic.Repository;
using TvdbLib.Data; using TvdbLib.Data;
using SubSonic.Extensions;
namespace NzbDrone.Core.Test namespace NzbDrone.Core.Test
{ {
@ -50,7 +43,6 @@ namespace NzbDrone.Core.Test
//mocker.GetMock<IRepository>().SetReturnsDefault(); //mocker.GetMock<IRepository>().SetReturnsDefault();
//Act //Act
var sw = Stopwatch.StartNew(); var sw = Stopwatch.StartNew();
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(seriesId); mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(seriesId);
@ -90,7 +82,6 @@ namespace NzbDrone.Core.Test
//repo.All<EpisodeFile>().Where(c => c.EpisodeId == episode.EpisodeId); //repo.All<EpisodeFile>().Where(c => c.EpisodeId == episode.EpisodeId);
//Act //Act

View File

@ -3,7 +3,6 @@ using System.IO;
using MbUnit.Framework; using MbUnit.Framework;
using NLog; using NLog;
using NLog.Config; using NLog.Config;
using System.Linq;
namespace NzbDrone.Core.Test namespace NzbDrone.Core.Test
{ {
@ -13,27 +12,32 @@ namespace NzbDrone.Core.Test
[TearDown] [TearDown]
public void TearDown() public void TearDown()
{ {
foreach (var file in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.db", SearchOption.AllDirectories)) foreach (
var file in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.db", SearchOption.AllDirectories))
{ {
try try
{ {
File.Delete(file); File.Delete(file);
} }
catch catch
{ } {
}
} }
} }
[FixtureTearDown] [FixtureTearDown]
public void FixtureTearDown() public void FixtureTearDown()
{ {
foreach (var file in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.*", SearchOption.AllDirectories)) foreach (var file in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.*", SearchOption.AllDirectories)
)
{ {
try try
{ {
File.Delete(file); File.Delete(file);
} }
catch { } catch
{
}
} }
} }
@ -42,7 +46,8 @@ namespace NzbDrone.Core.Test
{ {
try try
{ {
LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"), false); LogManager.Configuration =
new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"), false);
LogManager.ThrowExceptions = true; LogManager.ThrowExceptions = true;
} }
catch (Exception e) catch (Exception e)
@ -50,7 +55,5 @@ namespace NzbDrone.Core.Test
Console.WriteLine("Unable to configure logging. " + e); Console.WriteLine("Unable to configure logging. " + e);
} }
} }
} }
} }

View File

@ -1,10 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using Gallio.Framework;
using MbUnit.Framework; using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq; using Moq;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
@ -20,7 +17,14 @@ namespace NzbDrone.Core.Test
public void AllItems() public void AllItems()
{ {
//Setup //Setup
var indexer = new Indexer { Enabled = true, IndexerId = 0, IndexerName = "NzbMatrix", Order = 1, RssUrl = "http://www.nzbmatrix.com" }; var indexer = new Indexer
{
Enabled = true,
IndexerId = 0,
IndexerName = "NzbMatrix",
Order = 1,
RssUrl = "http://www.nzbmatrix.com"
};
var series = new Series var series = new Series
{ {
SeriesId = 5656, SeriesId = 5656,
@ -74,7 +78,13 @@ namespace NzbDrone.Core.Test
{ {
//Todo: This test fails... Moq Setup doesn't return the expected value //Todo: This test fails... Moq Setup doesn't return the expected value
//Setup //Setup
var indexer = new Indexer { Enabled = true, IndexerName = "NzbMatrix", Order = 1, RssUrl = "http://www.nzbmatrix.com" }; var indexer = new Indexer
{
Enabled = true,
IndexerName = "NzbMatrix",
Order = 1,
RssUrl = "http://www.nzbmatrix.com"
};
var series = new Series var series = new Series
{ {
SeriesId = 5656, SeriesId = 5656,
@ -113,7 +123,8 @@ namespace NzbDrone.Core.Test
var proper = false; var proper = false;
var repo = new Mock<IRepository>(); var repo = new Mock<IRepository>();
repo.Setup(r => r.Exists<History>(h => h.EpisodeId == episode.EpisodeId && h.IsProper == proper)).Returns(true); repo.Setup(r => r.Exists<History>(h => h.EpisodeId == episode.EpisodeId && h.IsProper == proper)).Returns(
true);
var target = new HistoryProvider(repo.Object); var target = new HistoryProvider(repo.Object);
@ -131,7 +142,13 @@ namespace NzbDrone.Core.Test
//Todo: This test fails... Moq Setup doesn't return the expected value //Todo: This test fails... Moq Setup doesn't return the expected value
//Setup //Setup
var indexer = new Indexer { Enabled = true, IndexerName = "NzbMatrix", Order = 1, RssUrl = "http://www.nzbmatrix.com" }; var indexer = new Indexer
{
Enabled = true,
IndexerName = "NzbMatrix",
Order = 1,
RssUrl = "http://www.nzbmatrix.com"
};
var series = new Series var series = new Series
{ {
SeriesId = 5656, SeriesId = 5656,
@ -168,7 +185,8 @@ namespace NzbDrone.Core.Test
}); });
var repo = new Mock<IRepository>(); var repo = new Mock<IRepository>();
repo.Setup(r => r.Exists<History>(h => h.Episode == episode && h.IsProper == list[0].IsProper)).Returns(false); repo.Setup(r => r.Exists<History>(h => h.Episode == episode && h.IsProper == list[0].IsProper)).Returns(
false);
var target = new HistoryProvider(repo.Object); var target = new HistoryProvider(repo.Object);

View File

@ -1,10 +1,6 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using Gallio.Framework;
using MbUnit.Framework; using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq; using Moq;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
@ -25,10 +21,14 @@ namespace NzbDrone.Core.Test
//Setup //Setup
var list = new List<Indexer>(); var list = new List<Indexer>();
list.Add(new Indexer { IndexerName = "Test1", RssUrl = "http://www.test1.com/rss.php", Enabled = true, Order = 1 }); list.Add(new Indexer
list.Add(new Indexer { IndexerName = "Test2", RssUrl = "http://www.test2.com/rss.php", Enabled = false, Order = 4 }); {IndexerName = "Test1", RssUrl = "http://www.test1.com/rss.php", Enabled = true, Order = 1});
list.Add(new Indexer { IndexerName = "Test3", RssUrl = "http://www.test3.com/rss.php", Enabled = true, Order = 3 }); list.Add(new Indexer
list.Add(new Indexer { IndexerName = "Test4", RssUrl = "http://www.test4.com/rss.php", Enabled = false, Order = 2 }); {IndexerName = "Test2", RssUrl = "http://www.test2.com/rss.php", Enabled = false, Order = 4});
list.Add(new Indexer
{IndexerName = "Test3", RssUrl = "http://www.test3.com/rss.php", Enabled = true, Order = 3});
list.Add(new Indexer
{IndexerName = "Test4", RssUrl = "http://www.test4.com/rss.php", Enabled = false, Order = 2});
var repo = new Mock<IRepository>(); var repo = new Mock<IRepository>();
var config = new Mock<ConfigProvider>(); var config = new Mock<ConfigProvider>();
@ -53,10 +53,14 @@ namespace NzbDrone.Core.Test
//Setup //Setup
var list = new List<Indexer>(); var list = new List<Indexer>();
list.Add(new Indexer { IndexerName = "Test1", RssUrl = "http://www.test1.com/rss.php", Enabled = true, Order = 1 }); list.Add(new Indexer
list.Add(new Indexer { IndexerName = "Test2", RssUrl = "http://www.test2.com/rss.php", Enabled = false, Order = 4 }); {IndexerName = "Test1", RssUrl = "http://www.test1.com/rss.php", Enabled = true, Order = 1});
list.Add(new Indexer { IndexerName = "Test3", RssUrl = "http://www.test3.com/rss.php", Enabled = true, Order = 3 }); list.Add(new Indexer
list.Add(new Indexer { IndexerName = "Test4", RssUrl = "http://www.test4.com/rss.php", Enabled = false, Order = 2 }); {IndexerName = "Test2", RssUrl = "http://www.test2.com/rss.php", Enabled = false, Order = 4});
list.Add(new Indexer
{IndexerName = "Test3", RssUrl = "http://www.test3.com/rss.php", Enabled = true, Order = 3});
list.Add(new Indexer
{IndexerName = "Test4", RssUrl = "http://www.test4.com/rss.php", Enabled = false, Order = 2});
var repo = new Mock<IRepository>(); var repo = new Mock<IRepository>();
var config = new Mock<ConfigProvider>(); var config = new Mock<ConfigProvider>();

View File

@ -1,16 +1,9 @@
using System; using System;
using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Text;
using AutoMoq; using AutoMoq;
using FizzWare.NBuilder; using FizzWare.NBuilder;
using Gallio.Framework;
using MbUnit.Framework; using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq; using Moq;
using Ninject;
using Ninject.Moq;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
@ -23,7 +16,6 @@ namespace NzbDrone.Core.Test
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
public class MediaFileProviderTests public class MediaFileProviderTests
{ {
[Test] [Test]
[Description("Verifies that a new file imported properly")] [Description("Verifies that a new file imported properly")]
public void import_new_file() public void import_new_file()
@ -45,12 +37,13 @@ namespace NzbDrone.Core.Test
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
mocker.GetMock<IRepository>() mocker.GetMock<IRepository>()
.Setup(r => r.Exists<EpisodeFile>(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable(); .Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
mocker.GetMock<IRepository>() mocker.GetMock<IRepository>()
.Setup(r => r.Add(It.IsAny<EpisodeFile>())).Returns(0).Verifiable(); .Setup(r => r.Add(It.IsAny<EpisodeFile>())).Returns(0).Verifiable();
mocker.GetMock<EpisodeProvider>() 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>() mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable(); .Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable();
@ -62,7 +55,7 @@ namespace NzbDrone.Core.Test
//Assert //Assert
Assert.IsNotNull(result); Assert.IsNotNull(result);
mocker.GetMock<IRepository>().VerifyAll(); mocker.GetMock<IRepository>().VerifyAll();
mocker.GetMock<IRepository>().Verify(r => r.Add<EpisodeFile>(result), Times.Once()); mocker.GetMock<IRepository>().Verify(r => r.Add(result), Times.Once());
mocker.GetMock<EpisodeProvider>().VerifyAll(); mocker.GetMock<EpisodeProvider>().VerifyAll();
mocker.GetMock<DiskProvider>().VerifyAll(); mocker.GetMock<DiskProvider>().VerifyAll();
@ -96,7 +89,7 @@ namespace NzbDrone.Core.Test
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
mocker.GetMock<IRepository>(MockBehavior.Strict) mocker.GetMock<IRepository>(MockBehavior.Strict)
.Setup(r => r.Exists<EpisodeFile>(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(true).Verifiable(); .Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(true).Verifiable();
mocker.GetMock<EpisodeProvider>(MockBehavior.Strict); mocker.GetMock<EpisodeProvider>(MockBehavior.Strict);
mocker.GetMock<DiskProvider>(MockBehavior.Strict); mocker.GetMock<DiskProvider>(MockBehavior.Strict);
@ -109,7 +102,7 @@ namespace NzbDrone.Core.Test
mocker.GetMock<EpisodeProvider>().VerifyAll(); mocker.GetMock<EpisodeProvider>().VerifyAll();
mocker.GetMock<DiskProvider>(MockBehavior.Strict).VerifyAll(); mocker.GetMock<DiskProvider>(MockBehavior.Strict).VerifyAll();
Assert.IsNull(result); Assert.IsNull(result);
mocker.GetMock<IRepository>().Verify(r => r.Add<EpisodeFile>(result), Times.Never()); mocker.GetMock<IRepository>().Verify(r => r.Add(result), Times.Never());
} }
[Test] [Test]
@ -130,10 +123,11 @@ namespace NzbDrone.Core.Test
//Mocks //Mocks
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
mocker.GetMock<IRepository>(MockBehavior.Strict) mocker.GetMock<IRepository>(MockBehavior.Strict)
.Setup(r => r.Exists<EpisodeFile>(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable(); .Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
mocker.GetMock<EpisodeProvider>(MockBehavior.Strict) mocker.GetMock<EpisodeProvider>(MockBehavior.Strict)
.Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns<Episode>(null).Verifiable(); .Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns<Episode>(null).
Verifiable();
mocker.GetMock<DiskProvider>(MockBehavior.Strict); mocker.GetMock<DiskProvider>(MockBehavior.Strict);
@ -144,12 +138,7 @@ namespace NzbDrone.Core.Test
//Assert //Assert
mocker.VerifyAllMocks(); mocker.VerifyAllMocks();
Assert.IsNull(result); Assert.IsNull(result);
mocker.GetMock<IRepository>().Verify(r => r.Add<EpisodeFile>(result), Times.Never()); mocker.GetMock<IRepository>().Verify(r => r.Add(result), Times.Never());
} }
} }
} }

View File

@ -1,45 +1,23 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using FizzWare.NBuilder;
using Moq; using Moq;
using NLog;
using NzbDrone.Core.Instrumentation; using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using SubSonic.DataProviders; using SubSonic.DataProviders;
using SubSonic.Repository; using SubSonic.Repository;
using TvdbLib;
namespace NzbDrone.Core.Test namespace NzbDrone.Core.Test
{ {
/// <summary> /// <summary>
/// Provides the standard Mocks needed for a typical test /// Provides the standard Mocks needed for a typical test
/// </summary> /// </summary>
static class MockLib internal static class MockLib
{ {
public static string[] StandardSeries public static string[] StandardSeries
{ {
get { return new string[] { "c:\\tv\\the simpsons", "c:\\tv\\family guy", "c:\\tv\\southpark", "c:\\tv\\24" }; } get { return new[] {"c:\\tv\\the simpsons", "c:\\tv\\family guy", "c:\\tv\\southpark", "c:\\tv\\24"}; }
}
public static IRepository GetEmptyRepository()
{
return GetEmptyRepository(true);
}
public static IRepository GetEmptyRepository(bool enableLogging)
{
Console.WriteLine("Creating an empty SQLite database");
var provider = ProviderFactory.GetProvider("Data Source=" + Guid.NewGuid() + ".db;Version=3;New=True", "System.Data.SQLite");
if (enableLogging)
{
provider.Log = new NlogWriter();
}
return new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations);
} }
public static ConfigProvider StandardConfig public static ConfigProvider StandardConfig
@ -52,6 +30,23 @@ namespace NzbDrone.Core.Test
} }
} }
public static IRepository GetEmptyRepository()
{
return GetEmptyRepository(true);
}
public static IRepository GetEmptyRepository(bool enableLogging)
{
Console.WriteLine("Creating an empty SQLite database");
var provider = ProviderFactory.GetProvider("Data Source=" + Guid.NewGuid() + ".db;Version=3;New=True",
"System.Data.SQLite");
if (enableLogging)
{
provider.Log = new NlogWriter();
}
return new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations);
}
public static DiskProvider GetStandardDisk(int seasons, int episodes) public static DiskProvider GetStandardDisk(int seasons, int episodes)
{ {
var mock = new Mock<DiskProvider>(); var mock = new Mock<DiskProvider>();

View File

@ -21,7 +21,10 @@ namespace Ninject.Moq
var haveBinding = builder as IHaveBinding; var haveBinding = builder as IHaveBinding;
if (haveBinding == null) if (haveBinding == null)
throw new NotSupportedException(String.Format("The binding builder for {0} is of type {1}, which does not implement IHaveBinding and is therefore not extensible.", typeof(T), builder.GetType())); throw new NotSupportedException(
String.Format(
"The binding builder for {0} is of type {1}, which does not implement IHaveBinding and is therefore not extensible.",
typeof (T), builder.GetType()));
IBinding binding = haveBinding.Binding; IBinding binding = haveBinding.Binding;

View File

@ -11,20 +11,8 @@ namespace Ninject.Moq
/// </summary> /// </summary>
public class MockProvider : IProvider public class MockProvider : IProvider
{ {
private static readonly Dictionary<Type, ConstructorInjector> _injectors = new Dictionary<Type, ConstructorInjector>(); private static readonly Dictionary<Type, ConstructorInjector> _injectors =
new Dictionary<Type, ConstructorInjector>();
/// <summary>
/// Gets the type (or prototype) of instances the provider creates.
/// </summary>
public Type Type
{
get { return typeof(Mock<>); }
}
/// <summary>
/// Gets the injector factory component.
/// </summary>
public IInjectorFactory InjectorFactory { get; private set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref = "MockProvider" /> class. /// Initializes a new instance of the <see cref = "MockProvider" /> class.
@ -35,6 +23,21 @@ namespace Ninject.Moq
InjectorFactory = injectorFactory; InjectorFactory = injectorFactory;
} }
/// <summary>
/// Gets the injector factory component.
/// </summary>
public IInjectorFactory InjectorFactory { get; private set; }
#region IProvider Members
/// <summary>
/// Gets the type (or prototype) of instances the provider creates.
/// </summary>
public Type Type
{
get { return typeof (Mock<>); }
}
/// <summary> /// <summary>
/// Creates an instance within the specified context. /// Creates an instance within the specified context.
/// </summary> /// </summary>
@ -47,6 +50,8 @@ namespace Ninject.Moq
return mock.Object; return mock.Object;
} }
#endregion
private ConstructorInjector GetInjector(Type service) private ConstructorInjector GetInjector(Type service)
{ {
lock (_injectors) lock (_injectors)

View File

@ -1,9 +1,4 @@
using System; using MbUnit.Framework;
using System.Collections.Generic;
using System.Text;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.Test namespace NzbDrone.Core.Test
@ -82,7 +77,6 @@ namespace NzbDrone.Core.Test
} }
[Test] [Test]
[Row(@"c:\test\", @"c:\test")] [Row(@"c:\test\", @"c:\test")]
[Row(@"c:\\test\\", @"c:\test")] [Row(@"c:\\test\\", @"c:\test")]

View File

@ -1,12 +1,10 @@
using System; using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using MbUnit.Framework;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("NzbDrone.Core.Test")] [assembly: AssemblyTitle("NzbDrone.Core.Test")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
@ -19,9 +17,11 @@ using MbUnit.Framework;
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM // The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("699aed1b-015e-4f0d-9c81-d5557b05d260")] [assembly: Guid("699aed1b-015e-4f0d-9c81-d5557b05d260")]
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
@ -34,5 +34,6 @@ using MbUnit.Framework;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,36 +1,30 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.Linq;
using FizzWare.NBuilder; using FizzWare.NBuilder;
using MbUnit.Framework; using MbUnit.Framework;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
using System.Linq;
using TvdbLib.Data;
namespace NzbDrone.Core.Test namespace NzbDrone.Core.Test
{ {
[TestFixture] [TestFixture]
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
public class QualityProfileTest public class QualityProfileTest
{ {
///<summary> ///<summary>
/// Test_s the storage. /// Test_s the storage.
///</summary> ///</summary>
///
///
[Test] [Test]
public void Test_Storage() public void Test_Storage()
{ {
//Arrange //Arrange
var repo = MockLib.GetEmptyRepository(); var repo = MockLib.GetEmptyRepository();
var testProfile = new QualityProfile var testProfile = new QualityProfile
{ {
Name = Guid.NewGuid().ToString(), Name = Guid.NewGuid().ToString(),
Cutoff = QualityTypes.TV, Cutoff = QualityTypes.TV,
Allowed = new List<QualityTypes>() { QualityTypes.HDTV, QualityTypes.DVD }, Allowed = new List<QualityTypes> {QualityTypes.HDTV, QualityTypes.DVD},
}; };
//Act //Act
@ -54,7 +48,7 @@ namespace NzbDrone.Core.Test
{ {
Name = Guid.NewGuid().ToString(), Name = Guid.NewGuid().ToString(),
Cutoff = QualityTypes.TV, Cutoff = QualityTypes.TV,
Allowed = new List<QualityTypes>() { QualityTypes.HDTV, QualityTypes.DVD }, Allowed = new List<QualityTypes> {QualityTypes.HDTV, QualityTypes.DVD},
}; };

View File

@ -3,10 +3,10 @@ using System.Linq;
using FizzWare.NBuilder; using FizzWare.NBuilder;
using MbUnit.Framework; using MbUnit.Framework;
using NLog; using NLog;
using NLog.Config;
using NzbDrone.Core.Instrumentation; using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using LogLevel = NzbDrone.Core.Instrumentation.LogLevel; using LogLevel = NLog.LogLevel;
using NLog.Config;
namespace NzbDrone.Core.Test namespace NzbDrone.Core.Test
{ {
@ -38,7 +38,9 @@ namespace NzbDrone.Core.Test
} }
[Test] [Test]
[Description("This test confirms that the tvdb id stored in the db is preserved rather than being replaced by an auto incrementing value")] [Description(
"This test confirms that the tvdb id stored in the db is preserved rather than being replaced by an auto incrementing value"
)]
public void tvdbid_is_preserved([RandomNumbers(Minimum = 100, Maximum = 999, Count = 1)] int tvdbId) public void tvdbid_is_preserved([RandomNumbers(Minimum = 100, Maximum = 999, Count = 1)] int tvdbId)
{ {
//Arrange //Arrange
@ -72,7 +74,7 @@ namespace NzbDrone.Core.Test
var sonicTarget = new SubsonicTarget(sonicRepo); var sonicTarget = new SubsonicTarget(sonicRepo);
LogManager.Configuration.AddTarget("DbLogger", sonicTarget); LogManager.Configuration.AddTarget("DbLogger", sonicTarget);
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Info, sonicTarget)); LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, sonicTarget));
LogManager.Configuration.Reload(); LogManager.Configuration.Reload();
Logger Logger = LogManager.GetCurrentClassLogger(); Logger Logger = LogManager.GetCurrentClassLogger();
@ -89,7 +91,7 @@ namespace NzbDrone.Core.Test
Assert.AreEqual(message, logItem.Message); Assert.AreEqual(message, logItem.Message);
Assert.AreEqual(Logger.Name, logItem.Logger); Assert.AreEqual(Logger.Name, logItem.Logger);
Assert.AreEqual(Logger.Name, logItem.Logger); Assert.AreEqual(Logger.Name, logItem.Logger);
Assert.AreEqual(LogLevel.Info, logItem.Level); Assert.AreEqual(Instrumentation.LogLevel.Info, logItem.Level);
} }
[Test] [Test]
@ -102,7 +104,7 @@ namespace NzbDrone.Core.Test
var sonicTarget = new SubsonicTarget(sonicRepo); var sonicTarget = new SubsonicTarget(sonicRepo);
LogManager.Configuration.AddTarget("DbLogger", sonicTarget); LogManager.Configuration.AddTarget("DbLogger", sonicTarget);
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Info, sonicTarget)); LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, sonicTarget));
LogManager.Configuration.Reload(); LogManager.Configuration.Reload();
Logger Logger = LogManager.GetCurrentClassLogger(); Logger Logger = LogManager.GetCurrentClassLogger();
@ -120,7 +122,7 @@ namespace NzbDrone.Core.Test
Assert.AreNotEqual(new DateTime(), logItem.Time); Assert.AreNotEqual(new DateTime(), logItem.Time);
Assert.AreEqual(message, logItem.Message); Assert.AreEqual(message, logItem.Message);
Assert.AreEqual(Logger.Name, logItem.Logger); Assert.AreEqual(Logger.Name, logItem.Logger);
Assert.AreEqual(LogLevel.Error, logItem.Level); Assert.AreEqual(Instrumentation.LogLevel.Error, logItem.Level);
Assert.AreEqual(ex.GetType().ToString(), logItem.ExceptionType); Assert.AreEqual(ex.GetType().ToString(), logItem.ExceptionType);
Assert.AreEqual(ex.ToString(), logItem.ExceptionString); Assert.AreEqual(ex.ToString(), logItem.ExceptionString);
Assert.AreEqual(ex.Message, logItem.ExceptionMessage); Assert.AreEqual(ex.Message, logItem.ExceptionMessage);
@ -136,7 +138,7 @@ namespace NzbDrone.Core.Test
var sonicTarget = new SubsonicTarget(sonicRepo); var sonicTarget = new SubsonicTarget(sonicRepo);
LogManager.Configuration.AddTarget("DbLogger", sonicTarget); LogManager.Configuration.AddTarget("DbLogger", sonicTarget);
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Info, sonicTarget)); LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, sonicTarget));
LogManager.Configuration.Reload(); LogManager.Configuration.Reload();
Logger Logger = LogManager.GetCurrentClassLogger(); Logger Logger = LogManager.GetCurrentClassLogger();
@ -154,7 +156,7 @@ namespace NzbDrone.Core.Test
Assert.AreNotEqual(new DateTime(), logItem.Time); Assert.AreNotEqual(new DateTime(), logItem.Time);
Assert.AreEqual(ex.Message, logItem.Message); Assert.AreEqual(ex.Message, logItem.Message);
Assert.AreEqual(Logger.Name, logItem.Logger); Assert.AreEqual(Logger.Name, logItem.Logger);
Assert.AreEqual(LogLevel.Error, logItem.Level); Assert.AreEqual(Instrumentation.LogLevel.Error, logItem.Level);
Assert.AreEqual(ex.GetType().ToString(), logItem.ExceptionType); Assert.AreEqual(ex.GetType().ToString(), logItem.ExceptionType);
Assert.AreEqual(ex.ToString(), logItem.ExceptionString); Assert.AreEqual(ex.ToString(), logItem.ExceptionString);
Assert.AreEqual(ex.Message, logItem.ExceptionMessage); Assert.AreEqual(ex.Message, logItem.ExceptionMessage);

View File

@ -1,12 +1,6 @@
using System; using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoMoq; using AutoMoq;
using Gallio.Framework;
using MbUnit.Framework; using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using SubSonic.Repository; using SubSonic.Repository;

View File

@ -1,22 +1,13 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.ServiceModel.Syndication; using System.ServiceModel.Syndication;
using System.Text;
using System.Xml; using System.Xml;
using AutoMoq; using AutoMoq;
using Gallio.Framework;
using MbUnit.Framework; using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq; using Moq;
using Ninject;
using Ninject.Moq;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.Feed; using NzbDrone.Core.Providers.Feed;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
namespace NzbDrone.Core.Test namespace NzbDrone.Core.Test
{ {
@ -25,7 +16,6 @@ namespace NzbDrone.Core.Test
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
{ {
[Test] [Test]
public void Download_feed_test() public void Download_feed_test()
{ {
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
@ -38,12 +28,13 @@ namespace NzbDrone.Core.Test
mocker.Resolve<MockFeedProvider>().Fetch(); mocker.Resolve<MockFeedProvider>().Fetch();
} }
} }
public class MockFeedProvider : FeedProviderBase public class MockFeedProvider : FeedProviderBase
{ {
public MockFeedProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider) public MockFeedProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider,
EpisodeProvider episodeProvider, ConfigProvider configProvider,
HttpProvider httpProvider)
: base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider) : base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider)
{ {
} }

View File

@ -1,15 +1,9 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text;
using AutoMoq; using AutoMoq;
using Gallio.Framework;
using MbUnit.Framework; using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using SubSonic.Repository;
namespace NzbDrone.Core.Test namespace NzbDrone.Core.Test
{ {
@ -49,11 +43,15 @@ namespace NzbDrone.Core.Test
.Returns(category); .Returns(category);
mocker.GetMock<HttpProvider>() mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=0&cat=tv&nzbname=This+is+an+Nzb&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass")) .Setup(
s =>
s.DownloadString(
"http://192.168.5.55:2222/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=0&cat=tv&nzbname=This+is+an+Nzb&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns("ok"); .Returns("ok");
//Act //Act
bool result = mocker.Resolve<SabProvider>().AddByUrl("http://www.nzbclub.com/nzb_download.aspx?mid=1950232", "This is an Nzb"); bool result = mocker.Resolve<SabProvider>().AddByUrl(
"http://www.nzbclub.com/nzb_download.aspx?mid=1950232", "This is an Nzb");
//Assert //Assert
Assert.AreEqual(true, result); Assert.AreEqual(true, result);
@ -83,11 +81,15 @@ namespace NzbDrone.Core.Test
fakeConfig.Setup(c => c.GetValue("SabTvCategory", String.Empty, true)).Returns(category); fakeConfig.Setup(c => c.GetValue("SabTvCategory", String.Empty, true)).Returns(category);
mocker.GetMock<HttpProvider>() mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=0&cat=tv&nzbname=This+is+an+Nzb&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass")) .Setup(
s =>
s.DownloadString(
"http://192.168.5.55:2222/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=0&cat=tv&nzbname=This+is+an+Nzb&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns("error"); .Returns("error");
//Act //Act
bool result = mocker.Resolve<SabProvider>().AddByUrl("http://www.nzbclub.com/nzb_download.aspx?mid=1950232", "This is an Nzb"); bool result = mocker.Resolve<SabProvider>().AddByUrl(
"http://www.nzbclub.com/nzb_download.aspx?mid=1950232", "This is an Nzb");
//Assert //Assert
Assert.AreEqual(false, result); Assert.AreEqual(false, result);
@ -113,7 +115,10 @@ namespace NzbDrone.Core.Test
fakeConfig.Setup(c => c.GetValue("SabPassword", String.Empty, false)).Returns(password); fakeConfig.Setup(c => c.GetValue("SabPassword", String.Empty, false)).Returns(password);
mocker.GetMock<HttpProvider>() mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass")) .Setup(
s =>
s.DownloadString(
"http://192.168.5.55:2222/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(new StreamReader(@".\Files\Queue.xml").ReadToEnd()); .Returns(new StreamReader(@".\Files\Queue.xml").ReadToEnd());
//Act //Act
@ -143,7 +148,10 @@ namespace NzbDrone.Core.Test
fakeConfig.Setup(c => c.GetValue("SabPassword", String.Empty, false)).Returns(password); fakeConfig.Setup(c => c.GetValue("SabPassword", String.Empty, false)).Returns(password);
mocker.GetMock<HttpProvider>() mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass")) .Setup(
s =>
s.DownloadString(
"http://192.168.5.55:2222/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(new StreamReader(@".\Files\QueueEmpty.xml").ReadToEnd()); .Returns(new StreamReader(@".\Files\QueueEmpty.xml").ReadToEnd());
//Act //Act
@ -173,7 +181,10 @@ namespace NzbDrone.Core.Test
fakeConfig.Setup(c => c.GetValue("SabPassword", String.Empty, false)).Returns(password); fakeConfig.Setup(c => c.GetValue("SabPassword", String.Empty, false)).Returns(password);
mocker.GetMock<HttpProvider>() mocker.GetMock<HttpProvider>()
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass")) .Setup(
s =>
s.DownloadString(
"http://192.168.5.55:2222/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
.Returns(new StreamReader(@".\Files\QueueError.xml").ReadToEnd()); .Returns(new StreamReader(@".\Files\QueueError.xml").ReadToEnd());

View File

@ -1,24 +1,18 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.Linq;
using System.Text;
using AutoMoq; using AutoMoq;
using FizzWare.NBuilder; using FizzWare.NBuilder;
using Gallio.Framework;
using MbUnit.Framework; using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq; using Moq;
using Ninject;
using Ninject.Moq;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
using SubSonic.Repository; using SubSonic.Repository;
using TvdbLib.Data; using TvdbLib.Data;
using System.Linq;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace NzbDrone.Core.Test namespace NzbDrone.Core.Test
{ {
[TestFixture] [TestFixture]
@ -65,7 +59,6 @@ namespace NzbDrone.Core.Test
[Test] [Test]
public void Add_new_series() public void Add_new_series()
{ {
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
mocker.SetConstant(MockLib.GetEmptyRepository()); mocker.SetConstant(MockLib.GetEmptyRepository());
@ -85,11 +78,9 @@ namespace NzbDrone.Core.Test
Assert.AreEqual(path, series.First().Path); Assert.AreEqual(path, series.First().Path);
Assert.AreEqual(tvDbId, series.First().SeriesId); Assert.AreEqual(tvDbId, series.First().SeriesId);
Assert.AreEqual(qualityProfileId, series.First().QualityProfileId); Assert.AreEqual(qualityProfileId, series.First().QualityProfileId);
} }
[Test] [Test]
[Row(new object[] {"That's Life - 2x03 -The Devil and Miss DeLucca", "That's Life"})] [Row(new object[] {"That's Life - 2x03 -The Devil and Miss DeLucca", "That's Life"})]
[Row(new object[] {"Van.Duin.Op.Zn.Best.S02E05.DUTCH.WS.PDTV.XViD-DiFFERENT", "Van Duin Op Zn Best"})] [Row(new object[] {"Van.Duin.Op.Zn.Best.S02E05.DUTCH.WS.PDTV.XViD-DiFFERENT", "Van Duin Op Zn Best"})]
@ -128,7 +119,6 @@ namespace NzbDrone.Core.Test
} }
[Test] [Test]
[Row(12, QualityTypes.TV, true)] [Row(12, QualityTypes.TV, true)]
[Row(12, QualityTypes.Unknown, false)] [Row(12, QualityTypes.Unknown, false)]
@ -139,7 +129,7 @@ namespace NzbDrone.Core.Test
public void QualityWanted(int seriesId, QualityTypes qualityTypes, Boolean result) public void QualityWanted(int seriesId, QualityTypes qualityTypes, Boolean result)
{ {
var quality = Builder<QualityProfile>.CreateNew() var quality = Builder<QualityProfile>.CreateNew()
.With(q => q.Allowed = new List<QualityTypes>() { QualityTypes.BDRip, QualityTypes.DVD, QualityTypes.TV }) .With(q => q.Allowed = new List<QualityTypes> {QualityTypes.BDRip, QualityTypes.DVD, QualityTypes.TV})
.With(q => q.Cutoff = QualityTypes.DVD) .With(q => q.Cutoff = QualityTypes.DVD)
.Build(); .Build();

View File

@ -1,15 +1,9 @@
using System; using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using AutoMoq; using AutoMoq;
using Gallio.Framework;
using MbUnit.Framework; using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using Moq; using Moq;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using SubSonic.Repository;
namespace NzbDrone.Core.Test namespace NzbDrone.Core.Test
{ {

View File

@ -1,9 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using Gallio.Framework;
using MbUnit.Framework; using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
namespace NzbDrone.Core.Test namespace NzbDrone.Core.Test
@ -85,8 +81,5 @@ namespace NzbDrone.Core.Test
//assert //assert
Assert.IsNull(result); Assert.IsNull(result);
} }
} }
} }

View File

@ -2,22 +2,16 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Web;
using System.Web.Hosting; using System.Web.Hosting;
using Ninject; using Ninject;
using NLog.Config; using NLog;
using NLog.Targets;
using NzbDrone.Core.Instrumentation; using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.Fakes;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
using SubSonic.DataProviders; using SubSonic.DataProviders;
using SubSonic.Query;
using SubSonic.Repository; using SubSonic.Repository;
using NLog;
using System.Linq;
namespace NzbDrone.Core namespace NzbDrone.Core
{ {
@ -28,6 +22,45 @@ namespace NzbDrone.Core
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static string _startupPath; private static string _startupPath;
public static String AppPath
{
get
{
if (!String.IsNullOrWhiteSpace(HostingEnvironment.ApplicationPhysicalPath))
{
return HostingEnvironment.ApplicationPhysicalPath;
}
return Directory.GetCurrentDirectory();
}
}
public static string ExecutablePath
{
get
{
//var uri = new Uri(Assembly.EscapedCodeBase);
//return Path.GetDirectoryName(uri.LocalPath);
return Directory.GetCurrentDirectory();
}
}
public static string StartupPath
{
get { return _startupPath; }
}
public static StandardKernel NinjectKernel
{
get
{
if (_kernel == null)
{
BindKernel();
}
return _kernel;
}
}
public static void BindKernel() public static void BindKernel()
{ {
lock (KernelLock) lock (KernelLock)
@ -42,10 +75,12 @@ namespace NzbDrone.Core
var AppDataPath = new DirectoryInfo(Path.Combine(AppPath, "App_Data", "nzbdrone.db")); var AppDataPath = new DirectoryInfo(Path.Combine(AppPath, "App_Data", "nzbdrone.db"));
if (!AppDataPath.Exists) AppDataPath.Create(); if (!AppDataPath.Exists) AppDataPath.Create();
string connectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppDataPath.FullName, "nzbdrone.db")); string connectionString = String.Format("Data Source={0};Version=3;",
Path.Combine(AppDataPath.FullName, "nzbdrone.db"));
var dbProvider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite"); var dbProvider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
string logConnectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppDataPath.FullName, "log.db")); string logConnectionString = String.Format("Data Source={0};Version=3;",
Path.Combine(AppDataPath.FullName, "log.db"));
var logDbProvider = ProviderFactory.GetProvider(logConnectionString, "System.Data.SQLite"); var logDbProvider = ProviderFactory.GetProvider(logConnectionString, "System.Data.SQLite");
@ -80,9 +115,11 @@ namespace NzbDrone.Core
_kernel.Bind<LogProvider>().ToSelf().InSingletonScope(); _kernel.Bind<LogProvider>().ToSelf().InSingletonScope();
_kernel.Bind<MediaFileProvider>().ToSelf().InSingletonScope(); _kernel.Bind<MediaFileProvider>().ToSelf().InSingletonScope();
_kernel.Bind<TimerProvider>().ToSelf().InSingletonScope(); _kernel.Bind<TimerProvider>().ToSelf().InSingletonScope();
_kernel.Bind<IRepository>().ToMethod(c => new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations)).InSingletonScope(); _kernel.Bind<IRepository>().ToMethod(
c => new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations)).InSingletonScope();
_kernel.Bind<IRepository>().ToConstant(logRepository).WhenInjectedInto<SubsonicTarget>().InSingletonScope(); _kernel.Bind<IRepository>().ToConstant(logRepository).WhenInjectedInto<SubsonicTarget>().
InSingletonScope();
_kernel.Bind<IRepository>().ToConstant(logRepository).WhenInjectedInto<LogProvider>().InSingletonScope(); _kernel.Bind<IRepository>().ToConstant(logRepository).WhenInjectedInto<LogProvider>().InSingletonScope();
ForceMigration(_kernel.Get<IRepository>()); ForceMigration(_kernel.Get<IRepository>());
@ -97,46 +134,6 @@ namespace NzbDrone.Core
} }
} }
public static String AppPath
{
get
{
if (!String.IsNullOrWhiteSpace(HostingEnvironment.ApplicationPhysicalPath))
{
return HostingEnvironment.ApplicationPhysicalPath;
}
return Directory.GetCurrentDirectory();
}
}
public static string ExecutablePath
{
get
{
//var uri = new Uri(Assembly.EscapedCodeBase);
//return Path.GetDirectoryName(uri.LocalPath);
return Directory.GetCurrentDirectory();
}
}
public static string StartupPath
{
get { return _startupPath; }
}
public static StandardKernel NinjectKernel
{
get
{
if (_kernel == null)
{
BindKernel();
}
return _kernel;
}
}
private static void ForceMigration(IRepository repository) private static void ForceMigration(IRepository repository)
{ {
repository.GetPaged<Series>(0, 1); repository.GetPaged<Series>(0, 1);
@ -155,7 +152,8 @@ namespace NzbDrone.Core
try try
{ {
Logger.Debug("Attaching to parent process for automatic termination."); Logger.Debug("Attaching to parent process for automatic termination.");
var pc = new PerformanceCounter("Process", "Creating Process ID", Process.GetCurrentProcess().ProcessName); var pc = new PerformanceCounter("Process", "Creating Process ID",
Process.GetCurrentProcess().ProcessName);
var pid = (int) pc.NextValue(); var pid = (int) pc.NextValue();
var hostProcess = Process.GetProcessById(pid); var hostProcess = Process.GetProcessById(pid);
@ -184,8 +182,10 @@ namespace NzbDrone.Core
{ {
//Setup the default providers in the Providers table //Setup the default providers in the Providers table
string nzbMatrixRss = "http://rss.nzbmatrix.com/rss.php?page=download&username={USERNAME}&apikey={APIKEY}&subcat=6,41&english=1"; string nzbMatrixRss =
string nzbMatrixApi = "http://rss.nzbmatrix.com/rss.php?page=download&username={USERNAME}&apikey={APIKEY}&subcat=6,41&english=1&age={AGE}&term={TERM}"; "http://rss.nzbmatrix.com/rss.php?page=download&username={USERNAME}&apikey={APIKEY}&subcat=6,41&english=1";
string nzbMatrixApi =
"http://rss.nzbmatrix.com/rss.php?page=download&username={USERNAME}&apikey={APIKEY}&subcat=6,41&english=1&age={AGE}&term={TERM}";
string nzbsOrgRss = "http://nzbs.org/rss.php?type=1&dl=1&num=100&i={UID}&h={HASH}"; string nzbsOrgRss = "http://nzbs.org/rss.php?type=1&dl=1&num=100&i={UID}&h={HASH}";
string nzbsOrgApi = String.Empty; string nzbsOrgApi = String.Empty;
string nzbsrusRss = "http://www.nzbsrus.com/rssfeed.php?cat=91,75&i={UID}&h={HASH}"; string nzbsrusRss = "http://www.nzbsrus.com/rssfeed.php?cat=91,75&i={UID}&h={HASH}";
@ -282,7 +282,9 @@ namespace NzbDrone.Core
var hd = new QualityProfile var hd = new QualityProfile
{ {
Name = "HD", Name = "HD",
Allowed = new List<QualityTypes> { QualityTypes.HDTV, QualityTypes.WEBDL, QualityTypes.BDRip, QualityTypes.Bluray720 }, Allowed =
new List<QualityTypes>
{QualityTypes.HDTV, QualityTypes.WEBDL, QualityTypes.BDRip, QualityTypes.Bluray720},
Cutoff = QualityTypes.HDTV Cutoff = QualityTypes.HDTV
}; };

View File

@ -8,23 +8,68 @@ namespace NzbDrone.Core.Helpers
{ {
private static readonly List<EpisodeSortingType> SeparatorStyles = new List<EpisodeSortingType> private static readonly List<EpisodeSortingType> SeparatorStyles = new List<EpisodeSortingType>
{ {
new EpisodeSortingType {Id = 0, Name = "Dash", Pattern = " - "}, new EpisodeSortingType
new EpisodeSortingType {Id = 1, Name = "Space", Pattern = " "} {
Id = 0,
Name = "Dash",
Pattern = " - "
},
new EpisodeSortingType
{
Id = 1,
Name = "Space",
Pattern = " "
}
}; };
private static readonly List<EpisodeSortingType> NumberStyles = new List<EpisodeSortingType> private static readonly List<EpisodeSortingType> NumberStyles = new List<EpisodeSortingType>
{ {
new EpisodeSortingType { Id = 0, Name = "1x05", Pattern = "%sx%0e"}, new EpisodeSortingType
new EpisodeSortingType { Id = 1, Name = "01x05", Pattern = "%0sx%0e"}, {
new EpisodeSortingType { Id = 2, Name = "S01E05", Pattern = "S%0sE%0e"}, Id = 0,
new EpisodeSortingType { Id = 3, Name = "s01e05", Pattern = "s%0se%0e"} Name = "1x05",
Pattern = "%sx%0e"
},
new EpisodeSortingType
{
Id = 1,
Name = "01x05",
Pattern = "%0sx%0e"
},
new EpisodeSortingType
{
Id = 2,
Name = "S01E05",
Pattern = "S%0sE%0e"
},
new EpisodeSortingType
{
Id = 3,
Name = "s01e05",
Pattern = "s%0se%0e"
}
}; };
private static readonly List<EpisodeSortingType> MultiEpisodeStyles = new List<EpisodeSortingType> private static readonly List<EpisodeSortingType> MultiEpisodeStyles = new List<EpisodeSortingType>
{ {
new EpisodeSortingType { Id = 0, Name = "Extend", Pattern = "" }, new EpisodeSortingType
new EpisodeSortingType { Id = 1, Name = "Duplicate", Pattern = "" }, {
new EpisodeSortingType { Id = 2, Name = "Repeat", Pattern = "" } Id = 0,
Name = "Extend",
Pattern = ""
},
new EpisodeSortingType
{
Id = 1,
Name = "Duplicate",
Pattern = ""
},
new EpisodeSortingType
{
Id = 2,
Name = "Repeat",
Pattern = ""
}
}; };
public static List<EpisodeSortingType> GetSeparatorStyles() public static List<EpisodeSortingType> GetSeparatorStyles()

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
namespace NzbDrone.Core.Helpers namespace NzbDrone.Core.Helpers
@ -10,68 +9,300 @@ namespace NzbDrone.Core.Helpers
{ {
private static readonly List<SceneNameModel> SceneNameMappings = new List<SceneNameModel> private static readonly List<SceneNameModel> SceneNameMappings = new List<SceneNameModel>
{ {
new SceneNameModel { SeriesId = 72546, Name = "CSI" }, new SceneNameModel
new SceneNameModel { SeriesId = 73696, Name = "CSI New York" }, {SeriesId = 72546, Name = "CSI"},
new SceneNameModel { SeriesId = 73696, Name = "CSI NY" }, new SceneNameModel
new SceneNameModel { SeriesId = 110381, Name = "Archer" }, {
new SceneNameModel { SeriesId = 83897, Name = "Life After People The Series" }, SeriesId = 73696,
new SceneNameModel { SeriesId = 83897, Name = "Life After People" }, Name = "CSI New York"
new SceneNameModel { SeriesId = 80552, Name = "Kitchen Nightmares US" }, },
new SceneNameModel { SeriesId = 71256, Name = "The Daily Show" }, new SceneNameModel
new SceneNameModel { SeriesId = 71256, Name = "The Daily Show with Jon Stewart" }, {SeriesId = 73696, Name = "CSI NY"},
new SceneNameModel { SeriesId = 75692, Name = "Law and Order SVU" }, new SceneNameModel
new SceneNameModel { SeriesId = 75692, Name = "Law and Order Special Victims Unit" }, {
new SceneNameModel { SeriesId = 71489, Name = "Law and Order Criminal Intent" }, SeriesId = 110381,
new SceneNameModel { SeriesId = 71489, Name = "Law and Order CI" }, Name = "Archer"
new SceneNameModel { SeriesId = 79590, Name = "Dancing With The Stars US" }, },
new SceneNameModel { SeriesId = 73387, Name = "Craig Ferguson" }, new SceneNameModel
new SceneNameModel { SeriesId = 85355, Name = "Jimmy Fallon" }, {
new SceneNameModel { SeriesId = 75088, Name = "David Letterman" }, SeriesId = 83897,
new SceneNameModel { SeriesId = 76706, Name = "Big Brother US" }, Name =
new SceneNameModel { SeriesId = 105521, Name = "The Colony" }, "Life After People The Series"
new SceneNameModel { SeriesId = 105521, Name = "The Colony US" }, },
new SceneNameModel { SeriesId = 76235, Name = "Americas Funniest Home Videos" }, new SceneNameModel
new SceneNameModel { SeriesId = 76235, Name = "AFHV" }, {
new SceneNameModel { SeriesId = 139941, Name = "Childrens Hospital US" }, SeriesId = 83897,
new SceneNameModel { SeriesId = 139941, Name = "Childrens Hospital" }, Name = "Life After People"
new SceneNameModel { SeriesId = 83123, Name = "Merlin" }, },
new SceneNameModel { SeriesId = 83123, Name = "Merlin 2008" }, new SceneNameModel
new SceneNameModel { SeriesId = 76779, Name = "WWE Monday Night RAW" }, {
new SceneNameModel { SeriesId = 164951, Name = "Shit My Dad Says" }, SeriesId = 80552,
new SceneNameModel { SeriesId = 83714, Name = "Genius with Dave Gorman" }, Name = "Kitchen Nightmares US"
new SceneNameModel { SeriesId = 168161, Name = "Law and Order Los Angeles" }, },
new SceneNameModel { SeriesId = 168161, Name = "Law and Order LA" }, new SceneNameModel
new SceneNameModel { SeriesId = 77526, Name = "Star Trek TOS" }, {
new SceneNameModel { SeriesId = 72073, Name = "Star Trek DS9" }, SeriesId = 71256,
new SceneNameModel { SeriesId = 72194, Name = "Ellen Degeneres" }, Name = "The Daily Show"
new SceneNameModel { SeriesId = 72194, Name = "Ellen Degeneres" }, },
new SceneNameModel { SeriesId = 195831, Name = "Drinking Made Easy" }, new SceneNameModel
new SceneNameModel { SeriesId = 195831, Name = "Zane Lampreys Drinking Made Easy" }, {
new SceneNameModel { SeriesId = 76133, Name = "Poirot" }, SeriesId = 71256,
new SceneNameModel { SeriesId = 76133, Name = "Agatha Christies Poirot" }, Name =
new SceneNameModel { SeriesId = 70870, Name = "The Real World Road Rules Challenge" }, "The Daily Show with Jon Stewart"
new SceneNameModel { SeriesId = 70870, Name = "The Challenge Cutthroat" }, },
new SceneNameModel { SeriesId = 77444, Name = "This Old House Program" }, new SceneNameModel
new SceneNameModel { SeriesId = 73290, Name = "60 Minutes US" }, {
new SceneNameModel { SeriesId = 194751, Name = "Conan" }, SeriesId = 75692,
new SceneNameModel { SeriesId = 194751, Name = "Conan 2010" }, Name = "Law and Order SVU"
new SceneNameModel { SeriesId = 164451, Name = "Carlos 2010" }, },
new SceneNameModel { SeriesId = 70726, Name = "Babalon 5" }, new SceneNameModel
new SceneNameModel { SeriesId = 70726, Name = "Babalon5" }, {
new SceneNameModel { SeriesId = 83714, Name = "Genius" }, SeriesId = 75692,
new SceneNameModel { SeriesId = 83714, Name = "Genius With Dave Gormand" }, Name =
new SceneNameModel { SeriesId = 212571, Name = "Come Fly With Me 2010" }, "Law and Order Special Victims Unit"
new SceneNameModel { SeriesId = 81563, Name = "Border Security" }, },
new SceneNameModel { SeriesId = 81563, Name = "Border Security Australias Frontline" }, new SceneNameModel
new SceneNameModel { SeriesId = 172381, Name = "Silent Library US" }, {
new SceneNameModel { SeriesId = 131791, Name = "Sci-Fi Science" }, SeriesId = 71489,
new SceneNameModel { SeriesId = 80646, Name = "Frontline" }, Name =
new SceneNameModel { SeriesId = 80646, Name = "Frontline US" }, "Law and Order Criminal Intent"
new SceneNameModel { SeriesId = 189931, Name = "RBT AU" }, },
new SceneNameModel { SeriesId = 73255, Name = "House" }, new SceneNameModel
new SceneNameModel { SeriesId = 73255, Name = "House MD" }, {
new SceneNameModel { SeriesId = 73244, Name = "The Office" }, SeriesId = 71489,
new SceneNameModel { SeriesId = 73244, Name = "The Office US" }, Name = "Law and Order CI"
},
new SceneNameModel
{
SeriesId = 79590,
Name = "Dancing With The Stars US"
},
new SceneNameModel
{
SeriesId = 73387,
Name = "Craig Ferguson"
},
new SceneNameModel
{
SeriesId = 85355,
Name = "Jimmy Fallon"
},
new SceneNameModel
{
SeriesId = 75088,
Name = "David Letterman"
},
new SceneNameModel
{
SeriesId = 76706,
Name = "Big Brother US"
},
new SceneNameModel
{
SeriesId = 105521,
Name = "The Colony"
},
new SceneNameModel
{
SeriesId = 105521,
Name = "The Colony US"
},
new SceneNameModel
{
SeriesId = 76235,
Name =
"Americas Funniest Home Videos"
},
new SceneNameModel
{SeriesId = 76235, Name = "AFHV"},
new SceneNameModel
{
SeriesId = 139941,
Name = "Childrens Hospital US"
},
new SceneNameModel
{
SeriesId = 139941,
Name = "Childrens Hospital"
},
new SceneNameModel
{SeriesId = 83123, Name = "Merlin"},
new SceneNameModel
{
SeriesId = 83123,
Name = "Merlin 2008"
},
new SceneNameModel
{
SeriesId = 76779,
Name = "WWE Monday Night RAW"
},
new SceneNameModel
{
SeriesId = 164951,
Name = "Shit My Dad Says"
},
new SceneNameModel
{
SeriesId = 83714,
Name = "Genius with Dave Gorman"
},
new SceneNameModel
{
SeriesId = 168161,
Name = "Law and Order Los Angeles"
},
new SceneNameModel
{
SeriesId = 168161,
Name = "Law and Order LA"
},
new SceneNameModel
{
SeriesId = 77526,
Name = "Star Trek TOS"
},
new SceneNameModel
{
SeriesId = 72073,
Name = "Star Trek DS9"
},
new SceneNameModel
{
SeriesId = 72194,
Name = "Ellen Degeneres"
},
new SceneNameModel
{
SeriesId = 72194,
Name = "Ellen Degeneres"
},
new SceneNameModel
{
SeriesId = 195831,
Name = "Drinking Made Easy"
},
new SceneNameModel
{
SeriesId = 195831,
Name =
"Zane Lampreys Drinking Made Easy"
},
new SceneNameModel
{SeriesId = 76133, Name = "Poirot"},
new SceneNameModel
{
SeriesId = 76133,
Name = "Agatha Christies Poirot"
},
new SceneNameModel
{
SeriesId = 70870,
Name =
"The Real World Road Rules Challenge"
},
new SceneNameModel
{
SeriesId = 70870,
Name = "The Challenge Cutthroat"
},
new SceneNameModel
{
SeriesId = 77444,
Name = "This Old House Program"
},
new SceneNameModel
{
SeriesId = 73290,
Name = "60 Minutes US"
},
new SceneNameModel
{SeriesId = 194751, Name = "Conan"},
new SceneNameModel
{
SeriesId = 194751,
Name = "Conan 2010"
},
new SceneNameModel
{
SeriesId = 164451,
Name = "Carlos 2010"
},
new SceneNameModel
{
SeriesId = 70726,
Name = "Babalon 5"
},
new SceneNameModel
{
SeriesId = 70726,
Name = "Babalon5"
},
new SceneNameModel
{SeriesId = 83714, Name = "Genius"},
new SceneNameModel
{
SeriesId = 83714,
Name = "Genius With Dave Gormand"
},
new SceneNameModel
{
SeriesId = 212571,
Name = "Come Fly With Me 2010"
},
new SceneNameModel
{
SeriesId = 81563,
Name = "Border Security"
},
new SceneNameModel
{
SeriesId = 81563,
Name =
"Border Security Australias Frontline"
},
new SceneNameModel
{
SeriesId = 172381,
Name = "Silent Library US"
},
new SceneNameModel
{
SeriesId = 131791,
Name = "Sci-Fi Science"
},
new SceneNameModel
{
SeriesId = 80646,
Name = "Frontline"
},
new SceneNameModel
{
SeriesId = 80646,
Name = "Frontline US"
},
new SceneNameModel
{
SeriesId = 189931,
Name = "RBT AU"
},
new SceneNameModel
{SeriesId = 73255, Name = "House"},
new SceneNameModel
{
SeriesId = 73255,
Name = "House MD"
},
new SceneNameModel
{
SeriesId = 73244,
Name = "The Office"
},
new SceneNameModel
{
SeriesId = 73244,
Name = "The Office US"
},
}; };
public static int FindByName(string cleanSeriesName) public static int FindByName(string cleanSeriesName)
@ -95,6 +326,5 @@ namespace NzbDrone.Core.Helpers
return results; return results;
} }
} }
} }

View File

@ -1,8 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
namespace NzbDrone.Core.Helpers namespace NzbDrone.Core.Helpers
{ {

View File

@ -11,7 +11,8 @@ namespace NzbDrone.Core.Instrumentation
protected override void Write(LogEventInfo logEvent) protected override void Write(LogEventInfo logEvent)
{ {
if (logEvent.Exception == null) if (logEvent.Exception == null)
throw new InvalidOperationException(@"Missing Exception Object.. Please Use Logger.FatalException() or Logger.ErrorException() rather throw new InvalidOperationException(
@"Missing Exception Object.. Please Use Logger.FatalException() or Logger.ErrorException() rather
than Logger.Fatal() and Logger.Error()"); than Logger.Fatal() and Logger.Error()");
if (!Debugger.IsAttached) if (!Debugger.IsAttached)

View File

@ -1,8 +1,8 @@
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using Ninject;
using NLog; using NLog;
using NLog.Config; using NLog.Config;
using Ninject;
namespace NzbDrone.Core.Instrumentation namespace NzbDrone.Core.Instrumentation
{ {
@ -15,7 +15,8 @@ namespace NzbDrone.Core.Instrumentation
LogManager.ThrowExceptions = true; LogManager.ThrowExceptions = true;
} }
LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"), false); LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"),
false);
LogManager.ConfigurationReloaded += ((s, e) => BindCustomLoggers()); LogManager.ConfigurationReloaded += ((s, e) => BindCustomLoggers());
BindCustomLoggers(); BindCustomLoggers();
} }
@ -35,9 +36,5 @@ namespace NzbDrone.Core.Instrumentation
LogManager.Configuration.Reload(); LogManager.Configuration.Reload();
} }
} }
} }

View File

@ -1,13 +1,9 @@
using System; using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog; using NLog;
using SubSonic.Repository; using SubSonic.Repository;
namespace NzbDrone.Core.Instrumentation namespace NzbDrone.Core.Instrumentation
{ {
public class LogProvider public class LogProvider
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

View File

@ -8,6 +8,11 @@ namespace NzbDrone.Core.Instrumentation
{ {
private static readonly Logger Logger = LogManager.GetLogger("NzbDrone.SubSonic"); private static readonly Logger Logger = LogManager.GetLogger("NzbDrone.SubSonic");
public override Encoding Encoding
{
get { return Encoding.Default; }
}
public override void Write(char[] buffer, int index, int count) public override void Write(char[] buffer, int index, int count)
{ {
@ -23,10 +28,5 @@ namespace NzbDrone.Core.Instrumentation
{ {
Logger.Trace(value); Logger.Trace(value);
} }
public override Encoding Encoding
{
get { return Encoding.Default; }
}
} }
} }

View File

@ -1,11 +1,7 @@
using System; using System;
using System.Diagnostics;
using Exceptioneer.WindowsFormsClient;
using NLog; using NLog;
using NLog.Targets; using NLog.Targets;
using SubSonic.Repository; using SubSonic.Repository;
using Ninject;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Instrumentation namespace NzbDrone.Core.Instrumentation
{ {

View File

@ -19,8 +19,8 @@ namespace NzbDrone.Core.Model
public override string ToString() public override string ToString()
{ {
return string.Format("Series:{0} Season:{1} Episode:{2}", SeriesTitle, SeasonNumber, String.Join(",", Episodes)); return string.Format("Series:{0} Season:{1} Episode:{2}", SeriesTitle, SeasonNumber,
} String.Join(",", Episodes));
}
} }
} }

View File

@ -1,8 +1,4 @@
using System; using NzbDrone.Core.Repository;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Model namespace NzbDrone.Core.Model
{ {

View File

@ -1,9 +1,4 @@
using System; namespace NzbDrone.Core.Model
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
{ {
public class EpisodeSortingType public class EpisodeSortingType
{ {

View File

@ -1,9 +1,4 @@
using System; namespace NzbDrone.Core.Model
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
{ {
public enum EpisodeStatusType public enum EpisodeStatusType
{ {

View File

@ -41,10 +41,7 @@ namespace NzbDrone.Core.Model.Notification
/// <value>The percent complete.</value> /// <value>The percent complete.</value>
public int PercentComplete public int PercentComplete
{ {
get get { return Convert.ToInt32(Convert.ToDouble(ProgressValue)/Convert.ToDouble(ProgressMax)*100); }
{
return Convert.ToInt32(Convert.ToDouble(ProgressValue) / Convert.ToDouble(ProgressMax) * 100);
}
} }
/// <summary> /// <summary>
@ -65,6 +62,8 @@ namespace NzbDrone.Core.Model.Notification
/// <value>The status.</value> /// <value>The status.</value>
public ProgressNotificationStatus Status { get; set; } public ProgressNotificationStatus Status { get; set; }
#region IDisposable Members
public void Dispose() public void Dispose()
{ {
if (Status == ProgressNotificationStatus.InProgress) if (Status == ProgressNotificationStatus.InProgress)
@ -73,5 +72,7 @@ namespace NzbDrone.Core.Model.Notification
Status = ProgressNotificationStatus.Failed; Status = ProgressNotificationStatus.Failed;
} }
} }
#endregion
} }
} }

View File

@ -1,9 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.Model namespace NzbDrone.Core.Model
{ {

View File

@ -1,9 +1,4 @@
using System; namespace NzbDrone.Core.Model
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
{ {
public class SceneNameModel public class SceneNameModel
{ {

View File

@ -14,6 +14,5 @@ namespace NzbDrone.Core.Model
{ {
return string.Format("Series:{0} Season:{1}", SeriesTitle, SeasonNumber); return string.Format("Series:{0} Season:{1}", SeriesTitle, SeasonNumber);
} }
} }
} }

View File

@ -1,7 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Model namespace NzbDrone.Core.Model

View File

@ -1,12 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using NLog; using NLog;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core namespace NzbDrone.Core
@ -17,16 +14,25 @@ namespace NzbDrone.Core
private static readonly Regex[] ReportTitleRegex = new[] private static readonly Regex[] ReportTitleRegex = new[]
{ {
new Regex(@"(?<title>.+?)?\W?(?<year>\d+?)?\WS?(?<season>\d+)(?:\-|\.|[a-z])(?<episode>\d+)\W(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled), new Regex(
new Regex(@"(?<title>.+?)?\W?(?<year>\d+?)?\WS?(?<season>\d+)(?<episode>\d{2})\W(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled) //Supports 103/113 naming @"(?<title>.+?)?\W?(?<year>\d+?)?\WS?(?<season>\d+)(?:\-|\.|[a-z])(?<episode>\d+)\W(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
new Regex(
@"(?<title>.+?)?\W?(?<year>\d+?)?\WS?(?<season>\d+)(?<episode>\d{2})\W(?!\\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled)
//Supports 103/113 naming
}; };
private static readonly Regex[] SeasonReportTitleRegex = new[] private static readonly Regex[] SeasonReportTitleRegex = new[]
{ {
new Regex(@"(?<title>.+?)?\W?(?<year>\d{4}?)?\W(?:S|Season)?\W?(?<season>\d+)(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled), new Regex(
@"(?<title>.+?)?\W?(?<year>\d{4}?)?\W(?:S|Season)?\W?(?<season>\d+)(?!\\)",
RegexOptions.IgnoreCase |
RegexOptions.Compiled),
}; };
private static readonly Regex NormalizeRegex = new Regex(@"((\s|^)the(\s|$))|((\s|^)and(\s|$))|[^a-z]", RegexOptions.IgnoreCase | RegexOptions.Compiled); private static readonly Regex NormalizeRegex = new Regex(@"((\s|^)the(\s|$))|((\s|^)and(\s|$))|[^a-z]",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
/// <summary> /// <summary>
/// Parses a post title into list of episodes it contains /// Parses a post title into list of episodes it contains
@ -64,7 +70,6 @@ namespace NzbDrone.Core
foreach (Match matchGroup in match) foreach (Match matchGroup in match)
{ {
parsedEpisode.Episodes.Add(Convert.ToInt32(matchGroup.Groups["episode"].Value)); parsedEpisode.Episodes.Add(Convert.ToInt32(matchGroup.Groups["episode"].Value));
} }
parsedEpisode.Quality = ParseQuality(title); parsedEpisode.Quality = ParseQuality(title);
@ -255,7 +260,5 @@ namespace NzbDrone.Core
return info.FullName.Trim('/', '\\', ' '); return info.FullName.Trim('/', '\\', ' ');
} }
} }
} }

View File

@ -1,7 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
@ -13,6 +10,7 @@ namespace NzbDrone.Core.Providers
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public virtual bool StartSearch(int seriesId) public virtual bool StartSearch(int seriesId)
{ {
throw new NotImplementedException(); throw new NotImplementedException();

View File

@ -5,8 +5,6 @@ namespace NzbDrone.Core.Providers.Core
{ {
public class DiskProvider public class DiskProvider
{ {
#region IDiskProvider Members
public virtual bool FolderExists(string path) public virtual bool FolderExists(string path)
{ {
return Directory.Exists(path); return Directory.Exists(path);
@ -48,7 +46,5 @@ namespace NzbDrone.Core.Providers.Core
{ {
File.Move(sourcePath, destinationPath); File.Move(sourcePath, destinationPath);
} }
#endregion
} }
} }

View File

@ -47,7 +47,6 @@ namespace NzbDrone.Core.Providers.Core
{ {
var webClient = new WebClient(); var webClient = new WebClient();
webClient.DownloadFile(request, filename); webClient.DownloadFile(request, filename);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -55,8 +54,6 @@ namespace NzbDrone.Core.Providers.Core
Logger.TraceException(ex.Message, ex); Logger.TraceException(ex.Message, ex);
throw; throw;
} }
} }
public virtual void DownloadFile(string request, string filename, string username, string password) public virtual void DownloadFile(string request, string filename, string username, string password)

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.RegularExpressions; using System.Linq;
using NLog; using NLog;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
@ -13,13 +12,13 @@ namespace NzbDrone.Core.Providers
{ {
//TODO: Remove parsing of the series name, it should be done in series provider //TODO: Remove parsing of the series name, it should be done in series provider
private readonly IRepository _sonicRepo; private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly SeriesProvider _series;
private readonly SeasonProvider _seasons;
private readonly TvDbProvider _tvDb;
private readonly HistoryProvider _history; private readonly HistoryProvider _history;
private readonly QualityProvider _quality; private readonly QualityProvider _quality;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private readonly SeasonProvider _seasons;
private readonly SeriesProvider _series;
private readonly IRepository _sonicRepo;
private readonly TvDbProvider _tvDb;
public EpisodeProvider(IRepository sonicRepo, SeriesProvider seriesProvider, public EpisodeProvider(IRepository sonicRepo, SeriesProvider seriesProvider,
SeasonProvider seasonProvider, TvDbProvider tvDbProvider, SeasonProvider seasonProvider, TvDbProvider tvDbProvider,
@ -35,7 +34,6 @@ namespace NzbDrone.Core.Providers
public EpisodeProvider() public EpisodeProvider()
{ {
} }
public virtual Episode GetEpisode(long id) public virtual Episode GetEpisode(long id)
@ -45,7 +43,9 @@ namespace NzbDrone.Core.Providers
public virtual Episode GetEpisode(int seriesId, int seasonNumber, int episodeNumber) public virtual Episode GetEpisode(int seriesId, int seasonNumber, int episodeNumber)
{ {
return _sonicRepo.Single<Episode>(c => c.SeriesId == seriesId && c.SeasonNumber == seasonNumber && c.EpisodeNumber == episodeNumber); return
_sonicRepo.Single<Episode>(
c => c.SeriesId == seriesId && c.SeasonNumber == seasonNumber && c.EpisodeNumber == episodeNumber);
} }
public virtual IList<Episode> GetEpisodeBySeries(long seriesId) public virtual IList<Episode> GetEpisodeBySeries(long seriesId)
@ -116,7 +116,6 @@ namespace NzbDrone.Core.Providers
} }
return false; return false;
} }
public virtual void RefreshEpisodeInfo(int seriesId) public virtual void RefreshEpisodeInfo(int seriesId)
@ -145,8 +144,9 @@ namespace NzbDrone.Core.Providers
if (episode.FirstAired < new DateTime(1753, 1, 1)) if (episode.FirstAired < new DateTime(1753, 1, 1))
episode.FirstAired = new DateTime(1753, 1, 1); episode.FirstAired = new DateTime(1753, 1, 1);
Logger.Trace("Updating info for series:{0} - episode:{1}", targetSeries.SeriesName, episode.EpisodeNumber); Logger.Trace("Updating info for series:{0} - episode:{1}", targetSeries.SeriesName,
var newEpisode = new Episode() episode.EpisodeNumber);
var newEpisode = new Episode
{ {
AirDate = episode.FirstAired, AirDate = episode.FirstAired,
EpisodeId = episode.Id, EpisodeId = episode.Id,
@ -172,7 +172,8 @@ namespace NzbDrone.Core.Providers
} }
catch (Exception e) catch (Exception e)
{ {
Logger.FatalException(String.Format("An error has occurred while updating episode info for series {0}", seriesId), e); Logger.FatalException(
String.Format("An error has occurred while updating episode info for series {0}", seriesId), e);
failCount++; failCount++;
} }
} }
@ -180,12 +181,14 @@ namespace NzbDrone.Core.Providers
_sonicRepo.AddMany(newList); _sonicRepo.AddMany(newList);
_sonicRepo.UpdateMany(updateList); _sonicRepo.UpdateMany(updateList);
Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ", targetSeries.SeriesName, successCount, failCount); Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ",
targetSeries.SeriesName, successCount, failCount);
} }
public virtual void RefreshEpisodeInfo(Season season) public virtual void RefreshEpisodeInfo(Season season)
{ {
Logger.Info("Starting episode info refresh for season {0} of series:{1}", season.SeasonNumber, season.SeriesId); Logger.Info("Starting episode info refresh for season {0} of series:{1}", season.SeasonNumber,
season.SeriesId);
int successCount = 0; int successCount = 0;
int failCount = 0; int failCount = 0;
var targetSeries = _tvDb.GetSeries(season.SeriesId, true); var targetSeries = _tvDb.GetSeries(season.SeriesId, true);
@ -204,8 +207,9 @@ namespace NzbDrone.Core.Providers
if (episode.FirstAired < new DateTime(1753, 1, 1)) if (episode.FirstAired < new DateTime(1753, 1, 1))
episode.FirstAired = new DateTime(1753, 1, 1); episode.FirstAired = new DateTime(1753, 1, 1);
Logger.Trace("Updating info for series:{0} - episode:{1}", targetSeries.SeriesName, episode.EpisodeNumber); Logger.Trace("Updating info for series:{0} - episode:{1}", targetSeries.SeriesName,
var newEpisode = new Episode() episode.EpisodeNumber);
var newEpisode = new Episode
{ {
AirDate = episode.FirstAired, AirDate = episode.FirstAired,
EpisodeId = episode.Id, EpisodeId = episode.Id,
@ -231,7 +235,9 @@ namespace NzbDrone.Core.Providers
} }
catch (Exception e) catch (Exception e)
{ {
Logger.FatalException(String.Format("An error has occurred while updating episode info for season {0} of series {1}", season.SeasonNumber, season.SeriesId), e); Logger.FatalException(
String.Format("An error has occurred while updating episode info for season {0} of series {1}",
season.SeasonNumber, season.SeriesId), e);
failCount++; failCount++;
} }
} }
@ -239,7 +245,8 @@ namespace NzbDrone.Core.Providers
_sonicRepo.AddMany(newList); _sonicRepo.AddMany(newList);
_sonicRepo.UpdateMany(updateList); _sonicRepo.UpdateMany(updateList);
Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ", targetSeries.SeriesName, successCount, failCount); Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ",
targetSeries.SeriesName, successCount, failCount);
} }
public virtual void DeleteEpisode(int episodeId) public virtual void DeleteEpisode(int episodeId)
@ -251,6 +258,5 @@ namespace NzbDrone.Core.Providers
{ {
_sonicRepo.Update(episode); _sonicRepo.Update(episode);
} }
} }
} }

View File

@ -1,29 +1,23 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog; using NLog;
using NzbDrone.Core.Helpers; using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
public class ExternalNotificationProvider public class ExternalNotificationProvider
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider; private readonly ConfigProvider _configProvider;
private readonly XbmcProvider _xbmcProvider; private readonly XbmcProvider _xbmcProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public ExternalNotificationProvider(ConfigProvider configProvider, XbmcProvider xbmcProvider) public ExternalNotificationProvider(ConfigProvider configProvider, XbmcProvider xbmcProvider)
{ {
_configProvider = configProvider; _configProvider = configProvider;
_xbmcProvider = xbmcProvider; _xbmcProvider = xbmcProvider;
} }
#region ExternalNotificationProvider Members
public virtual void OnGrab(string message) public virtual void OnGrab(string message)
{ {
var header = "NzbDrone [TV] - Grabbed"; var header = "NzbDrone [TV] - Grabbed";
@ -100,6 +94,5 @@ namespace NzbDrone.Core.Providers
throw new NotImplementedException(); throw new NotImplementedException();
} }
#endregion
} }
} }

View File

@ -4,24 +4,19 @@ using NzbDrone.Core.Model.Notification;
namespace NzbDrone.Core.Providers.Fakes namespace NzbDrone.Core.Providers.Fakes
{ {
class FakeNotificationProvider internal class FakeNotificationProvider
{ {
private readonly Dictionary<Guid, BasicNotification> _basicNotifications = new Dictionary<Guid, BasicNotification>(); private readonly Dictionary<Guid, BasicNotification> _basicNotifications =
private readonly Dictionary<Guid, ProgressNotification> _progressNotification = new Dictionary<Guid, ProgressNotification>(); new Dictionary<Guid, BasicNotification>();
private readonly Object _lock = new object(); private readonly Object _lock = new object();
private readonly Dictionary<Guid, ProgressNotification> _progressNotification =
new Dictionary<Guid, ProgressNotification>();
ProgressNotification fakeNotification = new ProgressNotification("Updating Series");
ProgressNotification fakeNotification2 = new ProgressNotification("Updating Series2");
public void Register(ProgressNotification notification)
{
_progressNotification.Add(notification.Id, notification);
}
public void Register(BasicNotification notification) private readonly ProgressNotification fakeNotification = new ProgressNotification("Updating Series");
{ private readonly ProgressNotification fakeNotification2 = new ProgressNotification("Updating Series2");
_basicNotifications.Add(notification.Id, notification);
}
public List<BasicNotification> BasicNotifications public List<BasicNotification> BasicNotifications
{ {
@ -30,7 +25,6 @@ namespace NzbDrone.Core.Providers.Fakes
public List<ProgressNotification> GetProgressNotifications public List<ProgressNotification> GetProgressNotifications
{ {
get get
{ {
fakeNotification.Status = ProgressNotificationStatus.InProgress; fakeNotification.Status = ProgressNotificationStatus.InProgress;
@ -41,6 +35,16 @@ namespace NzbDrone.Core.Providers.Fakes
} }
} }
public void Register(ProgressNotification notification)
{
_progressNotification.Add(notification.Id, notification);
}
public void Register(BasicNotification notification)
{
_basicNotifications.Add(notification.Id, notification);
}
public void Dismiss(Guid notificationId) public void Dismiss(Guid notificationId)
{ {
lock (_lock) lock (_lock)

View File

@ -1,5 +1,4 @@
using System.ServiceModel.Syndication; using System.ServiceModel.Syndication;
using System.Xml;
using NLog; using NLog;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
@ -8,15 +7,16 @@ namespace NzbDrone.Core.Providers.Feed
{ {
public abstract class FeedProviderBase public abstract class FeedProviderBase
{ {
protected readonly SeriesProvider _seriesProvider;
protected readonly SeasonProvider _seasonProvider;
protected readonly EpisodeProvider _episodeProvider;
protected readonly ConfigProvider _configProvider;
private readonly HttpProvider _httpProvider;
protected static readonly Logger Logger = LogManager.GetCurrentClassLogger(); protected static readonly Logger Logger = LogManager.GetCurrentClassLogger();
protected readonly ConfigProvider _configProvider;
protected readonly EpisodeProvider _episodeProvider;
private readonly HttpProvider _httpProvider;
protected readonly SeasonProvider _seasonProvider;
protected readonly SeriesProvider _seriesProvider;
public FeedProviderBase(SeriesProvider seriesProvider, SeasonProvider seasonProvider, public FeedProviderBase(SeriesProvider seriesProvider, SeasonProvider seasonProvider,
EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider) EpisodeProvider episodeProvider, ConfigProvider configProvider,
HttpProvider httpProvider)
{ {
_seriesProvider = seriesProvider; _seriesProvider = seriesProvider;
_seasonProvider = seasonProvider; _seasonProvider = seasonProvider;
@ -66,11 +66,9 @@ namespace NzbDrone.Core.Providers.Feed
Logger.Debug("Unable to map {0} to any of series in database", episodeParseResult.SeriesTitle); Logger.Debug("Unable to map {0} to any of series in database", episodeParseResult.SeriesTitle);
return null; return null;
} }
/// <summary> /// <summary>
/// Fetches RSS feed and process each news item. /// Fetches RSS feed and process each news item.
/// </summary> /// </summary>
@ -122,5 +120,4 @@ namespace NzbDrone.Core.Providers.Feed
} }
} }
} }
} }

View File

@ -1,15 +1,13 @@
using System; using System.ServiceModel.Syndication;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Syndication;
using System.Text;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers.Feed namespace NzbDrone.Core.Providers.Feed
{ {
class NzbsOrgFeedProvider : FeedProviderBase internal class NzbsOrgFeedProvider : FeedProviderBase
{ {
public NzbsOrgFeedProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider) public NzbsOrgFeedProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider,
EpisodeProvider episodeProvider, ConfigProvider configProvider,
HttpProvider httpProvider)
: base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider) : base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider)
{ {
} }
@ -18,7 +16,11 @@ namespace NzbDrone.Core.Providers.Feed
{ {
get get
{ {
return new[] { string.Format("http://nzbs.org/rss.php?type=1&i={0}&h={1}", _configProvider.NzbsOrgUId, _configProvider.NzbsOrgHash) }; return new[]
{
string.Format("http://nzbs.org/rss.php?type=1&i={0}&h={1}", _configProvider.NzbsOrgUId,
_configProvider.NzbsOrgHash)
};
} }
} }

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using NLog; using NLog;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
@ -11,9 +10,8 @@ namespace NzbDrone.Core.Providers
{ {
public class HistoryProvider public class HistoryProvider
{ {
private readonly IRepository _sonicRepo;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IRepository _sonicRepo;
public HistoryProvider(IRepository sonicRepo) public HistoryProvider(IRepository sonicRepo)
{ {
@ -24,8 +22,6 @@ namespace NzbDrone.Core.Providers
{ {
} }
#region HistoryProvider Members
public virtual List<History> AllItems() public virtual List<History> AllItems()
{ {
return _sonicRepo.All<History>().ToList(); return _sonicRepo.All<History>().ToList();
@ -54,13 +50,11 @@ namespace NzbDrone.Core.Providers
public virtual bool Exists(int episodeId, QualityTypes quality, bool proper) public virtual bool Exists(int episodeId, QualityTypes quality, bool proper)
{ {
//Looks for the existance of this episode in History //Looks for the existance of this episode in History
if (_sonicRepo.Exists<History>(h => h.EpisodeId == episodeId && (QualityTypes)h.Quality == quality && h.IsProper == proper)) if (_sonicRepo.Exists<History>(h => h.EpisodeId == episodeId && h.Quality == quality && h.IsProper == proper))
return true; return true;
Logger.Debug("Episode not in History: {0}", episodeId); Logger.Debug("Episode not in History: {0}", episodeId);
return false; return false;
} }
#endregion
} }
} }

View File

@ -1,21 +1,17 @@
using System; using System.Collections.Generic;
using System.Collections;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using NLog; using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using SubSonic.Repository;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
public class IndexerProvider public class IndexerProvider
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IRepository _sonicRepo;
private readonly ConfigProvider _configProvider; private readonly ConfigProvider _configProvider;
private readonly IRepository _sonicRepo;
public IndexerProvider(IRepository sonicRepo, ConfigProvider configProvider) public IndexerProvider(IRepository sonicRepo, ConfigProvider configProvider)
{ {
@ -23,8 +19,6 @@ namespace NzbDrone.Core.Providers
_configProvider = configProvider; _configProvider = configProvider;
} }
#region IndexerProvider Members
public virtual List<Indexer> AllIndexers() public virtual List<Indexer> AllIndexers()
{ {
return _sonicRepo.All<Indexer>().OrderBy(i => i.Order).ToList(); return _sonicRepo.All<Indexer>().OrderBy(i => i.Order).ToList();
@ -44,7 +38,5 @@ namespace NzbDrone.Core.Providers
{ {
return _sonicRepo.Single<Indexer>(indexerId); return _sonicRepo.Single<Indexer>(indexerId);
} }
#endregion
} }
} }

View File

@ -2,10 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using NLog; using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using SubSonic.Repository; using SubSonic.Repository;
@ -14,25 +11,22 @@ namespace NzbDrone.Core.Providers
{ {
public class MediaFileProvider public class MediaFileProvider
{ {
private readonly IRepository _repository;
private readonly ConfigProvider _configProvider;
private readonly DiskProvider _diskProvider;
private readonly EpisodeProvider _episodeProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static readonly string[] MediaExtentions = new[] { "*.mkv", "*.avi", "*.wmv" }; private static readonly string[] MediaExtentions = new[] { "*.mkv", "*.avi", "*.wmv" };
private readonly DiskProvider _diskProvider;
private readonly EpisodeProvider _episodeProvider;
private readonly IRepository _repository;
public MediaFileProvider(IRepository repository, ConfigProvider configProvider, DiskProvider diskProvider, EpisodeProvider episodeProvider) public MediaFileProvider(IRepository repository, DiskProvider diskProvider,
EpisodeProvider episodeProvider)
{ {
_repository = repository; _repository = repository;
_configProvider = configProvider;
_diskProvider = diskProvider; _diskProvider = diskProvider;
_episodeProvider = episodeProvider; _episodeProvider = episodeProvider;
} }
public MediaFileProvider() public MediaFileProvider()
{ {
} }
/// <summary> /// <summary>
@ -84,7 +78,8 @@ namespace NzbDrone.Core.Providers
foreach (var episodeNumber in episodesInFile.Episodes) foreach (var episodeNumber in episodesInFile.Episodes)
{ {
var episode = _episodeProvider.GetEpisode(series.SeriesId, episodesInFile.SeasonNumber, episodeNumber); var episode = _episodeProvider.GetEpisode(series.SeriesId, episodesInFile.SeasonNumber,
episodeNumber);
if (episode != null) if (episode != null)
{ {
@ -92,7 +87,8 @@ namespace NzbDrone.Core.Providers
} }
else else
Logger.Warn("Unable to find Series:{0} Season:{1} Episode:{2} in the database. File:{3}", series.Title, episodesInFile.SeasonNumber, episodeNumber, filePath); Logger.Warn("Unable to find Series:{0} Season:{1} Episode:{2} in the database. File:{3}",
series.Title, episodesInFile.SeasonNumber, episodeNumber, filePath);
} }
//Return null if no Episodes exist in the DB for the parsed episodes from file //Return null if no Episodes exist in the DB for the parsed episodes from file
@ -125,7 +121,8 @@ namespace NzbDrone.Core.Providers
_episodeProvider.UpdateEpisode(ep); _episodeProvider.UpdateEpisode(ep);
episodeList += String.Format(", {0}", ep.EpisodeId).Trim(' ', ','); episodeList += String.Format(", {0}", ep.EpisodeId).Trim(' ', ',');
} }
Logger.Trace("File {0}:{1} attached to episode(s): '{2}'", episodeFile.EpisodeFileId, filePath, episodeList); Logger.Trace("File {0}:{1} attached to episode(s): '{2}'", episodeFile.EpisodeFileId, filePath,
episodeList);
return episodeFile; return episodeFile;
} }

View File

@ -1,25 +1,19 @@
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Model.Notification;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
public class NotificationProvider public class NotificationProvider
{ {
private readonly Dictionary<Guid, BasicNotification> _basicNotifications = new Dictionary<Guid, BasicNotification>(); private readonly Dictionary<Guid, BasicNotification> _basicNotifications =
private Dictionary<Guid, ProgressNotification> _progressNotification = new Dictionary<Guid, ProgressNotification>(); new Dictionary<Guid, BasicNotification>();
private readonly Object _lock = new object(); private readonly Object _lock = new object();
public virtual void Register(ProgressNotification notification) private readonly Dictionary<Guid, ProgressNotification> _progressNotification =
{ new Dictionary<Guid, ProgressNotification>();
_progressNotification.Add(notification.Id, notification);
}
public virtual void Register(BasicNotification notification)
{
_basicNotifications.Add(notification.Id, notification);
}
public virtual List<BasicNotification> BasicNotifications public virtual List<BasicNotification> BasicNotifications
{ {
@ -30,10 +24,22 @@ namespace NzbDrone.Core.Providers
{ {
get get
{ {
return new List<ProgressNotification>(_progressNotification.Values.Where(p => p.Status == ProgressNotificationStatus.InProgress)); return
new List<ProgressNotification>(
_progressNotification.Values.Where(p => p.Status == ProgressNotificationStatus.InProgress));
} }
} }
public virtual void Register(ProgressNotification notification)
{
_progressNotification.Add(notification.Id, notification);
}
public virtual void Register(BasicNotification notification)
{
_basicNotifications.Add(notification.Id, notification);
}
public virtual void Dismiss(Guid notificationId) public virtual void Dismiss(Guid notificationId)
{ {
lock (_lock) lock (_lock)

View File

@ -1,19 +1,10 @@
using System; namespace NzbDrone.Core.Providers
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers
{ {
public class PostProcessingProvider public class PostProcessingProvider
{ {
private readonly SeriesProvider _seriesProvider;
private readonly MediaFileProvider _mediaFileProvider; private readonly MediaFileProvider _mediaFileProvider;
private readonly RenameProvider _renameProvider; private readonly RenameProvider _renameProvider;
private readonly SeriesProvider _seriesProvider;
public PostProcessingProvider(SeriesProvider seriesProvider, public PostProcessingProvider(SeriesProvider seriesProvider,
MediaFileProvider mediaFileProvider, RenameProvider renameProvider) MediaFileProvider mediaFileProvider, RenameProvider renameProvider)
@ -23,8 +14,6 @@ namespace NzbDrone.Core.Providers
_renameProvider = renameProvider; _renameProvider = renameProvider;
} }
#region PostProcessingProvider Members
public virtual void ProcessEpisode(string dir, string nzbName) public virtual void ProcessEpisode(string dir, string nzbName)
{ {
var parsedSeries = Parser.ParseSeriesName(nzbName); var parsedSeries = Parser.ParseSeriesName(nzbName);
@ -42,7 +31,5 @@ namespace NzbDrone.Core.Providers
_renameProvider.RenameEpisodeFile(file.EpisodeFileId, true); _renameProvider.RenameEpisodeFile(file.EpisodeFileId, true);
} }
} }
#endregion
} }
} }

View File

@ -1,8 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text;
using NLog; using NLog;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
using SubSonic.Repository; using SubSonic.Repository;
@ -11,12 +9,11 @@ namespace NzbDrone.Core.Providers
{ {
public class QualityProvider public class QualityProvider
{ {
private IRepository _sonicRepo;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IRepository _sonicRepo;
public QualityProvider() public QualityProvider()
{ {
} }
public QualityProvider(IRepository sonicRepo) public QualityProvider(IRepository sonicRepo)
@ -24,8 +21,6 @@ namespace NzbDrone.Core.Providers
_sonicRepo = sonicRepo; _sonicRepo = sonicRepo;
} }
#region IQualityProvider Members
public virtual void Add(QualityProfile profile) public virtual void Add(QualityProfile profile)
{ {
_sonicRepo.Add(profile); _sonicRepo.Add(profile);
@ -58,7 +53,5 @@ namespace NzbDrone.Core.Providers
{ {
return _sonicRepo.Single<QualityProfile>(q => q.QualityProfileId == profileId); return _sonicRepo.Single<QualityProfile>(q => q.QualityProfileId == profileId);
} }
#endregion
} }
} }

View File

@ -2,30 +2,27 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading; using System.Threading;
using NLog; using NLog;
using NzbDrone.Core.Helpers; using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
public class RenameProvider public class RenameProvider
{ {
private readonly SeriesProvider _seriesProvider; private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly SeasonProvider _seasonProvider;
private readonly EpisodeProvider _episodeProvider;
private readonly MediaFileProvider _mediaFileProvider;
private readonly DiskProvider _diskProvider;
private readonly ConfigProvider _configProvider; private readonly ConfigProvider _configProvider;
private readonly DiskProvider _diskProvider;
private readonly EpisodeProvider _episodeProvider;
private readonly List<EpisodeRenameModel> _epsToRename = new List<EpisodeRenameModel>();
private readonly ExternalNotificationProvider _externalNotificationProvider; private readonly ExternalNotificationProvider _externalNotificationProvider;
private readonly MediaFileProvider _mediaFileProvider;
private readonly SeasonProvider _seasonProvider;
private readonly SeriesProvider _seriesProvider;
private Thread _renameThread; private Thread _renameThread;
private List<EpisodeRenameModel> _epsToRename = new List<EpisodeRenameModel>();
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public RenameProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, public RenameProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider,
EpisodeProvider episodeProvider, MediaFileProvider mediaFileProvider, EpisodeProvider episodeProvider, MediaFileProvider mediaFileProvider,
@ -41,7 +38,6 @@ namespace NzbDrone.Core.Providers
_externalNotificationProvider = extenalNotificationProvider; _externalNotificationProvider = extenalNotificationProvider;
} }
#region RenameProvider Members
public virtual void RenameAll() public virtual void RenameAll()
{ {
//Get a list of all episode files/episodes and rename them //Get a list of all episode files/episodes and rename them
@ -49,12 +45,14 @@ namespace NzbDrone.Core.Providers
foreach (var episodeFile in _mediaFileProvider.GetEpisodeFiles()) foreach (var episodeFile in _mediaFileProvider.GetEpisodeFiles())
{ {
var series = _seriesProvider.GetSeries(episodeFile.SeriesId); var series = _seriesProvider.GetSeries(episodeFile.SeriesId);
var erm = new EpisodeRenameModel(); var erm = new EpisodeRenameModel {SeriesName = series.Title, Folder = series.Path};
erm.SeriesName = series.Title;
erm.Folder = series.Path;
if (series.SeasonFolder) if (series.SeasonFolder)
erm.Folder += Path.DirectorySeparatorChar + EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber, _configProvider.GetValue("Sorting_SeasonFolderFormat", "Season %s", true)); erm.Folder += Path.DirectorySeparatorChar +
EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber,
_configProvider.GetValue(
"Sorting_SeasonFolderFormat", "Season %s",
true));
erm.EpisodeFile = episodeFile; erm.EpisodeFile = episodeFile;
_epsToRename.Add(erm); _epsToRename.Add(erm);
@ -70,13 +68,14 @@ namespace NzbDrone.Core.Providers
foreach (var episodeFile in _mediaFileProvider.GetEpisodeFiles().Where(s => s.SeriesId == seriesId)) foreach (var episodeFile in _mediaFileProvider.GetEpisodeFiles().Where(s => s.SeriesId == seriesId))
{ {
var erm = new EpisodeRenameModel(); var erm = new EpisodeRenameModel {SeriesName = series.Title, Folder = series.Path};
erm.SeriesName = series.Title;
erm.Folder = series.Path;
if (series.SeasonFolder) if (series.SeasonFolder)
erm.Folder += Path.DirectorySeparatorChar + EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber, _configProvider.GetValue("Sorting_SeasonFolderFormat", "Season %s", true)); erm.Folder += Path.DirectorySeparatorChar +
EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber,
_configProvider.GetValue(
"Sorting_SeasonFolderFormat", "Season %s",
true));
erm.EpisodeFile = episodeFile; erm.EpisodeFile = episodeFile;
_epsToRename.Add(erm); _epsToRename.Add(erm);
@ -90,15 +89,17 @@ namespace NzbDrone.Core.Providers
var season = _seasonProvider.GetSeason(seasonId); var season = _seasonProvider.GetSeason(seasonId);
var series = _seriesProvider.GetSeries(season.SeriesId); var series = _seriesProvider.GetSeries(season.SeriesId);
foreach (var episodeFile in _mediaFileProvider.GetEpisodeFiles().Where(s => s.Episodes[0].SeasonId == seasonId)) foreach (
var episodeFile in _mediaFileProvider.GetEpisodeFiles().Where(s => s.Episodes[0].SeasonId == seasonId))
{ {
var erm = new EpisodeRenameModel(); var erm = new EpisodeRenameModel {SeriesName = series.Title, Folder = series.Path};
erm.SeriesName = series.Title;
erm.Folder = series.Path;
if (series.SeasonFolder) if (series.SeasonFolder)
erm.Folder += Path.DirectorySeparatorChar + EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber, _configProvider.GetValue("Sorting_SeasonFolderFormat", "Season %s", true)); erm.Folder += Path.DirectorySeparatorChar +
EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber,
_configProvider.GetValue(
"Sorting_SeasonFolderFormat", "Season %s",
true));
erm.EpisodeFile = episodeFile; erm.EpisodeFile = episodeFile;
_epsToRename.Add(erm); _epsToRename.Add(erm);
@ -112,15 +113,16 @@ namespace NzbDrone.Core.Providers
var episode = _episodeProvider.GetEpisode(episodeId); var episode = _episodeProvider.GetEpisode(episodeId);
var series = _seriesProvider.GetSeries(episode.SeriesId); var series = _seriesProvider.GetSeries(episode.SeriesId);
var episodeFile = _mediaFileProvider.GetEpisodeFiles().Where(s => s.Episodes.Contains(episode)).FirstOrDefault(); var episodeFile =
_mediaFileProvider.GetEpisodeFiles().Where(s => s.Episodes.Contains(episode)).FirstOrDefault();
var erm = new EpisodeRenameModel(); var erm = new EpisodeRenameModel {SeriesName = series.Title, Folder = series.Path};
erm.SeriesName = series.Title;
erm.Folder = series.Path;
if (series.SeasonFolder) if (series.SeasonFolder)
erm.Folder += Path.DirectorySeparatorChar + EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber, _configProvider.GetValue("Sorting_SeasonFolderFormat", "Season %s", true)); erm.Folder += Path.DirectorySeparatorChar +
EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber,
_configProvider.GetValue(
"Sorting_SeasonFolderFormat", "Season %s", true));
erm.EpisodeFile = episodeFile; erm.EpisodeFile = episodeFile;
_epsToRename.Add(erm); _epsToRename.Add(erm);
@ -133,21 +135,19 @@ namespace NzbDrone.Core.Providers
var episodeFile = _mediaFileProvider.GetEpisodeFile(episodeFileId); var episodeFile = _mediaFileProvider.GetEpisodeFile(episodeFileId);
var series = _seriesProvider.GetSeries(episodeFile.Series.SeriesId); var series = _seriesProvider.GetSeries(episodeFile.Series.SeriesId);
var erm = new EpisodeRenameModel(); var erm = new EpisodeRenameModel {SeriesName = series.Title, Folder = series.Path};
erm.SeriesName = series.Title;
erm.Folder = series.Path;
if (series.SeasonFolder) if (series.SeasonFolder)
erm.Folder += Path.DirectorySeparatorChar + EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber, _configProvider.GetValue("Sorting_SeasonFolderFormat", "Season %s", true)); erm.Folder += Path.DirectorySeparatorChar +
EpisodeRenameHelper.GetSeasonFolder(episodeFile.Episodes[0].SeasonNumber,
_configProvider.GetValue(
"Sorting_SeasonFolderFormat", "Season %s", true));
erm.EpisodeFile = episodeFile; erm.EpisodeFile = episodeFile;
_epsToRename.Add(erm); _epsToRename.Add(erm);
StartRename(); StartRename();
} }
#endregion
private void StartRename() private void StartRename()
{ {
Logger.Debug("Episode Rename Starting"); Logger.Debug("Episode Rename Starting");
@ -203,7 +203,6 @@ namespace NzbDrone.Core.Providers
else else
_externalNotificationProvider.OnRename(erm); _externalNotificationProvider.OnRename(erm);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -1,7 +1,5 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using SubSonic.Repository; using SubSonic.Repository;

View File

@ -1,15 +1,9 @@
using System; namespace NzbDrone.Core.Providers
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Providers
{ {
public class RssSyncProvider public class RssSyncProvider
{ {
public virtual void Begin() public virtual void Begin()
{ {
} }
} }
} }

View File

@ -9,19 +9,16 @@ namespace NzbDrone.Core.Providers
{ {
public class SabProvider public class SabProvider
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _config; private readonly ConfigProvider _config;
private readonly HttpProvider _http; private readonly HttpProvider _http;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public SabProvider(ConfigProvider config, HttpProvider http) public SabProvider(ConfigProvider config, HttpProvider http)
{ {
_config = config; _config = config;
_http = http; _http = http;
} }
#region IDownloadProvider Members
public virtual bool AddByUrl(string url, string title) public virtual bool AddByUrl(string url, string title)
{ {
const string mode = "addurl"; const string mode = "addurl";
@ -31,7 +28,8 @@ namespace NzbDrone.Core.Providers
string name = url.Replace("&", "%26"); string name = url.Replace("&", "%26");
string nzbName = HttpUtility.UrlEncode(title); string nzbName = HttpUtility.UrlEncode(title);
string action = string.Format("mode={0}&name={1}&priority={2}&cat={3}&nzbname={4}", mode, name, priority, cat, nzbName); string action = string.Format("mode={0}&name={1}&priority={2}&cat={3}&nzbname={4}", mode, name, priority,
cat, nzbName);
string request = GetSabRequest(action); string request = GetSabRequest(action);
Logger.Debug("Adding report [{0}] to the queue.", nzbName); Logger.Debug("Adding report [{0}] to the queue.", nzbName);
@ -61,7 +59,10 @@ namespace NzbDrone.Core.Providers
return false; return false;
//Get the Count of Items in Queue where 'filename' is Equal to goodName, if not zero, return true (isInQueue))) //Get the Count of Items in Queue where 'filename' is Equal to goodName, if not zero, return true (isInQueue)))
if ((xDoc.Descendants("slot").Where(s => s.Element("filename").Value.Equals(title, StringComparison.InvariantCultureIgnoreCase))).Count() != 0) if (
(xDoc.Descendants("slot").Where(
s => s.Element("filename").Value.Equals(title, StringComparison.InvariantCultureIgnoreCase))).Count() !=
0)
{ {
Logger.Debug("Episode in queue - '{0}'", title); Logger.Debug("Episode in queue - '{0}'", title);
@ -81,7 +82,8 @@ namespace NzbDrone.Core.Providers
string priority = _config.GetValue("SabTvPriority", String.Empty, false); string priority = _config.GetValue("SabTvPriority", String.Empty, false);
string nzbName = HttpUtility.UrlEncode(title); string nzbName = HttpUtility.UrlEncode(title);
string action = string.Format("mode={0}&name={1}&priority={2}&cat={3}&nzbname={4}", mode, id, priority, cat, nzbName); string action = string.Format("mode={0}&name={1}&priority={2}&cat={3}&nzbname={4}", mode, id, priority, cat,
nzbName);
string request = GetSabRequest(action); string request = GetSabRequest(action);
Logger.Debug("Adding report [{0}] to the queue.", nzbName); Logger.Debug("Adding report [{0}] to the queue.", nzbName);
@ -95,16 +97,17 @@ namespace NzbDrone.Core.Providers
return false; return false;
} }
#endregion
private string GetSabRequest(string action) private string GetSabRequest(string action)
{ {
string sabnzbdInfo = _config.GetValue("SabHost", String.Empty, false) + ":" + _config.GetValue("SabPort", String.Empty, false); string sabnzbdInfo = _config.GetValue("SabHost", String.Empty, false) + ":" +
_config.GetValue("SabPort", String.Empty, false);
string username = _config.GetValue("SabUsername", String.Empty, false); string username = _config.GetValue("SabUsername", String.Empty, false);
string password = _config.GetValue("SabPassword", String.Empty, false); string password = _config.GetValue("SabPassword", String.Empty, false);
string apiKey = _config.GetValue("SabApiKey", String.Empty, false); string apiKey = _config.GetValue("SabApiKey", String.Empty, false);
return string.Format(@"http://{0}/api?$Action&apikey={1}&ma_username={2}&ma_password={3}", sabnzbdInfo, apiKey, username, password).Replace("$Action", action); return
string.Format(@"http://{0}/api?$Action&apikey={1}&ma_username={2}&ma_password={3}", sabnzbdInfo, apiKey,
username, password).Replace("$Action", action);
} }
} }
} }

View File

@ -1,29 +1,24 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using NLog; using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using SubSonic.Repository; using SubSonic.Repository;
using System.Linq;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
public class SeasonProvider public class SeasonProvider
{ {
private readonly IRepository _sonicRepo;
private readonly SeriesProvider _seriesProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IRepository _sonicRepo;
public SeasonProvider(IRepository dataRepository, SeriesProvider seriesProvider) public SeasonProvider(IRepository dataRepository)
{ {
_sonicRepo = dataRepository; _sonicRepo = dataRepository;
_seriesProvider = seriesProvider;
} }
public SeasonProvider() public SeasonProvider()
{ {
} }
public virtual Season GetSeason(int seasonId) public virtual Season GetSeason(int seasonId)
@ -51,16 +46,17 @@ namespace NzbDrone.Core.Providers
if (_sonicRepo.Exists<Season>(s => s.SeasonId == seasonId)) if (_sonicRepo.Exists<Season>(s => s.SeasonId == seasonId))
return; return;
//TODO: Calculate Season Folder //TODO: Calculate Season Folder
Logger.Trace("Adding Season To DB. [SeriesID:{0} SeasonID:{1} SeasonNumber:{2}]", seriesId, seasonId, seasonNumber, "????"); Logger.Trace("Adding Season To DB. [SeriesID:{0} SeasonID:{1} SeasonNumber:{2}]", seriesId, seasonId,
seasonNumber, "????");
var newSeason = new Season() var newSeason = new Season
{ {
Monitored = true, Monitored = true,
SeasonId = seasonId, SeasonId = seasonId,
SeasonNumber = seasonNumber, SeasonNumber = seasonNumber,
SeriesId = seriesId SeriesId = seriesId
}; };
_sonicRepo.Add<Season>(newSeason); _sonicRepo.Add(newSeason);
} }
public virtual int SaveSeason(Season season) public virtual int SaveSeason(Season season)

View File

@ -1,9 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions;
using Ninject;
using NLog; using NLog;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
@ -19,11 +16,11 @@ namespace NzbDrone.Core.Providers
//Trims all white spaces and separators from the end of the title. //Trims all white spaces and separators from the end of the title.
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _config; private readonly ConfigProvider _config;
private readonly QualityProvider _quality;
private readonly IRepository _sonioRepo; private readonly IRepository _sonioRepo;
private readonly TvDbProvider _tvDb; private readonly TvDbProvider _tvDb;
private readonly QualityProvider _quality;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public SeriesProvider(ConfigProvider configProvider, public SeriesProvider(ConfigProvider configProvider,
IRepository dataRepository, TvDbProvider tvDbProvider, QualityProvider quality) IRepository dataRepository, TvDbProvider tvDbProvider, QualityProvider quality)
@ -38,8 +35,6 @@ namespace NzbDrone.Core.Providers
{ {
} }
#region SeriesProvider Members
public virtual IQueryable<Series> GetAllSeries() public virtual IQueryable<Series> GetAllSeries()
{ {
return _sonioRepo.All<Series>(); return _sonioRepo.All<Series>();
@ -149,7 +144,6 @@ namespace NzbDrone.Core.Providers
_sonioRepo.Delete<Series>(seriesId); _sonioRepo.Delete<Series>(seriesId);
Logger.Info("Successfully deleted Series [{0}]", seriesId); Logger.Info("Successfully deleted Series [{0}]", seriesId);
} }
catch (Exception e) catch (Exception e)
{ {
@ -165,8 +159,5 @@ namespace NzbDrone.Core.Providers
return false; return false;
} }
#endregion
} }
} }

View File

@ -1,11 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using NLog; using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
@ -13,17 +11,16 @@ namespace NzbDrone.Core.Providers
{ {
public class SyncProvider public class SyncProvider
{ {
private readonly SeriesProvider _seriesProvider; private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly DiskProvider _diskProvider;
private readonly EpisodeProvider _episodeProvider; private readonly EpisodeProvider _episodeProvider;
private readonly MediaFileProvider _mediaFileProvider; private readonly MediaFileProvider _mediaFileProvider;
private readonly NotificationProvider _notificationProvider; private readonly NotificationProvider _notificationProvider;
private readonly DiskProvider _diskProvider; private readonly SeriesProvider _seriesProvider;
private ProgressNotification _seriesSyncNotification; private ProgressNotification _seriesSyncNotification;
private Thread _seriesSyncThread; private Thread _seriesSyncThread;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public SyncProvider(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, public SyncProvider(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
MediaFileProvider mediaFileProvider, NotificationProvider notificationProvider, MediaFileProvider mediaFileProvider, NotificationProvider notificationProvider,
DiskProvider diskProvider) DiskProvider diskProvider)
@ -35,8 +32,6 @@ namespace NzbDrone.Core.Providers
_diskProvider = diskProvider; _diskProvider = diskProvider;
} }
#region ISyncProvider Members
public List<String> GetUnmappedFolders(string path) public List<String> GetUnmappedFolders(string path)
{ {
Logger.Debug("Generating list of unmapped folders"); Logger.Debug("Generating list of unmapped folders");
@ -64,8 +59,6 @@ namespace NzbDrone.Core.Providers
return results; return results;
} }
#endregion
public bool BeginUpdateNewSeries() public bool BeginUpdateNewSeries()
{ {
Logger.Debug("User has requested a scan of new series"); Logger.Debug("User has requested a scan of new series");
@ -120,8 +113,6 @@ namespace NzbDrone.Core.Providers
private void ScanSeries() private void ScanSeries()
{ {
var syncList = _seriesProvider.GetAllSeries().Where(s => s.LastInfoSync == null).ToList(); var syncList = _seriesProvider.GetAllSeries().Where(s => s.LastInfoSync == null).ToList();
if (syncList.Count == 0) return; if (syncList.Count == 0) return;
@ -131,13 +122,16 @@ namespace NzbDrone.Core.Providers
{ {
try try
{ {
_seriesSyncNotification.CurrentStatus = String.Format("Searching For: {0}", new DirectoryInfo(currentSeries.Path).Name); _seriesSyncNotification.CurrentStatus = String.Format("Searching For: {0}",
new DirectoryInfo(currentSeries.Path).Name);
var updatedSeries = _seriesProvider.UpdateSeriesInfo(currentSeries.SeriesId); var updatedSeries = _seriesProvider.UpdateSeriesInfo(currentSeries.SeriesId);
_seriesSyncNotification.CurrentStatus = String.Format("Downloading episode info For: {0}", updatedSeries.Title); _seriesSyncNotification.CurrentStatus = String.Format("Downloading episode info For: {0}",
updatedSeries.Title);
_episodeProvider.RefreshEpisodeInfo(updatedSeries.SeriesId); _episodeProvider.RefreshEpisodeInfo(updatedSeries.SeriesId);
_seriesSyncNotification.CurrentStatus = String.Format("Scanning series folder {0}", updatedSeries.Path); _seriesSyncNotification.CurrentStatus = String.Format("Scanning series folder {0}",
updatedSeries.Path);
_mediaFileProvider.Scan(_seriesProvider.GetSeries(updatedSeries.SeriesId)); _mediaFileProvider.Scan(_seriesProvider.GetSeries(updatedSeries.SeriesId));
//Todo: Launch Backlog search for this series _backlogProvider.StartSearch(mappedSeries.Id); //Todo: Launch Backlog search for this series _backlogProvider.StartSearch(mappedSeries.Id);

View File

@ -1,27 +1,25 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers; using System.Timers;
using NLog; using NLog;
using NzbDrone.Core.Model.Notification;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
public class TimerProvider public class TimerProvider
{ {
private readonly RssSyncProvider _rssSyncProvider; private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly SeriesProvider _seriesProvider;
private readonly SeasonProvider _seasonProvider;
private readonly EpisodeProvider _episodeProvider; private readonly EpisodeProvider _episodeProvider;
private readonly MediaFileProvider _mediaFileProvider; private readonly MediaFileProvider _mediaFileProvider;
private Timer _rssSyncTimer; private readonly Timer _minuteTimer;
private Timer _minuteTimer; private readonly RssSyncProvider _rssSyncProvider;
private readonly Timer _rssSyncTimer;
private readonly SeasonProvider _seasonProvider;
private readonly SeriesProvider _seriesProvider;
private DateTime _rssSyncNextInterval; private DateTime _rssSyncNextInterval;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public TimerProvider(RssSyncProvider rssSyncProvider, SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, MediaFileProvider mediaFileProvider) public TimerProvider(RssSyncProvider rssSyncProvider, SeriesProvider seriesProvider,
SeasonProvider seasonProvider, EpisodeProvider episodeProvider,
MediaFileProvider mediaFileProvider)
{ {
_rssSyncProvider = rssSyncProvider; _rssSyncProvider = rssSyncProvider;
_seriesProvider = seriesProvider; _seriesProvider = seriesProvider;
@ -33,8 +31,6 @@ namespace NzbDrone.Core.Providers
_minuteTimer = new Timer(60000); _minuteTimer = new Timer(60000);
} }
#region TimerProvider Members
public virtual void ResetRssSyncTimer() public virtual void ResetRssSyncTimer()
{ {
double interval = _rssSyncTimer.Interval; double interval = _rssSyncTimer.Interval;
@ -43,13 +39,14 @@ namespace NzbDrone.Core.Providers
public virtual void StartRssSyncTimer() public virtual void StartRssSyncTimer()
{ {
if (_rssSyncTimer.Interval < 900000) //If Timer is less than 15 minutes, throw an error! This should also be handled when saving the config, though a user could by-pass it by editing the DB directly... TNO (Trust No One) if (_rssSyncTimer.Interval < 900000)
//If Timer is less than 15 minutes, throw an error! This should also be handled when saving the config, though a user could by-pass it by editing the DB directly... TNO (Trust No One)
{ {
Logger.Error("RSS Sync Frequency is invalid, please set the interval first"); Logger.Error("RSS Sync Frequency is invalid, please set the interval first");
throw new InvalidOperationException("RSS Sync Frequency Invalid"); throw new InvalidOperationException("RSS Sync Frequency Invalid");
} }
_rssSyncTimer.Elapsed += new ElapsedEventHandler(RunRssSync); _rssSyncTimer.Elapsed += RunRssSync;
_rssSyncTimer.Start(); _rssSyncTimer.Start();
_rssSyncNextInterval = DateTime.Now.AddMilliseconds(_rssSyncTimer.Interval); _rssSyncNextInterval = DateTime.Now.AddMilliseconds(_rssSyncTimer.Interval);
} }
@ -77,7 +74,7 @@ namespace NzbDrone.Core.Providers
public virtual void StartMinuteTimer() public virtual void StartMinuteTimer()
{ {
_minuteTimer.Elapsed += new ElapsedEventHandler(MinuteTimer_Elapsed); _minuteTimer.Elapsed += MinuteTimer_Elapsed;
_minuteTimer.Start(); _minuteTimer.Start();
} }
@ -86,8 +83,6 @@ namespace NzbDrone.Core.Providers
_minuteTimer.Stop(); _minuteTimer.Stop();
} }
#endregion
private void RunRssSync(object obj, ElapsedEventArgs args) private void RunRssSync(object obj, ElapsedEventArgs args)
{ {
_rssSyncNextInterval = DateTime.Now.AddMilliseconds(_rssSyncTimer.Interval); _rssSyncNextInterval = DateTime.Now.AddMilliseconds(_rssSyncTimer.Interval);

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using NLog; using NLog;
using TvdbLib; using TvdbLib;
@ -11,10 +10,12 @@ namespace NzbDrone.Core.Providers
{ {
public class TvDbProvider public class TvDbProvider
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static readonly Regex CleanUpRegex = new Regex(@"((\s|^)the(\s|$))|((\s|^)and(\s|$))|[^a-z]", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private const string TVDB_APIKEY = "5D2D188E86E07F4F"; private const string TVDB_APIKEY = "5D2D188E86E07F4F";
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static readonly Regex CleanUpRegex = new Regex(@"((\s|^)the(\s|$))|((\s|^)and(\s|$))|[^a-z]",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
private readonly TvdbHandler _handler; private readonly TvdbHandler _handler;
public TvDbProvider() public TvDbProvider()
@ -22,8 +23,6 @@ namespace NzbDrone.Core.Providers
_handler = new TvdbHandler(new XmlCacheProvider(CentralDispatch.AppPath + @"\cache\tvdb"), TVDB_APIKEY); _handler = new TvdbHandler(new XmlCacheProvider(CentralDispatch.AppPath + @"\cache\tvdb"), TVDB_APIKEY);
} }
#region TvDbProvider Members
public virtual IList<TvdbSearchResult> SearchSeries(string title) public virtual IList<TvdbSearchResult> SearchSeries(string title)
{ {
Logger.Debug("Searching TVDB for '{0}'", title); Logger.Debug("Searching TVDB for '{0}'", title);
@ -85,8 +84,6 @@ namespace NzbDrone.Core.Providers
/// </returns> /// </returns>
public static bool IsTitleMatch(string directoryName, string tvdbTitle) public static bool IsTitleMatch(string directoryName, string tvdbTitle)
{ {
var result = false; var result = false;
if (String.IsNullOrEmpty(directoryName)) if (String.IsNullOrEmpty(directoryName))
@ -98,14 +95,13 @@ namespace NzbDrone.Core.Providers
{ {
result = true; result = true;
} }
else if (String.Equals(CleanUpRegex.Replace(directoryName, ""), CleanUpRegex.Replace(tvdbTitle, ""), StringComparison.InvariantCultureIgnoreCase)) else if (String.Equals(CleanUpRegex.Replace(directoryName, ""), CleanUpRegex.Replace(tvdbTitle, ""),
StringComparison.InvariantCultureIgnoreCase))
result = true; result = true;
Logger.Debug("Match between '{0}' and '{1}' was {2}", tvdbTitle, directoryName, result); Logger.Debug("Match between '{0}' and '{1}' was {2}", tvdbTitle, directoryName, result);
return result; return result;
} }
#endregion
} }
} }

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using SubSonic.Repository; using SubSonic.Repository;
@ -10,18 +9,18 @@ namespace NzbDrone.Core.Providers
{ {
public class UpcomingEpisodesProvider public class UpcomingEpisodesProvider
{ {
private IRepository _sonicRepo; private readonly IRepository _sonicRepo;
public UpcomingEpisodesProvider(IRepository sonicRepo) public UpcomingEpisodesProvider(IRepository sonicRepo)
{ {
_sonicRepo = sonicRepo; _sonicRepo = sonicRepo;
} }
#region UpcomingEpisodesProvider Members
public virtual UpcomingEpisodesModel Upcoming() public virtual UpcomingEpisodesModel Upcoming()
{ {
var allEps = _sonicRepo.All<Episode>().Where(e => e.AirDate >= DateTime.Today.AddDays(-1) && e.AirDate < DateTime.Today.AddDays(8)); var allEps =
_sonicRepo.All<Episode>().Where(
e => e.AirDate >= DateTime.Today.AddDays(-1) && e.AirDate < DateTime.Today.AddDays(8));
var yesterday = allEps.Where(e => e.AirDate == DateTime.Today.AddDays(-1)).ToList(); var yesterday = allEps.Where(e => e.AirDate == DateTime.Today.AddDays(-1)).ToList();
var today = allEps.Where(e => e.AirDate == DateTime.Today).ToList(); var today = allEps.Where(e => e.AirDate == DateTime.Today).ToList();
@ -42,9 +41,9 @@ namespace NzbDrone.Core.Providers
public virtual List<Episode> Week() public virtual List<Episode> Week()
{ {
return _sonicRepo.All<Episode>().Where(e => e.AirDate > DateTime.Today && e.AirDate < DateTime.Today.AddDays(8)).ToList(); return
} _sonicRepo.All<Episode>().Where(e => e.AirDate > DateTime.Today && e.AirDate < DateTime.Today.AddDays(8))
.ToList();
#endregion }
} }
} }

View File

@ -1,8 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
using NLog; using NLog;
using NzbDrone.Core.Helpers; using NzbDrone.Core.Helpers;
@ -12,19 +10,16 @@ namespace NzbDrone.Core.Providers
{ {
public class XbmcProvider public class XbmcProvider
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider; private readonly ConfigProvider _configProvider;
private readonly HttpProvider _httpProvider; private readonly HttpProvider _httpProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public XbmcProvider(ConfigProvider configProvider, HttpProvider httpProvider) public XbmcProvider(ConfigProvider configProvider, HttpProvider httpProvider)
{ {
_configProvider = configProvider; _configProvider = configProvider;
_httpProvider = httpProvider; _httpProvider = httpProvider;
} }
#region XbmcProvider Members
public virtual void Notify(string header, string message) public virtual void Notify(string header, string message)
{ {
//Get time in seconds and convert to ms //Get time in seconds and convert to ms
@ -55,7 +50,8 @@ namespace NzbDrone.Core.Providers
var xbmcSeriesPath = GetXbmcSeriesPath(host, seriesId); var xbmcSeriesPath = GetXbmcSeriesPath(host, seriesId);
//If the path is not found & the user wants to update the entire library, do it now. //If the path is not found & the user wants to update the entire library, do it now.
if (String.IsNullOrEmpty(xbmcSeriesPath) && Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true))) if (String.IsNullOrEmpty(xbmcSeriesPath) &&
Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true)))
{ {
//Update the entire library //Update the entire library
Logger.Trace("Series [{0}] doesn't exist on XBMC host: {1}, Updating Entire Library", seriesId, host); Logger.Trace("Series [{0}] doesn't exist on XBMC host: {1}, Updating Entire Library", seriesId, host);
@ -78,8 +74,6 @@ namespace NzbDrone.Core.Providers
} }
} }
#endregion
private string SendCommand(string host, string command) private string SendCommand(string host, string command)
{ {
var username = _configProvider.GetValue("XbmcUsername", String.Empty, true); var username = _configProvider.GetValue("XbmcUsername", String.Empty, true);
@ -96,10 +90,14 @@ namespace NzbDrone.Core.Providers
private string GetXbmcSeriesPath(string host, int seriesId) private string GetXbmcSeriesPath(string host, int seriesId)
{ {
var query = String.Format("select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = {0} and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath", seriesId); var query =
String.Format(
"select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = {0} and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath",
seriesId);
var command = String.Format("QueryVideoDatabase({0})", query); var command = String.Format("QueryVideoDatabase({0})", query);
var setResponseCommand = "SetResponseFormat(webheader;false;webfooter;false;header;<xml>;footer;</xml>;opentag;<tag>;closetag;</tag>;closefinaltag;false)"; var setResponseCommand =
"SetResponseFormat(webheader;false;webfooter;false;header;<xml>;footer;</xml>;opentag;<tag>;closetag;</tag>;closefinaltag;false)";
var resetResponseCommand = "SetResponseFormat()"; var resetResponseCommand = "SetResponseFormat()";
SendCommand(host, setResponseCommand); SendCommand(host, setResponseCommand);

View File

@ -9,6 +9,7 @@ namespace NzbDrone.Core.Repository
{ {
[SubSonicPrimaryKey(false)] [SubSonicPrimaryKey(false)]
public virtual int EpisodeId { get; set; } public virtual int EpisodeId { get; set; }
public virtual int SeriesId { get; set; } public virtual int SeriesId { get; set; }
public virtual int EpisodeFileId { get; set; } public virtual int EpisodeFileId { get; set; }
public virtual int SeasonId { get; set; } public virtual int SeasonId { get; set; }
@ -16,8 +17,10 @@ namespace NzbDrone.Core.Repository
public int EpisodeNumber { get; set; } public int EpisodeNumber { get; set; }
public string Title { get; set; } public string Title { get; set; }
public DateTime AirDate { get; set; } public DateTime AirDate { get; set; }
[SubSonicLongString] [SubSonicLongString]
public string Overview { get; set; } public string Overview { get; set; }
public string Language { get; set; } public string Language { get; set; }
public EpisodeStatusType Status { get; set; } public EpisodeStatusType Status { get; set; }

View File

@ -9,6 +9,7 @@ namespace NzbDrone.Core.Repository
{ {
[SubSonicPrimaryKey] [SubSonicPrimaryKey]
public virtual int EpisodeFileId { get; set; } public virtual int EpisodeFileId { get; set; }
public virtual int SeriesId { get; set; } public virtual int SeriesId { get; set; }
public string Path { get; set; } public string Path { get; set; }
public QualityTypes Quality { get; set; } public QualityTypes Quality { get; set; }

View File

@ -8,6 +8,7 @@ namespace NzbDrone.Core.Repository
{ {
[SubSonicPrimaryKey] [SubSonicPrimaryKey]
public virtual int HistoryId { get; set; } public virtual int HistoryId { get; set; }
public virtual int EpisodeId { get; set; } public virtual int EpisodeId { get; set; }
public virtual int IndexerId { get; set; } public virtual int IndexerId { get; set; }
public string NzbTitle { get; set; } public string NzbTitle { get; set; }

View File

@ -1,9 +1,5 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using SubSonic.SqlGeneration.Schema; using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository namespace NzbDrone.Core.Repository
@ -19,6 +15,7 @@ namespace NzbDrone.Core.Repository
[SubSonicNullStringAttribute] [SubSonicNullStringAttribute]
[DisplayFormat(ConvertEmptyStringToNull = false)] [DisplayFormat(ConvertEmptyStringToNull = false)]
public string ApiUrl { get; set; } public string ApiUrl { get; set; }
public bool Enabled { get; set; } public bool Enabled { get; set; }
public int Order { get; set; } public int Order { get; set; }

View File

@ -15,6 +15,7 @@ namespace NzbDrone.Core.Repository.Quality
[DisplayName("Name")] [DisplayName("Name")]
[DisplayFormat(ConvertEmptyStringToNull = false)] [DisplayFormat(ConvertEmptyStringToNull = false)]
public string Name { get; set; } public string Name { get; set; }
public bool UserProfile { get; set; } //Allows us to tell the difference between default and user profiles public bool UserProfile { get; set; } //Allows us to tell the difference between default and user profiles
[SubSonicIgnore] [SubSonicIgnore]

View File

@ -1,8 +1,4 @@
using System; using SubSonic.SqlGeneration.Schema;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository namespace NzbDrone.Core.Repository
{ {

View File

@ -8,6 +8,7 @@ namespace NzbDrone.Core.Repository
{ {
[SubSonicPrimaryKey(false)] [SubSonicPrimaryKey(false)]
public virtual int SeasonId { get; set; } public virtual int SeasonId { get; set; }
public virtual int SeriesId { get; set; } public virtual int SeriesId { get; set; }
public virtual int SeasonNumber { get; set; } public virtual int SeasonNumber { get; set; }
public bool Monitored { get; set; } public bool Monitored { get; set; }

View File

@ -1,21 +1,18 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Text;
using System.Xml;
using System.Xml.Linq; using System.Xml.Linq;
namespace NzbDrone.PostProcessor namespace NzbDrone.PostProcessor
{ {
class Program internal class Program
{ {
private static string _host = "localhost"; private static string _host = "localhost";
private static int _port = 8989; private static int _port = 8989;
private static string _apiKey = String.Empty; private static string _apiKey = String.Empty;
static void Main(string[] args) private static void Main(string[] args)
{ {
try try
{ {
@ -35,7 +32,8 @@ namespace NzbDrone.PostProcessor
var hostString = _host + ":" + _port; var hostString = _host + ":" + _port;
var url = String.Format("http://{0}/?apiKey={1}&dir={2}&nzbName={3}&category={4}", hostString, _apiKey, dir, nzbName, category); var url = String.Format("http://{0}/?apiKey={1}&dir={2}&nzbName={3}&category={4}", hostString, _apiKey,
dir, nzbName, category);
var webClient = new WebClient(); var webClient = new WebClient();
webClient.DownloadString(url); webClient.DownloadString(url);
@ -46,7 +44,7 @@ namespace NzbDrone.PostProcessor
} }
} }
static bool LoadConfig() private static bool LoadConfig()
{ {
var configFile = "PostProcessor.xml"; var configFile = "PostProcessor.xml";
if (!File.Exists(configFile)) if (!File.Exists(configFile))
@ -65,8 +63,10 @@ namespace NzbDrone.PostProcessor
} }
var hostNode = config.Descendants("Host").FirstOrDefault(); var hostNode = config.Descendants("Host").FirstOrDefault();
var portNode = config.Descendants("Port").FirstOrDefault(); ; var portNode = config.Descendants("Port").FirstOrDefault();
var apiKeyNode = config.Descendants("ApiKey").FirstOrDefault(); ; ;
var apiKeyNode = config.Descendants("ApiKey").FirstOrDefault();
;
if (hostNode == null || portNode == null || apiKeyNode == null) if (hostNode == null || portNode == null || apiKeyNode == null)
{ {

View File

@ -1,10 +1,10 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("NzbDrone.PostProcessor")] [assembly: AssemblyTitle("NzbDrone.PostProcessor")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM // The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6521fcb0-15dc-4324-b08a-f18f87d78859")] [assembly: Guid("6521fcb0-15dc-4324-b08a-f18f87d78859")]
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,8 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
@ -12,16 +10,17 @@ namespace NzbDrone.Web.Controllers
{ {
public class AddSeriesController : Controller public class AddSeriesController : Controller
{ {
private readonly SyncProvider _syncProvider;
private readonly RootDirProvider _rootFolderProvider;
private readonly ConfigProvider _configProvider; private readonly ConfigProvider _configProvider;
private readonly QualityProvider _qualityProvider; private readonly QualityProvider _qualityProvider;
private readonly TvDbProvider _tvDbProvider; private readonly RootDirProvider _rootFolderProvider;
private readonly SeriesProvider _seriesProvider; private readonly SeriesProvider _seriesProvider;
private readonly SyncProvider _syncProvider;
private readonly TvDbProvider _tvDbProvider;
public AddSeriesController(SyncProvider syncProvider, RootDirProvider rootFolderProvider, ConfigProvider configProvider, public AddSeriesController(SyncProvider syncProvider, RootDirProvider rootFolderProvider,
QualityProvider qualityProvider, TvDbProvider tvDbProvider, SeriesProvider seriesProvider) ConfigProvider configProvider,
QualityProvider qualityProvider, TvDbProvider tvDbProvider,
SeriesProvider seriesProvider)
{ {
_syncProvider = syncProvider; _syncProvider = syncProvider;
_rootFolderProvider = rootFolderProvider; _rootFolderProvider = rootFolderProvider;
@ -78,7 +77,6 @@ namespace NzbDrone.Web.Controllers
public ActionResult RenderPartial(string path) public ActionResult RenderPartial(string path)
{ {
var suggestions = GetSuggestionList(new DirectoryInfo(path).Name); var suggestions = GetSuggestionList(new DirectoryInfo(path).Name);
ViewData["guid"] = Guid.NewGuid(); ViewData["guid"] = Guid.NewGuid();
@ -92,10 +90,10 @@ namespace NzbDrone.Web.Controllers
qualityProfiles, qualityProfiles,
"QualityProfileId", "QualityProfileId",
"Name", "Name",
defaultQuality); ; defaultQuality);
;
return PartialView("AddSeriesItem", suggestions); return PartialView("AddSeriesItem", suggestions);
} }
public JsonResult AddSeries(string path, int seriesId, int qualityProfileId) public JsonResult AddSeries(string path, int seriesId, int qualityProfileId)
@ -104,9 +102,11 @@ namespace NzbDrone.Web.Controllers
//Create new folder for series //Create new folder for series
//Add the new series to the Database //Add the new series to the Database
_seriesProvider.AddSeries(path.Replace('|', Path.DirectorySeparatorChar).Replace('^', Path.VolumeSeparatorChar), seriesId, qualityProfileId); _seriesProvider.AddSeries(
path.Replace('|', Path.DirectorySeparatorChar).Replace('^', Path.VolumeSeparatorChar), seriesId,
qualityProfileId);
ScanNewSeries(); ScanNewSeries();
return new JsonResult() { Data = "ok" }; return new JsonResult {Data = "ok"};
} }
[HttpPost] [HttpPost]
@ -133,6 +133,5 @@ namespace NzbDrone.Web.Controllers
return new SelectList(dataVal, "Id", "SeriesName", selectId); return new SelectList(dataVal, "Id", "SeriesName", selectId);
} }
} }
} }

View File

@ -1,11 +1,5 @@
using System; using System.Web.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Xml.Linq;
using NLog; using NLog;
using NzbDrone.Core;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
@ -13,10 +7,9 @@ namespace NzbDrone.Web.Controllers
{ {
public class ApiController : Controller public class ApiController : Controller
{ {
private readonly PostProcessingProvider _postProcessingProvider;
private readonly ConfigProvider _configProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider;
private readonly PostProcessingProvider _postProcessingProvider;
public ApiController(PostProcessingProvider postProcessingProvider, ConfigProvider configProvider) public ApiController(PostProcessingProvider postProcessingProvider, ConfigProvider configProvider)
{ {

View File

@ -1,10 +1,6 @@
using System; using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Web.Models; using NzbDrone.Web.Models;
using Telerik.Web.Mvc; using Telerik.Web.Mvc;
@ -12,7 +8,7 @@ namespace NzbDrone.Web.Controllers
{ {
public class HistoryController : Controller public class HistoryController : Controller
{ {
private HistoryProvider _historyProvider; private readonly HistoryProvider _historyProvider;
public HistoryController(HistoryProvider historyProvider) public HistoryController(HistoryProvider historyProvider)
{ {

View File

@ -1,10 +1,5 @@
using System; using System.Web.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Instrumentation; using NzbDrone.Core.Instrumentation;
using SubSonic.Repository;
using Telerik.Web.Mvc; using Telerik.Web.Mvc;
namespace NzbDrone.Web.Controllers namespace NzbDrone.Web.Controllers
@ -28,7 +23,6 @@ namespace NzbDrone.Web.Controllers
{ {
_logProvider.DeleteAll(); _logProvider.DeleteAll();
return RedirectToAction("Index"); return RedirectToAction("Index");
} }
[GridAction] [GridAction]

View File

@ -1,8 +1,4 @@
using System; using System.Web.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
namespace NzbDrone.Web.Controllers namespace NzbDrone.Web.Controllers
@ -29,6 +25,5 @@ namespace NzbDrone.Web.Controllers
return Json(message, JsonRequestBehavior.AllowGet); return Json(message, JsonRequestBehavior.AllowGet);
} }
} }
} }

View File

@ -1,34 +1,27 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Web.Models; using NzbDrone.Web.Models;
using Telerik.Web.Mvc; using Telerik.Web.Mvc;
using TvdbLib.Data; using TvdbLib.Data;
using EpisodeModel = NzbDrone.Web.Models.EpisodeModel;
namespace NzbDrone.Web.Controllers namespace NzbDrone.Web.Controllers
{ {
[HandleError] [HandleError]
public class SeriesController : Controller public class SeriesController : Controller
{ {
private readonly SeriesProvider _seriesProvider;
private readonly EpisodeProvider _episodeProvider; private readonly EpisodeProvider _episodeProvider;
private readonly SyncProvider _syncProvider;
private readonly RssSyncProvider _rssSyncProvider;
private readonly QualityProvider _qualityProvider;
private readonly MediaFileProvider _mediaFileProvider; private readonly MediaFileProvider _mediaFileProvider;
private readonly QualityProvider _qualityProvider;
private readonly RenameProvider _renameProvider; private readonly RenameProvider _renameProvider;
private readonly RootDirProvider _rootDirProvider; private readonly RootDirProvider _rootDirProvider;
private readonly RssSyncProvider _rssSyncProvider;
private readonly SeriesProvider _seriesProvider;
private readonly SyncProvider _syncProvider;
private readonly TvDbProvider _tvDbProvider; private readonly TvDbProvider _tvDbProvider;
// //
// GET: /Series/ // GET: /Series/
@ -57,9 +50,6 @@ namespace NzbDrone.Web.Controllers
} }
public ActionResult RssSync() public ActionResult RssSync()
{ {
_rssSyncProvider.Begin(); _rssSyncProvider.Begin();
@ -68,7 +58,7 @@ namespace NzbDrone.Web.Controllers
public ActionResult UnMapped(string path) public ActionResult UnMapped(string path)
{ {
return View(_syncProvider.GetUnmappedFolders(path).Select(c => new MappingModel() { Id = 1, Path = c }).ToList()); return View(_syncProvider.GetUnmappedFolders(path).Select(c => new MappingModel {Id = 1, Path = c}).ToList());
} }
public ActionResult LoadEpisodes(int seriesId) public ActionResult LoadEpisodes(int seriesId)
@ -76,24 +66,32 @@ namespace NzbDrone.Web.Controllers
_episodeProvider.RefreshEpisodeInfo(seriesId); _episodeProvider.RefreshEpisodeInfo(seriesId);
return RedirectToAction("Details", new return RedirectToAction("Details", new
{ {
seriesId = seriesId seriesId
}); });
} }
[GridAction] [GridAction]
public ActionResult _AjaxSeasonGrid(int seasonId) public ActionResult _AjaxSeasonGrid(int seasonId)
{ {
var episodes = _episodeProvider.GetEpisodeBySeason(seasonId).Select(c => new EpisodeModel() var episodes = _episodeProvider.GetEpisodeBySeason(seasonId).Select(c => new EpisodeModel
{ {
EpisodeId = c.EpisodeId, EpisodeId = c.EpisodeId,
EpisodeNumber = c.EpisodeNumber, EpisodeNumber =
SeasonNumber = c.SeasonNumber, c.EpisodeNumber,
SeasonNumber =
c.SeasonNumber,
Title = c.Title, Title = c.Title,
Overview = c.Overview, Overview = c.Overview,
AirDate = c.AirDate, AirDate = c.AirDate,
Path = GetEpisodePath(c.EpisodeFile), Path =
Quality = c.EpisodeFile == null ? String.Empty : c.EpisodeFile.Quality.ToString() GetEpisodePath(
c.EpisodeFile),
Quality =
c.EpisodeFile == null
? String.Empty
: c.EpisodeFile.
Quality.
ToString()
}); });
return View(new GridModel(episodes)); return View(new GridModel(episodes));
} }
@ -163,7 +161,6 @@ namespace NzbDrone.Web.Controllers
private IEnumerable<Episode> GetData(GridCommand command) private IEnumerable<Episode> GetData(GridCommand command)
{ {
return null; return null;
/* /*
IQueryable<Episode> data = .Orders; IQueryable<Episode> data = .Orders;

View File

@ -1,11 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using NLog; using NLog;
using NzbDrone.Core;
using NzbDrone.Core.Helpers; using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
@ -19,14 +16,13 @@ namespace NzbDrone.Web.Controllers
[HandleError] [HandleError]
public class SettingsController : Controller public class SettingsController : Controller
{ {
private ConfigProvider _configProvider;
private IndexerProvider _indexerProvider;
private QualityProvider _qualityProvider;
private RootDirProvider _rootDirProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private const string SETTINGS_SAVED = "Settings Saved."; private const string SETTINGS_SAVED = "Settings Saved.";
private const string SETTINGS_FAILED = "Error Saving Settings, please fix any errors"; private const string SETTINGS_FAILED = "Error Saving Settings, please fix any errors";
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider;
private readonly IndexerProvider _indexerProvider;
private readonly QualityProvider _qualityProvider;
private readonly RootDirProvider _rootDirProvider;
public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider, public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider,
QualityProvider qualityProvider, RootDirProvider rootDirProvider) QualityProvider qualityProvider, RootDirProvider rootDirProvider)
@ -63,8 +59,10 @@ namespace NzbDrone.Web.Controllers
ViewData["viewName"] = "Indexers"; ViewData["viewName"] = "Indexers";
return View("Index", new IndexerSettingsModel return View("Index", new IndexerSettingsModel
{ {
NzbMatrixUsername = _configProvider.GetValue("NzbMatrixUsername", String.Empty, true), NzbMatrixUsername =
NzbMatrixApiKey = _configProvider.GetValue("NzbMatrixApiKey", String.Empty, true), _configProvider.GetValue("NzbMatrixUsername", String.Empty, true),
NzbMatrixApiKey =
_configProvider.GetValue("NzbMatrixApiKey", String.Empty, true),
NzbsOrgUId = _configProvider.GetValue("NzbsOrgUId", String.Empty, true), NzbsOrgUId = _configProvider.GetValue("NzbsOrgUId", String.Empty, true),
NzbsOrgHash = _configProvider.GetValue("NzbsOrgHash", String.Empty, true), NzbsOrgHash = _configProvider.GetValue("NzbsOrgHash", String.Empty, true),
NzbsrusUId = _configProvider.GetValue("NzbsrusUId", String.Empty, true), NzbsrusUId = _configProvider.GetValue("NzbsrusUId", String.Empty, true),
@ -80,7 +78,8 @@ namespace NzbDrone.Web.Controllers
var model = new DownloadSettingsModel var model = new DownloadSettingsModel
{ {
SyncFrequency = Convert.ToInt32(_configProvider.GetValue("SyncFrequency", "15", true)), SyncFrequency = Convert.ToInt32(_configProvider.GetValue("SyncFrequency", "15", true)),
DownloadPropers = Convert.ToBoolean(_configProvider.GetValue("DownloadPropers", "false", true)), DownloadPropers =
Convert.ToBoolean(_configProvider.GetValue("DownloadPropers", "false", true)),
Retention = Convert.ToInt32(_configProvider.GetValue("Retention", "500", true)), Retention = Convert.ToInt32(_configProvider.GetValue("Retention", "500", true)),
SabHost = _configProvider.GetValue("SabHost", "localhost", true), SabHost = _configProvider.GetValue("SabHost", "localhost", true),
SabPort = Convert.ToInt32(_configProvider.GetValue("SabPort", "8080", true)), SabPort = Convert.ToInt32(_configProvider.GetValue("SabPort", "8080", true)),
@ -88,7 +87,10 @@ namespace NzbDrone.Web.Controllers
SabUsername = _configProvider.GetValue("SabUsername", String.Empty, true), SabUsername = _configProvider.GetValue("SabUsername", String.Empty, true),
SabPassword = _configProvider.GetValue("SabPassword", String.Empty, true), SabPassword = _configProvider.GetValue("SabPassword", String.Empty, true),
SabTvCategory = _configProvider.GetValue("SabTvCategory", String.Empty, true), SabTvCategory = _configProvider.GetValue("SabTvCategory", String.Empty, true),
SabTvPriority = (SabnzbdPriorityType)Enum.Parse(typeof(SabnzbdPriorityType), _configProvider.GetValue("SabTvPriority", "Normal", true)), SabTvPriority =
(SabnzbdPriorityType)
Enum.Parse(typeof (SabnzbdPriorityType),
_configProvider.GetValue("SabTvPriority", "Normal", true)),
UseBlackHole = Convert.ToBoolean(_configProvider.GetValue("UseBlackHole", true, true)), UseBlackHole = Convert.ToBoolean(_configProvider.GetValue("UseBlackHole", true, true)),
BlackholeDirectory = _configProvider.GetValue("BlackholeDirectory", String.Empty, true) BlackholeDirectory = _configProvider.GetValue("BlackholeDirectory", String.Empty, true)
}; };
@ -112,7 +114,8 @@ namespace NzbDrone.Web.Controllers
var userProfiles = _qualityProvider.GetAllProfiles().Where(q => q.UserProfile).ToList(); var userProfiles = _qualityProvider.GetAllProfiles().Where(q => q.UserProfile).ToList();
var profiles = _qualityProvider.GetAllProfiles().ToList(); var profiles = _qualityProvider.GetAllProfiles().ToList();
var defaultQualityQualityProfileId = Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId, true)); var defaultQualityQualityProfileId =
Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId, true));
var selectList = new SelectList(profiles, "QualityProfileId", "Name"); var selectList = new SelectList(profiles, "QualityProfileId", "Name");
@ -134,16 +137,25 @@ namespace NzbDrone.Web.Controllers
var model = new NotificationSettingsModel var model = new NotificationSettingsModel
{ {
XbmcEnabled = Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false, true)), XbmcEnabled = Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false, true)),
XbmcNotifyOnGrab = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false, true)), XbmcNotifyOnGrab =
XbmcNotifyOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false, true)), Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false, true)),
XbmcNotifyOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false, true)), XbmcNotifyOnDownload =
XbmcNotificationImage = Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false, true)), Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false, true)),
XbmcNotifyOnRename =
Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false, true)),
XbmcNotificationImage =
Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false, true)),
XbmcDisplayTime = Convert.ToInt32(_configProvider.GetValue("XbmcDisplayTime", 3, true)), XbmcDisplayTime = Convert.ToInt32(_configProvider.GetValue("XbmcDisplayTime", 3, true)),
XbmcUpdateOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload ", false, true)), XbmcUpdateOnDownload =
XbmcUpdateOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false, true)), Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload ", false, true)),
XbmcFullUpdate = Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true)), XbmcUpdateOnRename =
XbmcCleanOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false, true)), Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false, true)),
XbmcCleanOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false, true)), XbmcFullUpdate =
Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true)),
XbmcCleanOnDownload =
Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false, true)),
XbmcCleanOnRename =
Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false, true)),
XbmcHosts = _configProvider.GetValue("XbmcHosts", "localhost:80", true), XbmcHosts = _configProvider.GetValue("XbmcHosts", "localhost:80", true),
XbmcUsername = _configProvider.GetValue("XbmcUsername", String.Empty, true), XbmcUsername = _configProvider.GetValue("XbmcUsername", String.Empty, true),
XbmcPassword = _configProvider.GetValue("XbmcPassword", String.Empty, true) XbmcPassword = _configProvider.GetValue("XbmcPassword", String.Empty, true)
@ -203,7 +215,8 @@ namespace NzbDrone.Web.Controllers
public QualityModel GetUpdatedProfileList() public QualityModel GetUpdatedProfileList()
{ {
var profiles = _qualityProvider.GetAllProfiles().ToList(); var profiles = _qualityProvider.GetAllProfiles().ToList();
var defaultQualityQualityProfileId = Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId, true)); var defaultQualityQualityProfileId =
Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId, true));
var selectList = new SelectList(profiles, "QualityProfileId", "Name"); var selectList = new SelectList(profiles, "QualityProfileId", "Name");
return new QualityModel {DefaultQualityProfileId = defaultQualityQualityProfileId, SelectList = selectList}; return new QualityModel {DefaultQualityProfileId = defaultQualityQualityProfileId, SelectList = selectList};

View File

@ -1,15 +1,11 @@
using System; using System.Web.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
namespace NzbDrone.Web.Controllers namespace NzbDrone.Web.Controllers
{ {
public class SharedController : Controller public class SharedController : Controller
{ {
private TimerProvider _timerProvider; private readonly TimerProvider _timerProvider;
public SharedController(TimerProvider timerProvider) public SharedController(TimerProvider timerProvider)
{ {

View File

@ -1,7 +1,4 @@
using System; using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Web.Models; using NzbDrone.Web.Models;
@ -11,7 +8,7 @@ namespace NzbDrone.Web.Controllers
{ {
public class UpcomingController : Controller public class UpcomingController : Controller
{ {
private UpcomingEpisodesProvider _upcomingEpisodesProvider; private readonly UpcomingEpisodesProvider _upcomingEpisodesProvider;
public UpcomingController(UpcomingEpisodesProvider upcomingEpisodesProvider) public UpcomingController(UpcomingEpisodesProvider upcomingEpisodesProvider)
{ {

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Data.SQLite; using System.Data.SQLite;
using System.Diagnostics;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
using System.Web; using System.Web;
@ -11,7 +10,6 @@ using Ninject.Web.Mvc;
using NLog; using NLog;
using NzbDrone.Core; using NzbDrone.Core;
using NzbDrone.Core.Instrumentation; using NzbDrone.Core.Instrumentation;
using SubSonic.Repository;
namespace NzbDrone.Web namespace NzbDrone.Web
{ {
@ -21,7 +19,6 @@ namespace NzbDrone.Web
public static void RegisterRoutes(RouteCollection routes) public static void RegisterRoutes(RouteCollection routes)
{ {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*robotstxt}", new {robotstxt = @"(.*/)?robots.txt(/.*)?"}); routes.IgnoreRoute("{*robotstxt}", new {robotstxt = @"(.*/)?robots.txt(/.*)?"});
routes.IgnoreRoute("{*favicon}", new {favicon = @"(.*/)?favicon.ico(/.*)?"}); routes.IgnoreRoute("{*favicon}", new {favicon = @"(.*/)?favicon.ico(/.*)?"});
@ -85,15 +82,11 @@ namespace NzbDrone.Web
Logger.Warn("Restarting application"); Logger.Warn("Restarting application");
HttpRuntime.UnloadAppDomain(); HttpRuntime.UnloadAppDomain();
} }
} }
protected void Application_BeginRequest() protected void Application_BeginRequest()
{ {
Thread.CurrentThread.Name = "UI"; Thread.CurrentThread.Name = "UI";
} }
} }
} }

View File

@ -1,7 +1,7 @@
using System; using System;
using System.Web.Mvc;
using System.Web;
using System.Collections.Generic; using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
namespace NzbDrone.Web.Helpers namespace NzbDrone.Web.Helpers
{ {
@ -15,7 +15,9 @@ namespace NzbDrone.Web.Helpers
string itemIndex = idsToReuse.Count > 0 ? idsToReuse.Dequeue() : Guid.NewGuid().ToString(); string itemIndex = idsToReuse.Count > 0 ? idsToReuse.Dequeue() : Guid.NewGuid().ToString();
// autocomplete="off" is needed to work around a very annoying Chrome behaviour whereby it reuses old values after the user clicks "Back", which causes the xyz.index and xyz[...] values to get out of sync. // autocomplete="off" is needed to work around a very annoying Chrome behaviour whereby it reuses old values after the user clicks "Back", which causes the xyz.index and xyz[...] values to get out of sync.
html.ViewContext.Writer.WriteLine(string.Format("<input type=\"hidden\" name=\"{0}.index\" autocomplete=\"off\" value=\"{1}\" />", collectionName, itemIndex)); html.ViewContext.Writer.WriteLine(
string.Format("<input type=\"hidden\" name=\"{0}.index\" autocomplete=\"off\" value=\"{1}\" />",
collectionName, itemIndex));
return BeginHtmlFieldPrefixScope(html, string.Format("{0}[{1}]", collectionName, itemIndex)); return BeginHtmlFieldPrefixScope(html, string.Format("{0}[{1}]", collectionName, itemIndex));
} }
@ -31,7 +33,8 @@ namespace NzbDrone.Web.Helpers
// otherwise the framework won't render the validation error messages next to each item. // otherwise the framework won't render the validation error messages next to each item.
string key = idsToReuseKey + collectionName; string key = idsToReuseKey + collectionName;
var queue = (Queue<string>) httpContext.Items[key]; var queue = (Queue<string>) httpContext.Items[key];
if (queue == null) { if (queue == null)
{
httpContext.Items[key] = queue = new Queue<string>(); httpContext.Items[key] = queue = new Queue<string>();
var previouslyUsedIds = httpContext.Request[collectionName + ".index"]; var previouslyUsedIds = httpContext.Request[collectionName + ".index"];
if (!string.IsNullOrEmpty(previouslyUsedIds)) if (!string.IsNullOrEmpty(previouslyUsedIds))
@ -41,10 +44,12 @@ namespace NzbDrone.Web.Helpers
return queue; return queue;
} }
#region Nested type: HtmlFieldPrefixScope
private class HtmlFieldPrefixScope : IDisposable private class HtmlFieldPrefixScope : IDisposable
{ {
private readonly TemplateInfo templateInfo;
private readonly string previousHtmlFieldPrefix; private readonly string previousHtmlFieldPrefix;
private readonly TemplateInfo templateInfo;
public HtmlFieldPrefixScope(TemplateInfo templateInfo, string htmlFieldPrefix) public HtmlFieldPrefixScope(TemplateInfo templateInfo, string htmlFieldPrefix)
{ {
@ -54,10 +59,16 @@ namespace NzbDrone.Web.Helpers
templateInfo.HtmlFieldPrefix = htmlFieldPrefix; templateInfo.HtmlFieldPrefix = htmlFieldPrefix;
} }
#region IDisposable Members
public void Dispose() public void Dispose()
{ {
templateInfo.HtmlFieldPrefix = previousHtmlFieldPrefix; templateInfo.HtmlFieldPrefix = previousHtmlFieldPrefix;
} }
}
#endregion
}
#endregion
} }
} }

View File

@ -1,11 +1,11 @@
using System; using System;
using System.Web.Mvc; using System.Web.Mvc;
using System.Web.Mvc.Html; using System.Web.Mvc.Html;
namespace Helpers namespace Helpers
{ {
public static class IsCurrentActionHelper public static class IsCurrentActionHelper
{ {
private static bool IsCurrentController(HtmlHelper helper, string actionName, string controllerName) private static bool IsCurrentController(HtmlHelper helper, string actionName, string controllerName)
{ {
var currentControllerName = (string) helper.ViewContext.RouteData.Values["controller"]; var currentControllerName = (string) helper.ViewContext.RouteData.Values["controller"];
@ -16,7 +16,8 @@ namespace Helpers
return false; return false;
} }
public static string CurrentActionLink(this HtmlHelper helper, string text, string actionName, string controllerName) public static string CurrentActionLink(this HtmlHelper helper, string text, string actionName,
string controllerName)
{ {
string result; string result;
@ -30,7 +31,6 @@ namespace Helpers
} }
return result + helper.ActionLink(text, actionName, controllerName).ToHtmlString() + @"</li>"; return result + helper.ActionLink(text, actionName, controllerName).ToHtmlString() + @"</li>";
} }
} }
} }

View File

@ -1,18 +1,16 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security; using System.Web.Security;
namespace NzbDrone.Web.Models namespace NzbDrone.Web.Models
{ {
#region Models #region Models
[PropertiesMustMatch("NewPassword", "ConfirmPassword", ErrorMessage = "The new password and confirmation password do not match.")]
[PropertiesMustMatch("NewPassword", "ConfirmPassword",
ErrorMessage = "The new password and confirmation password do not match.")]
public class ChangePasswordModel public class ChangePasswordModel
{ {
[Required] [Required]
@ -47,7 +45,8 @@ namespace NzbDrone.Web.Models
public bool RememberMe { get; set; } public bool RememberMe { get; set; }
} }
[PropertiesMustMatch("Password", "ConfirmPassword", ErrorMessage = "The password and confirmation password do not match.")] [PropertiesMustMatch("Password", "ConfirmPassword",
ErrorMessage = "The password and confirmation password do not match.")]
public class RegisterModel public class RegisterModel
{ {
[Required] [Required]
@ -70,9 +69,11 @@ namespace NzbDrone.Web.Models
[DisplayName("Confirm password")] [DisplayName("Confirm password")]
public string ConfirmPassword { get; set; } public string ConfirmPassword { get; set; }
} }
#endregion #endregion
#region Services #region Services
// The FormsAuthentication type is sealed and contains static members, so it is difficult to // The FormsAuthentication type is sealed and contains static members, so it is difficult to
// unit test code that calls its members. The interface and helper class below demonstrate // unit test code that calls its members. The interface and helper class below demonstrate
// how to create an abstract wrapper around such a type in order to make the AccountController // how to create an abstract wrapper around such a type in order to make the AccountController
@ -101,26 +102,29 @@ namespace NzbDrone.Web.Models
_provider = provider ?? Membership.Provider; _provider = provider ?? Membership.Provider;
} }
#region IMembershipService Members
public int MinPasswordLength public int MinPasswordLength
{ {
get get { return _provider.MinRequiredPasswordLength; }
{
return _provider.MinRequiredPasswordLength;
}
} }
public bool ValidateUser(string userName, string password) public bool ValidateUser(string userName, string password)
{ {
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName"); if (String.IsNullOrEmpty(userName))
if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", "password"); throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(password))
throw new ArgumentException("Value cannot be null or empty.", "password");
return _provider.ValidateUser(userName, password); return _provider.ValidateUser(userName, password);
} }
public MembershipCreateStatus CreateUser(string userName, string password, string email) public MembershipCreateStatus CreateUser(string userName, string password, string email)
{ {
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName"); if (String.IsNullOrEmpty(userName))
if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", "password"); throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(password))
throw new ArgumentException("Value cannot be null or empty.", "password");
if (String.IsNullOrEmpty(email)) throw new ArgumentException("Value cannot be null or empty.", "email"); if (String.IsNullOrEmpty(email)) throw new ArgumentException("Value cannot be null or empty.", "email");
MembershipCreateStatus status; MembershipCreateStatus status;
@ -130,9 +134,12 @@ namespace NzbDrone.Web.Models
public bool ChangePassword(string userName, string oldPassword, string newPassword) public bool ChangePassword(string userName, string oldPassword, string newPassword)
{ {
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName"); if (String.IsNullOrEmpty(userName))
if (String.IsNullOrEmpty(oldPassword)) throw new ArgumentException("Value cannot be null or empty.", "oldPassword"); throw new ArgumentException("Value cannot be null or empty.", "userName");
if (String.IsNullOrEmpty(newPassword)) throw new ArgumentException("Value cannot be null or empty.", "newPassword"); if (String.IsNullOrEmpty(oldPassword))
throw new ArgumentException("Value cannot be null or empty.", "oldPassword");
if (String.IsNullOrEmpty(newPassword))
throw new ArgumentException("Value cannot be null or empty.", "newPassword");
// The underlying ChangePassword() will throw an exception rather // The underlying ChangePassword() will throw an exception rather
// than return false in certain failure scenarios. // than return false in certain failure scenarios.
@ -150,6 +157,8 @@ namespace NzbDrone.Web.Models
return false; return false;
} }
} }
#endregion
} }
public interface IFormsAuthenticationService public interface IFormsAuthenticationService
@ -160,9 +169,12 @@ namespace NzbDrone.Web.Models
public class FormsAuthenticationService : IFormsAuthenticationService public class FormsAuthenticationService : IFormsAuthenticationService
{ {
#region IFormsAuthenticationService Members
public void SignIn(string userName, bool createPersistentCookie) public void SignIn(string userName, bool createPersistentCookie)
{ {
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName"); if (String.IsNullOrEmpty(userName))
throw new ArgumentException("Value cannot be null or empty.", "userName");
FormsAuthentication.SetAuthCookie(userName, createPersistentCookie); FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
} }
@ -171,10 +183,14 @@ namespace NzbDrone.Web.Models
{ {
FormsAuthentication.SignOut(); FormsAuthentication.SignOut();
} }
#endregion
} }
#endregion #endregion
#region Validation #region Validation
public static class AccountValidation public static class AccountValidation
{ {
public static string ErrorCodeToString(MembershipCreateStatus createStatus) public static string ErrorCodeToString(MembershipCreateStatus createStatus)
@ -205,13 +221,16 @@ namespace NzbDrone.Web.Models
return "The user name provided is invalid. Please check the value and try again."; return "The user name provided is invalid. Please check the value and try again.";
case MembershipCreateStatus.ProviderError: case MembershipCreateStatus.ProviderError:
return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator."; return
"The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
case MembershipCreateStatus.UserRejected: case MembershipCreateStatus.UserRejected:
return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator."; return
"The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
default: default:
return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator."; return
"An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
} }
} }
} }
@ -234,10 +253,7 @@ namespace NzbDrone.Web.Models
public override object TypeId public override object TypeId
{ {
get get { return _typeId; }
{
return _typeId;
}
} }
public override string FormatErrorMessage(string name) public override string FormatErrorMessage(string name)
@ -251,7 +267,7 @@ namespace NzbDrone.Web.Models
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value); PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value);
object originalValue = properties.Find(OriginalProperty, true /* ignoreCase */).GetValue(value); object originalValue = properties.Find(OriginalProperty, true /* ignoreCase */).GetValue(value);
object confirmValue = properties.Find(ConfirmProperty, true /* ignoreCase */).GetValue(value); object confirmValue = properties.Find(ConfirmProperty, true /* ignoreCase */).GetValue(value);
return Object.Equals(originalValue, confirmValue); return Equals(originalValue, confirmValue);
} }
} }
@ -278,6 +294,6 @@ namespace NzbDrone.Web.Models
return (valueAsString != null && valueAsString.Length >= _minCharacters); return (valueAsString != null && valueAsString.Length >= _minCharacters);
} }
} }
#endregion
#endregion
} }

View File

@ -1,8 +1,4 @@
using System; using System.ComponentModel;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
namespace NzbDrone.Web.Models namespace NzbDrone.Web.Models

View File

@ -1,9 +1,4 @@
using System; namespace NzbDrone.Web.Models
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NzbDrone.Web.Models
{ {
public class AddExistingSeriesModel public class AddExistingSeriesModel
{ {

View File

@ -1,9 +1,6 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;

View File

@ -1,9 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
@ -11,110 +8,63 @@ namespace NzbDrone.Web.Models
{ {
public class DownloadSettingsModel public class DownloadSettingsModel
{ {
public SelectList PrioritySelectList =
new SelectList(new[] {"Default", "Paused", "Low", "Normal", "High", "Top"});
[Required] [Required]
[Range(15, 120, ErrorMessage = "Must be between 15 and 120 minutes")] [Range(15, 120, ErrorMessage = "Must be between 15 and 120 minutes")]
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayName("Sync Frequency")] [DisplayName("Sync Frequency")]
public int SyncFrequency public int SyncFrequency { get; set; }
{
get;
set;
}
[DisplayName("Download Propers")] [DisplayName("Download Propers")]
public bool DownloadPropers public bool DownloadPropers { get; set; }
{
get;
set;
}
[Required(ErrorMessage = "Please enter a valid number")] [Required(ErrorMessage = "Please enter a valid number")]
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayName("Retention")] [DisplayName("Retention")]
public int Retention public int Retention { get; set; }
{
get;
set;
}
[Required(ErrorMessage = "Please enter a valid host")] [Required(ErrorMessage = "Please enter a valid host")]
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayName("SABnzbd Host")] [DisplayName("SABnzbd Host")]
public String SabHost public String SabHost { get; set; }
{
get;
set;
}
[Required(ErrorMessage = "Please enter a valid port")] [Required(ErrorMessage = "Please enter a valid port")]
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayName("SABnzbd Port")] [DisplayName("SABnzbd Port")]
public int SabPort public int SabPort { get; set; }
{
get;
set;
}
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayName("SABnzbd API Key")] [DisplayName("SABnzbd API Key")]
[DisplayFormat(ConvertEmptyStringToNull = false)] [DisplayFormat(ConvertEmptyStringToNull = false)]
public String SabApiKey public String SabApiKey { get; set; }
{
get;
set;
}
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayName("SABnzbd Username")] [DisplayName("SABnzbd Username")]
[DisplayFormat(ConvertEmptyStringToNull = false)] [DisplayFormat(ConvertEmptyStringToNull = false)]
public String SabUsername public String SabUsername { get; set; }
{
get;
set;
}
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayName("SABnzbd Password")] [DisplayName("SABnzbd Password")]
[DisplayFormat(ConvertEmptyStringToNull = false)] [DisplayFormat(ConvertEmptyStringToNull = false)]
public String SabPassword public String SabPassword { get; set; }
{
get;
set;
}
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayFormat(ConvertEmptyStringToNull = false)] [DisplayFormat(ConvertEmptyStringToNull = false)]
[DisplayName("SABnzbd TV Category")] [DisplayName("SABnzbd TV Category")]
public String SabTvCategory public String SabTvCategory { get; set; }
{
get;
set;
}
[Required(ErrorMessage = "Please select a valid priority")] [Required(ErrorMessage = "Please select a valid priority")]
[DisplayName("SABnzbd Priority")] [DisplayName("SABnzbd Priority")]
public SabnzbdPriorityType SabTvPriority public SabnzbdPriorityType SabTvPriority { get; set; }
{
get;
set;
}
[DisplayName("Use Blackhole")] [DisplayName("Use Blackhole")]
public bool UseBlackHole public bool UseBlackHole { get; set; }
{
get;
set;
}
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayFormat(ConvertEmptyStringToNull = false)] [DisplayFormat(ConvertEmptyStringToNull = false)]
[DisplayName("Blackhole Directory")] [DisplayName("Blackhole Directory")]
public String BlackholeDirectory public String BlackholeDirectory { get; set; }
{
get;
set;
}
public SelectList PrioritySelectList = new SelectList(new string[] { "Default", "Paused", "Low", "Normal", "High", "Top" });
} }
} }

View File

@ -1,8 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Web.Models namespace NzbDrone.Web.Models
{ {

View File

@ -1,11 +1,6 @@
using System; using System.ComponentModel;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using NzbDrone.Core.Model;
namespace NzbDrone.Web.Models namespace NzbDrone.Web.Models
{ {

View File

@ -1,9 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Web.Models namespace NzbDrone.Web.Models
{ {

View File

@ -2,8 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
namespace NzbDrone.Web.Models namespace NzbDrone.Web.Models
@ -13,61 +11,33 @@ namespace NzbDrone.Web.Models
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayName("NZBMatrix Username")] [DisplayName("NZBMatrix Username")]
[DisplayFormat(ConvertEmptyStringToNull = false)] [DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbMatrixUsername public String NzbMatrixUsername { get; set; }
{
get;
set;
}
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayName("NZBMatrix API Key")] [DisplayName("NZBMatrix API Key")]
[DisplayFormat(ConvertEmptyStringToNull = false)] [DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbMatrixApiKey public String NzbMatrixApiKey { get; set; }
{
get;
set;
}
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayName("NZBs.Org UID")] [DisplayName("NZBs.Org UID")]
[DisplayFormat(ConvertEmptyStringToNull = false)] [DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsOrgUId public String NzbsOrgUId { get; set; }
{
get;
set;
}
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayName("NZBs.Org Hash")] [DisplayName("NZBs.Org Hash")]
[DisplayFormat(ConvertEmptyStringToNull = false)] [DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsOrgHash public String NzbsOrgHash { get; set; }
{
get;
set;
}
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayName("NZBsRus UID")] [DisplayName("NZBsRus UID")]
[DisplayFormat(ConvertEmptyStringToNull = false)] [DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsrusUId public String NzbsrusUId { get; set; }
{
get;
set;
}
[DataType(DataType.Text)] [DataType(DataType.Text)]
[DisplayName("NZBsRus Hash")] [DisplayName("NZBsRus Hash")]
[DisplayFormat(ConvertEmptyStringToNull = false)] [DisplayFormat(ConvertEmptyStringToNull = false)]
public String NzbsrusHash public String NzbsrusHash { get; set; }
{
get;
set;
}
public List<Indexer> Indexers public List<Indexer> Indexers { get; set; }
{
get;
set;
}
} }
} }

View File

@ -1,8 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Web.Models namespace NzbDrone.Web.Models
{ {

View File

@ -1,9 +1,5 @@
using System; using System.ComponentModel;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace NzbDrone.Web.Models namespace NzbDrone.Web.Models
{ {

View File

@ -1,9 +1,5 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;

Some files were not shown because too many files have changed in this diff Show More