mirror of https://github.com/Jackett/Jackett
Use BencondNET instead of MonoTorrent (#2048)
This commit is contained in:
parent
e0833ba719
commit
5c35ada012
|
@ -1,5 +1,4 @@
|
||||||
using NLog;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
|
@ -7,9 +6,10 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Http;
|
using System.Web.Http;
|
||||||
using MonoTorrent.BEncoding;
|
using BencodeNET.Parsing;
|
||||||
using Jackett.Utils;
|
|
||||||
using Jackett.Services.Interfaces;
|
using Jackett.Services.Interfaces;
|
||||||
|
using Jackett.Utils;
|
||||||
|
using NLog;
|
||||||
|
|
||||||
namespace Jackett.Controllers
|
namespace Jackett.Controllers
|
||||||
{
|
{
|
||||||
|
@ -17,10 +17,10 @@ namespace Jackett.Controllers
|
||||||
[JackettAPINoCache]
|
[JackettAPINoCache]
|
||||||
public class DownloadController : ApiController
|
public class DownloadController : ApiController
|
||||||
{
|
{
|
||||||
Logger logger;
|
private Logger logger;
|
||||||
IIndexerManagerService indexerService;
|
private IIndexerManagerService indexerService;
|
||||||
IServerService serverService;
|
private IServerService serverService;
|
||||||
IProtectionService protectionService;
|
private IProtectionService protectionService;
|
||||||
|
|
||||||
public DownloadController(IIndexerManagerService i, Logger l, IServerService s, IProtectionService ps)
|
public DownloadController(IIndexerManagerService i, Logger l, IServerService s, IProtectionService ps)
|
||||||
{
|
{
|
||||||
|
@ -53,11 +53,12 @@ namespace Jackett.Controllers
|
||||||
var downloadBytes = await indexer.Download(target);
|
var downloadBytes = await indexer.Download(target);
|
||||||
|
|
||||||
// This will fix torrents where the keys are not sorted, and thereby not supported by Sonarr.
|
// This will fix torrents where the keys are not sorted, and thereby not supported by Sonarr.
|
||||||
var torrentDictionary = BEncodedDictionary.DecodeTorrent(downloadBytes);
|
var parser = new BencodeParser();
|
||||||
downloadBytes = torrentDictionary.Encode();
|
var torrentDictionary = parser.Parse(downloadBytes);
|
||||||
|
byte[] sortedDownloadBytes = torrentDictionary.EncodeAsBytes();
|
||||||
|
|
||||||
var result = new HttpResponseMessage(HttpStatusCode.OK);
|
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.ContentType = new MediaTypeHeaderValue("application/x-bittorrent");
|
||||||
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
|
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
|
||||||
{
|
{
|
||||||
|
|
|
@ -491,6 +491,9 @@
|
||||||
<PackageReference Include="AutoMapper">
|
<PackageReference Include="AutoMapper">
|
||||||
<Version>6.1.1</Version>
|
<Version>6.1.1</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="BencodeNET">
|
||||||
|
<Version>2.2.22</Version>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="CloudFlareUtilities">
|
<PackageReference Include="CloudFlareUtilities">
|
||||||
<Version>0.4.0-alpha</Version>
|
<Version>0.4.0-alpha</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
@ -506,9 +509,6 @@
|
||||||
<PackageReference Include="Microsoft.Owin.StaticFiles">
|
<PackageReference Include="Microsoft.Owin.StaticFiles">
|
||||||
<Version>3.1.0</Version>
|
<Version>3.1.0</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="MonoTorrent">
|
|
||||||
<Version>0.9.0</Version>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="NLog">
|
<PackageReference Include="NLog">
|
||||||
<Version>5.0.0-beta11</Version>
|
<Version>5.0.0-beta11</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
Loading…
Reference in New Issue