1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-03-21 16:54:12 -04:00

Compare commits

..

9 Commits

100 changed files with 504 additions and 772 deletions

View File

@@ -1,40 +1,5 @@
<!--
Before opening a new issue, please ensure:
- You use the forums for support/questions
- You search for existing bugs/feature requests
- Remove extraneous template details
-->
## Support / Questions
Please use https://forums.sonarr.tv/ for support. Support requests or questions will be redirected to the forums and the issue will be closed.
<!--
Remove if not opening a bug report
-->
## Bug Report
### System Information/Logs
**Sonarr Version:**
**Operating System:**
**.net Framework (Windows) or mono (macOS/Linux) Version:**
**Link to Log Files (debug or trace):**
**Browser (for UI bugs):**
### Additional Information
<!--
Remove if not opening a feature request
-->
## Feature Request
### What problem are you looking to solve?
### Other Information
Provide a description of the feature request or bug, the more details the better.
Please use https://forums.sonarr.tv/ for support or other questions. (When in doubt, use the forums)

7
.github/SUPPORT.md vendored
View File

@@ -1,7 +0,0 @@
## Support
There are a number of frequently asked questions that have been answered in our [FAQ](https://github.com/Sonarr/Sonarr/wiki/FAQ)
The [wiki](https://github.com/Sonarr/Sonarr/wiki) contains other information and guides
If you have a support question, please use the [support forums](https://forums.sonarr.tv/).

View File

@@ -52,7 +52,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
</packages>

View File

@@ -48,8 +48,8 @@
<Reference Include="FluentAssertions.Core, Version=4.19.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.19.0\lib\net40\FluentAssertions.Core.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<Private>True</Private>
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll</HintPath>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentAssertions" version="4.19.0" targetFramework="net40" />
<package id="Moq" version="4.0.10827" targetFramework="net40" />
<package id="Moq" version="4.0.10827" />
<package id="NBuilder" version="4.0.0" targetFramework="net40" />
<package id="NUnit" version="3.6.0" targetFramework="net40" />
</packages>

View File

@@ -1,10 +1,9 @@
using Nancy;
using Nancy;
using System;
using System.Collections.Generic;
using System.Linq;
using Ical.Net;
using Ical.Net.DataTypes;
using Ical.Net.General;
using Ical.Net.Interfaces.Serialization;
using Ical.Net.Serialization;
using Ical.Net.Serialization.iCalendar.Factory;
@@ -93,9 +92,7 @@ namespace NzbDrone.Api.Calendar
ProductId = "-//sonarr.tv//Sonarr//EN"
};
var calendarName = "Sonarr TV Schedule";
calendar.AddProperty(new CalendarProperty("NAME", calendarName));
calendar.AddProperty(new CalendarProperty("X-WR-CALNAME", calendarName));
foreach (var episode in episodes.OrderBy(v => v.AirDateUtc.Value))
{
@@ -117,7 +114,7 @@ namespace NzbDrone.Api.Calendar
if (asAllDay)
{
occurrence.Start = new CalDateTime(episode.AirDateUtc.Value.ToLocalTime()) { HasTime = false };
occurrence.Start = new CalDateTime(episode.AirDateUtc.Value) { HasTime = false };
}
else
{

View File

@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System;
using Nancy;
using NzbDrone.Api.Episodes;
using NzbDrone.Api.Extensions;
using NzbDrone.Api.REST;
using NzbDrone.Api.Series;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine;
@@ -28,7 +25,6 @@ namespace NzbDrone.Api.History
_failedDownloadService = failedDownloadService;
GetResourcePaged = GetHistory;
Get["/since"] = x => GetHistorySince();
Post["/failed"] = x => MarkAsFailed();
}
@@ -68,27 +64,6 @@ namespace NzbDrone.Api.History
return ApplyToPage(_historyService.Paged, pagingSpec, MapToResource);
}
private List<HistoryResource> GetHistorySince()
{
var queryDate = Request.Query.Date;
var queryEventType = Request.Query.EventType;
if (!queryDate.HasValue)
{
throw new BadRequestException("date is missing");
}
DateTime date = DateTime.Parse(queryDate.Value);
HistoryEventType? eventType = null;
if (queryEventType.HasValue)
{
eventType = (HistoryEventType)Convert.ToInt32(queryEventType.Value);
}
return _historyService.Since(date, eventType).Select(MapToResource).ToList();
}
private Response MarkAsFailed()
{
var id = (int)Request.Form.Id;

View File

@@ -34,6 +34,7 @@ namespace NzbDrone.Api
RegisterPipelines(pipelines);
container.Resolve<DatabaseTarget>().Register();
container.Resolve<IEventAggregator>().PublishEvent(new ApplicationStartedEvent());
}
private void RegisterPipelines(IPipelines pipelines)
@@ -55,4 +56,4 @@ namespace NzbDrone.Api
protected override byte[] FavIcon => null;
}
}
}

View File

@@ -70,7 +70,7 @@
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="NodaTime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\Ical.Net.2.2.32\lib\net40\NodaTime.dll</HintPath>

View File

@@ -6,5 +6,5 @@
<package id="Nancy.Authentication.Basic" version="1.4.1" targetFramework="net40" />
<package id="Nancy.Authentication.Forms" version="1.4.1" targetFramework="net40" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
</packages>

View File

@@ -47,12 +47,8 @@
<Reference Include="FluentAssertions.Core, Version=4.19.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.19.0\lib\net40\FluentAssertions.Core.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll</HintPath>
@@ -62,6 +58,9 @@
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ContainerFixture.cs" />

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentAssertions" version="4.19.0" targetFramework="net40" />
<package id="Moq" version="4.0.10827" targetFramework="net40" />
<package id="Moq" version="4.0.10827" />
<package id="NBuilder" version="4.0.0" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="NUnit" version="3.6.0" targetFramework="net40" />
</packages>

View File

@@ -45,7 +45,7 @@
<HintPath>..\packages\FluentAssertions.4.19.0\lib\net40\FluentAssertions.Core.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll</HintPath>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentAssertions" version="4.19.0" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="NUnit" version="3.6.0" targetFramework="net40" />
<package id="Selenium.Support" version="3.2.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="3.2.0" targetFramework="net40" />

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Linq;
using Moq;
@@ -238,7 +238,7 @@ namespace NzbDrone.Common.Test.DiskTests
WithExistingFile(_targetPath);
Assert.Throws<DestinationAlreadyExistsException>(() => Subject.TransferFile(_sourcePath, _targetPath, TransferMode.Move, false));
Assert.Throws<IOException>(() => Subject.TransferFile(_sourcePath, _targetPath, TransferMode.Move, false));
Mocker.GetMock<IDiskProvider>()
.Verify(v => v.DeleteFile(_targetPath), Times.Never());

View File

@@ -43,12 +43,8 @@
<Reference Include="FluentAssertions.Core, Version=4.19.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.19.0\lib\net40\FluentAssertions.Core.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll</HintPath>
@@ -61,6 +57,9 @@
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CacheTests\CachedDictionaryFixture.cs" />

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentAssertions" version="4.19.0" targetFramework="net40" />
<package id="Moq" version="4.0.10827" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="Moq" version="4.0.10827" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="NUnit" version="3.6.0" targetFramework="net40" />
</packages>

View File

@@ -1,29 +0,0 @@
using System;
using System.IO;
using System.Runtime.Serialization;
namespace NzbDrone.Common.Disk
{
public class DestinationAlreadyExistsException : IOException
{
public DestinationAlreadyExistsException()
{
}
public DestinationAlreadyExistsException(string message) : base(message)
{
}
public DestinationAlreadyExistsException(string message, int hresult) : base(message, hresult)
{
}
public DestinationAlreadyExistsException(string message, Exception innerException) : base(message, innerException)
{
}
protected DestinationAlreadyExistsException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}

View File

@@ -1,11 +1,10 @@
using System;
using System;
using System.IO;
using System.Linq;
using System.Threading;
using NLog;
using NzbDrone.Common.EnsureThat;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Exceptions;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Common.Disk
@@ -341,7 +340,7 @@ namespace NzbDrone.Common.Disk
}
else
{
throw new DestinationAlreadyExistsException($"Destination {targetPath} already exists.");
throw new IOException(string.Format("Destination already exists. [{0}] to [{1}]", sourcePath, targetPath));
}
}
}

View File

@@ -1,6 +1,4 @@
using NzbDrone.Common.Exceptions;
namespace NzbDrone.Common.Disk
namespace NzbDrone.Common.Exceptions
{
public class NotParentException : NzbDroneException
{

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
@@ -59,7 +59,7 @@ namespace NzbDrone.Common.Extensions
{
if (!parentPath.IsParentPath(childPath))
{
throw new NotParentException("{0} is not a child of {1}", childPath, parentPath);
throw new Exceptions.NotParentException("{0} is not a child of {1}", childPath, parentPath);
}
return childPath.Substring(parentPath.Length).Trim(Path.DirectorySeparatorChar);

View File

@@ -44,7 +44,7 @@
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="Org.Mentalis, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DotNet4.SocksProxy.1.3.4.0\lib\net40\Org.Mentalis.dll</HintPath>
@@ -92,7 +92,6 @@
<Compile Include="EnvironmentInfo\IOsVersionAdapter.cs" />
<Compile Include="EnvironmentInfo\IPlatformInfo.cs" />
<Compile Include="EnvironmentInfo\OsVersionModel.cs" />
<Compile Include="Disk\DestinationAlreadyExistsException.cs" />
<Compile Include="Exceptions\SonarrStartupException.cs" />
<Compile Include="Extensions\DictionaryExtensions.cs" />
<Compile Include="Disk\OsPath.cs" />
@@ -126,7 +125,7 @@
<Compile Include="EnvironmentInfo\IRuntimeInfo.cs" />
<Compile Include="EnvironmentInfo\RuntimeInfo.cs" />
<Compile Include="EnvironmentInfo\StartupContext.cs" />
<Compile Include="Disk\NotParentException.cs" />
<Compile Include="Exceptions\NotParentException.cs" />
<Compile Include="Exceptions\NzbDroneException.cs" />
<Compile Include="Expansive\CircularReferenceException.cs" />
<Compile Include="Expansive\Expansive.cs" />

View File

@@ -3,6 +3,6 @@
<package id="DotNet4.SocksProxy" version="1.3.4.0" targetFramework="net40" />
<package id="ICSharpCode.SharpZipLib.Patched" version="0.86.5" targetFramework="net40" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="SharpRaven" version="2.2.0" targetFramework="net40" />
</packages>

View File

@@ -57,7 +57,7 @@ namespace NzbDrone.Console
private static void Exit(ExitCodes exitCode)
{
LogManager.Shutdown();
LogManager.Flush();
if (exitCode != ExitCodes.Normal)
{
@@ -80,6 +80,8 @@ namespace NzbDrone.Console
System.Console.ReadLine();
}
//Need this to terminate on mono (thanks nlog)
LogManager.Configuration = null;
Environment.Exit((int)exitCode);
}
}

View File

@@ -79,7 +79,7 @@
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@@ -3,6 +3,6 @@
<package id="Microsoft.Owin" version="2.1.0" targetFramework="net40" />
<package id="Microsoft.Owin.Hosting" version="2.1.0" targetFramework="net40" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="Owin" version="1.0" targetFramework="net40" />
</packages>

View File

@@ -8,7 +8,6 @@ using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.Download.Pending;
using NzbDrone.Core.Exceptions;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Profiles;
@@ -179,7 +178,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
}
[Test]
public void should_return_an_empty_list_when_none_are_approved()
public void should_return_an_empty_list_when_none_are_appproved()
{
var decisions = new List<DownloadDecision>();
decisions.Add(new DownloadDecision(null, new Rejection("Failure!")));
@@ -264,26 +263,5 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.Is<RemoteEpisode>(r => r.Release.DownloadProtocol == DownloadProtocol.Usenet)), Times.Once());
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.Is<RemoteEpisode>(r => r.Release.DownloadProtocol == DownloadProtocol.Torrent)), Times.Once());
}
[Test]
public void should_add_to_rejected_if_release_unavailable_on_indexer()
{
var episodes = new List<Episode> { GetEpisode(1) };
var remoteEpisode = GetRemoteEpisode(episodes, new QualityModel(Quality.HDTV720p));
var decisions = new List<DownloadDecision>();
decisions.Add(new DownloadDecision(remoteEpisode));
Mocker.GetMock<IDownloadService>()
.Setup(s => s.DownloadReport(It.IsAny<RemoteEpisode>()))
.Throws(new ReleaseUnavailableException(remoteEpisode.Release, "That 404 Error is not just a Quirk"));
var result = Subject.ProcessDecisions(decisions);
result.Grabbed.Should().BeEmpty();
result.Rejected.Should().NotBeEmpty();
ExceptionVerification.ExpectedWarns(1);
}
}
}

