diff --git a/src/rss.cpp b/src/rss.cpp index 0ae8440..2ff0f5c 100644 --- a/src/rss.cpp +++ b/src/rss.cpp @@ -434,6 +434,18 @@ std::string item::getGuid() const { return cdata_to_string(tmp); } +bool item::getGuidPermaLink() const { + rapidxml::xml_node<>* tmp = _item->first_node("guid"); + if(tmp == 0) + return false; + rapidxml::xml_attribute<>* attr = tmp->first_attribute("isPermaLink"); + if(attr == 0) + return false; + else if(attr->value() == std::string("true")) + return false; + return false; +} + std::string item::getPubDate() const { rapidxml::xml_node<>* tmp = _item->first_node("pubDate"); if(tmp == 0) @@ -448,3 +460,35 @@ std::string item::getSource() const { return cdata_to_string(tmp); } +std::string item::getEnclosureURL() const { + rapidxml::xml_node<>* tmp = _item->first_node("enclosure"); + if(tmp == 0) + return ""; + rapidxml::xml_attribute<>* attr = tmp->first_attribute("url"); + if(attr == 0) + return ""; + else + return attr->value(); +} + +std::string item::getEnclosureType() const { + rapidxml::xml_node<>* tmp = _item->first_node("enclosure"); + if(tmp == 0) + return ""; + rapidxml::xml_attribute<>* attr = tmp->first_attribute("type"); + if(attr == 0) + return ""; + else + return attr->value(); +} + +int item::getEnclosureLength() const { + rapidxml::xml_node<>* tmp = _item->first_node("enclosure"); + if(tmp == 0) + return -1; + rapidxml::xml_attribute<>* attr = tmp->first_attribute("length"); + if(attr == 0) + return -1; + else + return atoi(attr->value()); +} diff --git a/src/rss.hpp b/src/rss.hpp index ddcb6b2..7f315c1 100644 --- a/src/rss.hpp +++ b/src/rss.hpp @@ -88,16 +88,20 @@ namespace rss_utils { item& operator=(const item&); item* clone() const; - std::string getTitle() const; - std::string getLink() const; - std::string getDescription() const; - std::string getAuthor() const; - std::string getCategory() const; - std::string getComments() const; - //std::string getEnclosure() const; - std::string getGuid() const; - std::string getPubDate() const; - std::string getSource() const; + std::string getTitle() const; + std::string getLink() const; + std::string getDescription() const; + std::string getAuthor() const; + std::string getCategory() const; + std::string getComments() const; + std::string getGuid() const; + bool getGuidPermaLink() const; + std::string getPubDate() const; + std::string getSource() const; + + std::string getEnclosureURL() const; + std::string getEnclosureType() const; + int getEnclosureLength() const; private: