From 0209d1a5b13e97ba8f4be0cae8a6328daf53d173 Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Fri, 5 Apr 2019 14:26:19 +0200 Subject: [PATCH] 5.0 release --- PocketSharp/Components/Explore.cs | 202 ++++++++++---------- PocketSharp/PocketSharp.csproj | 16 +- PocketSharp/PocketSharp.nuspec | 18 +- PocketSharp/Utilities/HtmlNodeExtensions.cs | 38 ++-- 4 files changed, 140 insertions(+), 134 deletions(-) diff --git a/PocketSharp/Components/Explore.cs b/PocketSharp/Components/Explore.cs index 350197b..4571353 100644 --- a/PocketSharp/Components/Explore.cs +++ b/PocketSharp/Components/Explore.cs @@ -1,101 +1,101 @@ -using HtmlAgilityPack; -using PocketSharp.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using System.Web; - -namespace PocketSharp -{ - /// - /// PocketClient - /// - public partial class PocketClient - { - /// - /// Term to use for trending articles in the Explore() method - /// - const string EXPLORE_TRENDING = "trending"; - - /// - /// Term to use for must-read articles in the Explore() method - /// - const string EXPLORE_MUST_READS = "must-reads"; - - - /// - /// Explore Pocket and find interesting articles by a certain topic - /// - /// Term or topic to get articles for - /// - /// - async Task> Explore(string topic, CancellationToken cancellationToken = default(CancellationToken)) - { - List items = new List(); - string html = await RequestAsString("https://getpocket.com/explore/" + HttpUtility.UrlEncode(topic) , cancellationToken); - - var document = new HtmlDocument(); - document.LoadHtml(html); - - IEnumerable nodes = document.DocumentNode.SelectNodesByClass("media_item"); - - if (nodes == null || !nodes.Any()) - { - return items; - } - - for (int i = 0; i < nodes.Count(); i++) - { - HtmlNode node = nodes.ElementAt(i); - PocketExploreItem item = new PocketExploreItem(); - item.ID = node.Id; - - HtmlNode title = node.SelectNodeByClass("title")?.FirstChild; - - if (title == null) - { - continue; - } - - // get uri - string uri = title.GetAttributeValue("data-saveurl", null); - item.Uri = new Uri(uri); - - // get image - string imageUri = node.SelectNodeByClass("item_image")?.GetAttributeValue("data-thumburl", null); - if (!String.IsNullOrEmpty(imageUri)) - { - PocketImage image = new PocketImage(); - image.Uri = new Uri(imageUri); - image.ID = "0"; - image.ItemID = item.ID; - item.Images = new List() { image }; - } - - // get basic infos - item.Title = title.InnerText; - item.Excerpt = node.SelectNodeByClass("excerpt")?.InnerText; - item.IsTrending = node.SelectNodeByClass("flag-trending") != null; - - // save count - string saveCountStr = node.SelectNodeByClass("save_count")?.InnerText?.Split(' ')?.FirstOrDefault(); - int saveCount = 0; - Int32.TryParse(saveCountStr, out saveCount); - item.SaveCount = saveCount; - - // add published date - DateTime publishedDate = DateTime.Now; - if (DateTime.TryParse(node.SelectNodeByClass("read_time")?.InnerText, out publishedDate)) - { - item.PublishedTime = publishedDate; - } - - items.Add(item); - } - - return items; - } - } -} +//using HtmlAgilityPack; +//using PocketSharp.Models; +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Threading; +//using System.Threading.Tasks; +//using System.Web; + +//namespace PocketSharp +//{ +// /// +// /// PocketClient +// /// +// public partial class PocketClient +// { +// /// +// /// Term to use for trending articles in the Explore() method +// /// +// const string EXPLORE_TRENDING = "trending"; + +// /// +// /// Term to use for must-read articles in the Explore() method +// /// +// const string EXPLORE_MUST_READS = "must-reads"; + + +// /// +// /// Explore Pocket and find interesting articles by a certain topic +// /// +// /// Term or topic to get articles for +// /// +// /// +// async Task> Explore(string topic, CancellationToken cancellationToken = default(CancellationToken)) +// { +// List items = new List(); +// string html = await RequestAsString("https://getpocket.com/explore/" + HttpUtility.UrlEncode(topic), cancellationToken); + +// var document = new HtmlDocument(); +// document.LoadHtml(html); + +// IEnumerable nodes = document.DocumentNode.SelectNodesByClass("media_item"); + +// if (nodes == null || !nodes.Any()) +// { +// return items; +// } + +// for (int i = 0; i < nodes.Count(); i++) +// { +// HtmlNode node = nodes.ElementAt(i); +// PocketExploreItem item = new PocketExploreItem(); +// item.ID = node.Id; + +// HtmlNode title = node.SelectNodeByClass("title")?.FirstChild; + +// if (title == null) +// { +// continue; +// } + +// // get uri +// string uri = title.GetAttributeValue("data-saveurl", null); +// item.Uri = new Uri(uri); + +// // get image +// string imageUri = node.SelectNodeByClass("item_image")?.GetAttributeValue("data-thumburl", null); +// if (!String.IsNullOrEmpty(imageUri)) +// { +// PocketImage image = new PocketImage(); +// image.Uri = new Uri(imageUri); +// image.ID = "0"; +// image.ItemID = item.ID; +// item.Images = new List() { image }; +// } + +// // get basic infos +// item.Title = title.InnerText; +// item.Excerpt = node.SelectNodeByClass("excerpt")?.InnerText; +// item.IsTrending = node.SelectNodeByClass("flag-trending") != null; + +// // save count +// string saveCountStr = node.SelectNodeByClass("save_count")?.InnerText?.Split(' ')?.FirstOrDefault(); +// int saveCount = 0; +// Int32.TryParse(saveCountStr, out saveCount); +// item.SaveCount = saveCount; + +// // add published date +// DateTime publishedDate = DateTime.Now; +// if (DateTime.TryParse(node.SelectNodeByClass("read_time")?.InnerText, out publishedDate)) +// { +// item.PublishedTime = publishedDate; +// } + +// items.Add(item); +// } + +// return items; +// } +// } +//} diff --git a/PocketSharp/PocketSharp.csproj b/PocketSharp/PocketSharp.csproj index a06d60d..fb26960 100644 --- a/PocketSharp/PocketSharp.csproj +++ b/PocketSharp/PocketSharp.csproj @@ -1,12 +1,22 @@ - + netstandard2.0 + 5.0.0 + Tobias Klika + brothers + https://github.com/ceee/PocketSharp + Copyright by brothers, 2019 + PocketAPI Pocket API PocketSharp Tobias Klika cee Scott Lovegrove scottisafool NReadability SgmlReader Reader Article SDK Pockem + PocketSharp is a .NET Standard library that integrates the Pocket API v3. + + true - - + \ No newline at end of file diff --git a/PocketSharp/PocketSharp.nuspec b/PocketSharp/PocketSharp.nuspec index 01489cd..4a56909 100644 --- a/PocketSharp/PocketSharp.nuspec +++ b/PocketSharp/PocketSharp.nuspec @@ -1,4 +1,4 @@ - + $id$ @@ -6,18 +6,14 @@ $title$ $author$ $author$ - https://raw.github.com/ceee/PocketSharp/master/LICENSE-MIT + MIT https://github.com/ceee/PocketSharp https://raw.github.com/ceee/PocketSharp/master/Assets/pocketsharp.png false - PocketSharp is a .NET Standard library that integrates the Pocket API v3. + $description$ en-US - - - - Copyright by brothers, 2018 - PocketAPI Pocket API PocketSharp Tobias Klika cee Scott Lovegrove scottisafool NReadability SgmlReader Reader Article SDK Pockem + $releaseNotes$ + $copyright$ + $tags$ - \ No newline at end of file + diff --git a/PocketSharp/Utilities/HtmlNodeExtensions.cs b/PocketSharp/Utilities/HtmlNodeExtensions.cs index 6d1fea7..6a117bc 100644 --- a/PocketSharp/Utilities/HtmlNodeExtensions.cs +++ b/PocketSharp/Utilities/HtmlNodeExtensions.cs @@ -1,22 +1,22 @@ -using HtmlAgilityPack; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +//using HtmlAgilityPack; +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Text; -namespace PocketSharp -{ - internal static class HtmlNodeExtensions - { - public static IEnumerable SelectNodesByClass(this HtmlNode node, string className) - { - return node.Descendants().Where(x => x.HasClass(className)); - } +//namespace PocketSharp +//{ +// internal static class HtmlNodeExtensions +// { +// public static IEnumerable SelectNodesByClass(this HtmlNode node, string className) +// { +// return node.Descendants().Where(x => x.HasClass(className)); +// } - public static HtmlNode SelectNodeByClass(this HtmlNode node, string className) - { - return node.Descendants().FirstOrDefault(x => x.HasClass(className)); - } - } -} +// public static HtmlNode SelectNodeByClass(this HtmlNode node, string className) +// { +// return node.Descendants().FirstOrDefault(x => x.HasClass(className)); +// } +// } +//}