mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 09:55:55 +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;
|
QDateTime date;
|
||||||
QString author;
|
QString author;
|
||||||
|
|
||||||
Q_ASSERT(xml.isStartElement() && xml.name() == "item");
|
while(!xml.atEnd()) {
|
||||||
|
xml.readNext();
|
||||||
|
|
||||||
while (xml.readNextStartElement()) {
|
if(xml.isEndElement() && xml.name() == "item")
|
||||||
if (xml.name() == "title")
|
break;
|
||||||
title = xml.readElementText();
|
|
||||||
else if (xml.name() == "enclosure") {
|
if (xml.isStartElement()) {
|
||||||
if (xml.attributes().value("type") == "application/x-bittorrent")
|
if (xml.name() == "title")
|
||||||
torrentUrl = xml.attributes().value("url").toString();
|
title = xml.readElementText();
|
||||||
}
|
else if (xml.name() == "enclosure") {
|
||||||
else if (xml.name() == "link")
|
if (xml.attributes().value("type") == "application/x-bittorrent")
|
||||||
link = xml.readElementText();
|
torrentUrl = xml.attributes().value("url").toString();
|
||||||
else if (xml.name() == "description")
|
}
|
||||||
description = xml.readElementText();
|
else if (xml.name() == "link")
|
||||||
else if (xml.name() == "pubDate")
|
link = xml.readElementText();
|
||||||
date = RssArticle::parseDate(xml.readElementText());
|
else if (xml.name() == "description")
|
||||||
else if (xml.name() == "author")
|
description = xml.readElementText();
|
||||||
author = xml.readElementText();
|
else if (xml.name() == "pubDate")
|
||||||
else if (xml.name() == "guid")
|
date = RssArticle::parseDate(xml.readElementText());
|
||||||
guid = xml.readElementText();
|
else if (xml.name() == "author")
|
||||||
else {
|
author = xml.readElementText();
|
||||||
qDebug() << "Skipping item tag: " << xml.name();
|
else if (xml.name() == "guid")
|
||||||
xml.skipCurrentElement();
|
guid = xml.readElementText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,31 +214,32 @@ void RssFeed::parseRSSChannel(QXmlStreamReader& xml)
|
|||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
Q_ASSERT(xml.isStartElement() && xml.name() == "channel");
|
Q_ASSERT(xml.isStartElement() && xml.name() == "channel");
|
||||||
|
|
||||||
while (xml.readNextStartElement()) {
|
while(!xml.atEnd()) {
|
||||||
if (xml.name() == "title") {
|
xml.readNext();
|
||||||
m_title = xml.readElementText();
|
|
||||||
if (m_alias == url())
|
if (xml.isStartElement()) {
|
||||||
rename(m_title);
|
if (xml.name() == "title") {
|
||||||
}
|
m_title = xml.readElementText();
|
||||||
else if (xml.name() == "image") {
|
if (m_alias == url())
|
||||||
QString icon_path = xml.attributes().value("url").toString();
|
rename(m_title);
|
||||||
if (!icon_path.isEmpty()) {
|
|
||||||
m_iconUrl = icon_path;
|
|
||||||
m_manager->rssDownloader()->downloadUrl(m_iconUrl);
|
|
||||||
}
|
}
|
||||||
}
|
else if (xml.name() == "image") {
|
||||||
else if (xml.name() == "item") {
|
QString icon_path = xml.attributes().value("url").toString();
|
||||||
RssArticlePtr article = xmlToRssArticle(this, xml);
|
if (!icon_path.isEmpty()) {
|
||||||
qDebug() << "Found RSS Item, valid: " << (article ? "True" : "False");
|
m_iconUrl = icon_path;
|
||||||
if (article) {
|
m_manager->rssDownloader()->downloadUrl(m_iconUrl);
|
||||||
QString guid = article->guid();
|
}
|
||||||
if (m_articles.contains(guid) && m_articles[guid]->isRead())
|
}
|
||||||
article->markAsRead();
|
else if (xml.name() == "item") {
|
||||||
m_articles[guid] = article;
|
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