1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

Fixed: Adjusted BTN Recent Feed (RssSync) to better use their api db indexes.

This commit is contained in:
Taloth Saldono 2016-05-10 21:21:20 +02:00
parent 2f3bc61af7
commit 0f1afd416b
5 changed files with 47 additions and 13 deletions

View File

@ -44,14 +44,27 @@ public HttpRequest(string url, HttpAccept httpAccept = null)
public override string ToString()
{
if (ContentSummary == null)
return ToString();
}
public string ToString(bool includeMethod = true, bool includeSummary = true)
{
var builder = new StringBuilder();
if (includeMethod)
{
return string.Format("Req: [{0}] {1}", Method, Url);
builder.AppendFormat("Req: [{0}] ", Method);
}
else
builder.Append(Url);
if (includeSummary && ContentSummary.IsNotNullOrWhiteSpace())
{
return string.Format("Req: [{0}] {1}: {2}", Method, Url, ContentSummary);
builder.Append(": ");
builder.Append(ContentSummary);
}
return builder.ToString();
}
public void SetContent(byte[] data)

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using NzbDrone.Common.Serializer;
namespace NzbDrone.Common.Http
@ -86,7 +87,7 @@ private void ConvertParameter(object value, out object data, out string summary)
else
{
data = value;
summary = data.ToJson();
summary = JsonConvert.SerializeObject(data);
}
}

View File

@ -28,7 +28,19 @@ public BroadcastheNet(IHttpClient httpClient, IIndexerStatusService indexerStatu
public override IIndexerRequestGenerator GetRequestGenerator()
{
return new BroadcastheNetRequestGenerator() { Settings = Settings, PageSize = PageSize };
var requestGenerator = new BroadcastheNetRequestGenerator() { Settings = Settings, PageSize = PageSize };
var releaseInfo = _indexerStatusService.GetLastRssSyncReleaseInfo(Definition.Id);
if (releaseInfo != null)
{
int torrentID;
if (int.TryParse(releaseInfo.Guid.Replace("BTN-", string.Empty), out torrentID))
{
requestGenerator.LastRecentTorrentID = torrentID;
}
}
return requestGenerator;
}
public override IParseIndexerResponse GetParser()

View File

@ -13,6 +13,8 @@ public class BroadcastheNetRequestGenerator : IIndexerRequestGenerator
public int PageSize { get; set; }
public BroadcastheNetSettings Settings { get; set; }
public int? LastRecentTorrentID { get; set; }
public BroadcastheNetRequestGenerator()
{
MaxPages = 10;
@ -23,7 +25,18 @@ public virtual IndexerPageableRequestChain GetRecentRequests()
{
var pageableRequests = new IndexerPageableRequestChain();
pageableRequests.Add(GetPagedRequests(MaxPages, null));
var parameters = new BroadcastheNetTorrentQuery();
if (LastRecentTorrentID.HasValue)
{
parameters.Id = ">=" + (LastRecentTorrentID.Value - 100);
}
else
{
parameters.Age = "<=86400";
}
pageableRequests.Add(GetPagedRequests(MaxPages, parameters));
return pageableRequests;
}
@ -167,11 +180,6 @@ private bool AddSeriesSearchParameters(BroadcastheNetTorrentQuery parameters, Se
private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, BroadcastheNetTorrentQuery parameters)
{
if (parameters == null)
{
parameters = new BroadcastheNetTorrentQuery();
}
var builder = new JsonRpcRequestBuilder(Settings.BaseUrl)
.Call("getTorrents", Settings.ApiKey, parameters, PageSize, 0);
builder.SuppressHttpError = true;

View File

@ -275,7 +275,7 @@ protected virtual IList<ReleaseInfo> FetchPage(IndexerRequest request, IParseInd
protected virtual IndexerResponse FetchIndexerResponse(IndexerRequest request)
{
_logger.Debug("Downloading Feed " + request.Url);
_logger.Debug("Downloading Feed " + request.HttpRequest.ToString(false));
if (request.HttpRequest.RateLimit < RateLimit)
{