Use BencondNET instead of MonoTorrent (#2048)

This commit is contained in:
flightlevel 2017-11-01 12:42:26 +11:00 committed by GitHub
parent e0833ba719
commit 5c35ada012
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 14 deletions

View File

@ -1,5 +1,4 @@
using NLog;
using System;
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
@ -7,9 +6,10 @@ using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using MonoTorrent.BEncoding;
using Jackett.Utils;
using BencodeNET.Parsing;
using Jackett.Services.Interfaces;
using Jackett.Utils;
using NLog;
namespace Jackett.Controllers
{
@ -17,10 +17,10 @@ namespace Jackett.Controllers
[JackettAPINoCache]
public class DownloadController : ApiController
{
Logger logger;
IIndexerManagerService indexerService;
IServerService serverService;
IProtectionService protectionService;
private Logger logger;
private IIndexerManagerService indexerService;
private IServerService serverService;
private IProtectionService protectionService;
public DownloadController(IIndexerManagerService i, Logger l, IServerService s, IProtectionService ps)
{
@ -53,11 +53,12 @@ namespace Jackett.Controllers
var downloadBytes = await indexer.Download(target);
// This will fix torrents where the keys are not sorted, and thereby not supported by Sonarr.
var torrentDictionary = BEncodedDictionary.DecodeTorrent(downloadBytes);
downloadBytes = torrentDictionary.Encode();
var parser = new BencodeParser();
var torrentDictionary = parser.Parse(downloadBytes);
byte[] sortedDownloadBytes = torrentDictionary.EncodeAsBytes();
var result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new ByteArrayContent(downloadBytes);
result.Content = new ByteArrayContent(sortedDownloadBytes);
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-bittorrent");
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{

View File

@ -491,6 +491,9 @@
<PackageReference Include="AutoMapper">
<Version>6.1.1</Version>
</PackageReference>
<PackageReference Include="BencodeNET">
<Version>2.2.22</Version>
</PackageReference>
<PackageReference Include="CloudFlareUtilities">
<Version>0.4.0-alpha</Version>
</PackageReference>
@ -506,9 +509,6 @@
<PackageReference Include="Microsoft.Owin.StaticFiles">
<Version>3.1.0</Version>
</PackageReference>
<PackageReference Include="MonoTorrent">
<Version>0.9.0</Version>
</PackageReference>
<PackageReference Include="NLog">
<Version>5.0.0-beta11</Version>
</PackageReference>