mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
Fix RSS parsing
This commit is contained in:
parent
c40801ce99
commit
12280c6a0f
@ -221,28 +221,29 @@ RssArticlePtr xmlToRssArticle(RssFeed* parent, QXmlStreamReader& xml)
|
||||
QDateTime date;
|
||||
QString author;
|
||||
|
||||
Q_ASSERT(xml.isStartElement() && xml.name() == "item");
|
||||
while(!xml.atEnd()) {
|
||||
xml.readNext();
|
||||
|
||||
while (xml.readNextStartElement()) {
|
||||
if (xml.name() == "title")
|
||||
title = xml.readElementText();
|
||||
else if (xml.name() == "enclosure") {
|
||||
if (xml.attributes().value("type") == "application/x-bittorrent")
|
||||
torrentUrl = xml.attributes().value("url").toString();
|
||||
}
|
||||
else if (xml.name() == "link")
|
||||
link = xml.readElementText();
|
||||
else if (xml.name() == "description")
|
||||
description = xml.readElementText();
|
||||
else if (xml.name() == "pubDate")
|
||||
date = RssArticle::parseDate(xml.readElementText());
|
||||
else if (xml.name() == "author")
|
||||
author = xml.readElementText();
|
||||
else if (xml.name() == "guid")
|
||||
guid = xml.readElementText();
|
||||
else {
|
||||
qDebug() << "Skipping item tag: " << xml.name();
|
||||
xml.skipCurrentElement();
|
||||
if(xml.isEndElement() && xml.name() == "item")
|
||||
break;
|
||||
|
||||
if (xml.isStartElement()) {
|
||||
if (xml.name() == "title")
|
||||
title = xml.readElementText();
|
||||
else if (xml.name() == "enclosure") {
|
||||
if (xml.attributes().value("type") == "application/x-bittorrent")
|
||||
torrentUrl = xml.attributes().value("url").toString();
|
||||
}
|
||||
else if (xml.name() == "link")
|
||||
link = xml.readElementText();
|
||||
else if (xml.name() == "description")
|
||||
description = xml.readElementText();
|
||||
else if (xml.name() == "pubDate")
|
||||
date = RssArticle::parseDate(xml.readElementText());
|
||||
else if (xml.name() == "author")
|
||||
author = xml.readElementText();
|
||||
else if (xml.name() == "guid")
|
||||
guid = xml.readElementText();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,31 +214,32 @@ void RssFeed::parseRSSChannel(QXmlStreamReader& xml)
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
Q_ASSERT(xml.isStartElement() && xml.name() == "channel");
|
||||
|
||||
while (xml.readNextStartElement()) {
|
||||
if (xml.name() == "title") {
|
||||
m_title = xml.readElementText();
|
||||
if (m_alias == url())
|
||||
rename(m_title);
|
||||
}
|
||||
else if (xml.name() == "image") {
|
||||
QString icon_path = xml.attributes().value("url").toString();
|
||||
if (!icon_path.isEmpty()) {
|
||||
m_iconUrl = icon_path;
|
||||
m_manager->rssDownloader()->downloadUrl(m_iconUrl);
|
||||
while(!xml.atEnd()) {
|
||||
xml.readNext();
|
||||
|
||||
if (xml.isStartElement()) {
|
||||
if (xml.name() == "title") {
|
||||
m_title = xml.readElementText();
|
||||
if (m_alias == url())
|
||||
rename(m_title);
|
||||
}
|
||||
}
|
||||
else if (xml.name() == "item") {
|
||||
RssArticlePtr article = xmlToRssArticle(this, xml);
|
||||
qDebug() << "Found RSS Item, valid: " << (article ? "True" : "False");
|
||||
if (article) {
|
||||
QString guid = article->guid();
|
||||
if (m_articles.contains(guid) && m_articles[guid]->isRead())
|
||||
article->markAsRead();
|
||||
m_articles[guid] = article;
|
||||
else if (xml.name() == "image") {
|
||||
QString icon_path = xml.attributes().value("url").toString();
|
||||
if (!icon_path.isEmpty()) {
|
||||
m_iconUrl = icon_path;
|
||||
m_manager->rssDownloader()->downloadUrl(m_iconUrl);
|
||||
}
|
||||
}
|
||||
else if (xml.name() == "item") {
|
||||
RssArticlePtr article = xmlToRssArticle(this, xml);
|
||||
qDebug() << "Found RSS Item, valid: " << (article ? "True" : "False");
|
||||
if (article) {
|
||||
QString guid = article->guid();
|
||||
if (m_articles.contains(guid) && m_articles[guid]->isRead())
|
||||
article->markAsRead();
|
||||
m_articles[guid] = article;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Skipping RSS tag: " << xml.name();
|
||||
xml.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user