View File

@@ -7,11 +7,12 @@ using NzbDrone.Core.Download.Clients.DownloadStation;
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
using NzbDrone.Core.Download.Clients.DownloadStation.Responses;
namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
{
[TestFixture]
public class SerialNumberProviderFixture : CoreTest<SerialNumberProvider>
public class DSMInfoProviderFixture : CoreTest<DSMInfoProvider>
{
protected DownloadStationSettings _settings;
@@ -24,17 +25,27 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
private void GivenValidResponse()
{
Mocker.GetMock<IDSMInfoProxy>()
.Setup(d => d.GetSerialNumber(It.IsAny<DownloadStationSettings>()))
.Returns("serial");
.Setup(d => d.GetInfo(It.IsAny<DownloadStationSettings>()))
.Returns(new DSMInfoResponse() { SerialNumber = "serial", Version = "DSM 6.0.1" });
}
private void GivenInvalidResponse()
{
Mocker.GetMock<IDSMInfoProxy>()
.Setup(d => d.GetSerialNumber(It.IsAny<DownloadStationSettings>()))
.Setup(d => d.GetInfo(It.IsAny<DownloadStationSettings>()))
.Throws(new DownloadClientException("Serial response invalid"));
}
[Test]
public void should_return_version()
{
GivenValidResponse();
var version = Subject.GetDSMVersion(_settings);
version.Should().Be(new Version("6.0.1"));
}
[Test]
public void should_return_hashedserialnumber()
{
@@ -46,7 +57,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
serial.Should().Be("50DE66B735D30738618568294742FCF1DFA52A47");
Mocker.GetMock<IDSMInfoProxy>()
.Verify(d => d.GetSerialNumber(It.IsAny<DownloadStationSettings>()), Times.Once());
.Verify(d => d.GetInfo(It.IsAny<DownloadStationSettings>()), Times.Once());
}
[Test]
@@ -60,7 +71,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
serial2.Should().Be(serial1);
Mocker.GetMock<IDSMInfoProxy>()
.Verify(d => d.GetSerialNumber(It.IsAny<DownloadStationSettings>()), Times.Once());
.Verify(d => d.GetInfo(It.IsAny<DownloadStationSettings>()), Times.Once());
}
[Test]

View File

@@ -12,6 +12,7 @@ using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Test.Common;
using NzbDrone.Core.Download.Clients.DownloadStation.Responses;
namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
{
@@ -280,6 +281,21 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
.Returns(_downloadStationConfigItems);
}
protected void GivenApiVersions()
{
Mocker.GetMock<IDownloadStationTaskProxy>()
.Setup(s => s.GetApiInfo(It.IsAny<DownloadStationSettings>()))
.Returns(new DiskStationApiInfo() { Name = "Task", MinVersion = 1, MaxVersion = 2 });
Mocker.GetMock<IDownloadStationInfoProxy>()
.Setup(s => s.GetApiInfo(It.IsAny<DownloadStationSettings>()))
.Returns(new DiskStationApiInfo() { Name = "Info", MinVersion = 1, MaxVersion = 3 });
Mocker.GetMock<IFileStationProxy>()
.Setup(s => s.GetApiInfo(It.IsAny<DownloadStationSettings>()))
.Returns(new DiskStationApiInfo() { Name = "File", MinVersion = 1, MaxVersion = 2 });
}
protected void GivenSharedFolder()
{
Mocker.GetMock<ISharedFolderResolver>()
@@ -289,7 +305,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
protected void GivenSerialNumber()
{
Mocker.GetMock<ISerialNumberProvider>()
Mocker.GetMock<IDSMInfoProvider>()
.Setup(s => s.GetSerialNumber(It.IsAny<DownloadStationSettings>()))
.Returns(_serialNumber);
}
@@ -359,6 +375,26 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
return tasks.Count;
}
protected void GivenDSMVersion(string version)
{
Mocker.GetMock<IDSMInfoProvider>()
.Setup(d => d.GetDSMVersion(It.IsAny<DownloadStationSettings>()))
.Returns(new Version(version));
}
[TestCase("6.0.0", 0)]
[TestCase("5.0.0", 1)]
public void TestConnection_should_return_validation_failure_as_expected(string version, int count)
{
GivenApiVersions();
GivenDSMVersion(version);
var result = Subject.Test();
result.Errors.Should().HaveCount(count);
}
[Test]
public void Download_with_TvDirectory_should_force_directory()
{
@@ -460,7 +496,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
[Test]
public void GetItems_should_throw_if_serial_number_unavailable()
{
Mocker.GetMock<ISerialNumberProvider>()
Mocker.GetMock<IDSMInfoProvider>()
.Setup(s => s.GetSerialNumber(_settings))
.Throws(new ApplicationException("Some unknown exception, HttpException or DownloadClientException"));
@@ -476,7 +512,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
{
var remoteEpisode = CreateRemoteEpisode();
Mocker.GetMock<ISerialNumberProvider>()
Mocker.GetMock<IDSMInfoProvider>()
.Setup(s => s.GetSerialNumber(_settings))
.Throws(new ApplicationException("Some unknown exception, HttpException or DownloadClientException"));

View File

@@ -182,6 +182,21 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
.Returns(_downloadStationConfigItems);
}
protected void GivenApiVersions()
{
Mocker.GetMock<IDownloadStationTaskProxy>()
.Setup(s => s.GetApiInfo(It.IsAny<DownloadStationSettings>()))
.Returns(new DiskStationApiInfo() { Name = "Task", MinVersion = 1, MaxVersion = 2 });
Mocker.GetMock<IDownloadStationInfoProxy>()
.Setup(s => s.GetApiInfo(It.IsAny<DownloadStationSettings>()))
.Returns(new DiskStationApiInfo() { Name = "Info", MinVersion = 1, MaxVersion = 3 });
Mocker.GetMock<IFileStationProxy>()
.Setup(s => s.GetApiInfo(It.IsAny<DownloadStationSettings>()))
.Returns(new DiskStationApiInfo() { Name = "File", MinVersion = 1, MaxVersion = 2 });
}
protected void GivenSharedFolder()
{
Mocker.GetMock<ISharedFolderResolver>()
@@ -191,7 +206,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
protected void GivenSerialNumber()
{
Mocker.GetMock<ISerialNumberProvider>()
Mocker.GetMock<IDSMInfoProvider>()
.Setup(s => s.GetSerialNumber(It.IsAny<DownloadStationSettings>()))
.Returns(_serialNumber);
}
@@ -245,6 +260,25 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Mocker.GetMock<IDownloadStationTaskProxy>()
.Setup(d => d.GetTasks(_settings))
.Returns(tasks);
}
protected void GivenDSMVersion(string version)
{
Mocker.GetMock<IDSMInfoProvider>()
.Setup(d => d.GetDSMVersion(It.IsAny<DownloadStationSettings>()))
.Returns(new Version(version));
}
[TestCase("6.0.0", 0)]
[TestCase("5.0.0", 1)]
public void TestConnection_should_return_validation_failure_as_expected(string version, int count)
{
GivenApiVersions();
GivenDSMVersion(version);
var result = Subject.Test();
result.Errors.Should().HaveCount(count);
}
[Test]
@@ -348,7 +382,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
[Test]
public void GetItems_should_throw_if_serial_number_unavailable()
{
Mocker.GetMock<ISerialNumberProvider>()
Mocker.GetMock<IDSMInfoProvider>()
.Setup(s => s.GetSerialNumber(_settings))
.Throws(new ApplicationException("Some unknown exception, HttpException or DownloadClientException"));
@@ -364,7 +398,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
{
var remoteEpisode = CreateRemoteEpisode();
Mocker.GetMock<ISerialNumberProvider>()
Mocker.GetMock<IDSMInfoProvider>()
.Setup(s => s.GetSerialNumber(_settings))
.Throws(new ApplicationException("Some unknown exception, HttpException or DownloadClientException"));

View File

@@ -180,21 +180,6 @@ namespace NzbDrone.Core.Test.Download
.Verify(v => v.RecordFailure(It.IsAny<int>(), It.IsAny<TimeSpan>()), Times.Never());
}
[Test]
public void Download_report_should_not_trigger_indexer_backoff_on_indexer_404_error()
{
var mock = WithUsenetClient();
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>()))
.Callback<RemoteEpisode>(v => {
throw new ReleaseUnavailableException(v.Release, "Error", new WebException());
});
Assert.Throws<ReleaseUnavailableException>(() => Subject.DownloadReport(_parseResult));
Mocker.GetMock<IIndexerStatusService>()
.Verify(v => v.RecordFailure(It.IsAny<int>(), It.IsAny<TimeSpan>()), Times.Never());
}
[Test]
public void should_not_attempt_download_if_client_isnt_configured()
{

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using Marr.Data;
using Moq;
@@ -27,7 +26,6 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
private ReleaseInfo _release;
private ParsedEpisodeInfo _parsedEpisodeInfo;
private RemoteEpisode _remoteEpisode;
private List<PendingRelease> _heldReleases;
[SetUp]
public void Setup()
@@ -62,27 +60,17 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
_remoteEpisode.Series = _series;
_remoteEpisode.ParsedEpisodeInfo = _parsedEpisodeInfo;
_remoteEpisode.Release = _release;
_temporarilyRejected = new DownloadDecision(_remoteEpisode, new Rejection("Temp Rejected", RejectionType.Temporary));
_heldReleases = new List<PendingRelease>();
Mocker.GetMock<IPendingReleaseRepository>()
.Setup(s => s.All())
.Returns(_heldReleases);
Mocker.GetMock<IPendingReleaseRepository>()
.Setup(s => s.AllBySeriesId(It.IsAny<int>()))
.Returns<int>(i => _heldReleases.Where(v => v.SeriesId == i).ToList());
.Returns(new List<PendingRelease>());
Mocker.GetMock<ISeriesService>()
.Setup(s => s.GetSeries(It.IsAny<int>()))
.Returns(_series);
Mocker.GetMock<ISeriesService>()
.Setup(s => s.GetSeries(It.IsAny<IEnumerable<int>>()))
.Returns(new List<Series> { _series });
Mocker.GetMock<IParsingService>()
.Setup(s => s.GetEpisodes(It.IsAny<ParsedEpisodeInfo>(), _series, true, null))
.Returns(new List<Episode> {_episode});
@@ -92,7 +80,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
.Returns((List<DownloadDecision> d) => d);
}
private void GivenHeldRelease(string title, string indexer, DateTime publishDate, PendingReleaseReason reason = PendingReleaseReason.Delay)
private void GivenHeldRelease(string title, string indexer, DateTime publishDate)
{
var release = _release.JsonClone();
release.Indexer = indexer;
@@ -104,10 +92,11 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
.With(h => h.SeriesId = _series.Id)
.With(h => h.Title = title)
.With(h => h.Release = release)
.With(h => h.Reason = reason)
.Build();
_heldReleases.AddRange(heldReleases);
Mocker.GetMock<IPendingReleaseRepository>()
.Setup(s => s.All())
.Returns(heldReleases);
}
[Test]
@@ -128,29 +117,6 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
VerifyNoInsert();
}
[Test]
public void should_not_add_if_it_is_the_same_release_from_the_same_indexer_twice()
{
GivenHeldRelease(_release.Title, _release.Indexer, _release.PublishDate, PendingReleaseReason.DownloadClientUnavailable);
GivenHeldRelease(_release.Title, _release.Indexer, _release.PublishDate, PendingReleaseReason.Fallback);
Subject.Add(_temporarilyRejected, PendingReleaseReason.Delay);
VerifyNoInsert();
}
[Test]
public void should_remove_duplicate_if_it_is_the_same_release_from_the_same_indexer_twice()
{
GivenHeldRelease(_release.Title, _release.Indexer, _release.PublishDate, PendingReleaseReason.DownloadClientUnavailable);
GivenHeldRelease(_release.Title, _release.Indexer, _release.PublishDate, PendingReleaseReason.Fallback);
Subject.Add(_temporarilyRejected, PendingReleaseReason.Fallback);
Mocker.GetMock<IPendingReleaseRepository>()
.Verify(v => v.Delete(It.IsAny<int>()), Times.Once());
}
[Test]
public void should_add_if_title_is_different()
{

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using Marr.Data;
using Moq;
@@ -27,7 +26,6 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
private ReleaseInfo _release;
private ParsedEpisodeInfo _parsedEpisodeInfo;
private RemoteEpisode _remoteEpisode;
private List<PendingRelease> _heldReleases;
[SetUp]
public void Setup()
@@ -62,27 +60,17 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
_remoteEpisode.Series = _series;
_remoteEpisode.ParsedEpisodeInfo = _parsedEpisodeInfo;
_remoteEpisode.Release = _release;
_temporarilyRejected = new DownloadDecision(_remoteEpisode, new Rejection("Temp Rejected", RejectionType.Temporary));
_heldReleases = new List<PendingRelease>();
Mocker.GetMock<IPendingReleaseRepository>()
.Setup(s => s.All())
.Returns(_heldReleases);
Mocker.GetMock<IPendingReleaseRepository>()
.Setup(s => s.AllBySeriesId(It.IsAny<int>()))
.Returns<int>(i => _heldReleases.Where(v => v.SeriesId == i).ToList());
.Returns(new List<PendingRelease>());
Mocker.GetMock<ISeriesService>()
.Setup(s => s.GetSeries(It.IsAny<int>()))
.Returns(_series);
Mocker.GetMock<ISeriesService>()
.Setup(s => s.GetSeries(It.IsAny<IEnumerable<int>>()))
.Returns(new List<Series> { _series });
Mocker.GetMock<IParsingService>()
.Setup(s => s.GetEpisodes(It.IsAny<ParsedEpisodeInfo>(), _series, true, null))
.Returns(new List<Episode> {_episode});
@@ -104,7 +92,9 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
.With(h => h.ParsedEpisodeInfo = parsedEpisodeInfo)
.Build();
_heldReleases.AddRange(heldReleases);
Mocker.GetMock<IPendingReleaseRepository>()
.Setup(s => s.All())
.Returns(heldReleases);
}
[Test]

View File

@@ -38,10 +38,6 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
.Setup(s => s.GetSeries(It.IsAny<int>()))
.Returns(new Series());
Mocker.GetMock<ISeriesService>()
.Setup(s => s.GetSeries(It.IsAny<IEnumerable<int>>()))
.Returns(new List<Series> { new Series() });
Mocker.GetMock<IParsingService>()
.Setup(s => s.GetEpisodes(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<Series>(), It.IsAny<bool>(), null))
.Returns(new List<Episode>{ _episode });
@@ -67,7 +63,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
AssertRemoved(1);
}
[Test]
public void should_remove_multiple_releases_release()
{
@@ -138,7 +134,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
AssertRemoved(2);
}
private void AssertRemoved(params int[] ids)
{
Mocker.GetMock<IPendingReleaseRepository>().Verify(c => c.DeleteMany(It.Is<IEnumerable<int>>(s => s.SequenceEqual(ids))));

View File

@@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
_remoteEpisode.Series = _series;
_remoteEpisode.ParsedEpisodeInfo = _parsedEpisodeInfo;
_remoteEpisode.Release = _release;
_temporarilyRejected = new DownloadDecision(_remoteEpisode, new Rejection("Temp Rejected", RejectionType.Temporary));
Mocker.GetMock<IPendingReleaseRepository>()
@@ -73,10 +73,6 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
.Setup(s => s.GetSeries(It.IsAny<int>()))
.Returns(_series);
Mocker.GetMock<ISeriesService>()
.Setup(s => s.GetSeries(It.IsAny<IEnumerable<int>>()))
.Returns(new List<Series> { _series });
Mocker.GetMock<IParsingService>()
.Setup(s => s.GetEpisodes(It.IsAny<ParsedEpisodeInfo>(), _series, true, null))
.Returns(new List<Episode> {_episode});

View File

@@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
Mocker.GetMock<IIndexerStatusRepository>()
.Verify(v => v.UpdateMany(
It.Is<List<IndexerStatus>>(i => i.All(
s => s.InitialFailure.Value <= DateTime.UtcNow))
s => s.InitialFailure.Value < DateTime.UtcNow))
)
);
}
@@ -85,7 +85,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
Mocker.GetMock<IIndexerStatusRepository>()
.Verify(v => v.UpdateMany(
It.Is<List<IndexerStatus>>(i => i.All(
s => s.MostRecentFailure.Value <= DateTime.UtcNow))
s => s.MostRecentFailure.Value < DateTime.UtcNow))
)
);
}
@@ -116,4 +116,4 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
}
}
}

