aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Fourchan.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-12-09 19:45:19 +0100
committerdec05eba <dec05eba@protonmail.com>2019-12-09 19:45:19 +0100
commit5ef35784af24e5fcaa0f8570c23299d01b46412a (patch)
tree5c0a6c11743990975360518ebec32e8788e8edcc /src/plugins/Fourchan.cpp
parent5e29715201f3b67648728a0cd048fd1b3e1dbcf7 (diff)
Show title of posts on 4chan
Diffstat (limited to 'src/plugins/Fourchan.cpp')
-rw-r--r--src/plugins/Fourchan.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp
index 88bcafa..c571ef8 100644
--- a/src/plugins/Fourchan.cpp
+++ b/src/plugins/Fourchan.cpp
@@ -178,6 +178,11 @@ namespace QuickMedia {
if(!thread.isObject())
continue;
+ const Json::Value &sub = thread["sub"];
+ const char *sub_begin = "";
+ const char *sub_end = sub_begin;
+ sub.getString(&sub_begin, &sub_end);
+
const Json::Value &com = thread["com"];
const char *comment_begin = "";
const char *comment_end = comment_begin;
@@ -188,6 +193,30 @@ namespace QuickMedia {
continue;
std::string comment_text;
+ extract_comment_pieces(sub_begin, sub_end - sub_begin,
+ [&comment_text](const CommentPiece &cp) {
+ switch(cp.type) {
+ case CommentPiece::Type::TEXT:
+ comment_text.append(cp.text.data, cp.text.size);
+ break;
+ case CommentPiece::Type::QUOTE:
+ comment_text += '>';
+ comment_text.append(cp.text.data, cp.text.size);
+ //comment_text += '\n';
+ break;
+ case CommentPiece::Type::QUOTELINK: {
+ comment_text.append(cp.text.data, cp.text.size);
+ break;
+ }
+ case CommentPiece::Type::LINE_CONTINUE: {
+ if(!comment_text.empty() && comment_text.back() == '\n') {
+ comment_text.pop_back();
+ }
+ break;
+ }
+ }
+ }
+ );
extract_comment_pieces(comment_begin, comment_end - comment_begin,
[&comment_text](const CommentPiece &cp) {
switch(cp.type) {
@@ -289,6 +318,11 @@ namespace QuickMedia {
if(!post.isObject())
continue;
+ const Json::Value &sub = post["sub"];
+ const char *sub_begin = "";
+ const char *sub_end = sub_begin;
+ sub.getString(&sub_begin, &sub_end);
+
const Json::Value &com = post["com"];
const char *comment_begin = "";
const char *comment_end = comment_begin;
@@ -304,6 +338,32 @@ namespace QuickMedia {
author_str = author.asString();
std::string comment_text;
+ extract_comment_pieces(sub_begin, sub_end - sub_begin,
+ [&comment_text](const CommentPiece &cp) {
+ switch(cp.type) {
+ case CommentPiece::Type::TEXT:
+ comment_text.append(cp.text.data, cp.text.size);
+ break;
+ case CommentPiece::Type::QUOTE:
+ comment_text += '>';
+ comment_text.append(cp.text.data, cp.text.size);
+ //comment_text += '\n';
+ break;
+ case CommentPiece::Type::QUOTELINK: {
+ comment_text.append(cp.text.data, cp.text.size);
+ break;
+ }
+ case CommentPiece::Type::LINE_CONTINUE: {
+ if(!comment_text.empty() && comment_text.back() == '\n') {
+ comment_text.pop_back();
+ }
+ break;
+ }
+ }
+ }
+ );
+ if(!comment_text.empty())
+ comment_text += '\n';
extract_comment_pieces(comment_begin, comment_end - comment_begin,
[&comment_text, &comment_by_postno, &result_items, body_item_index](const CommentPiece &cp) {
switch(cp.type) {