mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-03-11 15:19:56 -04:00
Compare commits
63 Commits
dsm-sid-fi
...
transfer-p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
942dddb5e4 | ||
|
|
2f02f0a92d | ||
|
|
5c1491ca06 | ||
|
|
e089bfb4d2 | ||
|
|
2c8489de43 | ||
|
|
74fbc97835 | ||
|
|
2a0a4cfb6d | ||
|
|
0553a39a02 | ||
|
|
4ca5e978ac | ||
|
|
025440ee86 | ||
|
|
40016f2928 | ||
|
|
581320e3a4 | ||
|
|
5fae2ac66f | ||
|
|
3ba61cd5aa | ||
|
|
0008f28236 | ||
|
|
f9ec4c6b0d | ||
|
|
2b20b91ec5 | ||
|
|
e070eeda4a | ||
|
|
195a761c29 | ||
|
|
4399d272dc | ||
|
|
9d7547e941 | ||
|
|
0a690eb4d8 | ||
|
|
32309260b9 | ||
|
|
e11e8ad272 | ||
|
|
b45b2017a8 | ||
|
|
ae2a97763d | ||
|
|
442d49046d | ||
|
|
3d8cd9616e | ||
|
|
9c68c89f24 | ||
|
|
59ad5f35df | ||
|
|
263f3c46b1 | ||
|
|
2c13fcf579 | ||
|
|
7a1c1064ae | ||
|
|
bb52f3d41c | ||
|
|
0688340722 | ||
|
|
cf7b8455d4 | ||
|
|
df3c6ed572 | ||
|
|
e6c01be2cb | ||
|
|
2196db9a58 | ||
|
|
f10174da37 | ||
|
|
b48eaa7fd3 | ||
|
|
c34eec160f | ||
|
|
393996fe88 | ||
|
|
1ef08424ff | ||
|
|
20af2c8c0f | ||
|
|
b7e74bd5be | ||
|
|
34ded19be4 | ||
|
|
f53cad822a | ||
|
|
090dd45541 | ||
|
|
e01e822394 | ||
|
|
ea5769fdd6 | ||
|
|
1d2b35fdde | ||
|
|
1d3c536c93 | ||
|
|
e6b8b17b21 | ||
|
|
2a0df7e83e | ||
|
|
12065948ca | ||
|
|
a9e1aee295 | ||
|
|
73cb789f59 | ||
|
|
7345811115 | ||
|
|
22378b28f5 | ||
|
|
961f0d0ad3 | ||
|
|
65187e7d01 | ||
|
|
00c3074216 |
39
.github/ISSUE_TEMPLATE.md
vendored
39
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,5 +1,40 @@
|
||||
<!--
|
||||
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.
|
||||
|
||||
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)
|
||||
<!--
|
||||
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
|
||||
|
||||
7
.github/SUPPORT.md
vendored
Normal file
7
.github/SUPPORT.md
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
## 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/).
|
||||
Binary file not shown.
Binary file not shown.
@@ -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.3\lib\net40\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NLog" version="4.4.3" targetFramework="net40" />
|
||||
<package id="NLog" version="4.4.12" targetFramework="net40" />
|
||||
</packages>
|
||||
@@ -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.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
|
||||
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
</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>
|
||||
|
||||
@@ -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" />
|
||||
<package id="Moq" version="4.0.10827" targetFramework="net40" />
|
||||
<package id="NBuilder" version="4.0.0" targetFramework="net40" />
|
||||
<package id="NUnit" version="3.6.0" targetFramework="net40" />
|
||||
</packages>
|
||||
@@ -1,9 +1,10 @@
|
||||
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;
|
||||
@@ -92,7 +93,9 @@ 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))
|
||||
{
|
||||
@@ -114,7 +117,7 @@ namespace NzbDrone.Api.Calendar
|
||||
|
||||
if (asAllDay)
|
||||
{
|
||||
occurrence.Start = new CalDateTime(episode.AirDateUtc.Value) { HasTime = false };
|
||||
occurrence.Start = new CalDateTime(episode.AirDateUtc.Value.ToLocalTime()) { HasTime = false };
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace NzbDrone.Api.Extensions.Pipelines
|
||||
|
||||
private void Handle(NancyContext context)
|
||||
{
|
||||
if (context.Request.Method == "OPTIONS") return;
|
||||
|
||||
if (_cacheableSpecification.IsCacheable(context))
|
||||
{
|
||||
context.Response.Headers.EnableCache();
|
||||
@@ -33,4 +35,4 @@ namespace NzbDrone.Api.Extensions.Pipelines
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using Nancy;
|
||||
using Nancy.Bootstrapper;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace NzbDrone.Api.Extensions.Pipelines
|
||||
{
|
||||
@@ -11,10 +12,25 @@ namespace NzbDrone.Api.Extensions.Pipelines
|
||||
|
||||
public void Register(IPipelines pipelines)
|
||||
{
|
||||
pipelines.AfterRequest.AddItemToEndOfPipeline((Action<NancyContext>) Handle);
|
||||
pipelines.BeforeRequest.AddItemToEndOfPipeline(HandleRequest);
|
||||
pipelines.AfterRequest.AddItemToEndOfPipeline(HandleResponse);
|
||||
}
|
||||
|
||||
private void Handle(NancyContext context)
|
||||
private Response HandleRequest(NancyContext context)
|
||||
{
|
||||
if (context == null || context.Request.Method != "OPTIONS")
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var response = new Response()
|
||||
.WithStatusCode(HttpStatusCode.OK)
|
||||
.WithContentType("");
|
||||
ApplyResponseHeaders(response, context.Request);
|
||||
return response;
|
||||
}
|
||||
|
||||
private void HandleResponse(NancyContext context)
|
||||
{
|
||||
if (context == null || context.Response.Headers.ContainsKey(AccessControlHeaders.AllowOrigin))
|
||||
{
|
||||
@@ -26,21 +42,39 @@ namespace NzbDrone.Api.Extensions.Pipelines
|
||||
|
||||
private static void ApplyResponseHeaders(Response response, Request request)
|
||||
{
|
||||
var allowedMethods = "GET, OPTIONS, PATCH, POST, PUT, DELETE";
|
||||
|
||||
if (response.Headers.ContainsKey("Allow"))
|
||||
if (request.IsApiRequest())
|
||||
{
|
||||
allowedMethods = response.Headers["Allow"];
|
||||
// Allow Cross-Origin access to the API since it's protected with the apikey, and nothing else.
|
||||
ApplyCorsResponseHeaders(response, request, "*", "GET, OPTIONS, PATCH, POST, PUT, DELETE");
|
||||
}
|
||||
|
||||
var requestedHeaders = string.Join(", ", request.Headers[AccessControlHeaders.RequestHeaders]);
|
||||
|
||||
response.Headers.Add(AccessControlHeaders.AllowOrigin, "*");
|
||||
response.Headers.Add(AccessControlHeaders.AllowMethods, allowedMethods);
|
||||
|
||||
if (request.Headers[AccessControlHeaders.RequestHeaders].Any())
|
||||
else if (request.IsSharedContentRequest())
|
||||
{
|
||||
response.Headers.Add(AccessControlHeaders.AllowHeaders, requestedHeaders);
|
||||
// Allow Cross-Origin access to specific shared content such as mediacovers and images.
|
||||
ApplyCorsResponseHeaders(response, request, "*", "GET, OPTIONS");
|
||||
}
|
||||
|
||||
// Disallow Cross-Origin access for any other route.
|
||||
}
|
||||
|
||||
private static void ApplyCorsResponseHeaders(Response response, Request request, string allowOrigin, string allowedMethods)
|
||||
{
|
||||
response.Headers.Add(AccessControlHeaders.AllowOrigin, allowOrigin);
|
||||
|
||||
if (request.Method == "OPTIONS")
|
||||
{
|
||||
if (response.Headers.ContainsKey("Allow"))
|
||||
{
|
||||
allowedMethods = response.Headers["Allow"];
|
||||
}
|
||||
|
||||
response.Headers.Add(AccessControlHeaders.AllowMethods, allowedMethods);
|
||||
|
||||
if (request.Headers[AccessControlHeaders.RequestHeaders].Any())
|
||||
{
|
||||
var requestedHeaders = request.Headers[AccessControlHeaders.RequestHeaders].Join(", ");
|
||||
|
||||
response.Headers.Add(AccessControlHeaders.AllowHeaders, requestedHeaders);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ namespace NzbDrone.Api.Extensions.Pipelines
|
||||
try
|
||||
{
|
||||
if (
|
||||
!response.ContentType.Contains("image")
|
||||
response.Contents != Response.NoBody
|
||||
&& !response.ContentType.Contains("image")
|
||||
&& !response.ContentType.Contains("font")
|
||||
&& request.Headers.AcceptEncoding.Any(x => x.Contains("gzip"))
|
||||
&& !AlreadyGzipEncoded(response)
|
||||
@@ -80,4 +81,4 @@ namespace NzbDrone.Api.Extensions.Pipelines
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,5 +36,11 @@ namespace NzbDrone.Api.Extensions
|
||||
{
|
||||
return request.Path.StartsWith("/Content/", StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public static bool IsSharedContentRequest(this Request request)
|
||||
{
|
||||
return request.Path.StartsWith("/MediaCover/", StringComparison.InvariantCultureIgnoreCase) ||
|
||||
request.Path.StartsWith("/Content/Images/", StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,12 @@ namespace NzbDrone.Api.Frontend.Mappers
|
||||
|
||||
public override bool CanHandle(string resourceUrl)
|
||||
{
|
||||
return !resourceUrl.Contains(".") && !resourceUrl.StartsWith("/login");
|
||||
resourceUrl = resourceUrl.ToLowerInvariant();
|
||||
|
||||
return !resourceUrl.StartsWith("/content") &&
|
||||
!resourceUrl.StartsWith("/mediacover") &&
|
||||
!resourceUrl.Contains(".") &&
|
||||
!resourceUrl.StartsWith("/login");
|
||||
}
|
||||
|
||||
public override Response GetResponse(string resourceUrl)
|
||||
@@ -113,4 +118,4 @@ namespace NzbDrone.Api.Frontend.Mappers
|
||||
return _generatedContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using NLog;
|
||||
@@ -42,7 +43,7 @@ namespace NzbDrone.Api.Frontend.Mappers
|
||||
|
||||
public override bool CanHandle(string resourceUrl)
|
||||
{
|
||||
return resourceUrl.StartsWith("/MediaCover");
|
||||
return resourceUrl.StartsWith("/MediaCover", StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
@@ -28,7 +29,9 @@ namespace NzbDrone.Api.Frontend.Mappers
|
||||
|
||||
public override bool CanHandle(string resourceUrl)
|
||||
{
|
||||
return resourceUrl.StartsWith("/Content") ||
|
||||
resourceUrl = resourceUrl.ToLowerInvariant();
|
||||
|
||||
return resourceUrl.StartsWith("/content") ||
|
||||
resourceUrl.EndsWith(".js") ||
|
||||
resourceUrl.EndsWith(".map") ||
|
||||
resourceUrl.EndsWith(".css") ||
|
||||
@@ -37,4 +40,4 @@ namespace NzbDrone.Api.Frontend.Mappers
|
||||
resourceUrl.EndsWith("oauth.html");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Nancy.Responses;
|
||||
using NLog;
|
||||
using Nancy;
|
||||
using NzbDrone.Api.Frontend.Mappers;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
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;
|
||||
@@ -25,6 +28,7 @@ namespace NzbDrone.Api.History
|
||||
_failedDownloadService = failedDownloadService;
|
||||
GetResourcePaged = GetHistory;
|
||||
|
||||
Get["/since"] = x => GetHistorySince();
|
||||
Post["/failed"] = x => MarkAsFailed();
|
||||
}
|
||||
|
||||
@@ -64,6 +68,27 @@ 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;
|
||||
|
||||
@@ -34,7 +34,6 @@ namespace NzbDrone.Api
|
||||
RegisterPipelines(pipelines);
|
||||
|
||||
container.Resolve<DatabaseTarget>().Register();
|
||||
container.Resolve<IEventAggregator>().PublishEvent(new ApplicationStartedEvent());
|
||||
}
|
||||
|
||||
private void RegisterPipelines(IPipelines pipelines)
|
||||
@@ -56,4 +55,4 @@ namespace NzbDrone.Api
|
||||
|
||||
protected override byte[] FavIcon => null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.3\lib\net40\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.4.12\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>
|
||||
|
||||
@@ -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.3" targetFramework="net40" />
|
||||
<package id="NLog" version="4.4.12" targetFramework="net40" />
|
||||
</packages>
|
||||
@@ -47,8 +47,12 @@
|
||||
<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.3\lib\net40\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.4.12\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>
|
||||
@@ -58,9 +62,6 @@
|
||||
<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" />
|
||||
|
||||
@@ -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" />
|
||||
<package id="Moq" version="4.0.10827" targetFramework="net40" />
|
||||
<package id="NBuilder" version="4.0.0" targetFramework="net40" />
|
||||
<package id="NLog" version="4.4.3" targetFramework="net40" />
|
||||
<package id="NLog" version="4.4.12" targetFramework="net40" />
|
||||
<package id="NUnit" version="3.6.0" targetFramework="net40" />
|
||||
</packages>
|
||||
@@ -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.3\lib\net40\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.4.12\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>
|
||||
|
||||
@@ -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.3" targetFramework="net40" />
|
||||
<package id="NLog" version="4.4.12" 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" />
|
||||
|
||||
@@ -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<IOException>(() => Subject.TransferFile(_sourcePath, _targetPath, TransferMode.Move, false));
|
||||
Assert.Throws<DestinationAlreadyExistsException>(() => Subject.TransferFile(_sourcePath, _targetPath, TransferMode.Move, false));
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Verify(v => v.DeleteFile(_targetPath), Times.Never());
|
||||
|
||||
@@ -43,8 +43,12 @@
|
||||
<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.3\lib\net40\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.4.12\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>
|
||||
@@ -57,9 +61,6 @@
|
||||
<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" />
|
||||
|
||||
@@ -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" />
|
||||
<package id="NLog" version="4.4.3" targetFramework="net40" />
|
||||
<package id="Moq" version="4.0.10827" targetFramework="net40" />
|
||||
<package id="NLog" version="4.4.12" targetFramework="net40" />
|
||||
<package id="NUnit" version="3.6.0" targetFramework="net40" />
|
||||
</packages>
|
||||
@@ -0,0 +1,29 @@
|
||||
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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
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
|
||||
@@ -340,7 +341,7 @@ namespace NzbDrone.Common.Disk
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IOException(string.Format("Destination already exists. [{0}] to [{1}]", sourcePath, targetPath));
|
||||
throw new DestinationAlreadyExistsException($"Destination {targetPath} already exists.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace NzbDrone.Common.Exceptions
|
||||
using NzbDrone.Common.Exceptions;
|
||||
|
||||
namespace NzbDrone.Common.Disk
|
||||
{
|
||||
public class NotParentException : NzbDroneException
|
||||
{
|
||||
@@ -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 Exceptions.NotParentException("{0} is not a child of {1}", childPath, parentPath);
|
||||
throw new NotParentException("{0} is not a child of {1}", childPath, parentPath);
|
||||
}
|
||||
|
||||
return childPath.Substring(parentPath.Length).Trim(Path.DirectorySeparatorChar);
|
||||
|
||||
@@ -76,5 +76,12 @@ namespace NzbDrone.Common.Http
|
||||
var encoding = HttpHeader.GetEncodingFromContentType(Headers.ContentType);
|
||||
ContentData = encoding.GetBytes(data);
|
||||
}
|
||||
|
||||
public void AddBasicAuthentication(string username, string password)
|
||||
{
|
||||
var authInfo = Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes($"{username}:{password}"));
|
||||
|
||||
Headers.Set("Authorization", "Basic " + authInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.3\lib\net40\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.4.12\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,6 +92,7 @@
|
||||
<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" />
|
||||
@@ -125,7 +126,7 @@
|
||||
<Compile Include="EnvironmentInfo\IRuntimeInfo.cs" />
|
||||
<Compile Include="EnvironmentInfo\RuntimeInfo.cs" />
|
||||
<Compile Include="EnvironmentInfo\StartupContext.cs" />
|
||||
<Compile Include="Exceptions\NotParentException.cs" />
|
||||
<Compile Include="Disk\NotParentException.cs" />
|
||||
<Compile Include="Exceptions\NzbDroneException.cs" />
|
||||
<Compile Include="Expansive\CircularReferenceException.cs" />
|
||||
<Compile Include="Expansive\Expansive.cs" />
|
||||
@@ -214,9 +215,11 @@
|
||||
<Compile Include="ServiceFactory.cs" />
|
||||
<Compile Include="ServiceProvider.cs" />
|
||||
<Compile Include="Extensions\StringExtensions.cs" />
|
||||
<Compile Include="Timeline\TimelineContext.cs" />
|
||||
<Compile Include="TinyIoC.cs" />
|
||||
<Compile Include="TPL\Debouncer.cs" />
|
||||
<Compile Include="TPL\LimitedConcurrencyLevelTaskScheduler.cs" />
|
||||
<Compile Include="Timeline\ProgressReporter.cs" />
|
||||
<Compile Include="TPL\RateLimitService.cs" />
|
||||
<Compile Include="TPL\TaskExtensions.cs" />
|
||||
<Compile Include="Extensions\TryParseExtensions.cs" />
|
||||
|
||||
77
src/NzbDrone.Common/Timeline/ProgressReporter.cs
Normal file
77
src/NzbDrone.Common/Timeline/ProgressReporter.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Common.Timeline
|
||||
{
|
||||
public interface IProgressReporter
|
||||
{
|
||||
long Raw { get; }
|
||||
long Total { get; }
|
||||
double Progress { get; }
|
||||
|
||||
void UpdateProgress(long currentProgress, long maxProgress);
|
||||
void FinishProgress();
|
||||
}
|
||||
|
||||
public class ProgressReporter : IProgressReporter
|
||||
{
|
||||
private readonly int _maxSteps;
|
||||
|
||||
public long Raw { get; protected set; }
|
||||
public long Total { get; private set; }
|
||||
|
||||
public double Progress => Total == 0 ? 1.0 : Math.Min(Raw, Total) / Total;
|
||||
|
||||
//public TimeSpan? EstimatedDurationRemaining { get; private set; }
|
||||
|
||||
public ProgressReporter(long initialProgress, long maxProgress, int maxSteps = 100)
|
||||
{
|
||||
_maxSteps = maxSteps;
|
||||
|
||||
Raw = initialProgress;
|
||||
Total = maxProgress;
|
||||
}
|
||||
|
||||
public void UpdateProgress(long currentProgress, long maxProgress)
|
||||
{
|
||||
bool shouldRaiseEvent;
|
||||
|
||||
lock (this)
|
||||
{
|
||||
var oldRaw = Raw;
|
||||
var oldTotal = Total;
|
||||
|
||||
Raw = currentProgress;
|
||||
Total = Total;
|
||||
|
||||
var oldStep = oldTotal <= 0 ? _maxSteps : oldRaw * _maxSteps / oldTotal;
|
||||
var newStep = Total <= 0 ? _maxSteps : Raw * _maxSteps / Total;
|
||||
|
||||
shouldRaiseEvent = (oldStep != newStep);
|
||||
}
|
||||
|
||||
if (shouldRaiseEvent)
|
||||
{
|
||||
RaiseEvent();
|
||||
}
|
||||
}
|
||||
|
||||
public void FinishProgress()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
Raw = Total;
|
||||
}
|
||||
|
||||
RaiseEvent();
|
||||
}
|
||||
|
||||
protected virtual void RaiseEvent()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
100
src/NzbDrone.Common/Timeline/TimelineContext.cs
Normal file
100
src/NzbDrone.Common/Timeline/TimelineContext.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Common.Timeline
|
||||
{
|
||||
public enum TimelineState
|
||||
{
|
||||
Pending,
|
||||
Started,
|
||||
Completed,
|
||||
Failed
|
||||
}
|
||||
|
||||
public interface ITimelineContext : IProgressReporter
|
||||
{
|
||||
string Name { get; }
|
||||
TimelineState State { get; }
|
||||
|
||||
void UpdateState(TimelineState state);
|
||||
ITimelineContext AppendTimeline(string name, long initialProgress = 0, long maxProgress = 1);
|
||||
void AppendTimeline(ITimelineContext timeline);
|
||||
}
|
||||
|
||||
public class TimelineContext : ProgressReporter, ITimelineContext
|
||||
{
|
||||
private List<ITimelineContext> _timelines = new List<ITimelineContext>();
|
||||
|
||||
public string Name { get; private set; }
|
||||
public TimelineState State { get; private set; }
|
||||
|
||||
public IEnumerable<ITimelineContext> Timelines
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
return _timelines.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TimelineContext(string name, long initialProgress, long maxProgress)
|
||||
: base(initialProgress, maxProgress)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public void UpdateState(TimelineState state)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
State = state;
|
||||
|
||||
if (State == TimelineState.Completed || State == TimelineState.Failed)
|
||||
{
|
||||
Raw = Total;
|
||||
}
|
||||
}
|
||||
|
||||
RaiseEvent();
|
||||
}
|
||||
|
||||
public ITimelineContext AppendTimeline(string name, long initialProgress = 0, long maxProgress = 1)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
var timeline = new TimelineContext(name, initialProgress, maxProgress);
|
||||
_timelines.Add(timeline);
|
||||
return timeline;
|
||||
}
|
||||
}
|
||||
|
||||
public void AppendTimeline(ITimelineContext timeline)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
_timelines.Add(timeline);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void RaiseEvent()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (Raw == Total)
|
||||
{
|
||||
State = TimelineState.Completed;
|
||||
}
|
||||
else
|
||||
{
|
||||
State = TimelineState.Started;
|
||||
}
|
||||
}
|
||||
|
||||
base.RaiseEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.3" targetFramework="net40" />
|
||||
<package id="NLog" version="4.4.12" targetFramework="net40" />
|
||||
<package id="SharpRaven" version="2.2.0" targetFramework="net40" />
|
||||
</packages>
|
||||
@@ -57,7 +57,7 @@ namespace NzbDrone.Console
|
||||
|
||||
private static void Exit(ExitCodes exitCode)
|
||||
{
|
||||
LogManager.Flush();
|
||||
LogManager.Shutdown();
|
||||
|
||||
if (exitCode != ExitCodes.Normal)
|
||||
{
|
||||
@@ -80,8 +80,6 @@ namespace NzbDrone.Console
|
||||
System.Console.ReadLine();
|
||||
}
|
||||
|
||||
//Need this to terminate on mono (thanks nlog)
|
||||
LogManager.Configuration = null;
|
||||
Environment.Exit((int)exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.3\lib\net40\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
||||
@@ -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.3" targetFramework="net40" />
|
||||
<package id="NLog" version="4.4.12" targetFramework="net40" />
|
||||
<package id="Owin" version="1.0" targetFramework="net40" />
|
||||
</packages>
|
||||
@@ -1,12 +1,11 @@
|
||||
using FizzWare.NBuilder;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications.Search;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Indexers.TorrentRss;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
@@ -8,6 +8,7 @@ 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;
|
||||
@@ -178,7 +179,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_an_empty_list_when_none_are_appproved()
|
||||
public void should_return_an_empty_list_when_none_are_approved()
|
||||
{
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(null, new Rejection("Failure!")));
|
||||
@@ -263,5 +264,26 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +180,21 @@ 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()
|
||||
{
|
||||
@@ -190,18 +205,26 @@ namespace NzbDrone.Core.Test.Download
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_attempt_download_if_client_is_disabled()
|
||||
public void should_attempt_download_even_if_client_is_disabled()
|
||||
{
|
||||
WithUsenetClient();
|
||||
var mockUsenet = WithUsenetClient();
|
||||
|
||||
Mocker.GetMock<IDownloadClientStatusService>()
|
||||
.Setup(v => v.IsDisabled(It.IsAny<int>()))
|
||||
.Returns(true);
|
||||
.Setup(v => v.GetBlockedProviders())
|
||||
.Returns(new List<DownloadClientStatus>
|
||||
{
|
||||
new DownloadClientStatus
|
||||
{
|
||||
ProviderId = _downloadClients.First().Definition.Id,
|
||||
DisabledTill = DateTime.UtcNow.AddHours(3)
|
||||
}
|
||||
});
|
||||
|
||||
Assert.Throws<DownloadClientUnavailableException>(() => Subject.DownloadReport(_parseResult));
|
||||
Subject.DownloadReport(_parseResult);
|
||||
|
||||
Mocker.GetMock<IDownloadClient>().Verify(c => c.Download(It.IsAny<RemoteEpisode>()), Times.Never());
|
||||
VerifyEventNotPublished<EpisodeGrabbedEvent>();
|
||||
Mocker.GetMock<IDownloadClientStatusService>().Verify(c => c.GetBlockedProviders(), Times.Never());
|
||||
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteEpisode>()), Times.Once());
|
||||
VerifyEventPublished<EpisodeGrabbedEvent>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download
|
||||
{
|
||||
[TestFixture]
|
||||
public class NzbValidationServiceFixture : CoreTest<NzbValidationService>
|
||||
{
|
||||
private byte[] GivenNzbFile(string name)
|
||||
{
|
||||
return File.ReadAllBytes(GetTestPath("Files/Nzbs/" + name + ".nzb"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_on_invalid_nzb()
|
||||
{
|
||||
var filename = "NotNzb";
|
||||
var fileContent = GivenNzbFile(filename);
|
||||
|
||||
Assert.Throws<InvalidNzbException>(() => Subject.Validate(filename, fileContent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_throw_when_no_files()
|
||||
{
|
||||
var filename = "NoFiles";
|
||||
var fileContent = GivenNzbFile(filename);
|
||||
|
||||
Assert.Throws<InvalidNzbException>(() => Subject.Validate(filename, fileContent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_validate_nzb()
|
||||
{
|
||||
var filename = "ValidNzb";
|
||||
var fileContent = GivenNzbFile(filename);
|
||||
|
||||
Subject.Validate(filename, fileContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using Marr.Data;
|
||||
using Moq;
|
||||
@@ -26,6 +27,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
||||
private ReleaseInfo _release;
|
||||
private ParsedEpisodeInfo _parsedEpisodeInfo;
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
private List<PendingRelease> _heldReleases;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
@@ -60,17 +62,27 @@ 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(new List<PendingRelease>());
|
||||
.Returns(_heldReleases);
|
||||
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Setup(s => s.AllBySeriesId(It.IsAny<int>()))
|
||||
.Returns<int>(i => _heldReleases.Where(v => v.SeriesId == i).ToList());
|
||||
|
||||
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});
|
||||
@@ -80,7 +92,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
||||
.Returns((List<DownloadDecision> d) => d);
|
||||
}
|
||||
|
||||
private void GivenHeldRelease(string title, string indexer, DateTime publishDate)
|
||||
private void GivenHeldRelease(string title, string indexer, DateTime publishDate, PendingReleaseReason reason = PendingReleaseReason.Delay)
|
||||
{
|
||||
var release = _release.JsonClone();
|
||||
release.Indexer = indexer;
|
||||
@@ -92,11 +104,10 @@ 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();
|
||||
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(heldReleases);
|
||||
_heldReleases.AddRange(heldReleases);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -117,6 +128,29 @@ 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()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using Marr.Data;
|
||||
using Moq;
|
||||
@@ -26,6 +27,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
||||
private ReleaseInfo _release;
|
||||
private ParsedEpisodeInfo _parsedEpisodeInfo;
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
private List<PendingRelease> _heldReleases;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
@@ -60,17 +62,27 @@ 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(new List<PendingRelease>());
|
||||
.Returns(_heldReleases);
|
||||
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Setup(s => s.AllBySeriesId(It.IsAny<int>()))
|
||||
.Returns<int>(i => _heldReleases.Where(v => v.SeriesId == i).ToList());
|
||||
|
||||
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,9 +104,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
||||
.With(h => h.ParsedEpisodeInfo = parsedEpisodeInfo)
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IPendingReleaseRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(heldReleases);
|
||||
_heldReleases.AddRange(heldReleases);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -38,6 +38,10 @@ 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 });
|
||||
@@ -63,7 +67,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
|
||||
|
||||
AssertRemoved(1);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_remove_multiple_releases_release()
|
||||
{
|
||||
@@ -134,7 +138,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))));
|
||||
|
||||
@@ -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,6 +73,10 @@ 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});
|
||||
|
||||
6
src/NzbDrone.Core.Test/Files/Nzbs/NoFiles.nzb
Normal file
6
src/NzbDrone.Core.Test/Files/Nzbs/NoFiles.nzb
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE nzb
|
||||
PUBLIC '-//newzBin//DTD NZB 1.1//EN'
|
||||
'http://www.newzbin.com/DTD/nzb/nzb-1.1.dtd'>
|
||||
<nzb xmlns="http://www.newzbin.com/DTD/2003/nzb">
|
||||
</nzb>
|
||||
102
src/NzbDrone.Core.Test/Files/Nzbs/NotNzb.nzb
Normal file
102
src/NzbDrone.Core.Test/Files/Nzbs/NotNzb.nzb
Normal file
@@ -0,0 +1,102 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<fail>
|
||||
<file date="1504571104" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[01/46] - "Series.Title.s04e06.720p.hdtv.x264-killers.nfo" yEnc (1/1)">
|
||||
<groups>
|
||||
<group>alt.binaries.teevee</group>
|
||||
</groups>
|
||||
<segments>
|
||||
<segment bytes="12053" number="1">ZQ9h749E781168561i4J0Q6-01m6Q3185@2894t-767038L.Pg7769</segment>
|
||||
</segments>
|
||||
</file>
|
||||
<file date="1504571104" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[02/46] - "Series.Title.s04e06.720p.hdtv.x264-killers.par2" yEnc (1/1)">
|
||||
<groups>
|
||||
<group>alt.binaries.teevee</group>
|
||||
</groups>
|
||||
<segments>
|
||||
<segment bytes="26932" number="1">405Z5Y4066010l377VP1k6$U4873W933@f32Bs90575538201.pj54</segment>
|
||||
</segments>
|
||||
</file>
|
||||
<file date="1504571104" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[03/46] - "Series.Title.s04e06.720p.hdtv.x264-killers.r00" yEnc (1/66)">
|
||||
<groups>
|
||||
<group>alt.binaries.teevee</group>
|
||||
</groups>
|
||||
<segments>
|
||||
<segment bytes="793068" number="1">1x9894417$M.1s25279485O1s1Fi95Z1_18Z554u440@D1k0854_134551.0794144</segment>
|
||||
<segment bytes="793234" number="2">48JYp$W18B2R1s2rI24EG7$907$r89875n60@8xK3374080716.115545M</segment>
|
||||
<segment bytes="793346" number="3">0U93471uI59Y781x77Q8-4286308-4aU35$07-179z@u90567568251.4zgUW968</segment>
|
||||
<segment bytes="793302" number="4">5119x6417a.s06F$1k46$2q89298-C0@G7C-7811268.bK9x00B</segment>
|
||||
<segment bytes="793289" number="5">B8$1_h0b64Z14-16_O6$ESw481L421n9agj7731k@414.473581-K$4.0Zd5A</segment>
|
||||
<segment bytes="793380" number="6">O-4731$tn71v05623J9GT.yc22O975111dR01r58065p@Da1G9L33q74h3095.5X240</segment>
|
||||
<segment bytes="793253" number="7">d9R03J$07w75945Z556197z50F0w.0-5.x9$58311S@J0-v50033110.4a440EYJ</segment>
|
||||
<segment bytes="793317" number="8">05e650149.5r1Hk$E0Bko7G5B.1107mz8l17PS8F@vr816$S6T19245w.042B9</segment>
|
||||
<segment bytes="793060" number="9">245Xy0w4o$tN6428321b.n1816Q1n95bE0816Y@q-qv7E12k.F3672H.16E19</segment>
|
||||
<segment bytes="793266" number="10">H681i185g64H23101kP125z41101O91P384l@E9n597k05j798D94X.2ezz1K</segment>
|
||||
<segment bytes="793223" number="11">T18.6136787.HLJ806.8$Si49m0459445101Z15-5@b80M7.788598D.gXu201cR</segment>
|
||||
<segment bytes="793346" number="12">Vdl8H243Go28j1o865772039416v2@090a20-v365N5S7qf.G225s6</segment>
|
||||
<segment bytes="793305" number="13">S9769892v956069345.0TN.i05R@I04825Gt2706N.BAj1DT1T</segment>
|
||||
<segment bytes="793187" number="14">041800q6F28q44365799m5CQ4D43895@1Bf6268z_Q20F.045JXl</segment>
|
||||
<segment bytes="793119" number="15">1c-e034z4l$9K45i44218ss25$X5_5R-1i76$40-71P@Xt691t8B686Fgv.VBSl</segment>
|
||||
<segment bytes="793262" number="16">76l441W.R146a5368ed02cp_44171410hT.l@Z98.k.70X9c.5mZ1w49</segment>
|
||||
<segment bytes="793221" number="17">12D035G5745-KO43wZ9920ttr1338@V7d871S2-t04t8520.uQ18</segment>
|
||||
<segment bytes="793221" number="18">59V4O77211HA1f5T8h1-53952zV-55294K4M04v@kS878H3g4z.B5561.L330519</segment>
|
||||
<segment bytes="793087" number="19">44-yi1-79$751944J7094$y7-y49994440d86cSn@5C82v-1O9N.wk8wMb6</segment>
|
||||
<segment bytes="793375" number="20">oF7Wj3$Ydh7e030oD4.e81JM464O791495lJ@Pm058Qt4-G8Wv.T1i1a6O1</segment>
|
||||
<segment bytes="793293" number="21">1T7_71M9d10F2.5953VP.11.4h75L@5049bBn384.14Ms</segment>
|
||||
<segment bytes="793266" number="22">u8601765028G662749SD41j0m57651Zq70u1@J5281423406375.z.6PDSx57</segment>
|
||||
<segment bytes="793376" number="23">XY0476$R87Y16g2n45OO335541589V140R026j@y2q9296x7f23C.sqK71b9</segment>
|
||||
<segment bytes="793363" number="24">X7N3440l08B9T5940na4Ls397-T2.P5M12241525J57@r44O419p594M6G4I.d66RQ1</segment>
|
||||
<segment bytes="793203" number="25">p4148978k45.t88w2K9886H4223y5553T7$7p287TN@N8e1T98b_0.mo55a14G</segment>
|
||||
<segment bytes="793039" number="26">50U0a9iP07$A66010-51h55w386f@c$42$S96V57F5u0Y.6UDV35D</segment>
|
||||
<segment bytes="792999" number="27">FnKN4n2749v958xa36J2570506414D293S@8H1A1X490$z3bv.ut6KQ4N</segment>
|
||||
<segment bytes="793316" number="28">q4$d0$X8x6rm85m0Ewh307m255N@t2C7484zq870u.1RLndQ</segment>
|
||||
<segment bytes="793238" number="29">364U4342$5I242404oH90-1W3c0t16705057m650Cq9f@K32rE5297347130W.UNs8evbH</segment>
|
||||
<segment bytes="793461" number="30">M3081U097-r06Y.yy9-1A538001B27f@L2834Y80c7b1075.Dy150</segment>
|
||||
<segment bytes="793326" number="31">189585554.NS66E5D840N4Yq5m07NC1n@51L0393057L528n.k1Mc3j0S</segment>
|
||||
<segment bytes="793380" number="32">189048V505q89216C149I5f$53x-T@0V9i8n7o95.I.Z1lBJ5</segment>
|
||||
<segment bytes="793205" number="33">5-L.555$139r45100-S23-59859@54844694q2.3EY9b</segment>
|
||||
<segment bytes="793258" number="34">641655313y0.Z002L0g39AZ11716U-uX015PI5.v6y@veS44H89Js91903K8.P3MAvk4k</segment>
|
||||
<segment bytes="793229" number="35">1C8f-yz-U-b20.610.0P1M-6Z5418i229160865010s1@M7l210D48Nc.nB0sPmi</segment>
|
||||
<segment bytes="793169" number="36">0653$L0.58749-1U_1PS95-1h9gQ145@0117y0-1x1p-h94.za18yc5</segment>
|
||||
<segment bytes="793109" number="37">77-Mo3-a6514904987865.K0W710G4HB9237@501F7910J6j50-Bh.6cHx1</segment>
|
||||
<segment bytes="793350" number="38">m4I47082655rz$b7P751u9W679475F.89p@f.o.XZv5O7y.855rgXX</segment>
|
||||
<segment bytes="793193" number="39">f075$y56E57d.t11787.0$6D155735M_w89-Y57q2@x0t5H91021wZ52Vh.1h7vabU</segment>
|
||||
<segment bytes="793251" number="40">H7U1331Ad7718$Y69T-q3w4$l247HV49s985J@vi800i0004p.YD5oK</segment>
|
||||
<segment bytes="793106" number="41">9nr786955Ker.M583315CoJ1-W65a817-704@IN-wU12$M1E0g466.5sMJ3</segment>
|
||||
<segment bytes="793006" number="42">0.3R9mN.n2_V086N0-4.Z5gAgZo@ey3G316U382o537.f51Ed5B</segment>
|
||||
<segment bytes="793198" number="43">l106Z1-N411r7j44197l628r.b5Uwc55@k4-Cl_n5xc.1B.xZbNm</segment>
|
||||
<segment bytes="793070" number="44">A91LT1X591x81.TI4130N$555A57q0@L70-p5qa50.40GB</segment>
|
||||
<segment bytes="793457" number="45">V5$765JR6503w0-K63099R615736843G$Qj0ev@mz776wM86445N0.4I56ne</segment>
|
||||
<segment bytes="793109" number="46">A86H2P415S689$568152-025O45V@s079644915.Dd57p0</segment>
|
||||
<segment bytes="793169" number="47">31x5o36q14y9554L42882X0Q10e360Z64W4K9Onx38D@5g1509788414q.Y8wib</segment>
|
||||
<segment bytes="793219" number="48">b$6795157EX1044V964e14-Y9E68614O94C@4061937876$f5.6.19tV</segment>
|
||||
<segment bytes="793349" number="49">D00v8X$b80m93181273J-g076Qj2p79867v5d9689Rb2@r0592.v900.j43E050E</segment>
|
||||
<segment bytes="793228" number="50">Tf78L4e535.o86PK0S.M2R3-66012814z@q-5j89Y29J214Y902.53Ra0f</segment>
|
||||
<segment bytes="793353" number="51">7i01.23411-lQW0212-Er260e9.N5e256jx243EX@91-T.15v40K5Hj.Fo1f</segment>
|
||||
<segment bytes="793290" number="52">3A$H7m63$i595.4713vv0A4$A7Lk7Jsq@0cM0Tw4107f.B520.q5Z91</segment>
|
||||
<segment bytes="793364" number="53">j572m$3h87LS$37167Wp10k41541.T779-Fn@V53C11045619xJ.52.0PnnX4v5</segment>
|
||||
<segment bytes="793506" number="54">A.2d4599a720rk2IB32h0X523MjTL415v89706-7Z45y@R4746-B106358.t3g62r4</segment>
|
||||
<segment bytes="793118" number="55">5q6100961jM-G9F7t755x366zxc102M1SdMF@7394521p651X1I.AL05545a</segment>
|
||||
<segment bytes="793137" number="56">04e851111$12u2213-80VR133125B@7x8865M4hQ9$5.1N345x</segment>
|
||||
<segment bytes="793180" number="57">K2476D3600-73B4W363$008s888980421f27125V$q0@0Zc0a56-m7550.1637vAr1</segment>
|
||||
<segment bytes="793214" number="58">0306u425024v448ZeCE3Q9825m9th1858@5648018-H0.2k7J4.12k0B</segment>
|
||||
<segment bytes="793274" number="59">220u4SK433564Cr2l004t0wP888545779g@19j360863S$55559m.70V7Ndr</segment>
|
||||
<segment bytes="793339" number="60">5u1q051C5Qq8Z9Iy$Z.5.1510NY.S2565n@7m.5-09$z235p74.8kW5</segment>
|
||||
<segment bytes="793297" number="61">6F472C8nh2621_X0C1093P7n39643b5p2f76s60r@1T55203qQY6.wZml1Vb</segment>
|
||||
<segment bytes="793351" number="62">5qC4568844767324-o8i05983-0f.n4.y.OBZ41f@q36B50684KU66.0R1784</segment>
|
||||
<segment bytes="793257" number="63">4P0g470-F59307aDf.JF070Xx959648dO3y00463J6s@71P$D961$C0.11.I096sQ</segment>
|
||||
<segment bytes="793277" number="64">z5kod75077z01w11-A5h.wiG550.J5-p756$81.Db@5l01K49h3K.Ok4R5512</segment>
|
||||
<segment bytes="793292" number="65">F3JX28.B8h90T0075-08001X5w611V071@D75X9263$6$9f.OT050p5Z</segment>
|
||||
<segment bytes="83545" number="66">2B8sT.A650z101514671183y47977219.M4211xYp@0b0021p736BX92.B0lSm4J3</segment>
|
||||
</segments>
|
||||
</file>
|
||||
<file date="1504571157" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[46/46] - "sample-Series.Title.s04e06.720p.hdtv.x264-killers.vol31+04.par2" yEnc (1/3)">
|
||||
<groups>
|
||||
<group>alt.binaries.teevee</group>
|
||||
</groups>
|
||||
<segments>
|
||||
<segment bytes="793316" number="1">16ND-8I545Pq-s107t0h07g8908870711@K401476783.5.0mFs1</segment>
|
||||
<segment bytes="793409" number="2">iYdZ2D11089F310711.ci-O7O4KG03@260c03388O84Kd.GCEgv</segment>
|
||||
<segment bytes="6784" number="3">r63cDD59Mg1c95738Sn75085O4X7823V1@16V6-b87O21S1937O.lw17o1VS</segment>
|
||||
</segments>
|
||||
</file>
|
||||
</fail>
|
||||
105
src/NzbDrone.Core.Test/Files/Nzbs/ValidNzb.nzb
Normal file
105
src/NzbDrone.Core.Test/Files/Nzbs/ValidNzb.nzb
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE nzb
|
||||
PUBLIC '-//newzBin//DTD NZB 1.1//EN'
|
||||
'http://www.newzbin.com/DTD/nzb/nzb-1.1.dtd'>
|
||||
<nzb xmlns="http://www.newzbin.com/DTD/2003/nzb">
|
||||
<file date="1504571104" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[01/46] - "Series.Title.s04e06.720p.hdtv.x264-killers.nfo" yEnc (1/1)">
|
||||
<groups>
|
||||
<group>alt.binaries.teevee</group>
|
||||
</groups>
|
||||
<segments>
|
||||
<segment bytes="12053" number="1">ZQ9h749E781168561i4J0Q6-01m6Q3185@2894t-767038L.Pg7769</segment>
|
||||
</segments>
|
||||
</file>
|
||||
<file date="1504571104" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[02/46] - "Series.Title.s04e06.720p.hdtv.x264-killers.par2" yEnc (1/1)">
|
||||
<groups>
|
||||
<group>alt.binaries.teevee</group>
|
||||
</groups>
|
||||
<segments>
|
||||
<segment bytes="26932" number="1">405Z5Y4066010l377VP1k6$U4873W933@f32Bs90575538201.pj54</segment>
|
||||
</segments>
|
||||
</file>
|
||||
<file date="1504571104" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[03/46] - "Series.Title.s04e06.720p.hdtv.x264-killers.r00" yEnc (1/66)">
|
||||
<groups>
|
||||
<group>alt.binaries.teevee</group>
|
||||
</groups>
|
||||
<segments>
|
||||
<segment bytes="793068" number="1">1x9894417$M.1s25279485O1s1Fi95Z1_18Z554u440@D1k0854_134551.0794144</segment>
|
||||
<segment bytes="793234" number="2">48JYp$W18B2R1s2rI24EG7$907$r89875n60@8xK3374080716.115545M</segment>
|
||||
<segment bytes="793346" number="3">0U93471uI59Y781x77Q8-4286308-4aU35$07-179z@u90567568251.4zgUW968</segment>
|
||||
<segment bytes="793302" number="4">5119x6417a.s06F$1k46$2q89298-C0@G7C-7811268.bK9x00B</segment>
|
||||
<segment bytes="793289" number="5">B8$1_h0b64Z14-16_O6$ESw481L421n9agj7731k@414.473581-K$4.0Zd5A</segment>
|
||||
<segment bytes="793380" number="6">O-4731$tn71v05623J9GT.yc22O975111dR01r58065p@Da1G9L33q74h3095.5X240</segment>
|
||||
<segment bytes="793253" number="7">d9R03J$07w75945Z556197z50F0w.0-5.x9$58311S@J0-v50033110.4a440EYJ</segment>
|
||||
<segment bytes="793317" number="8">05e650149.5r1Hk$E0Bko7G5B.1107mz8l17PS8F@vr816$S6T19245w.042B9</segment>
|
||||
<segment bytes="793060" number="9">245Xy0w4o$tN6428321b.n1816Q1n95bE0816Y@q-qv7E12k.F3672H.16E19</segment>
|
||||
<segment bytes="793266" number="10">H681i185g64H23101kP125z41101O91P384l@E9n597k05j798D94X.2ezz1K</segment>
|
||||
<segment bytes="793223" number="11">T18.6136787.HLJ806.8$Si49m0459445101Z15-5@b80M7.788598D.gXu201cR</segment>
|
||||
<segment bytes="793346" number="12">Vdl8H243Go28j1o865772039416v2@090a20-v365N5S7qf.G225s6</segment>
|
||||
<segment bytes="793305" number="13">S9769892v956069345.0TN.i05R@I04825Gt2706N.BAj1DT1T</segment>
|
||||
<segment bytes="793187" number="14">041800q6F28q44365799m5CQ4D43895@1Bf6268z_Q20F.045JXl</segment>
|
||||
<segment bytes="793119" number="15">1c-e034z4l$9K45i44218ss25$X5_5R-1i76$40-71P@Xt691t8B686Fgv.VBSl</segment>
|
||||
<segment bytes="793262" number="16">76l441W.R146a5368ed02cp_44171410hT.l@Z98.k.70X9c.5mZ1w49</segment>
|
||||
<segment bytes="793221" number="17">12D035G5745-KO43wZ9920ttr1338@V7d871S2-t04t8520.uQ18</segment>
|
||||
<segment bytes="793221" number="18">59V4O77211HA1f5T8h1-53952zV-55294K4M04v@kS878H3g4z.B5561.L330519</segment>
|
||||
<segment bytes="793087" number="19">44-yi1-79$751944J7094$y7-y49994440d86cSn@5C82v-1O9N.wk8wMb6</segment>
|
||||
<segment bytes="793375" number="20">oF7Wj3$Ydh7e030oD4.e81JM464O791495lJ@Pm058Qt4-G8Wv.T1i1a6O1</segment>
|
||||
<segment bytes="793293" number="21">1T7_71M9d10F2.5953VP.11.4h75L@5049bBn384.14Ms</segment>
|
||||
<segment bytes="793266" number="22">u8601765028G662749SD41j0m57651Zq70u1@J5281423406375.z.6PDSx57</segment>
|
||||
<segment bytes="793376" number="23">XY0476$R87Y16g2n45OO335541589V140R026j@y2q9296x7f23C.sqK71b9</segment>
|
||||
<segment bytes="793363" number="24">X7N3440l08B9T5940na4Ls397-T2.P5M12241525J57@r44O419p594M6G4I.d66RQ1</segment>
|
||||
<segment bytes="793203" number="25">p4148978k45.t88w2K9886H4223y5553T7$7p287TN@N8e1T98b_0.mo55a14G</segment>
|
||||
<segment bytes="793039" number="26">50U0a9iP07$A66010-51h55w386f@c$42$S96V57F5u0Y.6UDV35D</segment>
|
||||
<segment bytes="792999" number="27">FnKN4n2749v958xa36J2570506414D293S@8H1A1X490$z3bv.ut6KQ4N</segment>
|
||||
<segment bytes="793316" number="28">q4$d0$X8x6rm85m0Ewh307m255N@t2C7484zq870u.1RLndQ</segment>
|
||||
<segment bytes="793238" number="29">364U4342$5I242404oH90-1W3c0t16705057m650Cq9f@K32rE5297347130W.UNs8evbH</segment>
|
||||
<segment bytes="793461" number="30">M3081U097-r06Y.yy9-1A538001B27f@L2834Y80c7b1075.Dy150</segment>
|
||||
<segment bytes="793326" number="31">189585554.NS66E5D840N4Yq5m07NC1n@51L0393057L528n.k1Mc3j0S</segment>
|
||||
<segment bytes="793380" number="32">189048V505q89216C149I5f$53x-T@0V9i8n7o95.I.Z1lBJ5</segment>
|
||||
<segment bytes="793205" number="33">5-L.555$139r45100-S23-59859@54844694q2.3EY9b</segment>
|
||||
<segment bytes="793258" number="34">641655313y0.Z002L0g39AZ11716U-uX015PI5.v6y@veS44H89Js91903K8.P3MAvk4k</segment>
|
||||
<segment bytes="793229" number="35">1C8f-yz-U-b20.610.0P1M-6Z5418i229160865010s1@M7l210D48Nc.nB0sPmi</segment>
|
||||
<segment bytes="793169" number="36">0653$L0.58749-1U_1PS95-1h9gQ145@0117y0-1x1p-h94.za18yc5</segment>
|
||||
<segment bytes="793109" number="37">77-Mo3-a6514904987865.K0W710G4HB9237@501F7910J6j50-Bh.6cHx1</segment>
|
||||
<segment bytes="793350" number="38">m4I47082655rz$b7P751u9W679475F.89p@f.o.XZv5O7y.855rgXX</segment>
|
||||
<segment bytes="793193" number="39">f075$y56E57d.t11787.0$6D155735M_w89-Y57q2@x0t5H91021wZ52Vh.1h7vabU</segment>
|
||||
<segment bytes="793251" number="40">H7U1331Ad7718$Y69T-q3w4$l247HV49s985J@vi800i0004p.YD5oK</segment>
|
||||
<segment bytes="793106" number="41">9nr786955Ker.M583315CoJ1-W65a817-704@IN-wU12$M1E0g466.5sMJ3</segment>
|
||||
<segment bytes="793006" number="42">0.3R9mN.n2_V086N0-4.Z5gAgZo@ey3G316U382o537.f51Ed5B</segment>
|
||||
<segment bytes="793198" number="43">l106Z1-N411r7j44197l628r.b5Uwc55@k4-Cl_n5xc.1B.xZbNm</segment>
|
||||
<segment bytes="793070" number="44">A91LT1X591x81.TI4130N$555A57q0@L70-p5qa50.40GB</segment>
|
||||
<segment bytes="793457" number="45">V5$765JR6503w0-K63099R615736843G$Qj0ev@mz776wM86445N0.4I56ne</segment>
|
||||
<segment bytes="793109" number="46">A86H2P415S689$568152-025O45V@s079644915.Dd57p0</segment>
|
||||
<segment bytes="793169" number="47">31x5o36q14y9554L42882X0Q10e360Z64W4K9Onx38D@5g1509788414q.Y8wib</segment>
|
||||
<segment bytes="793219" number="48">b$6795157EX1044V964e14-Y9E68614O94C@4061937876$f5.6.19tV</segment>
|
||||
<segment bytes="793349" number="49">D00v8X$b80m93181273J-g076Qj2p79867v5d9689Rb2@r0592.v900.j43E050E</segment>
|
||||
<segment bytes="793228" number="50">Tf78L4e535.o86PK0S.M2R3-66012814z@q-5j89Y29J214Y902.53Ra0f</segment>
|
||||
<segment bytes="793353" number="51">7i01.23411-lQW0212-Er260e9.N5e256jx243EX@91-T.15v40K5Hj.Fo1f</segment>
|
||||
<segment bytes="793290" number="52">3A$H7m63$i595.4713vv0A4$A7Lk7Jsq@0cM0Tw4107f.B520.q5Z91</segment>
|
||||
<segment bytes="793364" number="53">j572m$3h87LS$37167Wp10k41541.T779-Fn@V53C11045619xJ.52.0PnnX4v5</segment>
|
||||
<segment bytes="793506" number="54">A.2d4599a720rk2IB32h0X523MjTL415v89706-7Z45y@R4746-B106358.t3g62r4</segment>
|
||||
<segment bytes="793118" number="55">5q6100961jM-G9F7t755x366zxc102M1SdMF@7394521p651X1I.AL05545a</segment>
|
||||
<segment bytes="793137" number="56">04e851111$12u2213-80VR133125B@7x8865M4hQ9$5.1N345x</segment>
|
||||
<segment bytes="793180" number="57">K2476D3600-73B4W363$008s888980421f27125V$q0@0Zc0a56-m7550.1637vAr1</segment>
|
||||
<segment bytes="793214" number="58">0306u425024v448ZeCE3Q9825m9th1858@5648018-H0.2k7J4.12k0B</segment>
|
||||
<segment bytes="793274" number="59">220u4SK433564Cr2l004t0wP888545779g@19j360863S$55559m.70V7Ndr</segment>
|
||||
<segment bytes="793339" number="60">5u1q051C5Qq8Z9Iy$Z.5.1510NY.S2565n@7m.5-09$z235p74.8kW5</segment>
|
||||
<segment bytes="793297" number="61">6F472C8nh2621_X0C1093P7n39643b5p2f76s60r@1T55203qQY6.wZml1Vb</segment>
|
||||
<segment bytes="793351" number="62">5qC4568844767324-o8i05983-0f.n4.y.OBZ41f@q36B50684KU66.0R1784</segment>
|
||||
<segment bytes="793257" number="63">4P0g470-F59307aDf.JF070Xx959648dO3y00463J6s@71P$D961$C0.11.I096sQ</segment>
|
||||
<segment bytes="793277" number="64">z5kod75077z01w11-A5h.wiG550.J5-p756$81.Db@5l01K49h3K.Ok4R5512</segment>
|
||||
<segment bytes="793292" number="65">F3JX28.B8h90T0075-08001X5w611V071@D75X9263$6$9f.OT050p5Z</segment>
|
||||
<segment bytes="83545" number="66">2B8sT.A650z101514671183y47977219.M4211xYp@0b0021p736BX92.B0lSm4J3</segment>
|
||||
</segments>
|
||||
</file>
|
||||
<file date="1504571157" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[46/46] - "sample-Series.Title.s04e06.720p.hdtv.x264-killers.vol31+04.par2" yEnc (1/3)">
|
||||
<groups>
|
||||
<group>alt.binaries.teevee</group>
|
||||
</groups>
|
||||
<segments>
|
||||
<segment bytes="793316" number="1">16ND-8I545Pq-s107t0h07g8908870711@K401476783.5.0mFs1</segment>
|
||||
<segment bytes="793409" number="2">iYdZ2D11089F310711.ci-O7O4KG03@260c03388O84Kd.GCEgv</segment>
|
||||
<segment bytes="6784" number="3">r63cDD59Mg1c95738Sn75085O4X7823V1@16V6-b87O21S1937O.lw17o1VS</segment>
|
||||
</segments>
|
||||
</file>
|
||||
</nzb>
|
||||
@@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||||
Mocker.GetMock<IDownloadClientStatusRepository>()
|
||||
.Verify(v => v.UpdateMany(
|
||||
It.Is<List<DownloadClientStatus>>(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<IDownloadClientStatusRepository>()
|
||||
.Verify(v => v.UpdateMany(
|
||||
It.Is<List<DownloadClientStatus>>(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
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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" });
|
||||
.Returns(new LocalEpisode() { Path = "test", ParsedEpisodeInfo = new ParsedEpisodeInfo { } });
|
||||
|
||||
_videoFiles = new List<string>
|
||||
{
|
||||
|
||||
@@ -145,5 +145,33 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests
|
||||
|
||||
MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(2.0m);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_AudioChannelPositionText_when_AudioChannelChannelPosition_is_invalid()
|
||||
{
|
||||
var mediaInfoModel = new MediaInfoModel
|
||||
{
|
||||
AudioChannels = 6,
|
||||
AudioChannelPositions = "15 objects",
|
||||
AudioChannelPositionsText = "15 objects / Front: L C R, Side: L R, LFE",
|
||||
SchemaRevision = 3
|
||||
};
|
||||
|
||||
MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(5.1m);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_remove_atmos_objects_from_AudioChannelPostions()
|
||||
{
|
||||
var mediaInfoModel = new MediaInfoModel
|
||||
{
|
||||
AudioChannels = 2,
|
||||
AudioChannelPositions = "15 objects / 3/2.1",
|
||||
AudioChannelPositionsText = null,
|
||||
SchemaRevision = 3
|
||||
};
|
||||
|
||||
MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(5.1m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = UpdateMediaInfoService.CURRENT_MEDIA_INFO_SCHEMA_REVISION })
|
||||
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = VideoFileInfoReader.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 = UpdateMediaInfoService.MINIMUM_MEDIA_INFO_SCHEMA_REVISION })
|
||||
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = VideoFileInfoReader.MINIMUM_MEDIA_INFO_SCHEMA_REVISION })
|
||||
.BuildList();
|
||||
|
||||
Mocker.GetMock<IMediaFileService>()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@@ -46,7 +46,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
|
||||
info.VideoProfile.Should().Be("Baseline@L2.1");
|
||||
info.VideoCodecLibrary.Should().Be("");
|
||||
info.AudioFormat.Should().Be("AAC");
|
||||
info.AudioCodecID.Should().Be("40");
|
||||
info.AudioCodecID.Should().BeOneOf("40", "mp4a-40-2");
|
||||
info.AudioProfile.Should().Be("LC");
|
||||
info.AudioCodecLibrary.Should().Be("");
|
||||
info.AudioBitrate.Should().Be(128000);
|
||||
@@ -82,7 +82,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
|
||||
info.VideoProfile.Should().Be("Baseline@L2.1");
|
||||
info.VideoCodecLibrary.Should().Be("");
|
||||
info.AudioFormat.Should().Be("AAC");
|
||||
info.AudioCodecID.Should().Be("40");
|
||||
info.AudioCodecID.Should().BeOneOf("40", "mp4a-40-2");
|
||||
info.AudioProfile.Should().Be("LC");
|
||||
info.AudioCodecLibrary.Should().Be("");
|
||||
info.AudioBitrate.Should().Be(128000);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
@@ -7,6 +7,7 @@ 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;
|
||||
@@ -33,12 +34,16 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.FileExists(It.IsAny<string>()))
|
||||
.Returns(true);
|
||||
.Setup(c => c.FolderExists(Directory.GetParent(_localEpisode.Series.Path).FullName))
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<IDiskProvider>()
|
||||
.Setup(c => c.GetParentFolder(It.IsAny<string>()))
|
||||
.Returns<string>(c => Path.GetDirectoryName(c));
|
||||
.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));
|
||||
}
|
||||
|
||||
private void GivenSingleEpisodeWithSingleEpisodeFile()
|
||||
@@ -175,5 +180,19 @@ 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,15 @@ 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());
|
||||
@@ -44,8 +53,10 @@ namespace NzbDrone.Core.Test.Messaging.Commands
|
||||
.Returns(_commandQueue.GetConsumingEnumerable);
|
||||
}
|
||||
|
||||
private void WaitForExecution(CommandModel commandModel)
|
||||
private void QueueAndWaitForExecution(CommandModel commandModel)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
|
||||
Mocker.GetMock<IManageCommandQueue>()
|
||||
.Setup(s => s.Complete(It.Is<CommandModel>(c => c == commandModel), It.IsAny<string>()))
|
||||
.Callback(() => _commandExecuted = true);
|
||||
@@ -54,12 +65,14 @@ 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);
|
||||
}
|
||||
|
||||
var t1 = 1;
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -82,9 +95,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands
|
||||
};
|
||||
|
||||
Subject.Handle(new ApplicationStartedEvent());
|
||||
_commandQueue.Add(commandModel);
|
||||
|
||||
WaitForExecution(commandModel);
|
||||
QueueAndWaitForExecution(commandModel);
|
||||
|
||||
_executorA.Verify(c => c.Execute(commandA), Times.Once());
|
||||
}
|
||||
@@ -100,9 +112,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands
|
||||
};
|
||||
|
||||
Subject.Handle(new ApplicationStartedEvent());
|
||||
_commandQueue.Add(commandModel);
|
||||
|
||||
WaitForExecution(commandModel);
|
||||
QueueAndWaitForExecution(commandModel);
|
||||
|
||||
_executorA.Verify(c => c.Execute(commandA), Times.Once());
|
||||
_executorB.Verify(c => c.Execute(It.IsAny<CommandB>()), Times.Never());
|
||||
@@ -122,9 +133,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands
|
||||
.Throws(new NotImplementedException());
|
||||
|
||||
Subject.Handle(new ApplicationStartedEvent());
|
||||
_commandQueue.Add(commandModel);
|
||||
|
||||
WaitForExecution(commandModel);
|
||||
QueueAndWaitForExecution(commandModel);
|
||||
|
||||
VerifyEventPublished<CommandExecutedEvent>();
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
@@ -141,9 +151,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands
|
||||
};
|
||||
|
||||
Subject.Handle(new ApplicationStartedEvent());
|
||||
_commandQueue.Add(commandModel);
|
||||
|
||||
WaitForExecution(commandModel);
|
||||
QueueAndWaitForExecution(commandModel);
|
||||
|
||||
VerifyEventPublished<CommandExecutedEvent>();
|
||||
}
|
||||
@@ -159,9 +168,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands
|
||||
};
|
||||
|
||||
Subject.Handle(new ApplicationStartedEvent());
|
||||
_commandQueue.Add(commandModel);
|
||||
|
||||
WaitForExecution(commandModel);
|
||||
QueueAndWaitForExecution(commandModel);
|
||||
|
||||
Mocker.GetMock<IManageCommandQueue>()
|
||||
.Setup(s => s.Complete(It.Is<CommandModel>(c => c == commandModel), commandA.CompletionMessage))
|
||||
@@ -180,9 +188,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands
|
||||
};
|
||||
|
||||
Subject.Handle(new ApplicationStartedEvent());
|
||||
_commandQueue.Add(commandModel);
|
||||
|
||||
WaitForExecution(commandModel);
|
||||
QueueAndWaitForExecution(commandModel);
|
||||
|
||||
Mocker.GetMock<IManageCommandQueue>()
|
||||
.Setup(s => s.Complete(It.Is<CommandModel>(c => c == commandModel), commandModel.Message))
|
||||
@@ -202,10 +209,10 @@ namespace NzbDrone.Core.Test.Messaging.Commands
|
||||
|
||||
public CommandB()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override string CompletionMessage => null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,10 @@
|
||||
<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>
|
||||
@@ -86,7 +90,7 @@
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.4.12\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>
|
||||
@@ -97,9 +101,6 @@
|
||||
<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>
|
||||
@@ -194,6 +195,7 @@
|
||||
<Compile Include="Download\DownloadClientTests\VuzeTests\VuzeFixture.cs" />
|
||||
<Compile Include="Download\DownloadServiceFixture.cs" />
|
||||
<Compile Include="Download\FailedDownloadServiceFixture.cs" />
|
||||
<Compile Include="Download\NzbValidationServiceFixture.cs" />
|
||||
<Compile Include="Download\Pending\PendingReleaseServiceTests\PendingReleaseServiceFixture.cs" />
|
||||
<Compile Include="Download\Pending\PendingReleaseServiceTests\RemovePendingFixture.cs" />
|
||||
<Compile Include="Download\Pending\PendingReleaseServiceTests\RemoveRejectedFixture.cs" />
|
||||
@@ -570,6 +572,12 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Files\Nzbs\NotNzb.nzb">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Files\Nzbs\NoFiles.nzb">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Files\TestArchive.tar.gz">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
@@ -588,6 +596,9 @@
|
||||
<Content Include="Files\Xem\Names.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="Files\Nzbs\ValidNzb.nzb">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||
public void should_parse_from_path(string path, int season, int episode)
|
||||
{
|
||||
var result = Parser.Parser.ParsePath(path.AsOsAgnostic());
|
||||
|
||||
result.EpisodeNumbers.Should().HaveCount(1);
|
||||
result.SeasonNumber.Should().Be(season);
|
||||
result.EpisodeNumbers[0].Should().Be(episode);
|
||||
@@ -42,5 +43,20 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||
|
||||
ExceptionVerification.IgnoreWarns();
|
||||
}
|
||||
|
||||
[TestCase("01-03\\The Series Title (2010) - 1x01-02-03 - Episode Title HDTV-720p Proper", "The Series Title (2010)", 1, new [] { 1, 2, 3 })]
|
||||
public void should_parse_multi_episode_from_path(string path, string title, int season, int[] episodes)
|
||||
{
|
||||
var result = Parser.Parser.ParsePath(path.AsOsAgnostic());
|
||||
|
||||
result.SeriesTitle.Should().Be(title);
|
||||
result.EpisodeNumbers.Should().HaveCount(episodes.Length);
|
||||
result.SeasonNumber.Should().Be(season);
|
||||
result.EpisodeNumbers.Should().BeEquivalentTo(episodes);
|
||||
result.AbsoluteEpisodeNumbers.Should().BeEmpty();
|
||||
result.FullSeason.Should().BeFalse();
|
||||
|
||||
ExceptionVerification.IgnoreWarns();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using FluentAssertions;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Qualities;
|
||||
@@ -117,6 +117,7 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||
[TestCase("[Eveyuu] No Game No Life - 10 [Hi10P 1280x720 H264][10B23BD8]", false)]
|
||||
[TestCase("Hells.Kitchen.US.S12E17.HR.WS.PDTV.X264-DIMENSION", false)]
|
||||
[TestCase("Survivorman.The.Lost.Pilots.Summer.HR.WS.PDTV.x264-DHD", false)]
|
||||
[TestCase("Victoria S01E07 - Motor zmen (CZ)[TvRip][HEVC][720p]", false)]
|
||||
public void should_parse_hdtv720p_quality(string title, bool proper)
|
||||
{
|
||||
ParseAndVerifyQuality(title, Quality.HDTV720p, proper);
|
||||
@@ -128,6 +129,7 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||
[TestCase("DEXTER.S07E01.ARE.YOU.1080P.HDTV.proper.X264-QCF", true)]
|
||||
[TestCase("Dexter - S01E01 - Title [HDTV-1080p]", false)]
|
||||
[TestCase("[HorribleSubs] Yowamushi Pedal - 32 [1080p]", false)]
|
||||
[TestCase("Victoria S01E07 - Motor zmen (CZ)[TvRip][HEVC][1080p]", false)]
|
||||
public void should_parse_hdtv1080p_quality(string title, bool proper)
|
||||
{
|
||||
ParseAndVerifyQuality(title, Quality.HDTV1080p, proper);
|
||||
|
||||
@@ -129,6 +129,7 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||
[TestCase("Jeopardy - 2016x231", "Jeopardy", 2016, 231)]
|
||||
[TestCase("Shortland.Street.S26E022.HDTV.x264-FiHTV", "Shortland Street", 26, 22)]
|
||||
[TestCase("Super.Potatoes.S01.Ep06.1080p.BluRay.DTS.x264-MiR", "Super Potatoes", 1, 6)]
|
||||
[TestCase("Room 104 - S01E07 The Missionaries [SDTV]", "Room 104", 1, 7)]
|
||||
//[TestCase("", "", 0, 0)]
|
||||
public void should_parse_single_episode(string postTitle, string title, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
|
||||
@@ -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" />
|
||||
<package id="Moq" version="4.0.10827" targetFramework="net40" />
|
||||
<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.3" targetFramework="net40" />
|
||||
<package id="NLog" version="4.4.12" 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" />
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ using NzbDrone.Core.Instrumentation;
|
||||
using NzbDrone.Core.Jobs;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Profiles.Delay;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
using NzbDrone.Core.Notifications;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
@@ -105,8 +104,7 @@ namespace NzbDrone.Core.Datastore
|
||||
|
||||
Mapper.Entity<PendingRelease>().RegisterModel("PendingReleases")
|
||||
.Ignore(e => e.RemoteEpisode);
|
||||
|
||||
Mapper.Entity<RemotePathMapping>().RegisterModel("RemotePathMappings");
|
||||
|
||||
Mapper.Entity<Tag>().RegisterModel("Tags");
|
||||
Mapper.Entity<Restriction>().RegisterModel("Restrictions");
|
||||
|
||||
|
||||
@@ -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);
|
||||
var oldest = _pendingReleaseService.OldestPendingRelease(subject.Series.Id, episodeIds.ToArray());
|
||||
|
||||
if (oldest != null && oldest.Release.AgeMinutes > delay)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
|
||||
namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||
{
|
||||
public class TorrentSeedingSpecification : IDecisionEngineSpecification
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@ using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles.TorrentInfo;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.Blackhole
|
||||
@@ -29,9 +28,8 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
Logger logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
|
||||
{
|
||||
_scanWatchFolder = scanWatchFolder;
|
||||
|
||||
@@ -99,7 +97,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
|
||||
TotalSize = item.TotalSize,
|
||||
RemainingTime = item.RemainingTime,
|
||||
|
||||
OutputPath = item.OutputPath,
|
||||
OutputPath = new DownloadClientPath(Definition.Id, item.OutputPath),
|
||||
|
||||
Status = item.Status,
|
||||
|
||||
@@ -124,7 +122,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
|
||||
return new DownloadClientInfo
|
||||
{
|
||||
IsLocalhost = true,
|
||||
OutputRootFolders = new List<OsPath> { new OsPath(Settings.WatchFolder) }
|
||||
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(Settings.WatchFolder)) }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using FluentValidation.Results;
|
||||
@@ -9,7 +9,6 @@ using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.Blackhole
|
||||
{
|
||||
@@ -23,9 +22,9 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
IValidateNzbs nzbValidationService,
|
||||
Logger logger)
|
||||
: base(httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(httpClient, configService, diskProvider, nzbValidationService, logger)
|
||||
{
|
||||
_scanWatchFolder = scanWatchFolder;
|
||||
|
||||
@@ -66,7 +65,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
|
||||
TotalSize = item.TotalSize,
|
||||
RemainingTime = item.RemainingTime,
|
||||
|
||||
OutputPath = item.OutputPath,
|
||||
OutputPath = new DownloadClientPath(Definition.Id, item.OutputPath),
|
||||
|
||||
Status = item.Status,
|
||||
|
||||
@@ -91,7 +90,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
|
||||
return new DownloadClientInfo
|
||||
{
|
||||
IsLocalhost = true,
|
||||
OutputRootFolders = new List<OsPath> { new OsPath(Settings.WatchFolder) }
|
||||
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(Settings.WatchFolder)) }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ using NzbDrone.Core.Validation;
|
||||
using NLog;
|
||||
using FluentValidation.Results;
|
||||
using System.Net;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.Deluge
|
||||
{
|
||||
@@ -24,9 +23,8 @@ namespace NzbDrone.Core.Download.Clients.Deluge
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
Logger logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
|
||||
{
|
||||
_proxy = proxy;
|
||||
}
|
||||
@@ -106,8 +104,8 @@ namespace NzbDrone.Core.Download.Clients.Deluge
|
||||
|
||||
item.DownloadClient = Definition.Name;
|
||||
|
||||
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.DownloadPath));
|
||||
item.OutputPath = outputPath + torrent.Name;
|
||||
var outputPath = new OsPath(torrent.DownloadPath) + torrent.Name;
|
||||
item.OutputPath = new DownloadClientPath(Definition.Id, outputPath);
|
||||
item.RemainingSize = torrent.Size - torrent.BytesDownloaded;
|
||||
|
||||
try
|
||||
@@ -176,7 +174,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
|
||||
|
||||
if (!destDir.IsEmpty)
|
||||
{
|
||||
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) };
|
||||
status.OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, destDir) };
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -12,7 +12,6 @@ using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
|
||||
using NzbDrone.Core.MediaFiles.TorrentInfo;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.DownloadStation
|
||||
@@ -34,9 +33,8 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
Logger logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
|
||||
{
|
||||
_dsInfoProxy = dsInfoProxy;
|
||||
_dsTaskProxy = dsTaskProxy;
|
||||
@@ -96,7 +94,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
|
||||
|
||||
if (item.Status == DownloadItemStatus.Completed || item.Status == DownloadItemStatus.Failed)
|
||||
{
|
||||
item.OutputPath = GetOutputPath(outputPath, torrent, serialNumber);
|
||||
item.OutputPath = new DownloadClientPath(Definition.Id, GetOutputPath(outputPath, torrent, serialNumber));
|
||||
}
|
||||
|
||||
items.Add(item);
|
||||
@@ -114,7 +112,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
|
||||
return new DownloadClientInfo
|
||||
{
|
||||
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
|
||||
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(path)) }
|
||||
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(path)) }
|
||||
};
|
||||
}
|
||||
catch (DownloadClientException e)
|
||||
@@ -140,9 +138,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
|
||||
{
|
||||
var fullPath = _sharedFolderResolver.RemapToFullPath(outputPath, Settings, serialNumber);
|
||||
|
||||
var remotePath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, fullPath);
|
||||
|
||||
var finalPath = remotePath + torrent.Title;
|
||||
var finalPath = fullPath + torrent.Title;
|
||||
|
||||
return finalPath;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@@ -10,7 +10,6 @@ using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.DownloadStation
|
||||
@@ -31,10 +30,10 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
IValidateNzbs nzbValidationService,
|
||||
Logger logger
|
||||
)
|
||||
: base(httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(httpClient, configService, diskProvider, nzbValidationService, logger)
|
||||
{
|
||||
_dsInfoProxy = dsInfoProxy;
|
||||
_dsTaskProxy = dsTaskProxy;
|
||||
@@ -110,7 +109,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
|
||||
|
||||
if (item.Status == DownloadItemStatus.Completed || item.Status == DownloadItemStatus.Failed)
|
||||
{
|
||||
item.OutputPath = GetOutputPath(outputPath, nzb, serialNumber);
|
||||
item.OutputPath = new DownloadClientPath(Definition.Id, GetOutputPath(outputPath, nzb, serialNumber));
|
||||
}
|
||||
|
||||
items.Add(item);
|
||||
@@ -123,7 +122,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
|
||||
{
|
||||
var fullPath = _sharedFolderResolver.RemapToFullPath(outputPath, Settings, serialNumber);
|
||||
|
||||
var remotePath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, fullPath);
|
||||
var remotePath = fullPath;
|
||||
|
||||
var finalPath = remotePath + task.Title;
|
||||
|
||||
@@ -139,7 +138,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
|
||||
return new DownloadClientInfo
|
||||
{
|
||||
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
|
||||
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(path)) }
|
||||
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(path)) }
|
||||
};
|
||||
}
|
||||
catch (DownloadClientException e)
|
||||
|
||||
@@ -10,7 +10,6 @@ using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients.Hadouken.Models;
|
||||
using NzbDrone.Core.MediaFiles.TorrentInfo;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.Hadouken
|
||||
@@ -24,9 +23,8 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
Logger logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
|
||||
{
|
||||
_proxy = proxy;
|
||||
}
|
||||
@@ -46,7 +44,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
|
||||
continue;
|
||||
}
|
||||
|
||||
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.SavePath));
|
||||
var outputPath = new OsPath(torrent.SavePath);
|
||||
var eta = TimeSpan.FromSeconds(0);
|
||||
|
||||
if (torrent.DownloadRate > 0 && torrent.TotalSize > 0)
|
||||
@@ -58,7 +56,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
|
||||
{
|
||||
DownloadClient = Definition.Name,
|
||||
DownloadId = torrent.InfoHash.ToUpper(),
|
||||
OutputPath = outputPath + torrent.Name,
|
||||
OutputPath = new DownloadClientPath(Definition.Id, outputPath + torrent.Name),
|
||||
RemainingSize = torrent.TotalSize - torrent.DownloadedBytes,
|
||||
RemainingTime = eta,
|
||||
Title = torrent.Name,
|
||||
@@ -119,7 +117,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
|
||||
|
||||
if (!destDir.IsEmpty)
|
||||
{
|
||||
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) };
|
||||
status.OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, destDir) };
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -10,7 +10,6 @@ using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Validation;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.NzbVortex
|
||||
{
|
||||
@@ -22,9 +21,9 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
IValidateNzbs nzbValidationService,
|
||||
Logger logger)
|
||||
: base(httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(httpClient, configService, diskProvider, nzbValidationService, logger)
|
||||
{
|
||||
_proxy = proxy;
|
||||
}
|
||||
@@ -87,7 +86,7 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
|
||||
break;
|
||||
}
|
||||
|
||||
queueItem.OutputPath = GetOutputPath(vortexQueueItem, queueItem);
|
||||
queueItem.OutputPath = new DownloadClientPath(Definition.Id, GetOutputPath(vortexQueueItem, queueItem));
|
||||
|
||||
if (vortexQueueItem.State == NzbVortexStateType.PasswordRequest)
|
||||
{
|
||||
@@ -220,7 +219,7 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
|
||||
|
||||
private OsPath GetOutputPath(NzbVortexQueueItem vortexQueueItem, DownloadClientItem queueItem)
|
||||
{
|
||||
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(vortexQueueItem.DestinationPath));
|
||||
var outputPath = new OsPath(vortexQueueItem.DestinationPath);
|
||||
|
||||
if (outputPath.FileName == vortexQueueItem.UiTitle)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
@@ -10,7 +10,6 @@ using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||
@@ -25,9 +24,9 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
IValidateNzbs nzbValidationService,
|
||||
Logger logger)
|
||||
: base(httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(httpClient, configService, diskProvider, nzbValidationService, logger)
|
||||
{
|
||||
_proxy = proxy;
|
||||
}
|
||||
@@ -122,7 +121,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||
historyItem.DownloadId = droneParameter == null ? item.Id.ToString() : droneParameter.Value.ToString();
|
||||
historyItem.Title = item.Name;
|
||||
historyItem.TotalSize = MakeInt64(item.FileSizeHi, item.FileSizeLo);
|
||||
historyItem.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(item.DestDir));
|
||||
historyItem.OutputPath = new DownloadClientPath(Definition.Id, new OsPath(item.DestDir));
|
||||
historyItem.Category = item.Category;
|
||||
historyItem.Message = $"PAR Status: {item.ParStatus} - Unpack Status: {item.UnpackStatus} - Move Status: {item.MoveStatus} - Script Status: {item.ScriptStatus} - Delete Status: {item.DeleteStatus} - Mark Status: {item.MarkStatus}";
|
||||
historyItem.Status = DownloadItemStatus.Completed;
|
||||
@@ -207,7 +206,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||
|
||||
if (category != null)
|
||||
{
|
||||
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(category.DestDir)) };
|
||||
status.OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(category.DestDir)) };
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -8,7 +8,6 @@ using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
@@ -21,9 +20,8 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
|
||||
public Pneumatic(IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
Logger logger)
|
||||
: base(configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(configService, diskProvider, logger)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
@@ -82,7 +80,7 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
|
||||
|
||||
TotalSize = _diskProvider.GetFileSize(file),
|
||||
|
||||
OutputPath = new OsPath(file)
|
||||
OutputPath = new DownloadClientPath(Definition.Id, new OsPath(file))
|
||||
};
|
||||
|
||||
if (_diskProvider.IsFileLocked(file))
|
||||
|
||||
@@ -11,7 +11,6 @@ using NzbDrone.Core.Validation;
|
||||
using FluentValidation.Results;
|
||||
using System.Net;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.QBittorrent
|
||||
{
|
||||
@@ -24,9 +23,8 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
Logger logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
|
||||
{
|
||||
_proxy = proxy;
|
||||
}
|
||||
@@ -109,16 +107,17 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
|
||||
item.RemainingSize = (long)(torrent.Size * (1.0 - torrent.Progress));
|
||||
item.RemainingTime = TimeSpan.FromSeconds(torrent.Eta);
|
||||
|
||||
item.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.SavePath));
|
||||
var outputPath = new OsPath(torrent.SavePath);
|
||||
if (!outputPath.IsEmpty && outputPath.FileName != torrent.Name)
|
||||
{
|
||||
outputPath += torrent.Name;
|
||||
}
|
||||
item.OutputPath = new DownloadClientPath(Definition.Id, outputPath);
|
||||
|
||||
// Avoid removing torrents that haven't reached the global max ratio.
|
||||
// Removal also requires the torrent to be paused, in case a higher max ratio was set on the torrent itself (which is not exposed by the api).
|
||||
item.CanMoveFiles = item.CanBeRemoved = (!config.MaxRatioEnabled || config.MaxRatio <= torrent.Ratio) && torrent.State == "pausedUP";
|
||||
|
||||
if (!item.OutputPath.IsEmpty && item.OutputPath.FileName != torrent.Name)
|
||||
{
|
||||
item.OutputPath += torrent.Name;
|
||||
}
|
||||
|
||||
switch (torrent.State)
|
||||
{
|
||||
@@ -176,7 +175,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
|
||||
return new DownloadClientInfo
|
||||
{
|
||||
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
|
||||
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) }
|
||||
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, destDir) }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
|
||||
public QBittorrentSettings()
|
||||
{
|
||||
Host = "localhost";
|
||||
Port = 9091;
|
||||
Port = 8080;
|
||||
TvCategory = "tv-sonarr";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -10,7 +10,6 @@ using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Validation;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||
{
|
||||
@@ -22,9 +21,9 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
IValidateNzbs nzbValidationService,
|
||||
Logger logger)
|
||||
: base(httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(httpClient, configService, diskProvider, nzbValidationService, logger)
|
||||
{
|
||||
_proxy = proxy;
|
||||
}
|
||||
@@ -162,23 +161,22 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||
historyItem.Status = DownloadItemStatus.Downloading;
|
||||
}
|
||||
|
||||
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(sabHistoryItem.Storage));
|
||||
var outputPath = new OsPath(sabHistoryItem.Storage);
|
||||
|
||||
if (!outputPath.IsEmpty)
|
||||
{
|
||||
historyItem.OutputPath = outputPath;
|
||||
|
||||
var parent = outputPath.Directory;
|
||||
while (!parent.IsEmpty)
|
||||
{
|
||||
if (parent.FileName == sabHistoryItem.Title)
|
||||
{
|
||||
historyItem.OutputPath = parent;
|
||||
outputPath = parent;
|
||||
}
|
||||
parent = parent.Directory;
|
||||
}
|
||||
}
|
||||
|
||||
historyItem.OutputPath = new DownloadClientPath(Definition.Id, outputPath);
|
||||
}
|
||||
|
||||
historyItems.Add(historyItem);
|
||||
}
|
||||
@@ -260,7 +258,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
|
||||
|
||||
if (category != null)
|
||||
{
|
||||
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, category.FullPath) };
|
||||
status.OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, category.FullPath) };
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -6,7 +6,6 @@ using NzbDrone.Core.Configuration;
|
||||
using NLog;
|
||||
using FluentValidation.Results;
|
||||
using NzbDrone.Core.MediaFiles.TorrentInfo;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.Transmission
|
||||
{
|
||||
@@ -17,9 +16,8 @@ namespace NzbDrone.Core.Download.Clients.Transmission
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
Logger logger)
|
||||
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles.TorrentInfo;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.Transmission
|
||||
@@ -24,9 +23,8 @@ namespace NzbDrone.Core.Download.Clients.Transmission
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
Logger logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
|
||||
{
|
||||
_proxy = proxy;
|
||||
}
|
||||
@@ -54,8 +52,6 @@ namespace NzbDrone.Core.Download.Clients.Transmission
|
||||
if (!directories.Contains(Settings.TvCategory)) continue;
|
||||
}
|
||||
|
||||
outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, outputPath);
|
||||
|
||||
var item = new DownloadClientItem();
|
||||
item.DownloadId = torrent.HashString.ToUpper();
|
||||
item.Category = Settings.TvCategory;
|
||||
@@ -63,7 +59,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
|
||||
|
||||
item.DownloadClient = Definition.Name;
|
||||
|
||||
item.OutputPath = GetOutputPath(outputPath, torrent);
|
||||
item.OutputPath = new DownloadClientPath(Definition.Id, GetOutputPath(outputPath, torrent));
|
||||
item.TotalSize = torrent.TotalSize;
|
||||
item.RemainingSize = torrent.LeftUntilDone;
|
||||
if (torrent.Eta >= 0)
|
||||
@@ -122,7 +118,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
|
||||
return new DownloadClientInfo
|
||||
{
|
||||
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
|
||||
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(destDir)) }
|
||||
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(destDir)) }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients.Transmission;
|
||||
using NzbDrone.Core.MediaFiles.TorrentInfo;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.Vuze
|
||||
{
|
||||
@@ -18,9 +17,8 @@ namespace NzbDrone.Core.Download.Clients.Vuze
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
Logger logger)
|
||||
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, logger)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ using FluentValidation.Results;
|
||||
using NzbDrone.Core.Download.Clients.rTorrent;
|
||||
using NzbDrone.Core.Exceptions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.RTorrent
|
||||
@@ -28,10 +27,9 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
IRTorrentDirectoryValidator rTorrentDirectoryValidator,
|
||||
Logger logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
|
||||
{
|
||||
_proxy = proxy;
|
||||
_rTorrentDirectoryValidator = rTorrentDirectoryValidator;
|
||||
@@ -100,7 +98,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
|
||||
item.DownloadClient = Definition.Name;
|
||||
item.Title = torrent.Name;
|
||||
item.DownloadId = torrent.Hash;
|
||||
item.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.Path));
|
||||
item.OutputPath = new DownloadClientPath(Definition.Id, new OsPath(torrent.Path));
|
||||
item.TotalSize = torrent.TotalSize;
|
||||
item.RemainingSize = torrent.RemainingSize;
|
||||
item.Category = torrent.Category;
|
||||
|
||||
@@ -11,7 +11,6 @@ using NzbDrone.Core.Validation;
|
||||
using FluentValidation.Results;
|
||||
using System.Net;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
using NzbDrone.Common.Cache;
|
||||
|
||||
namespace NzbDrone.Core.Download.Clients.UTorrent
|
||||
@@ -27,9 +26,8 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
Logger logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
|
||||
{
|
||||
_proxy = proxy;
|
||||
|
||||
@@ -99,16 +97,13 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
|
||||
item.RemainingTime = TimeSpan.FromSeconds(torrent.Eta);
|
||||
}
|
||||
|
||||
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.RootDownloadPath));
|
||||
var outputPath = new OsPath(torrent.RootDownloadPath);
|
||||
|
||||
if (outputPath == null || outputPath.FileName == torrent.Name)
|
||||
if (outputPath != null && outputPath.FileName != torrent.Name)
|
||||
{
|
||||
item.OutputPath = outputPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.OutputPath = outputPath + torrent.Name;
|
||||
outputPath += torrent.Name;
|
||||
}
|
||||
item.OutputPath = new DownloadClientPath(Definition.Id, outputPath);
|
||||
|
||||
if (torrent.Status.HasFlag(UTorrentTorrentStatus.Error))
|
||||
{
|
||||
@@ -209,7 +204,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
|
||||
|
||||
if (!destDir.IsEmpty)
|
||||
{
|
||||
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) };
|
||||
status.OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, destDir) };
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -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 = 9091;
|
||||
Port = 8080;
|
||||
TvCategory = "tv-sonarr";
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
@@ -19,7 +18,6 @@ namespace NzbDrone.Core.Download
|
||||
{
|
||||
protected readonly IConfigService _configService;
|
||||
protected readonly IDiskProvider _diskProvider;
|
||||
protected readonly IRemotePathMappingService _remotePathMappingService;
|
||||
protected readonly Logger _logger;
|
||||
|
||||
public abstract string Name { get; }
|
||||
@@ -36,14 +34,12 @@ namespace NzbDrone.Core.Download
|
||||
|
||||
protected TSettings Settings => (TSettings)Definition.Settings;
|
||||
|
||||
protected DownloadClientBase(IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
protected DownloadClientBase(IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
Logger logger)
|
||||
{
|
||||
_configService = configService;
|
||||
_diskProvider = diskProvider;
|
||||
_remotePathMappingService = remotePathMappingService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@@ -76,6 +72,9 @@ namespace NzbDrone.Core.Download
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME: Doesn't work if remote.
|
||||
throw new NotSupportedException();
|
||||
/*
|
||||
if (item.OutputPath.IsEmpty)
|
||||
{
|
||||
_logger.Trace("[{0}] Doesn't have an outputPath, skipping delete data.", item.Title);
|
||||
@@ -104,7 +103,7 @@ namespace NzbDrone.Core.Download
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Warn(ex, string.Format("[{0}] Error occurred while trying to delete data from '{1}'.", item.Title, item.OutputPath));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public ValidationResult Test()
|
||||
|
||||
@@ -6,6 +6,6 @@ namespace NzbDrone.Core.Download
|
||||
public class DownloadClientInfo
|
||||
{
|
||||
public bool IsLocalhost { get; set; }
|
||||
public List<OsPath> OutputRootFolders { get; set; }
|
||||
public List<DownloadClientPath> OutputRootFolders { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace NzbDrone.Core.Download
|
||||
public long RemainingSize { get; set; }
|
||||
public TimeSpan? RemainingTime { get; set; }
|
||||
|
||||
public OsPath OutputPath { get; set; }
|
||||
public DownloadClientPath OutputPath { get; set; }
|
||||
public string Message { get; set; }
|
||||
|
||||
public DownloadItemStatus Status { get; set; }
|
||||
|
||||
16
src/NzbDrone.Core/Download/DownloadClientPath.cs
Normal file
16
src/NzbDrone.Core/Download/DownloadClientPath.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using NzbDrone.Common.Disk;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
{
|
||||
public class DownloadClientPath
|
||||
{
|
||||
public int DownloadClientId { get; set; }
|
||||
public OsPath Path { get; set; }
|
||||
|
||||
public DownloadClientPath(int downloadClientId, OsPath path)
|
||||
{
|
||||
DownloadClientId = downloadClientId;
|
||||
Path = path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,11 +56,6 @@ namespace NzbDrone.Core.Download
|
||||
throw new DownloadClientUnavailableException($"{remoteEpisode.Release.DownloadProtocol} Download client isn't configured yet");
|
||||
}
|
||||
|
||||
if (_downloadClientStatusService.IsDisabled(downloadClient.Definition.Id))
|
||||
{
|
||||
throw new DownloadClientUnavailableException($"{downloadClient.Name} is disabled due to recent failues");
|
||||
}
|
||||
|
||||
// Limit grabs to 2 per second.
|
||||
if (remoteEpisode.Release.DownloadUrl.IsNotNullOrWhiteSpace() && !remoteEpisode.Release.DownloadUrl.StartsWith("magnet:"))
|
||||
{
|
||||
@@ -75,6 +70,11 @@ 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;
|
||||
|
||||
29
src/NzbDrone.Core/Download/InvalidNzbException.cs
Normal file
29
src/NzbDrone.Core/Download/InvalidNzbException.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using NzbDrone.Common.Exceptions;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
{
|
||||
public class InvalidNzbException : NzbDroneException
|
||||
{
|
||||
public InvalidNzbException(string message, params object[] args) : base(message, args)
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidNzbException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidNzbException(string message, Exception innerException, params object[] args) : base(message, innerException, args)
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidNzbException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidNzbException(string message, string nzbName)
|
||||
: base($"{message} [{0}]", nzbName)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
45
src/NzbDrone.Core/Download/NzbValidationService.cs
Normal file
45
src/NzbDrone.Core/Download/NzbValidationService.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
{
|
||||
public interface IValidateNzbs
|
||||
{
|
||||
void Validate(string filename, byte[] fileContent);
|
||||
}
|
||||
|
||||
public class NzbValidationService : IValidateNzbs
|
||||
{
|
||||
public void Validate(string filename, byte[] fileContent)
|
||||
{
|
||||
var reader = new StreamReader(new MemoryStream(fileContent));
|
||||
|
||||
using (var xmlTextReader = XmlReader.Create(reader, new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore, IgnoreComments = true }))
|
||||
{
|
||||
var xDoc = XDocument.Load(xmlTextReader);
|
||||
var nzb = xDoc.Root;
|
||||
|
||||
if (nzb == null)
|
||||
{
|
||||
throw new InvalidNzbException("No Root element", filename);
|
||||
}
|
||||
|
||||
if (!nzb.Name.LocalName.Equals("nzb"))
|
||||
{
|
||||
throw new InvalidNzbException("Invalid root element", filename);
|
||||
}
|
||||
|
||||
var ns = nzb.Name.Namespace;
|
||||
var files = nzb.Elements(ns + "file").ToList();
|
||||
|
||||
if (files.Empty())
|
||||
{
|
||||
throw new InvalidNzbException("No files", filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ namespace NzbDrone.Core.Download.Pending
|
||||
{
|
||||
void DeleteBySeriesId(int seriesId);
|
||||
List<PendingRelease> AllBySeriesId(int seriesId);
|
||||
List<PendingRelease> WithoutFallback();
|
||||
}
|
||||
|
||||
public class PendingReleaseRepository : BasicRepository<PendingRelease>, IPendingReleaseRepository
|
||||
@@ -26,5 +27,10 @@ namespace NzbDrone.Core.Download.Pending
|
||||
{
|
||||
return Query.Where(p => p.SeriesId == seriesId);
|
||||
}
|
||||
|
||||
public List<PendingRelease> WithoutFallback()
|
||||
{
|
||||
return Query.Where(p => p.Reason != PendingReleaseReason.Fallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,12 +21,13 @@ 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, IEnumerable<int> episodeIds);
|
||||
RemoteEpisode OldestPendingRelease(int seriesId, int[] episodeIds);
|
||||
}
|
||||
|
||||
public class PendingReleaseService : IPendingReleaseService,
|
||||
@@ -68,8 +69,27 @@ namespace NzbDrone.Core.Download.Pending
|
||||
|
||||
public void Add(DownloadDecision decision, PendingReleaseReason reason)
|
||||
{
|
||||
var alreadyPending = GetPendingReleases();
|
||||
var alreadyPending = _repository.AllBySeriesId(decision.RemoteEpisode.Series.Id);
|
||||
|
||||
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)
|
||||
@@ -80,24 +100,31 @@ namespace NzbDrone.Core.Download.Pending
|
||||
|
||||
if (matchingReports.Any())
|
||||
{
|
||||
var sameReason = true;
|
||||
var matchingReport = matchingReports.First();
|
||||
|
||||
foreach (var matchingReport in matchingReports)
|
||||
if (matchingReport.Reason != reason)
|
||||
{
|
||||
if (matchingReport.Reason != reason)
|
||||
_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))
|
||||
{
|
||||
_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;
|
||||
_repository.Delete(duplicate.Id);
|
||||
alreadyPending.Remove(duplicate);
|
||||
}
|
||||
}
|
||||
|
||||
if (sameReason)
|
||||
{
|
||||
_logger.Debug("The release {0} is already pending with reason {1}, not adding again", decision.RemoteEpisode, reason);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.Debug("Adding release {0} to pending releases with reason {1}", decision.RemoteEpisode, reason);
|
||||
@@ -125,7 +152,7 @@ namespace NzbDrone.Core.Download.Pending
|
||||
|
||||
public List<RemoteEpisode> GetPendingRemoteEpisodes(int seriesId)
|
||||
{
|
||||
return _repository.AllBySeriesId(seriesId).Select(GetRemoteEpisode).ToList();
|
||||
return IncludeRemoteEpisodes(_repository.AllBySeriesId(seriesId)).Select(v => v.RemoteEpisode).ToList();
|
||||
}
|
||||
|
||||
public List<Queue.Queue> GetPendingQueue()
|
||||
@@ -134,7 +161,8 @@ namespace NzbDrone.Core.Download.Pending
|
||||
|
||||
var nextRssSync = new Lazy<DateTime>(() => _taskManager.GetNextExecution(typeof(RssSyncCommand)));
|
||||
|
||||
foreach (var pendingRelease in GetPendingReleases().Where(p => p.Reason != PendingReleaseReason.Fallback))
|
||||
var pendingReleases = IncludeRemoteEpisodes(_repository.WithoutFallback());
|
||||
foreach (var pendingRelease in pendingReleases)
|
||||
{
|
||||
foreach (var episode in pendingRelease.RemoteEpisode.Episodes)
|
||||
{
|
||||
@@ -206,24 +234,48 @@ namespace NzbDrone.Core.Download.Pending
|
||||
_repository.DeleteMany(releasesToRemove.Select(c => c.Id));
|
||||
}
|
||||
|
||||
public RemoteEpisode OldestPendingRelease(int seriesId, IEnumerable<int> episodeIds)
|
||||
public RemoteEpisode OldestPendingRelease(int seriesId, int[] episodeIds)
|
||||
{
|
||||
return GetPendingRemoteEpisodes(seriesId).Where(r => r.Episodes.Select(e => e.Id).Intersect(episodeIds).Any())
|
||||
.OrderByDescending(p => p.Release.AgeHours)
|
||||
.FirstOrDefault();
|
||||
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();
|
||||
}
|
||||
|
||||
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 _repository.All())
|
||||
foreach (var release in releases)
|
||||
{
|
||||
var remoteEpisode = GetRemoteEpisode(release);
|
||||
var series = seriesMap.GetValueOrDefault(release.SeriesId);
|
||||
|
||||
if (remoteEpisode == null) continue;
|
||||
// Just in case the series was removed, but wasn't cleaned up yet (housekeeper will clean it up)
|
||||
if (series == null) return null;
|
||||
|
||||
release.RemoteEpisode = remoteEpisode;
|
||||
var episodes = _parsingService.GetEpisodes(release.ParsedEpisodeInfo, series, true);
|
||||
|
||||
release.RemoteEpisode = new RemoteEpisode
|
||||
{
|
||||
Series = series,
|
||||
Episodes = episodes,
|
||||
ParsedEpisodeInfo = release.ParsedEpisodeInfo,
|
||||
Release = release.Release
|
||||
};
|
||||
|
||||
result.Add(release);
|
||||
}
|
||||
@@ -231,24 +283,6 @@ 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
|
||||
@@ -288,7 +322,7 @@ namespace NzbDrone.Core.Download.Pending
|
||||
|
||||
private void RemoveGrabbed(RemoteEpisode remoteEpisode)
|
||||
{
|
||||
var pendingReleases = GetPendingReleases();
|
||||
var pendingReleases = GetPendingReleases(remoteEpisode.Series.Id);
|
||||
var episodeIds = remoteEpisode.Episodes.Select(e => e.Id);
|
||||
|
||||
var existingReports = pendingReleases.Where(r => r.RemoteEpisode.Episodes.Select(e => e.Id)
|
||||
|
||||
@@ -6,6 +6,7 @@ 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
|
||||
@@ -40,6 +41,7 @@ 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;
|
||||
@@ -74,6 +76,11 @@ 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)
|
||||
@@ -99,7 +106,7 @@ namespace NzbDrone.Core.Download
|
||||
|
||||
pending.AddRange(ProcessFailedGrabs(grabbed, failed));
|
||||
|
||||
return new ProcessedDecisions(grabbed, pending, decisions.Where(d => d.Rejected).ToList());
|
||||
return new ProcessedDecisions(grabbed, pending, rejected);
|
||||
}
|
||||
|
||||
internal List<DownloadDecision> GetQualifiedReports(IEnumerable<DownloadDecision> decisions)
|
||||
@@ -124,6 +131,8 @@ 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
|
||||
@@ -134,22 +143,27 @@ namespace NzbDrone.Core.Download
|
||||
|
||||
if (IsEpisodeProcessed(grabbed, report))
|
||||
{
|
||||
_pendingReleaseService.Add(report, PendingReleaseReason.Fallback);
|
||||
addQueue.Add(Tuple.Create(report, PendingReleaseReason.Fallback));
|
||||
pending.Add(report);
|
||||
}
|
||||
else if (IsEpisodeProcessed(stored, report))
|
||||
{
|
||||
_pendingReleaseService.Add(report, PendingReleaseReason.Fallback);
|
||||
addQueue.Add(Tuple.Create(report, PendingReleaseReason.Fallback));
|
||||
pending.Add(report);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pendingReleaseService.Add(report, PendingReleaseReason.DownloadClientUnavailable);
|
||||
addQueue.Add(Tuple.Create(report, PendingReleaseReason.DownloadClientUnavailable));
|
||||
pending.Add(report);
|
||||
stored.Add(report);
|
||||
}
|
||||
}
|
||||
|
||||
if (addQueue.Any())
|
||||
{
|
||||
_pendingReleaseService.AddMany(addQueue);
|
||||
}
|
||||
|
||||
return pending;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NLog;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
{
|
||||
@@ -26,14 +25,13 @@ namespace NzbDrone.Core.Download
|
||||
IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
Logger logger)
|
||||
: base(configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(configService, diskProvider, logger)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
_torrentFileInfoReader = torrentFileInfoReader;
|
||||
}
|
||||
|
||||
|
||||
public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
|
||||
|
||||
public virtual bool PreferTorrentFile => false;
|
||||
@@ -61,7 +59,7 @@ namespace NzbDrone.Core.Download
|
||||
{
|
||||
magnetUrl = torrentInfo.MagnetUrl;
|
||||
}
|
||||
|
||||
|
||||
if (PreferTorrentFile)
|
||||
{
|
||||
if (torrentUrl.IsNotNullOrWhiteSpace())
|
||||
@@ -160,6 +158,12 @@ 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);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Net;
|
||||
using System.Net;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Exceptions;
|
||||
@@ -8,7 +8,6 @@ using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NLog;
|
||||
using NzbDrone.Core.RemotePathMappings;
|
||||
|
||||
namespace NzbDrone.Core.Download
|
||||
{
|
||||
@@ -16,17 +15,19 @@ namespace NzbDrone.Core.Download
|
||||
where TSettings : IProviderConfig, new()
|
||||
{
|
||||
protected readonly IHttpClient _httpClient;
|
||||
private readonly IValidateNzbs _nzbValidationService;
|
||||
|
||||
protected UsenetClientBase(IHttpClient httpClient,
|
||||
IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IRemotePathMappingService remotePathMappingService,
|
||||
IValidateNzbs nzbValidationService,
|
||||
Logger logger)
|
||||
: base(configService, diskProvider, remotePathMappingService, logger)
|
||||
: base(configService, diskProvider, logger)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
_nzbValidationService = nzbValidationService;
|
||||
}
|
||||
|
||||
|
||||
public override DownloadProtocol Protocol => DownloadProtocol.Usenet;
|
||||
|
||||
protected abstract string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent);
|
||||
@@ -46,6 +47,12 @@ 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);
|
||||
@@ -64,6 +71,8 @@ namespace NzbDrone.Core.Download
|
||||
throw new ReleaseDownloadException(remoteEpisode.Release, "Downloading nzb failed", ex);
|
||||
}
|
||||
|
||||
_nzbValidationService.Validate(filename, nzbData);
|
||||
|
||||
_logger.Info("Adding report [{0}] to the queue.", remoteEpisode.Release.Title);
|
||||
return AddFromNzbFile(remoteEpisode, filename, nzbData);
|
||||
}
|
||||
|
||||
28
src/NzbDrone.Core/Exceptions/ReleaseUnavailableException.cs
Normal file
28
src/NzbDrone.Core/Exceptions/ReleaseUnavailableException.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Configuration.Events;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Download.Clients.Nzbget;
|
||||
using NzbDrone.Core.Download.Clients.Sabnzbd;
|
||||
using NzbDrone.Core.ThingiProvider.Events;
|
||||
|
||||
namespace NzbDrone.Core.HealthCheck.Checks
|
||||
{
|
||||
[CheckOn(typeof(ProviderUpdatedEvent<IDownloadClient>))]
|
||||
[CheckOn(typeof(ProviderDeletedEvent<IDownloadClient>))]
|
||||
[CheckOn(typeof(ConfigSavedEvent))]
|
||||
public class ImportMechanismCheck : HealthCheckBase
|
||||
{
|
||||
private readonly IConfigService _configService;
|
||||
private readonly IProvideDownloadClient _provideDownloadClient;
|
||||
|
||||
|
||||
public ImportMechanismCheck(IConfigService configService, IProvideDownloadClient provideDownloadClient)
|
||||
{
|
||||
_configService = configService;
|
||||
_provideDownloadClient = provideDownloadClient;
|
||||
}
|
||||
|
||||
public override HealthCheck Check()
|
||||
{
|
||||
var droneFactoryFolder = new OsPath(_configService.DownloadedEpisodesFolder);
|
||||
List<ImportMechanismCheckStatus> downloadClients;
|
||||
|
||||
try
|
||||
{
|
||||
downloadClients = _provideDownloadClient.GetDownloadClients().Select(v => new ImportMechanismCheckStatus
|
||||
{
|
||||
DownloadClient = v,
|
||||
Status = v.GetStatus()
|
||||
}).ToList();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// One or more download clients failed, assume the health is okay and verify later
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
var downloadClientIsLocalHost = downloadClients.All(v => v.Status.IsLocalhost);
|
||||
var downloadClientOutputInDroneFactory = !droneFactoryFolder.IsEmpty &&
|
||||
downloadClients.Any(v => v.Status.OutputRootFolders != null &&
|
||||
v.Status.OutputRootFolders.Any(droneFactoryFolder.Contains));
|
||||
|
||||
if (!_configService.IsDefined("EnableCompletedDownloadHandling"))
|
||||
{
|
||||
// Migration helper logic
|
||||
if (!downloadClientIsLocalHost)
|
||||
{
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Multi-Computer unsupported)", "Migrating-to-Completed-Download-Handling#Unsupported-download-client-on-different-computer");
|
||||
}
|
||||
|
||||
if (downloadClients.All(v => v.DownloadClient is Sabnzbd))
|
||||
{
|
||||
// With Sabnzbd we can check if the category should be changed.
|
||||
if (downloadClientOutputInDroneFactory)
|
||||
{
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Sabnzbd - Conflicting Category)", "Migrating-to-Completed-Download-Handling#sabnzbd-conflicting-download-client-category");
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Sabnzbd)", "Migrating-to-Completed-Download-Handling#sabnzbd-enable-completed-download-handling");
|
||||
}
|
||||
|
||||
if (downloadClients.All(v => v.DownloadClient is Nzbget))
|
||||
{
|
||||
// With Nzbget we can check if the category should be changed.
|
||||
if (downloadClientOutputInDroneFactory)
|
||||
{
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Nzbget - Conflicting Category)", "Migrating-to-Completed-Download-Handling#nzbget-conflicting-download-client-category");
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible (Nzbget)", "Migrating-to-Completed-Download-Handling#nzbget-enable-completed-download-handling");
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling if possible", "Migrating-to-Completed-Download-Handling");
|
||||
}
|
||||
|
||||
if (!_configService.EnableCompletedDownloadHandling && droneFactoryFolder.IsEmpty)
|
||||
{
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, "Enable Completed Download Handling or configure Drone factory");
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
}
|
||||
|
||||
public class ImportMechanismCheckStatus
|
||||
{
|
||||
public IDownloadClient DownloadClient { get; set; }
|
||||
public DownloadClientInfo Status { get; set; }
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user