mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
improve BEncode error handling
This commit is contained in:
@@ -34,6 +34,9 @@ namespace Jackett.Common.Indexers
|
|||||||
public string Type { get; protected set; }
|
public string Type { get; protected set; }
|
||||||
public virtual string ID { get { return GetIndexerID(GetType()); } }
|
public virtual string ID { get { return GetIndexerID(GetType()); } }
|
||||||
|
|
||||||
|
[JsonConverter(typeof(EncodingJsonConverter))]
|
||||||
|
public Encoding Encoding { get; protected set; }
|
||||||
|
|
||||||
public virtual bool IsConfigured { get; protected set; }
|
public virtual bool IsConfigured { get; protected set; }
|
||||||
protected Logger logger;
|
protected Logger logger;
|
||||||
protected IIndexerConfigurationService configurationService;
|
protected IIndexerConfigurationService configurationService;
|
||||||
@@ -835,8 +838,6 @@ namespace Jackett.Common.Indexers
|
|||||||
|
|
||||||
public override TorznabCapabilities TorznabCaps { get; protected set; }
|
public override TorznabCapabilities TorznabCaps { get; protected set; }
|
||||||
|
|
||||||
[JsonConverter(typeof(EncodingJsonConverter))]
|
|
||||||
public Encoding Encoding { get; protected set; }
|
|
||||||
|
|
||||||
private List<CategoryMapping> categoryMapping = new List<CategoryMapping>();
|
private List<CategoryMapping> categoryMapping = new List<CategoryMapping>();
|
||||||
protected WebClient webclient;
|
protected WebClient webclient;
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jackett.Common.Models;
|
using Jackett.Common.Models;
|
||||||
using Jackett.Common.Models.IndexerConfig;
|
using Jackett.Common.Models.IndexerConfig;
|
||||||
@@ -30,6 +31,7 @@ namespace Jackett.Common.Indexers
|
|||||||
string Language { get; }
|
string Language { get; }
|
||||||
string LastError { get; set; }
|
string LastError { get; set; }
|
||||||
string ID { get; }
|
string ID { get; }
|
||||||
|
Encoding Encoding { get; }
|
||||||
|
|
||||||
TorznabCapabilities TorznabCaps { get; }
|
TorznabCapabilities TorznabCaps { get; }
|
||||||
|
|
||||||
|
@@ -71,9 +71,19 @@ namespace Jackett.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
|
byte[] sortedDownloadBytes = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
var parser = new BencodeParser();
|
var parser = new BencodeParser();
|
||||||
var torrentDictionary = parser.Parse(downloadBytes);
|
var torrentDictionary = parser.Parse(downloadBytes);
|
||||||
byte[] sortedDownloadBytes = torrentDictionary.EncodeAsBytes();
|
sortedDownloadBytes = torrentDictionary.EncodeAsBytes();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
var content = indexer.Encoding.GetString(downloadBytes);
|
||||||
|
logger.Error(content);
|
||||||
|
throw new Exception("BencodeParser failed", e);
|
||||||
|
}
|
||||||
|
|
||||||
var result = new HttpResponseMessage(HttpStatusCode.OK);
|
var result = new HttpResponseMessage(HttpStatusCode.OK);
|
||||||
result.Content = new ByteArrayContent(sortedDownloadBytes);
|
result.Content = new ByteArrayContent(sortedDownloadBytes);
|
||||||
|
Reference in New Issue
Block a user