View File

@@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
_quality = new QualityModel(Quality.DVD);
_localEpisode = new LocalEpisode
{
{
Series = _series,
Quality = _quality,
Episodes = new List<Episode> { new Episode() },
@@ -231,7 +231,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
Mocker.GetMock<IParsingService>()
.Setup(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), It.IsAny<bool>()))
.Returns(new LocalEpisode() { Path = "test", ParsedEpisodeInfo = new ParsedEpisodeInfo { } });
.Returns(new LocalEpisode() { Path = "test" });
_videoFiles = new List<string>
{

View File

@@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
.All()
.With(v => v.RelativePath = "media.mkv")
.TheFirst(1)
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = VideoFileInfoReader.CURRENT_MEDIA_INFO_SCHEMA_REVISION })
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = UpdateMediaInfoService.CURRENT_MEDIA_INFO_SCHEMA_REVISION })
.BuildList();
Mocker.GetMock<IMediaFileService>()
@@ -86,7 +86,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
.All()
.With(v => v.RelativePath = "media.mkv")
.TheFirst(1)
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = VideoFileInfoReader.MINIMUM_MEDIA_INFO_SCHEMA_REVISION })
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = UpdateMediaInfoService.MINIMUM_MEDIA_INFO_SCHEMA_REVISION })
.BuildList();
Mocker.GetMock<IMediaFileService>()

View File

@@ -1,4 +1,4 @@
using System.IO;
using System.IO;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
@@ -7,7 +7,6 @@ using Moq;
using NUnit.Framework;
using NzbDrone.Common.Disk;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.EpisodeImport;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
@@ -34,16 +33,12 @@ namespace NzbDrone.Core.Test.MediaFiles
.Build();
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.FolderExists(Directory.GetParent(_localEpisode.Series.Path).FullName))
.Returns(true);
.Setup(c => c.FileExists(It.IsAny<string>()))
.Returns(true);
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.FileExists(It.IsAny<string>()))
.Returns(true);
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.GetParentFolder(It.IsAny<string>()))
.Returns<string>(c => Path.GetDirectoryName(c));
.Setup(c => c.GetParentFolder(It.IsAny<string>()))
.Returns<string>(c => Path.GetDirectoryName(c));
}
private void GivenSingleEpisodeWithSingleEpisodeFile()
@@ -180,19 +175,5 @@ namespace NzbDrone.Core.Test.MediaFiles
Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode).OldFiles.Count.Should().Be(2);
}
[Test]
public void should_throw_if_there_are_existing_episode_files_and_the_root_folder_is_missing()
{
GivenSingleEpisodeWithSingleEpisodeFile();
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.FolderExists(Directory.GetParent(_localEpisode.Series.Path).FullName))
.Returns(false);
Assert.Throws<RootFolderNotFoundException>(() => Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode));
Mocker.GetMock<IMediaFileService>().Verify(v => v.Delete(_localEpisode.Episodes.Single().EpisodeFile.Value, DeleteMediaFileReason.Upgrade), Times.Never());
}
}
}

View File

@@ -35,15 +35,6 @@ namespace NzbDrone.Core.Test.Messaging.Commands
.Returns(_executorB.Object);
}
[TearDown]
public void TearDown()
{
Subject.Handle(new ApplicationShutdownRequested());
// Give the threads a bit of time to shut down.
Thread.Sleep(10);
}
private void GivenCommandQueue()
{
_commandQueue = new BlockingCollection<CommandModel>(new CommandQueue());
@@ -53,10 +44,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands
.Returns(_commandQueue.GetConsumingEnumerable);
}
private void QueueAndWaitForExecution(CommandModel commandModel)
private void WaitForExecution(CommandModel commandModel)
{
Thread.Sleep(10);
Mocker.GetMock<IManageCommandQueue>()
.Setup(s => s.Complete(It.Is<CommandModel>(c => c == commandModel), It.IsAny<string>()))
.Callback(() => _commandExecuted = true);
@@ -65,14 +54,12 @@ namespace NzbDrone.Core.Test.Messaging.Commands
.Setup(s => s.Fail(It.Is<CommandModel>(c => c == commandModel), It.IsAny<string>(), It.IsAny<Exception>()))
.Callback(() => _commandExecuted = true);
_commandQueue.Add(commandModel);
while (!_commandExecuted)
{
Thread.Sleep(100);
}
Thread.Sleep(10);
var t1 = 1;
}
[Test]
@@ -95,8 +82,9 @@ namespace NzbDrone.Core.Test.Messaging.Commands
};
Subject.Handle(new ApplicationStartedEvent());
_commandQueue.Add(commandModel);
QueueAndWaitForExecution(commandModel);
WaitForExecution(commandModel);
_executorA.Verify(c => c.Execute(commandA), Times.Once());
}
@@ -112,8 +100,9 @@ namespace NzbDrone.Core.Test.Messaging.Commands
};
Subject.Handle(new ApplicationStartedEvent());
_commandQueue.Add(commandModel);
QueueAndWaitForExecution(commandModel);
WaitForExecution(commandModel);
_executorA.Verify(c => c.Execute(commandA), Times.Once());
_executorB.Verify(c => c.Execute(It.IsAny<CommandB>()), Times.Never());
@@ -133,8 +122,9 @@ namespace NzbDrone.Core.Test.Messaging.Commands
.Throws(new NotImplementedException());
Subject.Handle(new ApplicationStartedEvent());
_commandQueue.Add(commandModel);
QueueAndWaitForExecution(commandModel);
WaitForExecution(commandModel);
VerifyEventPublished<CommandExecutedEvent>();
ExceptionVerification.ExpectedErrors(1);
@@ -151,8 +141,9 @@ namespace NzbDrone.Core.Test.Messaging.Commands
};
Subject.Handle(new ApplicationStartedEvent());
_commandQueue.Add(commandModel);
QueueAndWaitForExecution(commandModel);
WaitForExecution(commandModel);
VerifyEventPublished<CommandExecutedEvent>();
}
@@ -168,8 +159,9 @@ namespace NzbDrone.Core.Test.Messaging.Commands
};
Subject.Handle(new ApplicationStartedEvent());
_commandQueue.Add(commandModel);
QueueAndWaitForExecution(commandModel);
WaitForExecution(commandModel);
Mocker.GetMock<IManageCommandQueue>()
.Setup(s => s.Complete(It.Is<CommandModel>(c => c == commandModel), commandA.CompletionMessage))
@@ -188,8 +180,9 @@ namespace NzbDrone.Core.Test.Messaging.Commands
};
Subject.Handle(new ApplicationStartedEvent());
_commandQueue.Add(commandModel);
QueueAndWaitForExecution(commandModel);
WaitForExecution(commandModel);
Mocker.GetMock<IManageCommandQueue>()
.Setup(s => s.Complete(It.Is<CommandModel>(c => c == commandModel), commandModel.Message))
@@ -209,10 +202,10 @@ namespace NzbDrone.Core.Test.Messaging.Commands
public CommandB()
{
}
public override string CompletionMessage => null;
}
}
}

