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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#include "feedbinurlreader.h"
#include <cinttypes>
#include "fileurlreader.h"
#include "logger.h"
#include "remoteapi.h"
#include "utils.h"
namespace newsboat {
FeedbinUrlReader::FeedbinUrlReader(const Filepath& url_file, RemoteApi* a)
: file(url_file)
, api(a)
{
}
nonstd::optional<utils::ReadTextFileError> FeedbinUrlReader::reload()
{
urls.clear();
tags.clear();
alltags.clear();
FileUrlReader ur(file);
const auto error_message = ur.reload();
if (error_message.has_value()) {
LOG(Level::DEBUG, "Reloading failed: %s", error_message.value().message);
// Ignore errors for now: https://github.com/newsboat/newsboat/issues/1273
}
const std::vector<std::string>& file_urls(ur.get_urls());
LOG(Level::INFO, "URL count: %" PRIu64, static_cast<uint64_t>(file_urls.size()));
for (const auto& url : file_urls) {
LOG(Level::INFO, "It's a URL: %s", url);
if (utils::is_query_url(url)) {
urls.push_back(url);
}
}
const std::vector<TaggedFeedUrl> feedurls = api->get_subscribed_urls();
for (const auto& url : feedurls) {
LOG(Level::INFO, "added %s to URL list", url.first);
urls.push_back(url.first);
tags[url.first] = url.second;
for (const auto& tag : url.second) {
LOG(Level::DEBUG, "%s: added tag %s", url.first, tag);
alltags.insert(tag);
}
}
return {};
}
std::string FeedbinUrlReader::get_source()
{
return "Feedbin";
}
} // namespace newsboat
|