logicp 5 years ago
parent
commit
0387740bcf
1 changed files with 32 additions and 0 deletions
  1. 32 0
      src/utils.h

+ 32 - 0
src/utils.h

@@ -0,0 +1,32 @@
+#include <string>
+#include <iostream>
+#include <json.hpp>
+
+using json = nlohmann::json;
+
+namespace KIQUtils {
+
+void research_topic(std::string topic) {
+  std::cout << "researching topic: " << topic << std::endl;
+}
+
+void process_channel_info(json& json_obj) {
+  bool complete = false;
+  std::string topic_string{};
+  if (json_obj.size() > 0) {
+    for (const auto& [k, v] : json_obj.items()) {
+      if (k == "channelName") {
+        std::cout << "Parsed channel name: " << v << std::endl;
+      }
+
+      if (k == "categoryName") {
+        std::string topic = v[0].get<std::string>();
+        topic_string = topic.substr(topic.find("https://en.wikipedia.org/wiki/") + 30);
+      }
+    }
+    if (topic_string.size() > 0) {
+      research_topic(topic_string);
+    }
+  }
+}
+};