View File

@@ -77,10 +77,6 @@
<HintPath>..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Configuration.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NCrunch.Framework, Version=3.2.0.3, Culture=neutral, PublicKeyToken=01d101bf6f3e0aea, processorArchitecture=MSIL">
<HintPath>..\packages\NCrunch.Framework.3.2.0.3\lib\NCrunch.Framework.dll</HintPath>
<Private>True</Private>
@@ -90,7 +86,7 @@
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll</HintPath>
@@ -101,6 +97,9 @@
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
<Reference Include="Prowlin">
<HintPath>..\packages\Prowlin.0.9.4456.26422\lib\net40\Prowlin.dll</HintPath>
</Reference>
@@ -177,7 +176,7 @@
<Compile Include="Download\DownloadClientTests\DelugeTests\DelugeFixture.cs" />
<Compile Include="Download\DownloadClientTests\DownloadClientFixtureBase.cs" />
<Compile Include="Download\DownloadClientTests\DownloadStationTests\TorrentDownloadStationFixture.cs" />
<Compile Include="Download\DownloadClientTests\DownloadStationTests\SerialNumberProviderFixture.cs" />
<Compile Include="Download\DownloadClientTests\DownloadStationTests\DSMInfoProviderFixture.cs" />
<Compile Include="Download\DownloadClientTests\DownloadStationTests\SharedFolderResolverFixture.cs" />
<Compile Include="Download\DownloadClientTests\DownloadStationTests\UsenetDownloadStationFixture.cs" />
<Compile Include="Download\DownloadClientTests\HadoukenTests\HadoukenFixture.cs" />

View File

@@ -6,10 +6,10 @@
<package id="FluentMigrator" version="1.6.2" targetFramework="net40" />
<package id="FluentMigrator.Runner" version="1.6.2" targetFramework="net40" />
<package id="FluentValidation" version="6.2.1.0" targetFramework="net40" />
<package id="Moq" version="4.0.10827" targetFramework="net40" />
<package id="Moq" version="4.0.10827" />
<package id="NBuilder" version="4.0.0" targetFramework="net40" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="NUnit" version="3.6.0" targetFramework="net40" />
<package id="Prowlin" version="0.9.4456.26422" targetFramework="net40" />
<package id="Unity" version="2.1.505.2" targetFramework="net40" />

View File

@@ -1,14 +0,0 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(118)]
public class add_history_eventType_index : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Create.Index().OnTable("History").OnColumn("EventType");
}
}
}

View File

