blob: cabe6dd7e32b21aa0aac720793ad0b3f7f53eaa5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#include "RSS.hpp"
#include <curl/curl.h>
#include <fstream>
#include <iostream>
#include <string>
#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 (char *ex) {
std::cout << "failed to read config file: " << ex << std::endl;
return 1;
}
// RSS("https://www.independent.co.uk/news/uk/rss").print();
// RSS("https://news.yahoo.com/rss/mostviewed").print();
return 0;
}
|