|
|
@ -1,20 +1,20 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
using System.Net;
|
|
|
|
using System.Net;
|
|
|
|
using NzbDrone.Core.Indexers.Exceptions;
|
|
|
|
using System.Web;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using System.Web;
|
|
|
|
using NzbDrone.Core.Indexers.Exceptions;
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Indexers.HDBits
|
|
|
|
namespace NzbDrone.Core.Indexers.HDBits
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class HdBitsParser : IParseIndexerResponse
|
|
|
|
public class HDBitsParser : IParseIndexerResponse
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly HdBitsSettings _settings;
|
|
|
|
private readonly HDBitsSettings _settings;
|
|
|
|
|
|
|
|
|
|
|
|
public HdBitsParser(HdBitsSettings settings)
|
|
|
|
public HDBitsParser(HDBitsSettings settings)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_settings = settings;
|
|
|
|
_settings = settings;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -25,28 +25,25 @@ namespace NzbDrone.Core.Indexers.HDBits
|
|
|
|
|
|
|
|
|
|
|
|
if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK)
|
|
|
|
if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new IndexerException(
|
|
|
|
throw new IndexerException(indexerResponse,
|
|
|
|
indexerResponse,
|
|
|
|
|
|
|
|
"Unexpected response status {0} code from API request",
|
|
|
|
"Unexpected response status {0} code from API request",
|
|
|
|
indexerResponse.HttpResponse.StatusCode);
|
|
|
|
indexerResponse.HttpResponse.StatusCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var jsonResponse = JsonConvert.DeserializeObject<HdBitsResponse>(indexerResponse.Content);
|
|
|
|
var jsonResponse = JsonConvert.DeserializeObject<HDBitsResponse>(indexerResponse.Content);
|
|
|
|
|
|
|
|
|
|
|
|
if (jsonResponse.Status != StatusCode.Success)
|
|
|
|
if (jsonResponse.Status != StatusCode.Success)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new IndexerException(
|
|
|
|
throw new IndexerException(indexerResponse,
|
|
|
|
indexerResponse,
|
|
|
|
"HDBits API request returned status code {0}: {1}",
|
|
|
|
@"HDBits API request returned status code {0} with message ""{1}""",
|
|
|
|
|
|
|
|
jsonResponse.Status,
|
|
|
|
jsonResponse.Status,
|
|
|
|
jsonResponse.Message ?? "");
|
|
|
|
jsonResponse.Message ?? string.Empty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var responseData = jsonResponse.Data as JArray;
|
|
|
|
var responseData = jsonResponse.Data as JArray;
|
|
|
|
if (responseData == null)
|
|
|
|
if (responseData == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new IndexerException(
|
|
|
|
throw new IndexerException(indexerResponse,
|
|
|
|
indexerResponse,
|
|
|
|
|
|
|
|
"Indexer API call response missing result data");
|
|
|
|
"Indexer API call response missing result data");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -60,6 +57,7 @@ namespace NzbDrone.Core.Indexers.HDBits
|
|
|
|
Guid = string.Format("HDBits-{0}", id),
|
|
|
|
Guid = string.Format("HDBits-{0}", id),
|
|
|
|
Title = result.Name,
|
|
|
|
Title = result.Name,
|
|
|
|
Size = result.Size,
|
|
|
|
Size = result.Size,
|
|
|
|
|
|
|
|
InfoHash = result.Hash,
|
|
|
|
DownloadUrl = GetDownloadUrl(id),
|
|
|
|
DownloadUrl = GetDownloadUrl(id),
|
|
|
|
InfoUrl = GetInfoUrl(id),
|
|
|
|
InfoUrl = GetInfoUrl(id),
|
|
|
|
Seeders = result.Seeders,
|
|
|
|
Seeders = result.Seeders,
|