diff --git a/ReadSharp/Reader.cs b/ReadSharp/Reader.cs index 46a4eec..d824bfe 100644 --- a/ReadSharp/Reader.cs +++ b/ReadSharp/Reader.cs @@ -34,6 +34,11 @@ namespace ReadSharp /// protected NReadabilityTranscoder _transcoder; + /// + /// The HTTP options + /// + protected HttpOptions _options; + /// /// Redirect faulty mobile URIs to desktop equivalents /// @@ -66,6 +71,8 @@ namespace ReadSharp options = HttpOptions.CreateDefault(); } + _options = options; + // initialize custom encoder _encoder = new Encodings.Encoder(true); @@ -133,10 +140,9 @@ namespace ReadSharp // get images from article int id = 1; - - List images = response.TranscodingResult.Images.Select(image => + List images = response.TranscodingResult.Images.Select(image => { - Uri imageUri; + Uri imageUri = null; Uri.TryCreate(image.GetAttributeValue("src", null), UriKind.Absolute, out imageUri); return new ArticleImage() @@ -146,7 +152,7 @@ namespace ReadSharp Title = image.GetAttributeValue("title", 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 string plainContent; @@ -349,7 +355,7 @@ namespace ReadSharp // multiple pages are available 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() {