add ability to mark faulty mobile URIs
This commit is contained in:
@@ -156,6 +156,13 @@ namespace ReadSharp.Tests
|
|||||||
Assert.Equal(result.NextPage.ToString(), "http://arstechnica.com/apple/2014/01/two-steps-forward-a-review-of-the-2013-mac-pro/2");
|
Assert.Equal(result.NextPage.ToString(), "http://arstechnica.com/apple/2014/01/two-steps-forward-a-review-of-the-2013-mac-pro/2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task AreSinglepageArticlesNotPopulatingNextPage()
|
||||||
|
{
|
||||||
|
Article result = await reader.Read(new Uri("http://www.buzzfeed.com/mattlynley/the-16-most-interesting-things-to-come-out-of-bill-gates-qa"));
|
||||||
|
Assert.Null(result.NextPage);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task TestCriticalURIs()
|
public async Task TestCriticalURIs()
|
||||||
{
|
{
|
||||||
@@ -192,6 +199,9 @@ namespace ReadSharp.Tests
|
|||||||
{
|
{
|
||||||
Article result = await reader.Read(new Uri("http://www.dgtle.com/article-5682-1.html"));
|
Article result = await reader.Read(new Uri("http://www.dgtle.com/article-5682-1.html"));
|
||||||
Assert.Contains("http://img.dgtle.com/forum/201402/13/162237x8oumb8i0i0y0087.jpeg!680px", result.Content);
|
Assert.Contains("http://img.dgtle.com/forum/201402/13/162237x8oumb8i0i0y0087.jpeg!680px", result.Content);
|
||||||
|
|
||||||
|
result = await reader.Read(new Uri("http://m.spiegel.de/spiegelgeschichte/a-946060.html"));
|
||||||
|
Assert.DoesNotContain("Detecting browser settings", result.Content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,14 @@ namespace ReadSharp
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected NReadabilityTranscoder _transcoder;
|
protected NReadabilityTranscoder _transcoder;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Redirect faulty mobile URIs to desktop equivalents
|
||||||
|
/// </summary>
|
||||||
|
private static readonly Dictionary<string, string> _redirectFaultyMobileURIs = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "//m.spiegel.de", "//www.spiegel.de" }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -106,12 +114,22 @@ namespace ReadSharp
|
|||||||
Response response;
|
Response response;
|
||||||
TranscodingResult transcodingResult;
|
TranscodingResult transcodingResult;
|
||||||
Encoding encoding;
|
Encoding encoding;
|
||||||
|
string uriString = uri.OriginalString;
|
||||||
|
|
||||||
if (options == null)
|
if (options == null)
|
||||||
{
|
{
|
||||||
options = ReadOptions.CreateDefault();
|
options = ReadOptions.CreateDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// replace domain when URI is marked as faulty
|
||||||
|
foreach (string faultyUri in _redirectFaultyMobileURIs.Keys)
|
||||||
|
{
|
||||||
|
if (uriString.Contains(faultyUri))
|
||||||
|
{
|
||||||
|
uri = new Uri(uriString.Replace(faultyUri, _redirectFaultyMobileURIs[faultyUri]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// make async request
|
// make async request
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user