mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 00:06:16 -07:00
RSS: parse lastBuildDate tag and abort parsing if the feed has not changed since last time.
Optimization to address issue #34.
This commit is contained in:
parent
c50c9239ea
commit
a26723a57a
3 changed files with 26 additions and 0 deletions
|
@ -221,6 +221,13 @@ void RssParser::parseRssFile(const QString& feedUrl, const QString& filePath)
|
|||
m_mutex.unlock();
|
||||
}
|
||||
|
||||
void RssParser::clearFeedData(const QString &feedUrl)
|
||||
{
|
||||
m_mutex.lock();
|
||||
m_lastBuildDates.remove(feedUrl);
|
||||
m_mutex.unlock();
|
||||
}
|
||||
|
||||
void RssParser::run()
|
||||
{
|
||||
while (m_running) {
|
||||
|
@ -300,6 +307,17 @@ void RssParser::parseRSSChannel(QXmlStreamReader& xml, const QString& feedUrl)
|
|||
QString title = xml.readElementText();
|
||||
emit feedTitle(feedUrl, title);
|
||||
}
|
||||
else if (xml.name() == "lastBuildDate") {
|
||||
QString lastBuildDate = xml.readElementText();
|
||||
if (!lastBuildDate.isEmpty()) {
|
||||
QMutexLocker locker(&m_mutex);
|
||||
if (m_lastBuildDates.value(feedUrl, "") == lastBuildDate) {
|
||||
qDebug() << "The RSS feed has not changed since last time, aborting parsing.";
|
||||
return;
|
||||
}
|
||||
m_lastBuildDates[feedUrl] = lastBuildDate;
|
||||
}
|
||||
}
|
||||
else if (xml.name() == "item") {
|
||||
parseRssArticle(xml, feedUrl);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue