aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-06-02 18:36:36 +0200
committerdec05eba <dec05eba@protonmail.com>2020-06-02 18:36:36 +0200
commit5ccd94a771cf1031b837c7bc4d0baeab4b810a38 (patch)
tree3e59a84138a41ca6ed914930dddd4785a19932bd /src
parent032ac2eb98f02dd18da7b642917635c81ba43cf6 (diff)
4chan: Use cached boards.json instead of downloading it everytime
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Fourchan.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp
index 06728fe..073356b 100644
--- a/src/plugins/Fourchan.cpp
+++ b/src/plugins/Fourchan.cpp
@@ -1,7 +1,8 @@
#include "../../plugins/Fourchan.hpp"
+#include "../../include/DataView.hpp"
+#include "../../include/Storage.hpp"
#include <json/reader.h>
#include <string.h>
-#include "../../include/DataView.hpp"
#include <tidy.h>
#include <tidybuffio.h>
@@ -45,10 +46,17 @@ namespace QuickMedia {
}
PluginResult Fourchan::get_front_page(BodyItems &result_items) {
+#if 0
std::string server_response;
if(download_to_string(fourchan_url + "boards.json", server_response, {}, use_tor) != DownloadResult::OK)
return PluginResult::NET_ERR;
-
+#else
+ std::string server_response;
+ if(file_get_content("../../../boards.json", server_response) != 0) {
+ fprintf(stderr, "failed to read boards.json\n");
+ return PluginResult::ERR;
+ }
+#endif
Json::Value json_root;
Json::CharReaderBuilder json_builder;
std::unique_ptr<Json::CharReader> json_reader(json_builder.newCharReader());