#include "RSS.hpp" #include #include #include #include #define CONFIG_LOCATION std::getenv("HOME") + "/.config/rsshit.xml" // #define CONFIG_LOCATION "rsshit.xml" std::string read_config() { std::ifstream file(std::string(std::getenv("HOME")) + "/.config/rsshit.xml"); std::stringstream buffer; buffer << file.rdbuf(); return buffer.str(); } int main() { std::string config; try { config = read_config(); if (config.length() == 0) { std::cout << "failed to read config file: the file is empty" << std::endl; return 1; } XML_leaf configParsed(config); auto span = std::stoi(configParsed.GetChild("lastminutes").GetValue()); std::cout << "News of the last " << span << " minutes:" << std::endl; auto sources = configParsed.GetChildren("source"); for (auto src : sources) { // std::cout << "URL: " << src.GetValue() << std::endl; RSS(src.GetValue()).print_latest(span); } } catch (std::exception& err) { std::cout << "failed to read config file: " << err.what() << std::endl; return 1; } // RSS("https://www.independent.co.uk/news/uk/rss").print(); // RSS("https://news.yahoo.com/rss/mostviewed").print(); return 0; }