respect multipage limit
This commit is contained in:
+11
-5
@@ -34,6 +34,11 @@ namespace ReadSharp
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected NReadabilityTranscoder _transcoder;
|
protected NReadabilityTranscoder _transcoder;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The HTTP options
|
||||||
|
/// </summary>
|
||||||
|
protected HttpOptions _options;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Redirect faulty mobile URIs to desktop equivalents
|
/// Redirect faulty mobile URIs to desktop equivalents
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -66,6 +71,8 @@ namespace ReadSharp
|
|||||||
options = HttpOptions.CreateDefault();
|
options = HttpOptions.CreateDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_options = options;
|
||||||
|
|
||||||
// initialize custom encoder
|
// initialize custom encoder
|
||||||
_encoder = new Encodings.Encoder(true);
|
_encoder = new Encodings.Encoder(true);
|
||||||
|
|
||||||
@@ -133,10 +140,9 @@ namespace ReadSharp
|
|||||||
|
|
||||||
// get images from article
|
// get images from article
|
||||||
int id = 1;
|
int id = 1;
|
||||||
|
List<ArticleImage> images = response.TranscodingResult.Images.Select(image =>
|
||||||
List<ArticleImage> images = response.TranscodingResult.Images.Select<XElement, ArticleImage>(image =>
|
|
||||||
{
|
{
|
||||||
Uri imageUri;
|
Uri imageUri = null;
|
||||||
Uri.TryCreate(image.GetAttributeValue("src", null), UriKind.Absolute, out imageUri);
|
Uri.TryCreate(image.GetAttributeValue("src", null), UriKind.Absolute, out imageUri);
|
||||||
|
|
||||||
return new ArticleImage()
|
return new ArticleImage()
|
||||||
@@ -146,7 +152,7 @@ namespace ReadSharp
|
|||||||
Title = image.GetAttributeValue("title", null),
|
Title = image.GetAttributeValue("title", null),
|
||||||
AlternativeText = image.GetAttributeValue("alt", null)
|
AlternativeText = image.GetAttributeValue("alt", null)
|
||||||
};
|
};
|
||||||
}).ToList();
|
}).GroupBy(image => image.Uri).Select(g => g.First()).Where(image => image.Uri != null).ToList();
|
||||||
|
|
||||||
// get word count and plain text
|
// get word count and plain text
|
||||||
string plainContent;
|
string plainContent;
|
||||||
@@ -349,7 +355,7 @@ namespace ReadSharp
|
|||||||
// multiple pages are available
|
// multiple pages are available
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (options.MultipageDownload && transcodingResult.NextPageUrl != null && (previousResponse == null || (previousResponse != null && previousResponse.PageCount < 10)))
|
if (options.MultipageDownload && transcodingResult.NextPageUrl != null && (previousResponse == null || (previousResponse != null && previousResponse.PageCount < _options.MultipageLimit)))
|
||||||
{
|
{
|
||||||
return await Request(new Uri(transcodingResult.NextPageUrl), new ReadOptions()
|
return await Request(new Uri(transcodingResult.NextPageUrl), new ReadOptions()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user