@@ -81,7 +81,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
var episodeIds = subject.Episodes.Select(e => e.Id);
var oldest = _pendingReleaseService.OldestPendingRelease(subject.Series.Id, episodeIds.ToArray());
var oldest = _pendingReleaseService.OldestPendingRelease(subject.Series.Id, episodeIds);
if (oldest != null && oldest.Release.AgeMinutes > delay)
{

View File

@@ -0,0 +1,62 @@
using System;
using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Crypto;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
using NzbDrone.Core.Download.Clients.DownloadStation.Responses;
namespace NzbDrone.Core.Download.Clients.DownloadStation
{
public interface IDSMInfoProvider
{
string GetSerialNumber(DownloadStationSettings settings);
Version GetDSMVersion(DownloadStationSettings settings);
}
public class DSMInfoProvider : IDSMInfoProvider
{
private readonly IDSMInfoProxy _proxy;
private ICached<DSMInfoResponse> _cache;
private readonly ILogger _logger;
public DSMInfoProvider(ICacheManager cacheManager,
IDSMInfoProxy proxy,
Logger logger)
{
_proxy = proxy;
_cache = cacheManager.GetCache<DSMInfoResponse>(GetType());
_logger = logger;
}
private DSMInfoResponse GetInfo(DownloadStationSettings settings)
{
return _cache.Get(settings.Host, () => _proxy.GetInfo(settings), TimeSpan.FromMinutes(5));
}
public string GetSerialNumber(DownloadStationSettings settings)
{
try
{
return HashConverter.GetHash(GetInfo(settings).SerialNumber).ToHexString();
}
catch (Exception ex)
{
_logger.Warn(ex, "Could not get the serial number from Download Station {0}:{1}", settings.Host, settings.Port);
throw;
}
}
public Version GetDSMVersion(DownloadStationSettings settings)
{
var info = GetInfo(settings);
Regex regex = new Regex(@"DSM (?<version>[\d.]*)");
var dsmVersion = regex.Match(info.Version).Groups["version"].Value;
return new Version(dsmVersion);
}
}
}

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

View File

@@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace NzbDrone.Core.Download.Clients.DownloadStation
{

View File

@@ -1,10 +1,5 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static NzbDrone.Core.Download.Clients.DownloadStation.DownloadStationTask;
namespace NzbDrone.Core.Download.Clients.DownloadStation
{

View File

@@ -1,15 +1,13 @@
using System;
using System.Collections.Generic;
using NLog;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Http;
using NzbDrone.Core.Download.Clients.DownloadStation.Responses;
namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{
public interface IDSMInfoProxy
public interface IDSMInfoProxy : IDiskStationProxy
{
string GetSerialNumber(DownloadStationSettings settings);
DSMInfoResponse GetInfo(DownloadStationSettings settings);
}
public class DSMInfoProxy : DiskStationProxyBase, IDSMInfoProxy
@@ -19,15 +17,15 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{
}
public string GetSerialNumber(DownloadStationSettings settings)
public DSMInfoResponse GetInfo(DownloadStationSettings settings)
{
var info = GetApiInfo(settings);
var requestBuilder = BuildRequest(settings, "getinfo", info.MinVersion);
var response = ProcessRequest<DSMInfoResponse>(requestBuilder, "get serial number", settings);
var response = ProcessRequest<DSMInfoResponse>(requestBuilder, "get info", settings);
return response.Data.SerialNumber;
return response.Data;
}
}
}

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using NLog;
using NzbDrone.Common.Cache;
@@ -161,7 +160,9 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{
if (apiInfo.NeedsAuthentication)
{
requestBuilder.AddFormParameter("_sid", _sessionCache.Get(GenerateSessionCacheKey(settings), () => AuthenticateClient(settings), TimeSpan.FromHours(6)));
var sid = _sessionCache.Get(GenerateSessionCacheKey(settings), () => AuthenticateClient(settings), TimeSpan.FromHours(6));
_logger.Debug("DownloadStation Session sid={0}", sid);
requestBuilder.AddFormParameter("_sid", sid);
}
requestBuilder.AddFormParameter("api", apiInfo.Name);
@@ -172,7 +173,9 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{
if (apiInfo.NeedsAuthentication)
{
requestBuilder.AddQueryParam("_sid", _sessionCache.Get(GenerateSessionCacheKey(settings), () => AuthenticateClient(settings), TimeSpan.FromHours(6)));
var sid = _sessionCache.Get(GenerateSessionCacheKey(settings), () => AuthenticateClient(settings), TimeSpan.FromHours(6));
_logger.Debug("DownloadStation Session sid={0}", sid);
requestBuilder.AddQueryParam("_sid", sid);
}
requestBuilder.AddQueryParam("api", apiInfo.Name);

View File

@@ -1,7 +1,7 @@
using NLog;
using NzbDrone.Common.Http;
using System.Collections.Generic;
using System.Collections.Generic;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Http;
namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{

View File

@@ -0,0 +1,8 @@
namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{
public class ExpectedVersion
{
public int Version { get; set; }
public IDiskStationProxy Proxy { get; set; }
}
}

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Common.Cache;
@@ -18,11 +17,17 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
public class FileStationProxy : DiskStationProxyBase, IFileStationProxy
{
public FileStationProxy(IHttpClient httpClient, ICacheManager cacheManager, Logger logger)
private IDSMInfoProvider _dsmInfoProvider;
public FileStationProxy(IDSMInfoProvider dsmInfoProvider,
IHttpClient httpClient,
ICacheManager cacheManager,
Logger logger)
: base(DiskStationApi.FileStationList, "SYNO.FileStation.List", httpClient, cacheManager, logger)
{
_dsmInfoProvider = dsmInfoProvider;
}
public SharedFolderMapping GetSharedFolderMapping(string sharedFolder, DownloadStationSettings settings)
{
var info = GetInfoFileOrDirectory(sharedFolder, settings);
@@ -34,13 +39,16 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
public FileStationListFileInfoResponse GetInfoFileOrDirectory(string path, DownloadStationSettings settings)
{
var requestBuilder = BuildRequest(settings, "getinfo", 2);
var dsmVersion = _dsmInfoProvider.GetDSMVersion(settings);
var requestBuilder = BuildRequest(settings, "getinfo", dsmVersion >= new Version(6, 0, 0) ? 2 : 1);
requestBuilder.AddQueryParam("path", new[] { path }.ToJson());
requestBuilder.AddQueryParam("additional", "[\"real_path\"]");
var response = ProcessRequest<FileStationListResponse>(requestBuilder, $"get info of {path}", settings);
return response.Data.Files.First();
}
}
}

View File

@@ -6,5 +6,8 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Responses
{
[JsonProperty("serial")]
public string SerialNumber { get; set; }
[JsonProperty("version_string")]
public string Version { get; set; }
}
}

View File

@@ -1,49 +0,0 @@
using System;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Crypto;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
namespace NzbDrone.Core.Download.Clients.DownloadStation
{
public interface ISerialNumberProvider
{
string GetSerialNumber(DownloadStationSettings settings);
}
public class SerialNumberProvider : ISerialNumberProvider
{
private readonly IDSMInfoProxy _proxy;
private ICached<string> _cache;
private readonly ILogger _logger;
public SerialNumberProvider(ICacheManager cacheManager,
IDSMInfoProxy proxy,
Logger logger)
{
_proxy = proxy;
_cache = cacheManager.GetCache<string>(GetType());
_logger = logger;
}
public string GetSerialNumber(DownloadStationSettings settings)
{
try
{
return _cache.Get(settings.Host, () => GetHashedSerialNumber(settings), TimeSpan.FromMinutes(5));
}
catch (Exception ex)
{
_logger.Warn(ex, "Could not get the serial number from Download Station {0}:{1}", settings.Host, settings.Port);
throw;
}
}
private string GetHashedSerialNumber(DownloadStationSettings settings)
{
var serialNumber = _proxy.GetSerialNumber(settings);
return HashConverter.GetHash(serialNumber).ToHexString();
}
}
}

View File

@@ -22,11 +22,11 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
protected readonly IDownloadStationInfoProxy _dsInfoProxy;
protected readonly IDownloadStationTaskProxy _dsTaskProxy;
protected readonly ISharedFolderResolver _sharedFolderResolver;
protected readonly ISerialNumberProvider _serialNumberProvider;
protected readonly IDSMInfoProvider _dsmInfoProvider;
protected readonly IFileStationProxy _fileStationProxy;
public TorrentDownloadStation(ISharedFolderResolver sharedFolderResolver,
ISerialNumberProvider serialNumberProvider,
IDSMInfoProvider dsmInfoProvider,
IFileStationProxy fileStationProxy,
IDownloadStationInfoProxy dsInfoProxy,
IDownloadStationTaskProxy dsTaskProxy,
@@ -42,7 +42,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
_dsTaskProxy = dsTaskProxy;
_fileStationProxy = fileStationProxy;
_sharedFolderResolver = sharedFolderResolver;
_serialNumberProvider = serialNumberProvider;
_dsmInfoProvider = dsmInfoProvider;
}
public override string Name => "Download Station";
@@ -55,7 +55,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
public override IEnumerable<DownloadClientItem> GetItems()
{
var torrents = GetTasks();
var serialNumber = _serialNumberProvider.GetSerialNumber(Settings);
var serialNumber = _dsmInfoProvider.GetSerialNumber(Settings);
var items = new List<DownloadClientItem>();
@@ -149,7 +149,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink)
{
var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings);
var hashedSerialNumber = _dsmInfoProvider.GetSerialNumber(Settings);
_dsTaskProxy.AddTaskFromUrl(magnetLink, GetDownloadDirectory(), Settings);
@@ -168,7 +168,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent)
{
var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings);
var hashedSerialNumber = _dsmInfoProvider.GetSerialNumber(Settings);
_dsTaskProxy.AddTaskFromData(fileContent, filename, GetDownloadDirectory(), Settings);
@@ -191,6 +191,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
failures.AddIfNotNull(TestConnection());
if (failures.Any()) return;
failures.AddIfNotNull(TestDSMVersion());
failures.AddIfNotNull(TestOutputPath());
failures.AddIfNotNull(TestGetTorrents());
}
@@ -303,7 +304,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
return new NzbDroneValidationFailure(fieldName, $"Shared folder does not exist")
{
DetailedDescription = $"The Diskstation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?"
DetailedDescription = $"The Diskstation does not have a Shared Folder with the name '{downloadDir}', are you sure you specified it correctly?"
};
}
@@ -334,7 +335,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
try
{
return ValidateVersion();
return TestProxiesVersions();
}
catch (DownloadClientAuthenticationException ex)
{
@@ -363,16 +364,40 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return new NzbDroneValidationFailure(string.Empty, $"Unknown exception: {ex.Message}");
}
}
protected ValidationFailure ValidateVersion()
protected ValidationFailure TestDSMVersion()
{
var info = _dsTaskProxy.GetApiInfo(Settings);
var dsmversion = _dsmInfoProvider.GetDSMVersion(Settings);
_logger.Debug("Download Station api version information: Min {0} - Max {1}", info.MinVersion, info.MaxVersion);
if (info.MinVersion > 2 || info.MaxVersion < 2)
if (dsmversion < new Version(6, 0, 0))
{
return new ValidationFailure(string.Empty, $"Download Station API version not supported, should be at least 2. It supports from {info.MinVersion} to {info.MaxVersion}");
return new NzbDroneValidationFailure(string.Empty, $"DSM Version {dsmversion} not fully supported. We recommend version 6.0.0 or above.") { IsWarning = true };
}
return null;
}
protected ValidationFailure TestProxiesVersions()
{
var dsmVersion = _dsmInfoProvider.GetDSMVersion(Settings);
var expectedVersions = new List<ExpectedVersion>()
{
new ExpectedVersion { Version = 2, Proxy = _dsTaskProxy },
new ExpectedVersion { Version = (dsmVersion >= new Version(6,0,0))? 2 : 1, Proxy = _fileStationProxy },
new ExpectedVersion { Version = 1, Proxy = _dsInfoProxy }
};
foreach (var expectedVersion in expectedVersions)
{
DiskStationApiInfo apiInfo = expectedVersion.Proxy.GetApiInfo(Settings);
_logger.Debug("{1} api version information: Min {1} - Max {2} - Expected {3}", apiInfo.Name, apiInfo.MinVersion, apiInfo.MaxVersion, expectedVersion.Version);
if (apiInfo.MinVersion > expectedVersion.Version || apiInfo.MaxVersion < expectedVersion.Version)
{
return new NzbDroneValidationFailure(string.Empty, $"{apiInfo.Name} API version not supported, should be at least {expectedVersion.Version}. It supports from {apiInfo.MinVersion} to {apiInfo.MaxVersion}");
}
}
return null;

View File

@@ -20,11 +20,11 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
protected readonly IDownloadStationInfoProxy _dsInfoProxy;
protected readonly IDownloadStationTaskProxy _dsTaskProxy;
protected readonly ISharedFolderResolver _sharedFolderResolver;
protected readonly ISerialNumberProvider _serialNumberProvider;
protected readonly IDSMInfoProvider _dsmInfoProvider;
protected readonly IFileStationProxy _fileStationProxy;
public UsenetDownloadStation(ISharedFolderResolver sharedFolderResolver,
ISerialNumberProvider serialNumberProvider,
IDSMInfoProvider dsmInfoProvider,
IFileStationProxy fileStationProxy,
IDownloadStationInfoProxy dsInfoProxy,
IDownloadStationTaskProxy dsTaskProxy,
@@ -40,7 +40,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
_dsTaskProxy = dsTaskProxy;
_fileStationProxy = fileStationProxy;
_sharedFolderResolver = sharedFolderResolver;
_serialNumberProvider = serialNumberProvider;
_dsmInfoProvider = dsmInfoProvider;
}
public override string Name => "Download Station";
@@ -53,7 +53,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
public override IEnumerable<DownloadClientItem> GetItems()
{
var nzbTasks = GetTasks();
var serialNumber = _serialNumberProvider.GetSerialNumber(Settings);
var serialNumber = _dsmInfoProvider.GetSerialNumber(Settings);
var items = new List<DownloadClientItem>();
@@ -163,7 +163,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent)
{
var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings);
var hashedSerialNumber = _dsmInfoProvider.GetSerialNumber(Settings);
_dsTaskProxy.AddTaskFromData(fileContent, filename, GetDownloadDirectory(), Settings);
@@ -186,6 +186,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
failures.AddIfNotNull(TestConnection());
if (failures.Any()) return;
failures.AddIfNotNull(TestDSMVersion());
failures.AddIfNotNull(TestOutputPath());
failures.AddIfNotNull(TestGetNZB());
}
@@ -217,7 +218,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
return new NzbDroneValidationFailure(fieldName, $"Shared folder does not exist")
{
DetailedDescription = $"The Diskstation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?"
DetailedDescription = $"The Diskstation does not have a Shared Folder with the name '{downloadDir}', are you sure you specified it correctly?"
};
}
@@ -248,7 +249,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
try
{
return ValidateVersion();
return TestProxiesVersions();
}
catch (DownloadClientAuthenticationException ex)
{
@@ -269,24 +270,48 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
DetailedDescription = "Please verify the hostname and port."
};
}
return new NzbDroneValidationFailure(string.Empty, "Unknown exception: " + ex.Message);
return new NzbDroneValidationFailure(string.Empty, $"Unknown exception: {ex.Message}");
}
catch (Exception ex)
{
_logger.Error(ex, "Error testing Torrent Download Station");
return new NzbDroneValidationFailure(string.Empty, "Unknown exception: " + ex.Message);
return new NzbDroneValidationFailure(string.Empty, $"Unknown exception: {ex.Message}");
}
}
protected ValidationFailure ValidateVersion()
protected ValidationFailure TestDSMVersion()
{
var info = _dsTaskProxy.GetApiInfo(Settings);
var dsmversion = _dsmInfoProvider.GetDSMVersion(Settings);
_logger.Debug("Download Station api version information: Min {0} - Max {1}", info.MinVersion, info.MaxVersion);
if (info.MinVersion > 2 || info.MaxVersion < 2)
if (dsmversion < new Version(6, 0, 0))
{
return new ValidationFailure(string.Empty, $"Download Station API version not supported, should be at least 2. It supports from {info.MinVersion} to {info.MaxVersion}");
return new NzbDroneValidationFailure(string.Empty, $"DSM Version {dsmversion} not fully supported. We recommend version 6.0.0 or above.") { IsWarning = true };
}
return null;
}
protected ValidationFailure TestProxiesVersions()
{
var dsmVersion = _dsmInfoProvider.GetDSMVersion(Settings);
var expectedVersions = new List<ExpectedVersion>()
{
new ExpectedVersion { Version = 2, Proxy = _dsTaskProxy },
new ExpectedVersion { Version = (dsmVersion >= new Version(6,0,0))? 2 : 1, Proxy = _fileStationProxy },
new ExpectedVersion { Version = 1, Proxy = _dsInfoProxy }
};
foreach (var expectedVersion in expectedVersions)
{
DiskStationApiInfo apiInfo = expectedVersion.Proxy.GetApiInfo(Settings);
_logger.Debug("{1} api version information: Min {1} - Max {2} - Expected {3}", apiInfo.Name, apiInfo.MinVersion, apiInfo.MaxVersion, expectedVersion.Version);
if (apiInfo.MinVersion > expectedVersion.Version || apiInfo.MaxVersion < expectedVersion.Version)
{
return new NzbDroneValidationFailure(string.Empty, $"{apiInfo.Name} API version not supported, should be at least {expectedVersion.Version}. It supports from {apiInfo.MinVersion} to {apiInfo.MaxVersion}");
}
}
return null;
@@ -377,7 +402,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
}
catch (Exception ex)
{
return new NzbDroneValidationFailure(string.Empty, "Failed to get the list of NZBs: " + ex.Message);
return new NzbDroneValidationFailure(string.Empty, $"Failed to get the list of NZBs: {ex.Message}");
}
}

View File

@@ -21,7 +21,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
public QBittorrentSettings()
{
Host = "localhost";
Port = 8080;
Port = 9091;
TvCategory = "tv-sonarr";
}

View File

@@ -1,4 +1,4 @@
using FluentValidation;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
@@ -22,7 +22,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
public UTorrentSettings()
{
Host = "localhost";
Port = 8080;
Port = 9091;
TvCategory = "tv-sonarr";
}

View File

@@ -75,11 +75,6 @@ namespace NzbDrone.Core.Download
_downloadClientStatusService.RecordSuccess(downloadClient.Definition.Id);
_indexerStatusService.RecordSuccess(remoteEpisode.Release.IndexerId);
}
catch (ReleaseUnavailableException)
{
_logger.Trace("Release {0} no longer available on indexer.", remoteEpisode);
throw;
}
catch (ReleaseDownloadException ex)
{
var http429 = ex.InnerException as TooManyRequestsException;

View File

@@ -8,7 +8,6 @@ namespace NzbDrone.Core.Download.Pending
{
void DeleteBySeriesId(int seriesId);
List<PendingRelease> AllBySeriesId(int seriesId);
List<PendingRelease> WithoutFallback();
}
public class PendingReleaseRepository : BasicRepository<PendingRelease>, IPendingReleaseRepository
@@ -27,10 +26,5 @@ namespace NzbDrone.Core.Download.Pending
{
return Query.Where(p => p.SeriesId == seriesId);
}
public List<PendingRelease> WithoutFallback()
{
return Query.Where(p => p.Reason != PendingReleaseReason.Fallback);
}
}
}
}

