From 80739ccaa0cd732d0dbf0b71d04a816a7308f5bc Mon Sep 17 00:00:00 2001 From: "craig.p.drummond" Date: Sun, 7 Dec 2014 14:47:30 +0000 Subject: [PATCH] If 'url' entry is empty in 'enclusure' section of podcast RSS file, then use 'guid' text as url - if possible. BUG: 602 --- ChangeLog | 2 ++ online/rssparser.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index 35bb4a6a3..d02415fa2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -38,6 +38,8 @@ race conditions. 16. If fading volume on stop, then reset volume just before stopping. Some outputs (e.g. pulse audio) only allow setting a volume whilst playing. +17. If 'url' entry is empty in 'enclusure' section of podcast RSS file, then + use 'guid' text as url - if possible. 1.5.1 ----- diff --git a/online/rssparser.cpp b/online/rssparser.cpp index e6073ea07..6715ad251 100644 --- a/online/rssparser.cpp +++ b/online/rssparser.cpp @@ -89,6 +89,8 @@ static QUrl parseImage(QXmlStreamReader &reader) static Episode parseEpisode(QXmlStreamReader &reader) { Episode ep; + bool isAudio=false; + QUrl guidUrl; while (!reader.atEnd()) { reader.readNext(); @@ -115,6 +117,7 @@ static Episode parseEpisode(QXmlStreamReader &reader) } QString type=reader.attributes().value(QLatin1String("type")).toString(); if (type.startsWith(QLatin1String("audio/")) || audioFormats.contains(type)) { + isAudio=true; ep.url=QUrl::fromEncoded(reader.attributes().value(QLatin1String("url")).toString().toLatin1()); } else if (type.startsWith(QLatin1String("video/")) ) { // At least one broken feed (BUG: 588) has the audio podcast listed as video/mp4, @@ -130,6 +133,8 @@ static Episode parseEpisode(QXmlStreamReader &reader) } } consumeCurrentElement(reader); + } else if (QLatin1String("guid")==name) { + guidUrl=QUrl(reader.readElementText()); } else if (QLatin1String("pubDate")==name) { ep.publicationDate=parseRfc822DateTime(reader.readElementText()); } else { @@ -139,6 +144,12 @@ static Episode parseEpisode(QXmlStreamReader &reader) break; } } + + // Sometimes the url entry in 'enclusure' is empty, but there is a url in 'guid' - so use + // that if present (BUG: 602) + if (isAudio && ep.url.isEmpty() && !guidUrl.isEmpty()) { + ep.url=guidUrl; + } return ep; }