diff --git a/PocketSharp/Models/PocketArticle.cs b/PocketSharp/Models/PocketArticle.cs
index 89ce37a..4361156 100644
--- a/PocketSharp/Models/PocketArticle.cs
+++ b/PocketSharp/Models/PocketArticle.cs
@@ -40,6 +40,6 @@ namespace PocketSharp.Models
///
/// The next page URL.
///
- public string NextPageUrl { get; set; }
+ public Uri NextPage { get; set; }
}
}
diff --git a/PocketSharp/PocketClient.cs b/PocketSharp/PocketClient.cs
index bdded50..d4c34ff 100644
--- a/PocketSharp/PocketClient.cs
+++ b/PocketSharp/PocketClient.cs
@@ -112,6 +112,7 @@ namespace PocketSharp
// every single Pocket API endpoint requires HTTP POST data
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, method);
+ HttpResponseMessage response = null;
if (parameters == null)
{
@@ -131,7 +132,14 @@ namespace PocketSharp
request.Content = new FormUrlEncodedContent(parameters);
// make async request
- HttpResponseMessage response = await _restClient.SendAsync(request);
+ try
+ {
+ response = await _restClient.SendAsync(request);
+ }
+ catch (HttpRequestException exc)
+ {
+ throw new PocketException(exc.Message, exc);
+ }
// validate HTTP response
ValidateResponse(response);
diff --git a/PocketSharp/PocketReader.cs b/PocketSharp/PocketReader.cs
index 9001348..0071a61 100644
--- a/PocketSharp/PocketReader.cs
+++ b/PocketSharp/PocketReader.cs
@@ -42,6 +42,25 @@ namespace PocketSharp
+ ///
+ /// Reads article content from the given URI.
+ /// This method does not use the official Article View API, which is private.
+ /// The PocketReader is based on a custom PCL port of NReadability and SgmlReader.
+ ///
+ /// An URI.
+ /// A Pocket article with extracted content and title.
+ ///
+ public async Task Read(Uri uri)
+ {
+ return await Read(new PocketItem()
+ {
+ ID = 0,
+ Uri = uri
+ });
+ }
+
+
+
///
/// Reads article content from the given PocketItem.
/// This method does not use the official Article View API, which is private.
@@ -49,7 +68,7 @@ namespace PocketSharp
///
/// The pocket item.
/// A Pocket article with extracted content and title.
- ///
+ ///
public async Task Read(PocketItem item)
{
// initialize transcoder
@@ -87,7 +106,7 @@ namespace PocketSharp
{
Content = transcodingResult.ExtractedContent,
Title = transcodingResult.ExtractedTitle,
- NextPageUrl = transcodingResult.NextPageUrl,
+ NextPage = transcodingResult.NextPageUrl != null ? new Uri(transcodingResult.NextPageUrl, UriKind.Absolute) : null,
PocketItemID = item.ID
};
}
@@ -102,9 +121,17 @@ namespace PocketSharp
protected async Task Request(Uri uri)
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, uri);
+ HttpResponseMessage response = null;
// make async request
- HttpResponseMessage response = await _httpClient.SendAsync(request);
+ try
+ {
+ response = await _httpClient.SendAsync(request);
+ }
+ catch (HttpRequestException exc)
+ {
+ throw new PocketException(exc.Message, exc);
+ }
// validate HTTP response
if (response.StatusCode != HttpStatusCode.OK)
@@ -115,9 +142,7 @@ namespace PocketSharp
}
// read response
- var responseString = await response.Content.ReadAsStringAsync();
-
- return responseString;
+ return await response.Content.ReadAsStringAsync();
}
}
}
\ No newline at end of file
diff --git a/PocketSharp/PocketSharp.csproj b/PocketSharp/PocketSharp.csproj
index aa37969..0d50e15 100644
--- a/PocketSharp/PocketSharp.csproj
+++ b/PocketSharp/PocketSharp.csproj
@@ -43,13 +43,13 @@
-
+
-
+
@@ -69,7 +69,7 @@
-
+
diff --git a/PocketSharp/JsonExtensions.cs b/PocketSharp/Utilities/JsonExtensions.cs
similarity index 100%
rename from PocketSharp/JsonExtensions.cs
rename to PocketSharp/Utilities/JsonExtensions.cs
diff --git a/PocketSharp/PocketException.cs b/PocketSharp/Utilities/PocketException.cs
similarity index 100%
rename from PocketSharp/PocketException.cs
rename to PocketSharp/Utilities/PocketException.cs
diff --git a/PocketSharp/Utilities.cs b/PocketSharp/Utilities/Utilities.cs
similarity index 100%
rename from PocketSharp/Utilities.cs
rename to PocketSharp/Utilities/Utilities.cs