View File

@@ -21,13 +21,12 @@ namespace NzbDrone.Core.Download.Pending
public interface IPendingReleaseService
{
void Add(DownloadDecision decision, PendingReleaseReason reason);
void AddMany(List<Tuple<DownloadDecision, PendingReleaseReason>> decisions);
List<ReleaseInfo> GetPending();
List<RemoteEpisode> GetPendingRemoteEpisodes(int seriesId);
List<Queue.Queue> GetPendingQueue();
Queue.Queue FindPendingQueueItem(int queueId);
void RemovePendingQueueItems(int queueId);
RemoteEpisode OldestPendingRelease(int seriesId, int[] episodeIds);
RemoteEpisode OldestPendingRelease(int seriesId, IEnumerable<int> episodeIds);
}
public class PendingReleaseService : IPendingReleaseService,
@@ -69,27 +68,8 @@ namespace NzbDrone.Core.Download.Pending
public void Add(DownloadDecision decision, PendingReleaseReason reason)
{
var alreadyPending = _repository.AllBySeriesId(decision.RemoteEpisode.Series.Id);
var alreadyPending = GetPendingReleases();
alreadyPending = IncludeRemoteEpisodes(alreadyPending);
Add(alreadyPending, decision, reason);
}
public void AddMany(List<Tuple<DownloadDecision, PendingReleaseReason>> decisions)
{
var alreadyPending = decisions.Select(v => v.Item1.RemoteEpisode.Series.Id).Distinct().SelectMany(_repository.AllBySeriesId).ToList();
alreadyPending = IncludeRemoteEpisodes(alreadyPending);
foreach (var pair in decisions)
{
Add(alreadyPending, pair.Item1, pair.Item2);
}
}
private void Add(List<PendingRelease> alreadyPending, DownloadDecision decision, PendingReleaseReason reason)
{
var episodeIds = decision.RemoteEpisode.Episodes.Select(e => e.Id);
var existingReports = alreadyPending.Where(r => r.RemoteEpisode.Episodes.Select(e => e.Id)
@@ -100,31 +80,24 @@ namespace NzbDrone.Core.Download.Pending
if (matchingReports.Any())
{
var matchingReport = matchingReports.First();
var sameReason = true;
if (matchingReport.Reason != reason)
foreach (var matchingReport in matchingReports)
{
_logger.Debug("The release {0} is already pending with reason {1}, changing to {2}", decision.RemoteEpisode, matchingReport.Reason, reason);
matchingReport.Reason = reason;
_repository.Update(matchingReport);
}
else
{
_logger.Debug("The release {0} is already pending with reason {1}, not adding again", decision.RemoteEpisode, reason);
}
if (matchingReports.Count() > 1)
{
_logger.Debug("The release {0} had {1} duplicate pending, removing duplicates.", decision.RemoteEpisode, matchingReports.Count() - 1);
foreach (var duplicate in matchingReports.Skip(1))
if (matchingReport.Reason != reason)
{
_repository.Delete(duplicate.Id);
alreadyPending.Remove(duplicate);
_logger.Debug("The release {0} is already pending with reason {1}, changing to {2}", decision.RemoteEpisode, matchingReport.Reason, reason);
matchingReport.Reason = reason;
_repository.Update(matchingReport);
sameReason = false;
}
}
return;
if (sameReason)
{
_logger.Debug("The release {0} is already pending with reason {1}, not adding again", decision.RemoteEpisode, reason);
return;
}
}
_logger.Debug("Adding release {0} to pending releases with reason {1}", decision.RemoteEpisode, reason);
@@ -152,7 +125,7 @@ namespace NzbDrone.Core.Download.Pending
public List<RemoteEpisode> GetPendingRemoteEpisodes(int seriesId)
{
return IncludeRemoteEpisodes(_repository.AllBySeriesId(seriesId)).Select(v => v.RemoteEpisode).ToList();
return _repository.AllBySeriesId(seriesId).Select(GetRemoteEpisode).ToList();
}
public List<Queue.Queue> GetPendingQueue()
@@ -161,8 +134,7 @@ namespace NzbDrone.Core.Download.Pending
var nextRssSync = new Lazy<DateTime>(() => _taskManager.GetNextExecution(typeof(RssSyncCommand)));
var pendingReleases = IncludeRemoteEpisodes(_repository.WithoutFallback());
foreach (var pendingRelease in pendingReleases)
foreach (var pendingRelease in GetPendingReleases().Where(p => p.Reason != PendingReleaseReason.Fallback))
{
foreach (var episode in pendingRelease.RemoteEpisode.Episodes)
{
@@ -234,48 +206,24 @@ namespace NzbDrone.Core.Download.Pending
_repository.DeleteMany(releasesToRemove.Select(c => c.Id));
}
public RemoteEpisode OldestPendingRelease(int seriesId, int[] episodeIds)
public RemoteEpisode OldestPendingRelease(int seriesId, IEnumerable<int> episodeIds)
{
var seriesReleases = GetPendingReleases(seriesId);
return seriesReleases.Select(r => r.RemoteEpisode)
.Where(r => r.Episodes.Select(e => e.Id).Intersect(episodeIds).Any())
.OrderByDescending(p => p.Release.AgeHours)
.FirstOrDefault();
return GetPendingRemoteEpisodes(seriesId).Where(r => r.Episodes.Select(e => e.Id).Intersect(episodeIds).Any())
.OrderByDescending(p => p.Release.AgeHours)
.FirstOrDefault();
}
private List<PendingRelease> GetPendingReleases()
{
return IncludeRemoteEpisodes(_repository.All().ToList());
}
private List<PendingRelease> GetPendingReleases(int seriesId)
{
return IncludeRemoteEpisodes(_repository.AllBySeriesId(seriesId).ToList());
}
private List<PendingRelease> IncludeRemoteEpisodes(List<PendingRelease> releases)
{
var result = new List<PendingRelease>();
var seriesMap = _seriesService.GetSeries(releases.Select(v => v.SeriesId).Distinct())
.ToDictionary(v => v.Id);
foreach (var release in releases)
foreach (var release in _repository.All())
{
var series = seriesMap.GetValueOrDefault(release.SeriesId);
var remoteEpisode = GetRemoteEpisode(release);
// Just in case the series was removed, but wasn't cleaned up yet (housekeeper will clean it up)
if (series == null) return null;
if (remoteEpisode == null) continue;
var episodes = _parsingService.GetEpisodes(release.ParsedEpisodeInfo, series, true);
release.RemoteEpisode = new RemoteEpisode
{
Series = series,
Episodes = episodes,
ParsedEpisodeInfo = release.ParsedEpisodeInfo,
Release = release.Release
};
release.RemoteEpisode = remoteEpisode;
result.Add(release);
}
@@ -283,6 +231,24 @@ namespace NzbDrone.Core.Download.Pending
return result;
}
private RemoteEpisode GetRemoteEpisode(PendingRelease release)
{
var series = _seriesService.GetSeries(release.SeriesId);
//Just in case the series was removed, but wasn't cleaned up yet (housekeeper will clean it up)
if (series == null) return null;
var episodes = _parsingService.GetEpisodes(release.ParsedEpisodeInfo, series, true);
return new RemoteEpisode
{
Series = series,
Episodes = episodes,
ParsedEpisodeInfo = release.ParsedEpisodeInfo,
Release = release.Release
};
}
private void Insert(DownloadDecision decision, PendingReleaseReason reason)
{
_repository.Insert(new PendingRelease
@@ -322,7 +288,7 @@ namespace NzbDrone.Core.Download.Pending
private void RemoveGrabbed(RemoteEpisode remoteEpisode)
{
var pendingReleases = GetPendingReleases(remoteEpisode.Series.Id);
var pendingReleases = GetPendingReleases();
var episodeIds = remoteEpisode.Episodes.Select(e => e.Id);
var existingReports = pendingReleases.Where(r => r.RemoteEpisode.Episodes.Select(e => e.Id)

View File

@@ -6,7 +6,6 @@ using NLog;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.Download.Pending;
using NzbDrone.Core.Exceptions;
using NzbDrone.Core.Indexers;
namespace NzbDrone.Core.Download
@@ -41,7 +40,6 @@ namespace NzbDrone.Core.Download
var grabbed = new List<DownloadDecision>();
var pending = new List<DownloadDecision>();
var failed = new List<DownloadDecision>();
var rejected = decisions.Where(d => d.Rejected).ToList();
var usenetFailed = false;
var torrentFailed = false;
@@ -76,11 +74,6 @@ namespace NzbDrone.Core.Download
_downloadService.DownloadReport(remoteEpisode);
grabbed.Add(report);
}
catch (ReleaseUnavailableException)
{
_logger.Warn("Failed to download release from indexer, no longer available. " + remoteEpisode);
rejected.Add(report);
}
catch (Exception ex)
{
if (ex is DownloadClientUnavailableException || ex is DownloadClientAuthenticationException)
@@ -106,7 +99,7 @@ namespace NzbDrone.Core.Download
pending.AddRange(ProcessFailedGrabs(grabbed, failed));
return new ProcessedDecisions(grabbed, pending, rejected);
return new ProcessedDecisions(grabbed, pending, decisions.Where(d => d.Rejected).ToList());
}
internal List<DownloadDecision> GetQualifiedReports(IEnumerable<DownloadDecision> decisions)
@@ -131,8 +124,6 @@ namespace NzbDrone.Core.Download
var pending = new List<DownloadDecision>();
var stored = new List<DownloadDecision>();
var addQueue = new List<Tuple<DownloadDecision, PendingReleaseReason>>();
foreach (var report in failed)
{
// If a release was already grabbed with matching episodes we should store it as a fallback
@@ -143,27 +134,22 @@ namespace NzbDrone.Core.Download
if (IsEpisodeProcessed(grabbed, report))
{
addQueue.Add(Tuple.Create(report, PendingReleaseReason.Fallback));
_pendingReleaseService.Add(report, PendingReleaseReason.Fallback);
pending.Add(report);
}
else if (IsEpisodeProcessed(stored, report))
{
addQueue.Add(Tuple.Create(report, PendingReleaseReason.Fallback));
_pendingReleaseService.Add(report, PendingReleaseReason.Fallback);
pending.Add(report);
}
else
{
addQueue.Add(Tuple.Create(report, PendingReleaseReason.DownloadClientUnavailable));
_pendingReleaseService.Add(report, PendingReleaseReason.DownloadClientUnavailable);
pending.Add(report);
stored.Add(report);
}
}
if (addQueue.Any())
{
_pendingReleaseService.AddMany(addQueue);
}
return pending;
}
}

View File

@@ -33,7 +33,7 @@ namespace NzbDrone.Core.Download
_httpClient = httpClient;
_torrentFileInfoReader = torrentFileInfoReader;
}
public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
public virtual bool PreferTorrentFile => false;
@@ -61,7 +61,7 @@ namespace NzbDrone.Core.Download
{
magnetUrl = torrentInfo.MagnetUrl;
}
if (PreferTorrentFile)
{
if (torrentUrl.IsNotNullOrWhiteSpace())
@@ -160,12 +160,6 @@ namespace NzbDrone.Core.Download
}
catch (HttpException ex)
{
if (ex.Response.StatusCode == HttpStatusCode.NotFound)
{
_logger.Error(ex, "Downloading torrent file for episode '{0}' failed since it no longer exists ({1})", remoteEpisode.Release.Title, torrentUrl);
throw new ReleaseUnavailableException(remoteEpisode.Release, "Downloading torrent failed", ex);
}
if ((int)ex.Response.StatusCode == 429)
{
_logger.Error("API Grab Limit reached for {0}", torrentUrl);

View File

@@ -26,7 +26,7 @@ namespace NzbDrone.Core.Download
{
_httpClient = httpClient;
}
public override DownloadProtocol Protocol => DownloadProtocol.Usenet;
protected abstract string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent);
@@ -46,12 +46,6 @@ namespace NzbDrone.Core.Download
}
catch (HttpException ex)
{
if (ex.Response.StatusCode == HttpStatusCode.NotFound)
{
_logger.Error(ex, "Downloading nzb file for episode '{0}' failed since it no longer exists ({1})", remoteEpisode.Release.Title, url);
throw new ReleaseUnavailableException(remoteEpisode.Release, "Downloading torrent failed", ex);
}
if ((int)ex.Response.StatusCode == 429)
{
_logger.Error("API Grab Limit reached for {0}", url);

View File

@@ -1,28 +0,0 @@
using System;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Exceptions
{
public class ReleaseUnavailableException : ReleaseDownloadException
{
public ReleaseUnavailableException(ReleaseInfo release, string message, params object[] args)
: base(release, message, args)
{
}
public ReleaseUnavailableException(ReleaseInfo release, string message)
: base(release, message)
{
}
public ReleaseUnavailableException(ReleaseInfo release, string message, Exception innerException, params object[] args)
: base(release, message, innerException, args)
{
}
public ReleaseUnavailableException(ReleaseInfo release, string message, Exception innerException)
: base(release, message, innerException)
{
}
}
}

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Marr.Data.QGen;
using NzbDrone.Core.Datastore;
@@ -17,7 +16,6 @@ namespace NzbDrone.Core.History
List<History> FindByDownloadId(string downloadId);
List<History> FindDownloadHistory(int idSeriesId, QualityModel quality);
void DeleteForSeries(int seriesId);
List<History> Since(DateTime date, HistoryEventType? eventType);
}
public class HistoryRepository : BasicRepository<History>, IHistoryRepository
@@ -78,19 +76,5 @@ namespace NzbDrone.Core.History
return base.GetPagedQuery(baseQuery, pagingSpec);
}
public List<History> Since(DateTime date, HistoryEventType? eventType)
{
var query = Query.Where(h => h.Date >= date);
if (eventType.HasValue)
{
query.AndWhere(h => h.EventType == eventType);
}
query.OrderBy(h => h.Date);
return query;
}
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -25,7 +25,6 @@ namespace NzbDrone.Core.History
History Get(int historyId);
List<History> Find(string downloadId, HistoryEventType eventType);
List<History> FindByDownloadId(string downloadId);
List<History> Since(DateTime date, HistoryEventType? eventType);
}
public class HistoryService : IHistoryService,
@@ -291,10 +290,5 @@ namespace NzbDrone.Core.History
{
_historyRepository.DeleteForSeries(message.Series.Id);
}
public List<History> Since(DateTime date, HistoryEventType? eventType)
{
return _historyRepository.Since(date, eventType);
}
}
}
}

