From 8f29b70c1e080b9fed8415cd1d59a30745851d4c Mon Sep 17 00:00:00 2001 From: Matan Bareket Date: Wed, 8 May 2019 06:36:10 -0400 Subject: [PATCH] Download RSS enclosure element if no proper MIME type is found In the case where an RSS feed doesn't have the "enclosure" element with type "application/x-bittorrent", fallback to the last enclosure element which has no "type" attribute. --- src/base/rss/private/rss_parser.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/base/rss/private/rss_parser.cpp b/src/base/rss/private/rss_parser.cpp index 1d445f1c7..e9d6c0efa 100644 --- a/src/base/rss/private/rss_parser.cpp +++ b/src/base/rss/private/rss_parser.cpp @@ -590,6 +590,7 @@ void Parser::parse_impl(const QByteArray &feedData) void Parser::parseRssArticle(QXmlStreamReader &xml) { QVariantHash article; + QString altTorrentUrl; while (!xml.atEnd()) { xml.readNext(); @@ -605,6 +606,8 @@ void Parser::parseRssArticle(QXmlStreamReader &xml) else if (name == QLatin1String("enclosure")) { if (xml.attributes().value("type") == QLatin1String("application/x-bittorrent")) article[Article::KeyTorrentURL] = xml.attributes().value(QLatin1String("url")).toString(); + else if (xml.attributes().value("type").isEmpty()) + altTorrentUrl = xml.attributes().value(QLatin1String("url")).toString(); } else if (name == QLatin1String("link")) { const QString text {xml.readElementText().trimmed()}; @@ -631,6 +634,9 @@ void Parser::parseRssArticle(QXmlStreamReader &xml) } } + if (article[Article::KeyTorrentURL].toString().isEmpty()) + article[Article::KeyTorrentURL] = altTorrentUrl; + m_result.articles.prepend(article); }