Item* RSS091Parser::ParseItem (const QDomElement& item, const IDType_t& channelId) const { Item *result = new Item (channelId); result->Title_ = UnescapeHTML (item.firstChildElement ("title").text ()); if (result->Title_.isEmpty ()) result->Title_ = "<>"; result->Link_ = item.firstChildElement ("link").text (); result->Description_ = item.firstChildElement ("description").text (); GetDescription (item, result->Description_); result->PubDate_ = RFC822TimeToQDateTime (item.firstChildElement ("pubDate").text ()); if (!result->PubDate_.isValid () || result->PubDate_.isNull ()) { qWarning () << "Aggregator RSS 0.91: Can't parse item pubDate: " << item.firstChildElement ("pubDate").text (); result->PubDate_ = QDateTime::currentDateTime (); } result->Guid_ = item.firstChildElement ("guid").text (); if (result->Guid_.isEmpty ()) result->Guid_ = "empty"; result->Categories_ = GetAllCategories (item); result->Unread_ = true; result->Author_ = GetAuthor (item); result->NumComments_ = GetNumComments (item); result->CommentsLink_ = GetCommentsRSS (item); result->CommentsPageLink_ = GetCommentsLink (item); result->Enclosures_ = GetEnclosures (item, result->ItemID_); result->Enclosures_ += GetEncEnclosures (item, result->ItemID_); QPair<double, double> point = GetGeoPoint (item); result->Latitude_ = point.first; result->Longitude_ = point.second; return result; }
Item* Atom10Parser::ParseItem (const QDomElement& entry, const IDType_t& channelId) const { Item *item = new Item (channelId); item->Title_ = entry.firstChildElement ("title").text (); item->Link_ = GetLink (entry); item->Guid_ = entry.firstChildElement ("id").text (); item->PubDate_ = FromRFC3339 (entry.firstChildElement ("updated").text ()); item->Unread_ = true; item->Categories_ = GetAllCategories (entry); item->Author_ = GetAuthor (entry); item->NumComments_ = GetNumComments (entry); item->CommentsLink_ = GetCommentsRSS (entry); item->CommentsPageLink_ = GetCommentsLink (entry); QDomElement summary = entry.firstChildElement ("content"); if (summary.isNull ()) summary = entry.firstChildElement ("summary"); item->Description_ = ParseEscapeAware (summary); GetDescription (entry, item->Description_); item->Enclosures_ = GetEnclosures (entry, item->ItemID_); item->Enclosures_ += GetEncEnclosures (entry, item->ItemID_); QPair<double, double> point = GetGeoPoint (entry); item->Latitude_ = point.first; item->Longitude_ = point.second; item->MRSSEntries_ = GetMediaRSS (entry, item->ItemID_); return item; }
Item* RSS20Parser::ParseItem (const QDomElement& item, const IDType_t& channelId) const { Item *result = new Item (channelId); result->Title_ = UnescapeHTML (item.firstChildElement ("title").text ()); if (result->Title_.isEmpty ()) result->Title_ = "<>"; result->Link_ = item.firstChildElement ("link").text (); result->Description_ = item.firstChildElement ("description").text (); GetDescription (item, result->Description_); QDomNodeList duration = item.elementsByTagNameNS (ITunes_, "duration"); if (duration.size ()) { if (!result->Description_.isEmpty ()) result->Description_ += "<br /><br />"; result->Description_ += QObject::tr ("Duration: %1") .arg (duration.at (0).toElement ().text ()); } QString pubDateText = item.firstChildElement ("pubDate").text (); if (pubDateText.size ()) { result->PubDate_ = RFC822TimeToQDateTime (pubDateText); if (!result->PubDate_.isValid () || result->PubDate_.isNull ()) result->PubDate_ = QDateTime::currentDateTime (); } result->Guid_ = item.firstChildElement ("guid").text (); if (result->Guid_.isEmpty ()) result->Guid_ = "empty"; result->Categories_ = GetAllCategories (item); result->Unread_ = true; result->Author_ = GetAuthor (item); result->NumComments_ = GetNumComments (item); result->CommentsLink_ = GetCommentsRSS (item); result->CommentsPageLink_ = GetCommentsLink (item); result->Enclosures_ = GetEnclosures (item, result->ItemID_); result->Enclosures_ += GetEncEnclosures (item, result->ItemID_); QPair<double, double> point = GetGeoPoint (item); result->Latitude_ = point.first; result->Longitude_ = point.second; result->MRSSEntries_ = GetMediaRSS (item, result->ItemID_); return result; }
channels_container_t RSS10Parser::Parse (const QDomDocument& doc, const IDType_t& feedId) const { channels_container_t result; QMap<QString, Channel_ptr> item2Channel; QDomElement root = doc.documentElement (); QDomElement channelDescr = root.firstChildElement ("channel"); while (!channelDescr.isNull ()) { Channel_ptr channel (new Channel (feedId)); channel->Title_ = channelDescr.firstChildElement ("title").text ().trimmed (); channel->Link_ = channelDescr.firstChildElement ("link").text (); channel->Description_ = channelDescr.firstChildElement ("description").text (); channel->PixmapURL_ = channelDescr.firstChildElement ("image") .firstChildElement ("url").text (); channel->LastBuild_ = GetDCDateTime (channelDescr); QDomElement itemsRoot = channelDescr.firstChildElement ("items"); QDomNodeList seqs = itemsRoot.elementsByTagNameNS (RDF_, "Seq"); channelDescr = channelDescr.nextSiblingElement ("channel"); if (!seqs.size ()) continue; QDomElement seqElem = seqs.at (0).toElement (); QDomNodeList lis = seqElem.elementsByTagNameNS (RDF_, "li"); for (int i = 0; i < lis.size (); ++i) item2Channel [lis.at (i).toElement ().attribute ("resource")] = channel; result.push_back (channel); } QDomElement itemDescr = root.firstChildElement ("item"); while (!itemDescr.isNull ()) { QString about = itemDescr.attributeNS (RDF_, "about"); if (item2Channel.contains (about)) { Item_ptr item (new Item (item2Channel [about]->ChannelID_)); item->Title_ = itemDescr.firstChildElement ("title").text (); item->Link_ = itemDescr.firstChildElement ("link").text (); item->Description_ = itemDescr.firstChildElement ("description").text (); GetDescription (itemDescr, item->Description_); item->Categories_ = GetAllCategories (itemDescr); item->Author_ = GetAuthor (itemDescr); item->PubDate_ = GetDCDateTime (itemDescr); item->Unread_ = true; item->NumComments_ = GetNumComments (itemDescr); item->CommentsLink_ = GetCommentsRSS (itemDescr); item->CommentsPageLink_ = GetCommentsLink (itemDescr); item->Enclosures_ = GetEncEnclosures (itemDescr, item->ItemID_); QPair<double, double> point = GetGeoPoint (itemDescr); item->Latitude_ = point.first; item->Longitude_ = point.second; if (item->Guid_.isEmpty ()) item->Guid_ = "empty"; item2Channel [about]->Items_.push_back (item); } itemDescr = itemDescr.nextSiblingElement ("item"); } return result; }