More renaming.

This commit is contained in:
tastytea 2019-12-28 09:10:32 +01:00
parent a692e00128
commit 2b0a091e87
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 17 additions and 17 deletions

View File

@ -45,7 +45,7 @@ bool operator !=(const Item &a, const Item &b)
Document::Document(Config &cfg)
: _cfg{cfg}
, profiledata{cfg.data}
, _profiledata{_cfg.profiledata}
{
RestClient::init();
@ -70,20 +70,20 @@ void Document::download(const string &uri)
case 200:
{
_raw_doc = response.body;
BOOST_LOG_TRIVIAL(debug) << "Downloaded feed: " << profiledata.feedurl;
BOOST_LOG_TRIVIAL(debug) << "Downloaded feed: " << _profiledata.feedurl;
break;
}
case 301:
case 308:
{
profiledata.feedurl = extract_location(response.headers);
if (profiledata.feedurl.empty())
_profiledata.feedurl = extract_location(response.headers);
if (_profiledata.feedurl.empty())
{
throw HTTPException{response.code};
}
BOOST_LOG_TRIVIAL(debug) << "Feed has new location (permanent): "
<< profiledata.feedurl;
<< _profiledata.feedurl;
_cfg.write();
download();
break;
@ -99,7 +99,7 @@ void Document::download(const string &uri)
}
BOOST_LOG_TRIVIAL(debug) << "Feed has new location (temporary): "
<< profiledata.feedurl;
<< _profiledata.feedurl;
download(newuri);
break;
}
@ -116,7 +116,7 @@ void Document::download(const string &uri)
void Document::download()
{
download(profiledata.feedurl);
download(_profiledata.feedurl);
}
void Document::parse()
@ -145,14 +145,14 @@ void Document::parse_rss(const pt::ptree &tree)
{
guid = rssitem.get<string>("link");
}
if (guid == profiledata.last_guid)
if (guid == _profiledata.last_guid)
{
break;
}
bool skipthis{false};
string title{rssitem.get<string>("title")};
for (const auto &skip : profiledata.skip)
for (const auto &skip : _profiledata.skip)
{
if (title.substr(0, skip.length()) == skip)
{
@ -171,7 +171,7 @@ void Document::parse_rss(const pt::ptree &tree)
{
string desc
{remove_html(rssitem.get<string>("description"))};
for (const auto &fix : profiledata.fixes)
for (const auto &fix : _profiledata.fixes)
{
desc = regex_replace(desc, regex{fix}, "");
}
@ -184,7 +184,7 @@ void Document::parse_rss(const pt::ptree &tree)
BOOST_LOG_TRIVIAL(debug) << "Found GUID: " << item.guid;
if (profiledata.last_guid.empty())
if (_profiledata.last_guid.empty())
{
BOOST_LOG_TRIVIAL(debug) << "This is the first run.";
break;

View File

@ -90,25 +90,25 @@ int main(int argc, char *argv[])
}
else
{
const string_view profile{args[1]};
BOOST_LOG_TRIVIAL(debug) << "Using profile: " << profile;
const string_view profilename{args[1]};
BOOST_LOG_TRIVIAL(debug) << "Using profile: " << profilename;
try
{
Config cfg{profile.data()};
Config cfg{profilename.data()};
Document doc{cfg};
doc.parse();
MastoAPI masto{cfg.data};
MastoAPI masto{cfg.profiledata};
if (!doc.new_items.empty())
{
for (const auto &item : doc.new_items)
{
masto.post_item(item);
cfg.data.last_guid = item.guid;
cfg.profiledata.last_guid = item.guid;
if (item != *doc.new_items.rbegin())
{ // Don't sleep if this is the last item.
sleep_for(seconds(cfg.data.interval));
sleep_for(seconds(cfg.profiledata.interval));
}
}
cfg.write();