aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/Fourchan.cpp51
1 files changed, 33 insertions, 18 deletions
diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp
index 87c6364..424dab8 100644
--- a/src/plugins/Fourchan.cpp
+++ b/src/plugins/Fourchan.cpp
@@ -516,16 +516,23 @@ namespace QuickMedia {
} else {
fprintf(stderr, "TODO: Support file extension: %s\n", ext_str.c_str());
}
- // "s" means small, that's the url 4chan uses for thumbnails.
- // thumbnails always has .jpg extension even if they are gifs or webm.
- body_item->thumbnail_url = fourchan_image_url + board_id + "/" + std::to_string(tim.asInt64()) + "s.jpg";
- mgl::vec2i thumbnail_size(64, 64);
- const Json::Value &tn_w = thread["tn_w"];
- const Json::Value &tn_h = thread["tn_h"];
- if(tn_w.isNumeric() && tn_h.isNumeric())
- thumbnail_size = mgl::vec2i(tn_w.asInt() / 2, tn_h.asInt() / 2);
- body_item->thumbnail_size = std::move(thumbnail_size);
+ const Json::Value &spoiler_json = thread["spoiler"];
+ if(spoiler_json.isInt() && spoiler_json.asInt() == 1) {
+ body_item->thumbnail_url = "https://s.4cdn.org/image/spoiler-a1.png";
+ body_item->thumbnail_size = {100, 100};
+ } else {
+ // "s" means small, that's the url 4chan uses for thumbnails.
+ // thumbnails always has .jpg extension even if they are gifs or webm.
+ body_item->thumbnail_url = fourchan_image_url + board_id + "/" + std::to_string(tim.asInt64()) + "s.jpg";
+
+ mgl::vec2i thumbnail_size(64, 64);
+ const Json::Value &tn_w = thread["tn_w"];
+ const Json::Value &tn_h = thread["tn_h"];
+ if(tn_w.isNumeric() && tn_h.isNumeric())
+ thumbnail_size = mgl::vec2i(tn_w.asInt() / 2, tn_h.asInt() / 2);
+ body_item->thumbnail_size = std::move(thumbnail_size);
+ }
}
result_items.push_back(std::move(body_item));
@@ -620,18 +627,26 @@ namespace QuickMedia {
} else {
fprintf(stderr, "TODO: Support file extension: %s\n", ext_str.c_str());
}
- // "s" means small, that's the url 4chan uses for thumbnails.
- // thumbnails always has .jpg extension even if they are gifs or webm.
+
std::string tim_str = std::to_string(tim.asInt64());
- body_item->thumbnail_url = fourchan_image_url + board_id + "/" + tim_str + "s.jpg";
body_item->url = fourchan_image_url + board_id + "/" + tim_str + ext_str;
- mgl::vec2i thumbnail_size(64, 64);
- const Json::Value &tn_w = post["tn_w"];
- const Json::Value &tn_h = post["tn_h"];
- if(tn_w.isNumeric() && tn_h.isNumeric())
- thumbnail_size = mgl::vec2i(tn_w.asInt(), tn_h.asInt());
- body_item->thumbnail_size = std::move(thumbnail_size);
+ const Json::Value &spoiler_json = post["spoiler"];
+ if(spoiler_json.isInt() && spoiler_json.asInt() == 1) {
+ body_item->thumbnail_url = "https://s.4cdn.org/image/spoiler-a1.png";
+ body_item->thumbnail_size = {100, 100};
+ } else {
+ // "s" means small, that's the url 4chan uses for thumbnails.
+ // thumbnails always has .jpg extension even if they are gifs or webm.
+ body_item->thumbnail_url = fourchan_image_url + board_id + "/" + tim_str + "s.jpg";
+
+ mgl::vec2i thumbnail_size(64, 64);
+ const Json::Value &tn_w = post["tn_w"];
+ const Json::Value &tn_h = post["tn_h"];
+ if(tn_w.isNumeric() && tn_h.isNumeric())
+ thumbnail_size = mgl::vec2i(tn_w.asInt(), tn_h.asInt());
+ body_item->thumbnail_size = std::move(thumbnail_size);
+ }
}
++body_item_index;