Add config option keep_looking.
continuous-integration/drone/push Build is passing Details

If set, don't stop at first already posted guid.
This commit is contained in:
tastytea 2020-01-01 13:25:05 +01:00
parent 80db08a9c6
commit 986bac21da
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
4 changed files with 18 additions and 3 deletions

View File

@ -2,7 +2,7 @@
:doctype: manpage
:Author: tastytea
:Email: tastytea@tastytea.de
:Date: 2019-12-31
:Date: 2020-01-01
:Revision: 0.0.0
:man source: mastorss
:man manual: General Commands Manual
@ -67,6 +67,11 @@ information about the syntax see *perlre*(1).
*instance*::
Hostname of the instance you're using to post.
*keep_looking*::
If true, keep looking for new items after encountering the first that was
already posted. If you set this in the beginning, the whole feed will get
posted, since all items are new.
*interval*::
Time to wait between posts.
@ -104,6 +109,7 @@ If true, only post titles, no descriptions.
],
"instance" : "newsbots.eu",
"interval" : 600,
"keep_looking" : false,
"max_size" : 500,
"skip" :
[

View File

@ -64,6 +64,7 @@ std::ostream &operator <<(std::ostream &out, const ProfileData &data)
out << "], "
<< "instance: \"" << data.instance << "\", "
<< "interval: " << data.interval << ", "
<< "keep_looking: " << data.keep_looking << ", "
<< "last_guid: \"" << data.last_guid << "\", "
<< "max_size: " << data.max_size << ", "
<< "skip: [";
@ -230,6 +231,7 @@ void Config::parse()
profiledata.interval =
static_cast<uint32_t>(_json[profile]["interval"].asUInt64());
}
profiledata.keep_looking = _json[profile]["keep_looking"].asBool();
profiledata.last_guid = _json[profile]["last_guid"].asString();
if (!_json[profile]["max_size"].isNull())
{
@ -251,6 +253,7 @@ void Config::write()
_json[profile]["fixes"] = stringlist_to_jsonarray(profiledata.fixes);
_json[profile]["instance"] = profiledata.instance;
_json[profile]["interval"] = profiledata.interval;
_json[profile]["keep_looking"] = profiledata.keep_looking;
_json[profile]["last_guid"] = profiledata.last_guid;
_json[profile]["max_size"]
= static_cast<Json::Value::UInt64>(profiledata.max_size);

View File

@ -46,6 +46,7 @@ struct ProfileData
list<string> fixes;
list<string> guids;
string instance;
bool keep_looking{false};
uint32_t interval{30};
string last_guid;
size_t max_size{500};

View File

@ -165,8 +165,13 @@ void Document::parse_rss(const pt::ptree &tree)
[&](const auto &old_guid)
{ return guid == old_guid; }))
{
BOOST_LOG_TRIVIAL(debug)
<< "Found already posted GUID, stopped parsing.";
BOOST_LOG_TRIVIAL(debug) << "Found already posted GUID.";
if (_profiledata.keep_looking)
{
continue;
}
BOOST_LOG_TRIVIAL(debug) << "Stopped parsing.";
break;
}