This commit is contained in:
tastytea 2018-05-14 21:44:44 +02:00
rodič cea2f7c295
revize 286a9baa06
Podepsáno: tastytea
ID GPG klíče: 59346E0EA35C67E5
4 změnil soubory, kde provedl 23 přidání a 18 odebrání

Zobrazit soubor

@ -30,6 +30,8 @@ using Mastodon::API;
using Mastodon::Easy;
void signal_handler(int signum);
/*!
* @brief Extract URLs from HTML
*
@ -37,7 +39,6 @@ void signal_handler(int signum);
*/
const std::vector<string> get_urls(const string &html);
/*!
* @brief Expands shortened URLs
*

Zobrazit soubor

@ -47,23 +47,6 @@ void signal_handler(int signum)
}
}
const std::vector<string> get_urls(const string &html)
{
const std::regex re_url("href=\"([^\"]+)\" rel");
std::smatch match;
string buffer = html;
std::vector<string> v;
while (std::regex_search(buffer, match, re_url))
{
string url = Easy::unescape_html(match[1].str());
v.push_back(strip(expand(url)));
buffer = match.suffix().str();
}
return v;
}
int main(int argc, char *argv[])
{
signal(SIGINT, signal_handler);

Zobrazit soubor

@ -74,6 +74,10 @@ const void Listener::stop()
_ptr->cancel_stream();
_thread.join();
}
else
{
cout << "DEBUG: _ptr is false.\n";
}
}
std::vector<Easy::Notification> Listener::get_new_messages()

Zobrazit soubor

@ -27,6 +27,23 @@ using std::cerr;
using std::string;
namespace curlopts = curlpp::options;
const std::vector<string> get_urls(const string &html)
{
const std::regex re_url("href=\"([^\"]+)\" rel");
std::smatch match;
string buffer = html;
std::vector<string> v;
while (std::regex_search(buffer, match, re_url))
{
string url = Easy::unescape_html(match[1].str());
v.push_back(strip(expand(url)));
buffer = match.suffix().str();
}
return v;
}
const string expand(const string &url)
{
curlpp::Easy request;