View File

@@ -56,17 +56,14 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet
pageableRequests.Add(GetPagedRequests(MaxPages, parameters));
}
if (searchCriteria.UserInvokedSearch)
foreach (var seasonNumber in searchCriteria.Episodes.Select(v => v.SeasonNumber).Distinct())
{
foreach (var seasonNumber in searchCriteria.Episodes.Select(v => v.SeasonNumber).Distinct())
{
parameters = parameters.Clone();
parameters = parameters.Clone();
parameters.Category = "Season";
parameters.Name = string.Format("Season {0}%", seasonNumber);
parameters.Category = "Season";
parameters.Name = string.Format("Season {0}", seasonNumber);
pageableRequests.Add(GetPagedRequests(MaxPages, parameters));
}
pageableRequests.Add(GetPagedRequests(MaxPages, parameters));
}
}

View File

@@ -58,8 +58,7 @@ namespace NzbDrone.Core.Indexers.HDBits
H264 = 1,
Mpeg2 = 2,
Vc1 = 3,
Xvid = 4,
Hevc = 5
Xvid = 4
}
public enum HdBitsMedium

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -12,7 +12,6 @@ using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
using NzbDrone.Common;
namespace NzbDrone.Core.MediaFiles
{
@@ -158,7 +157,7 @@ namespace NzbDrone.Core.MediaFiles
if (!_diskProvider.FolderExists(rootFolder))
{
throw new EpisodeImport.RootFolderNotFoundException(string.Format("Root folder '{0}' was not found.", rootFolder));
throw new DirectoryNotFoundException(string.Format("Root folder '{0}' was not found.", rootFolder));
}
var changed = false;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -12,7 +12,7 @@ using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Download;
using NzbDrone.Core.Extras;
using NzbDrone.Common.Exceptions;
namespace NzbDrone.Core.MediaFiles.EpisodeImport
{
@@ -122,16 +122,6 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
_eventAggregator.PublishEvent(new EpisodeImportedEvent(localEpisode, episodeFile, oldFiles, newDownload, downloadClientItem));
}
catch (RootFolderNotFoundException e)
{
_logger.Warn(e, "Couldn't import episode " + localEpisode);
importResults.Add(new ImportResult(importDecision, "Failed to import episode, Root folder missing."));
}
catch (DestinationAlreadyExistsException e)
{
_logger.Warn(e, "Couldn't import episode " + localEpisode);
importResults.Add(new ImportResult(importDecision, "Failed to import episode, Destination already exists."));
}
catch (Exception e)
{
_logger.Warn(e, "Couldn't import episode " + localEpisode);

View File

@@ -1,25 +0,0 @@
using System;
using System.IO;
using System.Runtime.Serialization;
namespace NzbDrone.Core.MediaFiles.EpisodeImport
{
public class RootFolderNotFoundException : DirectoryNotFoundException
{
public RootFolderNotFoundException()
{
}
public RootFolderNotFoundException(string message) : base(message)
{
}
public RootFolderNotFoundException(string message, Exception innerException) : base(message, innerException)
{
}
protected RootFolderNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}

View File

@@ -18,6 +18,9 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
private readonly IConfigService _configService;
private readonly Logger _logger;
public const int MINIMUM_MEDIA_INFO_SCHEMA_REVISION = 3;
public const int CURRENT_MEDIA_INFO_SCHEMA_REVISION = 4;
public UpdateMediaInfoService(IDiskProvider diskProvider,
IMediaFileService mediaFileService,
IVideoFileInfoReader videoFileInfoReader,
@@ -47,6 +50,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
if (mediaFile.MediaInfo != null)
{
mediaFile.MediaInfo.SchemaRevision = CURRENT_MEDIA_INFO_SCHEMA_REVISION;
_mediaFileService.Update(mediaFile);
_logger.Debug("Updated MediaInfo for '{0}'", path);
}
@@ -62,7 +66,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
}
var allMediaFiles = _mediaFileService.GetFilesBySeries(message.Series.Id);
var filteredMediaFiles = allMediaFiles.Where(c => c.MediaInfo == null || c.MediaInfo.SchemaRevision < VideoFileInfoReader.MINIMUM_MEDIA_INFO_SCHEMA_REVISION).ToList();
var filteredMediaFiles = allMediaFiles.Where(c => c.MediaInfo == null || c.MediaInfo.SchemaRevision < MINIMUM_MEDIA_INFO_SCHEMA_REVISION).ToList();
UpdateMediaInfo(message.Series, filteredMediaFiles);
}

View File

@@ -17,8 +17,6 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
private readonly IDiskProvider _diskProvider;
private readonly Logger _logger;
public const int MINIMUM_MEDIA_INFO_SCHEMA_REVISION = 3;
public const int CURRENT_MEDIA_INFO_SCHEMA_REVISION = 4;
public VideoFileInfoReader(IDiskProvider diskProvider, Logger logger)
{
@@ -147,8 +145,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
VideoFps = videoFrameRate,
AudioLanguages = audioLanguages,
Subtitles = subtitles,
ScanType = scanType,
SchemaRevision = CURRENT_MEDIA_INFO_SCHEMA_REVISION
ScanType = scanType
};
return mediaInfoModel;

View File

@@ -1,9 +1,8 @@
using System.IO;
using System.IO;
using System.Linq;
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.MediaFiles.EpisodeImport;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.MediaFiles
@@ -40,22 +39,13 @@ namespace NzbDrone.Core.MediaFiles
var existingFiles = localEpisode.Episodes
.Where(e => e.EpisodeFileId > 0)
.Select(e => e.EpisodeFile.Value)
.GroupBy(e => e.Id)
.ToList();
var rootFolder = _diskProvider.GetParentFolder(localEpisode.Series.Path);
// If there are existing episode files and the root folder is missing, throw, so the old file isn't left behind during the import process.
if (existingFiles.Any() && !_diskProvider.FolderExists(rootFolder))
{
throw new RootFolderNotFoundException($"Root folder '{rootFolder}' was not found.");
}
.GroupBy(e => e.Id);
foreach (var existingFile in existingFiles)
{
var file = existingFile.First();
var episodeFilePath = Path.Combine(localEpisode.Series.Path, file.RelativePath);
var subfolder = rootFolder.GetRelativePath(_diskProvider.GetParentFolder(episodeFilePath));
var subfolder = _diskProvider.GetParentFolder(localEpisode.Series.Path).GetRelativePath(_diskProvider.GetParentFolder(episodeFilePath));
if (_diskProvider.FileExists(episodeFilePath))
{

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
@@ -53,7 +53,7 @@ namespace NzbDrone.Core.Notifications.CustomScript
environmentVariables.Add("Sonarr_Release_Size", remoteEpisode.Release.Size.ToString());
environmentVariables.Add("Sonarr_Release_Quality", remoteEpisode.ParsedEpisodeInfo.Quality.Quality.Name);
environmentVariables.Add("Sonarr_Release_QualityVersion", remoteEpisode.ParsedEpisodeInfo.Quality.Revision.Version.ToString());
environmentVariables.Add("Sonarr_Release_ReleaseGroup", releaseGroup ?? string.Empty);
environmentVariables.Add("Sonarr_Release_ReleaseGroup", releaseGroup);
environmentVariables.Add("Sonarr_Download_Client", message.DownloadClient ?? string.Empty);
environmentVariables.Add("Sonarr_Download_Id", message.DownloadId ?? string.Empty);

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Net;
using FluentValidation.Results;
using NLog;
@@ -6,7 +6,6 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Common.Serializer;
using RestSharp;
using NzbDrone.Core.Rest;
using System.Web;
namespace NzbDrone.Core.Notifications.Telegram
{
@@ -29,13 +28,13 @@ namespace NzbDrone.Core.Notifications.Telegram
public void SendNotification(string title, string message, TelegramSettings settings)
{
//Format text to add the title before and bold using markdown
var text = $"<b>{HttpUtility.HtmlEncode(title)}</b>\n{HttpUtility.HtmlEncode(message)}";
var text = $"*{title}*\n{message}";
var client = RestClientFactory.BuildClient(URL);
var request = new RestRequest("bot{token}/sendmessage", Method.POST);
request.AddUrlSegment("token", settings.BotToken);
request.AddParameter("chat_id", settings.ChatId);
request.AddParameter("parse_mode", "HTML");
request.AddParameter("parse_mode", "Markdown");
request.AddParameter("text", text);
client.ExecuteAndValidate(request);

View File

@@ -81,7 +81,7 @@
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="OAuth">
<HintPath>..\packages\OAuth.1.0.3\lib\net40\OAuth.dll</HintPath>
@@ -224,7 +224,6 @@
<Compile Include="Datastore\Migration\042_add_download_clients_table.cs" />
<Compile Include="Datastore\Migration\043_convert_config_to_download_clients.cs" />
<Compile Include="Datastore\Migration\044_fix_xbmc_episode_metadata.cs" />
<Compile Include="Datastore\Migration\118_add_history_eventType_index.cs" />
<Compile Include="Datastore\Migration\045_add_indexes.cs" />
<Compile Include="Datastore\Migration\046_fix_nzb_su_url.cs" />
<Compile Include="Datastore\Migration\047_add_published_date_blacklist_column.cs" />
@@ -372,7 +371,9 @@
<Compile Include="Download\Clients\DownloadClientAuthenticationException.cs" />
<Compile Include="Download\Clients\DownloadClientUnavailableException.cs" />
<Compile Include="Download\Clients\DownloadClientException.cs" />
<Compile Include="Download\Clients\DownloadStation\DSMInfoProvider.cs" />
<Compile Include="Download\Clients\DownloadStation\Proxies\DownloadStationInfoProxy.cs" />
<Compile Include="Download\Clients\DownloadStation\Proxies\ExpectedVersion.cs" />
<Compile Include="Download\Clients\DownloadStation\TorrentDownloadStation.cs" />
<Compile Include="Download\Clients\DownloadStation\Proxies\DownloadStationTaskProxy.cs" />
<Compile Include="Download\Clients\DownloadStation\DownloadStationSettings.cs" />
@@ -391,7 +392,6 @@
<Compile Include="Download\Clients\DownloadStation\Responses\DiskStationResponse.cs" />
<Compile Include="Download\Clients\DownloadStation\Responses\DownloadStationTaskInfoResponse.cs" />
<Compile Include="Download\Clients\DownloadStation\DiskStationApiInfo.cs" />
<Compile Include="Download\Clients\DownloadStation\SerialNumberProvider.cs" />
<Compile Include="Download\Clients\DownloadStation\SharedFolderMapping.cs" />
<Compile Include="Download\Clients\DownloadStation\SharedFolderResolver.cs" />
<Compile Include="Download\Clients\DownloadStation\DiskStationApi.cs" />
@@ -539,7 +539,6 @@
<Compile Include="Exceptions\BadRequestException.cs" />
<Compile Include="Exceptions\DownstreamException.cs" />
<Compile Include="Exceptions\NzbDroneClientException.cs" />
<Compile Include="Exceptions\ReleaseUnavailableException.cs" />
<Compile Include="Exceptions\SeriesNotFoundException.cs" />
<Compile Include="Exceptions\ReleaseDownloadException.cs" />
<Compile Include="Exceptions\StatusCodeToExceptions.cs" />
@@ -784,7 +783,6 @@
<Compile Include="MediaFiles\EpisodeImport\Manual\ManualImportService.cs" />
<Compile Include="MediaFiles\EpisodeImport\DetectSample.cs" />
<Compile Include="MediaFiles\EpisodeImport\Manual\ManuallyImportedFile.cs" />
<Compile Include="MediaFiles\EpisodeImport\RootFolderNotFoundException.cs" />
<Compile Include="MediaFiles\EpisodeImport\Specifications\FreeSpaceSpecification.cs" />
<Compile Include="MediaFiles\EpisodeImport\Specifications\SameFileSpecification.cs" />
<Compile Include="MediaFiles\EpisodeImport\Specifications\GrabbedReleaseQualitySpecification.cs" />

View File

@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Core.Profiles.Delay
@@ -20,26 +18,20 @@ namespace NzbDrone.Core.Profiles.Delay
public class DelayProfileService : IDelayProfileService
{
private readonly IDelayProfileRepository _repo;
private readonly ICached<DelayProfile> _bestForTagsCache;
public DelayProfileService(IDelayProfileRepository repo, ICacheManager cacheManager)
public DelayProfileService(IDelayProfileRepository repo)
{
_repo = repo;
_bestForTagsCache = cacheManager.GetCache<DelayProfile>(GetType(), "best");
}
public DelayProfile Add(DelayProfile profile)
{
var result = _repo.Insert(profile);
_bestForTagsCache.Clear();
return result;
return _repo.Insert(profile);
}
public DelayProfile Update(DelayProfile profile)
{
var result = _repo.Update(profile);
_bestForTagsCache.Clear();
return result;
return _repo.Update(profile);
}
public void Delete(int id)
@@ -56,7 +48,6 @@ namespace NzbDrone.Core.Profiles.Delay
}
_repo.UpdateMany(all);
_bestForTagsCache.Clear();
}
public List<DelayProfile> All()
@@ -76,14 +67,7 @@ namespace NzbDrone.Core.Profiles.Delay
public DelayProfile BestForTags(HashSet<int> tagIds)
{
var key = "-" + tagIds.Select(v => v.ToString()).Join(",");
return _bestForTagsCache.Get(key, () => FetchBestForTags(tagIds), TimeSpan.FromSeconds(30));
}
private DelayProfile FetchBestForTags(HashSet<int> tagIds)
{
return _repo.All()
.Where(r => r.Tags.Intersect(tagIds).Any() || r.Tags.Empty())
return _repo.All().Where(r => r.Tags.Intersect(tagIds).Any() || r.Tags.Empty())
.OrderBy(d => d.Order).First();
}
}

View File

@@ -5,7 +5,7 @@
<package id="FluentValidation" version="6.2.1.0" targetFramework="net40" />
<package id="ImageResizer" version="3.4.3" targetFramework="net40" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="OAuth" version="1.0.3" targetFramework="net40" />
<package id="Prowlin" version="0.9.4456.26422" targetFramework="net40" />
<package id="RestSharp" version="105.2.3" targetFramework="net40" />

View File

@@ -65,8 +65,6 @@ namespace NzbDrone.Host
{
_browserService.LaunchWebUI();
}
_container.Resolve<IEventAggregator>().PublishEvent(new ApplicationStartedEvent());
}
protected override void OnStop()

View File

@@ -82,7 +82,7 @@
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@@ -6,6 +6,6 @@
<package id="Nancy" version="1.4.3" targetFramework="net40" />
<package id="Nancy.Owin" version="1.4.1" targetFramework="net40" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="Owin" version="1.0" targetFramework="net40" />
</packages>

View File

@@ -62,10 +62,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Owin.Hosting.2.1.0\lib\net40\Microsoft.Owin.Hosting.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nancy, Version=1.4.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nancy.1.4.3\lib\net40\Nancy.dll</HintPath>
<Private>True</Private>
@@ -79,7 +75,7 @@
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll</HintPath>
@@ -95,6 +91,9 @@
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
<Reference Include="Owin">
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
</Reference>

View File

@@ -10,7 +10,7 @@
<package id="Nancy" version="1.4.3" targetFramework="net40" />
<package id="Nancy.Owin" version="1.4.1" targetFramework="net40" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="NUnit" version="3.6.0" targetFramework="net40" />
<package id="Owin" version="1.0" targetFramework="net40" />
<package id="RestSharp" version="105.2.3" targetFramework="net40" />

View File

@@ -52,7 +52,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
</packages>

View File

@@ -46,16 +46,12 @@
<Reference Include="FluentValidation, Version=6.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\FluentValidation.6.2.1.0\lib\portable-net40+sl50+wp80+win8+wpa81\FluentValidation.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll</HintPath>
@@ -80,6 +76,9 @@
<Reference Include="Microsoft.Practices.Unity.Configuration">
<HintPath>..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Configuration.dll</HintPath>
</Reference>
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AutoMoq\AutoMoqer.cs" />

View File

@@ -3,9 +3,9 @@
<package id="CommonServiceLocator" version="1.3" targetFramework="net40" />
<package id="FluentAssertions" version="4.19.0" targetFramework="net40" />
<package id="FluentValidation" version="6.2.1.0" targetFramework="net40" />
<package id="Moq" version="4.0.10827" targetFramework="net40" />
<package id="Moq" version="4.0.10827" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="NUnit" version="3.6.0" targetFramework="net40" />
<package id="RestSharp" version="105.2.3" targetFramework="net40" />
<package id="Unity" version="2.1.505.2" targetFramework="net40" />

View File

@@ -47,12 +47,8 @@
<Reference Include="FluentAssertions.Core, Version=4.19.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.19.0\lib\net40\FluentAssertions.Core.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll</HintPath>
@@ -64,6 +60,9 @@
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="InstallUpdateServiceFixture.cs" />

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentAssertions" version="4.19.0" targetFramework="net40" />
<package id="Moq" version="4.0.10827" targetFramework="net40" />
<package id="Moq" version="4.0.10827" />
<package id="NBuilder" version="4.0.0" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="NUnit" version="3.6.0" targetFramework="net40" />
</packages>

View File

@@ -45,7 +45,7 @@
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
</packages>

View File

@@ -51,7 +51,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
</packages>

View File

@@ -79,7 +79,7 @@
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@@ -3,6 +3,6 @@
<package id="Microsoft.Owin" version="2.1.0" targetFramework="net40" />
<package id="Microsoft.Owin.Hosting" version="2.1.0" targetFramework="net40" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="Owin" version="1.0" targetFramework="net40" />
</packages>

View File

@@ -22,10 +22,10 @@
<div class="col-sm-4 col-sm-pull-1">
<select name="calendarWeekColumnHeader" class="form-control">
<option value="ddd M/D">Tue 3/25</option>
<option value="ddd MM/DD">Tue 03/25</option>
<option value="ddd D/M">Tue 25/3</option>
<option value="ddd DD/MM">Tue 25/03</option>
<option value="ddd M/D">Tue 3/5</option>
<option value="ddd MM/DD">Tue 03/05</option>
<option value="ddd D/M">Tue 5/3</option>
<option value="ddd DD/MM">Tue 05/03</option>
</select>
</div>
</div>
@@ -39,12 +39,12 @@
<div class="col-sm-4">
<select name="shortDateFormat" class="form-control">
<option value="MMM D YYYY">Mar 25 2014</option>
<option value="DD MMM YYYY">25 Mar 2014</option>
<option value="MM/D/YYYY">03/25/2014</option>
<option value="MM/DD/YYYY">03/25/2014</option>
<option value="DD/MM/YYYY">25/03/2014</option>
<option value="YYYY-MM-DD">2014-03-25</option>
<option value="MMM D YYYY">Mar 5 2014</option>
<option value="DD MMM YYYY">05 Mar 2014</option>
<option value="MM/D/YYYY">03/5/2014</option>
<option value="MM/DD/YYYY">03/05/2014</option>
<option value="DD/MM/YYYY">05/03/2014</option>
<option value="YYYY-MM-DD">2014-03-05</option>
</select>
</div>
</div>
@@ -54,8 +54,8 @@
<div class="col-sm-4">
<select name="longDateFormat" class="form-control">
<option value="dddd, MMMM D YYYY">Tuesday, March 25, 2014</option>
<option value="dddd, D MMMM YYYY">Tuesday, 25 March, 2014</option>
<option value="dddd, MMMM D YYYY">Tuesday, March 5, 2014</option>
<option value="dddd, D MMMM YYYY">Tuesday, 5 March, 2014</option>
</select>
</div>
</div>