add Explore method

This commit is contained in:
2018-07-14 23:26:57 +02:00
parent ab3b532e30
commit eb89784117
9 changed files with 11115 additions and 22 deletions
@@ -1,4 +1,4 @@
using PocketSharp.Models; using PocketSharp.Models;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
File diff suppressed because it is too large Load Diff
+25
View File
@@ -0,0 +1,25 @@
using PocketSharp.Models;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;
using System.Linq;
namespace PocketSharp.Tests
{
public class ExploreTests : TestsBase
{
public ExploreTests() : base()
{
}
[Fact]
public async Task CheckPreRequestAction()
{
var results = await client.Explore(".net");
Assert.NotEmpty(results);
}
}
}
-18
View File
@@ -17,8 +17,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PocketSharp", "PocketSharp\
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PocketSharp.Tests", "PocketSharp.Tests\PocketSharp.Tests.csproj", "{3BAA93AD-3B5C-47C4-816B-F29A1E6D1C2D}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PocketSharp.Tests", "PocketSharp.Tests\PocketSharp.Tests.csproj", "{3BAA93AD-3B5C-47C4-816B-F29A1E6D1C2D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.Explore", "PocketSharp.Explore\PocketSharp.Explore.csproj", "{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -85,22 +83,6 @@ Global
{3BAA93AD-3B5C-47C4-816B-F29A1E6D1C2D}.Release|x64.Build.0 = Release|Any CPU {3BAA93AD-3B5C-47C4-816B-F29A1E6D1C2D}.Release|x64.Build.0 = Release|Any CPU
{3BAA93AD-3B5C-47C4-816B-F29A1E6D1C2D}.Release|x86.ActiveCfg = Release|Any CPU {3BAA93AD-3B5C-47C4-816B-F29A1E6D1C2D}.Release|x86.ActiveCfg = Release|Any CPU
{3BAA93AD-3B5C-47C4-816B-F29A1E6D1C2D}.Release|x86.Build.0 = Release|Any CPU {3BAA93AD-3B5C-47C4-816B-F29A1E6D1C2D}.Release|x86.Build.0 = Release|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Debug|ARM.ActiveCfg = Debug|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Debug|ARM.Build.0 = Debug|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Debug|x64.ActiveCfg = Debug|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Debug|x64.Build.0 = Debug|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Debug|x86.ActiveCfg = Debug|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Debug|x86.Build.0 = Debug|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Release|Any CPU.Build.0 = Release|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Release|ARM.ActiveCfg = Release|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Release|ARM.Build.0 = Release|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Release|x64.ActiveCfg = Release|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Release|x64.Build.0 = Release|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Release|x86.ActiveCfg = Release|Any CPU
{9A72F701-72B5-4400-AE9B-2814FE5FCBB1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
+9 -2
View File
@@ -473,7 +473,7 @@ namespace PocketSharp
Task<PocketLimits> GetUsageLimits(CancellationToken cancellationToken = default(CancellationToken)); Task<PocketLimits> GetUsageLimits(CancellationToken cancellationToken = default(CancellationToken));
#endregion #endregion
#region trending methods #region explore/trending methods
/// <summary> /// <summary>
/// Get trending articles on Pocket. /// Get trending articles on Pocket.
/// Requires an active GUID from GetGuid() and will therefore make two HTTP requests. /// Requires an active GUID from GetGuid() and will therefore make two HTTP requests.
@@ -485,7 +485,6 @@ namespace PocketSharp
/// <exception cref="PocketException"></exception> /// <exception cref="PocketException"></exception>
Task<IEnumerable<PocketItem>> GetTrendingArticles(int count = 20, string languageCode = "en", CancellationToken cancellationToken = default(CancellationToken)); Task<IEnumerable<PocketItem>> GetTrendingArticles(int count = 20, string languageCode = "en", CancellationToken cancellationToken = default(CancellationToken));
/// <summary> /// <summary>
/// Get trending topics on Pocket. /// Get trending topics on Pocket.
/// Requires an active GUID from GetGuid() and will therefore make two HTTP requests. /// Requires an active GUID from GetGuid() and will therefore make two HTTP requests.
@@ -495,6 +494,14 @@ namespace PocketSharp
/// <returns></returns> /// <returns></returns>
/// <exception cref="PocketException"></exception> /// <exception cref="PocketException"></exception>
Task<IEnumerable<PocketTopic>> GetTrendingTopics(string languageCode = "en", CancellationToken cancellationToken = default(CancellationToken)); Task<IEnumerable<PocketTopic>> GetTrendingTopics(string languageCode = "en", CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Explore Pocket and find interesting articles by a certain topic
/// </summary>
/// <param name="topic">Term or topic to get articles for</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<IEnumerable<PocketItem>> Explore(string topic, CancellationToken cancellationToken = default(CancellationToken));
#endregion #endregion
/// <summary> /// <summary>
+9
View File
@@ -360,6 +360,15 @@ namespace PocketSharp.Models
[JsonConverter(typeof(ObjectToArrayConverter<PocketAuthor>))] [JsonConverter(typeof(ObjectToArrayConverter<PocketAuthor>))]
public IEnumerable<PocketAuthor> Authors { get; set; } public IEnumerable<PocketAuthor> Authors { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is trending.
/// </summary>
/// <value>
/// <c>true</c> if this instance is trending; otherwise, <c>false</c>.
/// </value>
[JsonProperty("trending")]
public bool IsTrending { get; set; }
/// <summary> /// <summary>
/// Gets the lead image. /// Gets the lead image.
/// </summary> /// </summary>
+1 -1
View File
@@ -141,7 +141,7 @@ namespace PocketSharp
this.isMobileClient = isMobileClient; this.isMobileClient = isMobileClient;
this.useInsideWebAuthenticationBroker = useInsideWebAuthenticationBroker; this.useInsideWebAuthenticationBroker = useInsideWebAuthenticationBroker;
this.cacheHTTPResponseData = cacheHTTPResponseData; this.cacheHTTPResponseData = cacheHTTPResponseData;
PocketClient.parserUri = parserUri.OriginalString; PocketClient.parserUri = parserUri?.OriginalString;
// assign access code if submitted // assign access code if submitted
if (accessCode != null) if (accessCode != null)
+1
View File
@@ -5,6 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.8.5" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup> </ItemGroup>
@@ -0,0 +1,23 @@
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Text;
namespace PocketSharp
{
internal static class HtmlNodeExtensions
{
public static HtmlNodeCollection SelectNodesByClass(this HtmlNode node, string className, bool isRoot = false)
{
string prefix = isRoot ? "//" : "";
return node.SelectNodes($"{prefix}*[contains(@class, '{className}')]");
}
public static HtmlNode SelectNodeByClass(this HtmlNode node, string className, bool isRoot = false)
{
string prefix = isRoot ? "//" : "";
return node.SelectSingleNode($"{prefix}*[contains(@class, '{className}')]");
}
}
}