From c07fc4de44cb61152e006d27e09a681299ca9b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Simonsen?= Date: Mon, 26 Oct 2015 20:13:09 +0100 Subject: [PATCH] Fixes some invalid torrent files Sonarr would not accept torrents where the keys were not sorted. This update will sort the keys before sending the file to the downloader to make the torrent valid for Sonarr. --- src/Jackett/Controllers/DownloadController.cs | 5 +++++ src/Jackett/Jackett.csproj | 4 ++++ src/Jackett/packages.config | 1 + 3 files changed, 10 insertions(+) diff --git a/src/Jackett/Controllers/DownloadController.cs b/src/Jackett/Controllers/DownloadController.cs index 9841843a4..e3cdc9686 100644 --- a/src/Jackett/Controllers/DownloadController.cs +++ b/src/Jackett/Controllers/DownloadController.cs @@ -10,6 +10,7 @@ using System.Text; using System.Threading.Tasks; using System.Web; using System.Web.Http; +using MonoTorrent.BEncoding; namespace Jackett.Controllers { @@ -51,6 +52,10 @@ 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 result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new ByteArrayContent(downloadBytes); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-bittorrent"); diff --git a/src/Jackett/Jackett.csproj b/src/Jackett/Jackett.csproj index b62444f8f..bc5a8c01c 100644 --- a/src/Jackett/Jackett.csproj +++ b/src/Jackett/Jackett.csproj @@ -110,6 +110,10 @@ ..\packages\Microsoft.Owin.StaticFiles.3.0.1\lib\net45\Microsoft.Owin.StaticFiles.dll True + + ..\packages\MonoTorrent.0.9.0\lib\net20\MonoTorrent.dll + True + ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll True diff --git a/src/Jackett/packages.config b/src/Jackett/packages.config index b602742aa..427976d0d 100644 --- a/src/Jackett/packages.config +++ b/src/Jackett/packages.config @@ -22,6 +22,7 @@ +