1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 07:18:08 +00:00

Perform more RSS parsing in working thread

This commit is contained in:
Vladimir Golovnev (Glassez) 2019-06-02 13:05:50 +03:00
parent 84e683cc99
commit d710bbd9ef
No known key found for this signature in database
GPG Key ID: 52A2C7DEE2DFA6F7
3 changed files with 21 additions and 17 deletions

View File

@ -635,7 +635,7 @@ void Parser::parseRssArticle(QXmlStreamReader &xml)
if (article[Article::KeyTorrentURL].toString().isEmpty())
article[Article::KeyTorrentURL] = altTorrentUrl;
m_result.articles.prepend(article);
addArticle(article);
}
void Parser::parseRSSChannel(QXmlStreamReader &xml)
@ -730,7 +730,7 @@ void Parser::parseAtomArticle(QXmlStreamReader &xml)
}
}
m_result.articles.prepend(article);
addArticle(article);
}
void Parser::parseAtomChannel(QXmlStreamReader &xml)
@ -760,3 +760,20 @@ void Parser::parseAtomChannel(QXmlStreamReader &xml)
}
}
}
void Parser::addArticle(QVariantHash article)
{
QVariant &torrentURL = article[Article::KeyTorrentURL];
if (torrentURL.toString().isEmpty())
torrentURL = article[Article::KeyLink];
// If item does not have an ID, fall back to some other identifier.
QVariant &localId = article[Article::KeyId];
if (localId.toString().isEmpty())
localId = article.value(Article::KeyTorrentURL);
if (localId.toString().isEmpty())
localId = article.value(Article::KeyTitle);
if (!localId.toString().isEmpty())
m_result.articles.prepend(article);
}

View File

@ -65,6 +65,7 @@ namespace RSS
void parseRSSChannel(QXmlStreamReader &xml);
void parseAtomArticle(QXmlStreamReader &xml);
void parseAtomChannel(QXmlStreamReader &xml);
void addArticle(QVariantHash article);
QString m_baseUrl;
ParsingResult m_result;

View File

@ -411,24 +411,10 @@ int Feed::updateArticles(const QList<QVariantHash> &loadedArticles)
QVector<QVariantHash> newArticles;
newArticles.reserve(loadedArticles.size());
for (QVariantHash article : loadedArticles) {
QVariant &torrentURL = article[Article::KeyTorrentURL];
if (torrentURL.toString().isEmpty())
torrentURL = article[Article::KeyLink];
// If item does not have an ID, fall back to some other identifier.
QVariant &localId = article[Article::KeyId];
if (localId.toString().isEmpty())
localId = article.value(Article::KeyTorrentURL);
if (localId.toString().isEmpty())
localId = article.value(Article::KeyTitle);
if (localId.toString().isEmpty())
continue;
// If article has no publication date we use feed update time as a fallback.
// To prevent processing of "out-of-limit" articles we must not assign dates
// that are earlier than the dates of existing articles.
const Article *existingArticle = articleByGUID(localId.toString());
const Article *existingArticle = articleByGUID(article[Article::KeyId].toString());
if (existingArticle) {
dummyPubDate = existingArticle->date().addMSecs(-1);
continue;