void rss_parser::set_item_title(std::tr1::shared_ptr<rss_feed> feed, std::tr1::shared_ptr<rss_item> x, rsspp::item& item) { if (is_html_type(item.title_type)) { x->set_title(render_xhtml_title(item.title, feed->link())); } else { std::string title = item.title; replace_newline_characters(title); x->set_title(title); } }
void rss_parser::fill_feed_items(std::tr1::shared_ptr<rss_feed> feed) { /* * we iterate over all items of a feed, create an rss_item object for * each item, and fill it with the appropriate values from the data structure. */ for (std::vector<rsspp::item>::iterator item=f.items.begin();item!=f.items.end();item++) { std::tr1::shared_ptr<rss_item> x(new rss_item(ch)); set_item_title(feed, x, *item); if (item->link != "") { x->set_link(utils::absolute_url(feed->link(), item->link)); } set_item_author(x, *item); x->set_feedurl(feed->rssurl()); if (f.rss_version == rsspp::ATOM_1_0 && item->labels.size() > 0) { std::vector<std::string>::const_iterator start, finish; start = item->labels.begin(); finish = item->labels.end(); if (std::find(start, finish, "fresh") != finish) { x->set_unread_nowrite(true); x->set_override_unread(true); } if (std::find(start, finish, "kept-unread") != finish) { x->set_unread_nowrite(true); x->set_override_unread(true); } if (std::find(start, finish, "read") != finish) { x->set_unread_nowrite(false); x->set_override_unread(true); } } set_item_content(x, *item); if (item->pubDate != "") x->set_pubDate(parse_date(item->pubDate)); else x->set_pubDate(::time(NULL)); x->set_guid(get_guid(*item)); x->set_base(item->base); set_item_enclosure(x, *item); LOG(LOG_DEBUG, "rss_parser::parse: item title = `%s' link = `%s' pubDate = `%s' (%d) description = `%s'", x->title().c_str(), x->link().c_str(), x->pubDate().c_str(), x->pubDate_timestamp(), x->description().c_str()); add_item_to_feed(feed, x); } }
void rss_parser::set_item_content(std::tr1::shared_ptr<rss_item> x, rsspp::item& item) { handle_content_encoded(x, item); handle_itunes_summary(x, item); if (x->description() == "") { x->set_description(item.description); } else { if (cfgcont->get_configvalue_as_bool("always-display-description") && item.description != "") x->set_description(x->description() + "<hr>" + item.description); } /* if it's still empty and we shall download the full page, then we do so. */ if (x->description() == "" && cfgcont->get_configvalue_as_bool("download-full-page") && x->link() != "") { x->set_description(utils::retrieve_url(x->link(), cfgcont)); } LOG(LOG_DEBUG, "rss_parser::set_item_content: content = %s", x->description().c_str()); }
void rss_parser::fill_feed_fields(std::tr1::shared_ptr<rss_feed> feed) { /* * we fill all the feed members with the appropriate values from the rsspp data structure */ if (is_html_type(f.title_type)) { feed->set_title(render_xhtml_title(f.title, feed->link())); } else { feed->set_title(f.title); } feed->set_description(f.description); feed->set_link(utils::absolute_url(my_uri, f.link)); if (f.pubDate != "") feed->set_pubDate(parse_date(f.pubDate)); else feed->set_pubDate(::time(NULL)); set_rtl(feed, f.language.c_str()); LOG(LOG_DEBUG, "rss_parser::parse: feed title = `%s' link = `%s'", feed->title().c_str(), feed->link().c_str()); }
bool operator()(std::tr1::shared_ptr<rss_item> a, std::tr1::shared_ptr<rss_item> b) { return reverse ? (strcmp(a->link().c_str(), b->link().c_str()) > 0) : (strcmp(a->link().c_str(), b->link().c_str()) < 0); }
void rss_parser::add_item_to_feed(std::tr1::shared_ptr<rss_feed> feed, std::tr1::shared_ptr<rss_item> item) { // only add item to feed if it isn't on the ignore list or if there is no ignore list if (!ign || !ign->matches(item.get())) { feed->add_item(item); LOG(LOG_INFO, "rss_parser::parse: added article title = `%s' link = `%s' ign = %p", item->title().c_str(), item->link().c_str(), ign); } else { LOG(LOG_INFO, "rss_parser::parse: ignored article title = `%s' link = `%s'", item->title().c_str(), item->link().c_str()); } }