mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
added support for offset when queries seasons in newznab,
This commit is contained in:
parent
a00587dbd4
commit
227e13d858
@ -24,7 +24,7 @@ public class HttpProvider : IHttpProvider
|
|||||||
{
|
{
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public const string CONTENT_LENGHT_HEADER = "Content-Length";
|
public const string CONTENT_LENGTH_HEADER = "Content-Length";
|
||||||
|
|
||||||
private readonly string _userAgent;
|
private readonly string _userAgent;
|
||||||
|
|
||||||
|
16
NzbDrone.Common/IEnumerableExtensions.cs
Normal file
16
NzbDrone.Common/IEnumerableExtensions.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace NzbDrone.Common
|
||||||
|
{
|
||||||
|
public static class IEnumerableExtensions
|
||||||
|
{
|
||||||
|
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
|
||||||
|
{
|
||||||
|
var knownKeys = new HashSet<TKey>();
|
||||||
|
|
||||||
|
return source.Where(element => knownKeys.Add(keySelector(element)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -89,6 +89,7 @@
|
|||||||
<Compile Include="EnvironmentInfo\RuntimeInfo.cs" />
|
<Compile Include="EnvironmentInfo\RuntimeInfo.cs" />
|
||||||
<Compile Include="EnvironmentInfo\OsInfo.cs" />
|
<Compile Include="EnvironmentInfo\OsInfo.cs" />
|
||||||
<Compile Include="Exceptions\NzbDroneException.cs" />
|
<Compile Include="Exceptions\NzbDroneException.cs" />
|
||||||
|
<Compile Include="IEnumerableExtensions.cs" />
|
||||||
<Compile Include="Instrumentation\GlobalExceptionHandlers.cs" />
|
<Compile Include="Instrumentation\GlobalExceptionHandlers.cs" />
|
||||||
<Compile Include="Instrumentation\ExceptronTarget.cs" />
|
<Compile Include="Instrumentation\ExceptronTarget.cs" />
|
||||||
<Compile Include="PathEqualityComparer.cs" />
|
<Compile Include="PathEqualityComparer.cs" />
|
||||||
|
@ -48,7 +48,7 @@ public void should_return_false_if_file_not_exists()
|
|||||||
public void should_return_false_if_file_exists_but_diffrent_size()
|
public void should_return_false_if_file_exists_but_diffrent_size()
|
||||||
{
|
{
|
||||||
GivenExistingFileSize(100);
|
GivenExistingFileSize(100);
|
||||||
_headers.Add(HttpProvider.CONTENT_LENGHT_HEADER, "200");
|
_headers.Add(HttpProvider.CONTENT_LENGTH_HEADER, "200");
|
||||||
|
|
||||||
Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeFalse();
|
Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeFalse();
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ public void should_return_false_if_file_exists_but_diffrent_size()
|
|||||||
public void should_return_ture_if_file_exists_and_same_size()
|
public void should_return_ture_if_file_exists_and_same_size()
|
||||||
{
|
{
|
||||||
GivenExistingFileSize(100);
|
GivenExistingFileSize(100);
|
||||||
_headers.Add(HttpProvider.CONTENT_LENGHT_HEADER, "100");
|
_headers.Add(HttpProvider.CONTENT_LENGTH_HEADER, "100");
|
||||||
|
|
||||||
Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeTrue();
|
Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
@ -22,5 +22,16 @@ public DownloadDecision(RemoteEpisode episode, params string[] rejections)
|
|||||||
RemoteEpisode = episode;
|
RemoteEpisode = episode;
|
||||||
Rejections = rejections.ToList();
|
Rejections = rejections.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
if (Approved)
|
||||||
|
{
|
||||||
|
return "[OK] " + RemoteEpisode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "[Rejected " + Rejections.Count() + "]" + RemoteEpisode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,19 +0,0 @@
|
|||||||
namespace NzbDrone.Core.IndexerSearch.Definitions
|
|
||||||
{
|
|
||||||
public class PartialSeasonSearchCriteria : SeasonSearchCriteria
|
|
||||||
{
|
|
||||||
public int Prefix { get; set; }
|
|
||||||
|
|
||||||
public PartialSeasonSearchCriteria(SeasonSearchCriteria seasonSearch, int prefix)
|
|
||||||
{
|
|
||||||
Prefix = prefix;
|
|
||||||
SceneTitle = seasonSearch.SceneTitle;
|
|
||||||
SeasonNumber = seasonSearch.SeasonNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return string.Format("[{0} : S{1:00}E{2:0}*]", SceneTitle, SeasonNumber, Prefix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,6 +19,6 @@ public interface IIndexer
|
|||||||
|
|
||||||
IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int episodeNumber);
|
IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int episodeNumber);
|
||||||
IEnumerable<string> GetDailyEpisodeSearchUrls(string seriesTitle, int tvRageId, DateTime date);
|
IEnumerable<string> GetDailyEpisodeSearchUrls(string seriesTitle, int tvRageId, DateTime date);
|
||||||
IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber);
|
IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -36,6 +36,6 @@ public virtual IParseFeed Parser
|
|||||||
public abstract IEnumerable<string> RecentFeed { get; }
|
public abstract IEnumerable<string> RecentFeed { get; }
|
||||||
public abstract IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int episodeNumber);
|
public abstract IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int episodeNumber);
|
||||||
public abstract IEnumerable<string> GetDailyEpisodeSearchUrls(string seriesTitle, int tvRageId, DateTime date);
|
public abstract IEnumerable<string> GetDailyEpisodeSearchUrls(string seriesTitle, int tvRageId, DateTime date);
|
||||||
public abstract IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber);
|
public abstract IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,6 +5,7 @@
|
|||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Indexers
|
namespace NzbDrone.Core.Indexers
|
||||||
{
|
{
|
||||||
@ -14,7 +15,6 @@ public interface IFetchFeedFromIndexers
|
|||||||
|
|
||||||
IList<ReportInfo> Fetch(IIndexer indexer, SeasonSearchCriteria searchCriteria);
|
IList<ReportInfo> Fetch(IIndexer indexer, SeasonSearchCriteria searchCriteria);
|
||||||
IList<ReportInfo> Fetch(IIndexer indexer, SingleEpisodeSearchCriteria searchCriteria);
|
IList<ReportInfo> Fetch(IIndexer indexer, SingleEpisodeSearchCriteria searchCriteria);
|
||||||
IList<ReportInfo> Fetch(IIndexer indexer, PartialSeasonSearchCriteria searchCriteria);
|
|
||||||
IList<ReportInfo> Fetch(IIndexer indexer, DailyEpisodeSearchCriteria searchCriteria);
|
IList<ReportInfo> Fetch(IIndexer indexer, DailyEpisodeSearchCriteria searchCriteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,11 +46,29 @@ public IList<ReportInfo> Fetch(IIndexer indexer, SeasonSearchCriteria searchCrit
|
|||||||
{
|
{
|
||||||
_logger.Debug("Searching for {0}", searchCriteria);
|
_logger.Debug("Searching for {0}", searchCriteria);
|
||||||
|
|
||||||
var searchUrls = indexer.GetSeasonSearchUrls(searchCriteria.QueryTitle, searchCriteria.SeriesTvRageId, searchCriteria.SeasonNumber);
|
var result = Fetch(indexer, searchCriteria, 0).DistinctBy(c => c.NzbUrl).ToList();
|
||||||
|
|
||||||
|
_logger.Info("Finished searching {0} on {1}. Found {2}", indexer.Name, searchCriteria, result.Count);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private IList<ReportInfo> Fetch(IIndexer indexer, SeasonSearchCriteria searchCriteria, int offset)
|
||||||
|
{
|
||||||
|
_logger.Debug("Searching for {0} offset: {1}", searchCriteria, offset);
|
||||||
|
|
||||||
|
var searchUrls = indexer.GetSeasonSearchUrls(searchCriteria.QueryTitle, searchCriteria.SeriesTvRageId, searchCriteria.SeasonNumber, offset);
|
||||||
var result = Fetch(indexer, searchUrls);
|
var result = Fetch(indexer, searchUrls);
|
||||||
|
|
||||||
|
|
||||||
_logger.Info("Finished searching {0} on {1}. Found {2}", indexer.Name, searchCriteria, result.Count);
|
_logger.Info("{0} offset {1}. Found {2}", indexer.Name, searchCriteria, result.Count);
|
||||||
|
|
||||||
|
if (result.Count > 90)
|
||||||
|
{
|
||||||
|
result.AddRange(Fetch(indexer, searchCriteria, offset + 90));
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,17 +85,6 @@ public IList<ReportInfo> Fetch(IIndexer indexer, SingleEpisodeSearchCriteria sea
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<ReportInfo> Fetch(IIndexer indexer, PartialSeasonSearchCriteria searchCriteria)
|
|
||||||
{
|
|
||||||
_logger.Debug("Searching for {0}", searchCriteria);
|
|
||||||
|
|
||||||
var searchUrls = indexer.GetSeasonSearchUrls(searchCriteria.QueryTitle, searchCriteria.SeriesTvRageId, searchCriteria.SeasonNumber);
|
|
||||||
var result = Fetch(indexer, searchUrls);
|
|
||||||
|
|
||||||
|
|
||||||
_logger.Info("Finished searching {0} on {1}. Found {2}", indexer.Name, searchCriteria, result.Count);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IList<ReportInfo> Fetch(IIndexer indexer, DailyEpisodeSearchCriteria searchCriteria)
|
public IList<ReportInfo> Fetch(IIndexer indexer, DailyEpisodeSearchCriteria searchCriteria)
|
||||||
{
|
{
|
||||||
|
@ -104,16 +104,17 @@ public override IEnumerable<string> GetDailyEpisodeSearchUrls(string seriesTitle
|
|||||||
return RecentFeed.Select(url => String.Format("{0}&limit=100&q={1}&season={2:yyyy}&ep={2:MM/dd}", url, NewsnabifyTitle(seriesTitle), date)).ToList();
|
return RecentFeed.Select(url => String.Format("{0}&limit=100&q={1}&season={2:yyyy}&ep={2:MM/dd}", url, NewsnabifyTitle(seriesTitle), date)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber)
|
public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int offset)
|
||||||
{
|
{
|
||||||
if (tvRageId > 0)
|
if (tvRageId > 0)
|
||||||
{
|
{
|
||||||
return RecentFeed.Select(url => String.Format("{0}&limit=100&rid={1}&season={2}", url, tvRageId, seasonNumber));
|
return RecentFeed.Select(url => String.Format("{0}&limit=100&rid={1}&season={2}&offset={3}", url, tvRageId, seasonNumber, offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
return RecentFeed.Select(url => String.Format("{0}&limit=100&q={1}&season={2}", url, NewsnabifyTitle(seriesTitle), seasonNumber));
|
return RecentFeed.Select(url => String.Format("{0}&limit=100&q={1}&season={2}&offset={3}", url, NewsnabifyTitle(seriesTitle), seasonNumber, offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override string Name
|
public override string Name
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -47,7 +47,7 @@ public override IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int
|
|||||||
return searchUrls;
|
return searchUrls;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber)
|
public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int offset)
|
||||||
{
|
{
|
||||||
var searchUrls = new List<string>();
|
var searchUrls = new List<string>();
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public override IEnumerable<string> GetDailyEpisodeSearchUrls(string seriesTitle
|
|||||||
return searchUrls;
|
return searchUrls;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber)
|
public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int offset)
|
||||||
{
|
{
|
||||||
var searchUrls = new List<String>();
|
var searchUrls = new List<String>();
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ public override IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int
|
|||||||
return new List<string>();
|
return new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber)
|
public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int tvRageId, int seasonNumber, int offset)
|
||||||
{
|
{
|
||||||
return new List<string>();
|
return new List<string>();
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public bool AlreadyExists(string url, string path)
|
|||||||
|
|
||||||
string sizeString;
|
string sizeString;
|
||||||
|
|
||||||
if (headers.TryGetValue(HttpProvider.CONTENT_LENGHT_HEADER, out sizeString))
|
if (headers.TryGetValue(HttpProvider.CONTENT_LENGTH_HEADER, out sizeString))
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
int.TryParse(sizeString, out size);
|
int.TryParse(sizeString, out size);
|
||||||
|
@ -249,7 +249,6 @@
|
|||||||
<Compile Include="Helpers\SortHelper.cs" />
|
<Compile Include="Helpers\SortHelper.cs" />
|
||||||
<Compile Include="History\HistoryRepository.cs" />
|
<Compile Include="History\HistoryRepository.cs" />
|
||||||
<Compile Include="IndexerSearch\Definitions\DailyEpisodeSearchCriteria.cs" />
|
<Compile Include="IndexerSearch\Definitions\DailyEpisodeSearchCriteria.cs" />
|
||||||
<Compile Include="IndexerSearch\Definitions\PartialSeasonSearchCriteria.cs" />
|
|
||||||
<Compile Include="IndexerSearch\Definitions\SearchCriteriaBase.cs" />
|
<Compile Include="IndexerSearch\Definitions\SearchCriteriaBase.cs" />
|
||||||
<Compile Include="IndexerSearch\Definitions\SeasonSearchCriteria.cs" />
|
<Compile Include="IndexerSearch\Definitions\SeasonSearchCriteria.cs" />
|
||||||
<Compile Include="IndexerSearch\Definitions\SingleEpisodeSearchCriteria.cs" />
|
<Compile Include="IndexerSearch\Definitions\SingleEpisodeSearchCriteria.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user