mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-27 08:19:30 +08:00
[RSS] Handle magnet links as torrents instead of news URLs. Closes #3560
This commit is contained in:
parent
51e0e485f4
commit
c3592304b6
@ -259,8 +259,13 @@ void RssParser::parseRssArticle(QXmlStreamReader& xml, const QString& feedUrl)
|
|||||||
if (xml.attributes().value("type") == "application/x-bittorrent")
|
if (xml.attributes().value("type") == "application/x-bittorrent")
|
||||||
article["torrent_url"] = xml.attributes().value("url").toString();
|
article["torrent_url"] = xml.attributes().value("url").toString();
|
||||||
}
|
}
|
||||||
else if (xml.name() == "link")
|
else if (xml.name() == "link") {
|
||||||
article["news_link"] = xml.readElementText();
|
QString link = xml.readElementText().trimmed();
|
||||||
|
if (link.startsWith("magnet:", Qt::CaseInsensitive))
|
||||||
|
article["torrent_url"] = link; // magnet link instead of a news URL
|
||||||
|
else
|
||||||
|
article["news_link"] = link;
|
||||||
|
}
|
||||||
else if (xml.name() == "description")
|
else if (xml.name() == "description")
|
||||||
article["description"] = xml.readElementText();
|
article["description"] = xml.readElementText();
|
||||||
else if (xml.name() == "pubDate")
|
else if (xml.name() == "pubDate")
|
||||||
@ -341,17 +346,18 @@ void RssParser::parseAtomArticle(QXmlStreamReader& xml, const QString& feedUrl,
|
|||||||
article["title"] = doc.toPlainText();
|
article["title"] = doc.toPlainText();
|
||||||
}
|
}
|
||||||
else if (xml.name() == "link") {
|
else if (xml.name() == "link") {
|
||||||
QString theLink = ( xml.attributes().isEmpty() ?
|
QString link = ( xml.attributes().isEmpty() ?
|
||||||
xml.readElementText() :
|
xml.readElementText().trimmed() :
|
||||||
xml.attributes().value("href").toString() );
|
xml.attributes().value("href").toString() );
|
||||||
|
|
||||||
// Atom feeds can have relative links, work around this and
|
if (link.startsWith("magnet:", Qt::CaseInsensitive))
|
||||||
// take the stress of figuring article full URI from UI
|
article["torrent_url"] = link; // magnet link instead of a news URL
|
||||||
|
else
|
||||||
|
// Atom feeds can have relative links, work around this and
|
||||||
|
// take the stress of figuring article full URI from UI
|
||||||
|
// Assemble full URI
|
||||||
|
article["news_link"] = ( baseUrl.isEmpty() ? link : baseUrl + link );
|
||||||
|
|
||||||
// Assemble full URI
|
|
||||||
article["news_link"] = ( baseUrl.isEmpty() ?
|
|
||||||
theLink :
|
|
||||||
baseUrl + theLink );
|
|
||||||
}
|
}
|
||||||
else if (xml.name() == "summary" || xml.name() == "content"){
|
else if (xml.name() == "summary" || xml.name() == "content"){
|
||||||
if(double_content) { // Duplicate content -> ignore
|
if(double_content) { // Duplicate content -> ignore
|
||||||
|
Loading…
Reference in New Issue
Block a user