From 0b33c62a108f3789e679ee357284f4ea206320a5 Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Fri, 30 Jul 2021 14:20:51 +0200 Subject: [PATCH] Select first enclosure if entry has multiple enclosure entries Kasts can currently only handle one enclosure per entry. In case an entry/item has multiple enclosures, it's probably safe to assume that the first one is the one that's preferred by the author. CCBUG: 440389 --- src/fetcher.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/fetcher.cpp b/src/fetcher.cpp index 1c83925d..7ee0e7e0 100644 --- a/src/fetcher.cpp +++ b/src/fetcher.cpp @@ -303,8 +303,11 @@ bool Fetcher::processEntry(Syndication::ItemPtr entry, const QString &url, bool processAuthor(url, entry->id(), authorName, QLatin1String(""), QLatin1String("")); } - for (const auto &enclosure : entry->enclosures()) { - processEnclosure(enclosure, entry, url); + // only process first enclosure if there are multiple (e.g. mp3 and ogg); + // the first one is probably the podcast author's preferred version + // TODO: handle more than one enclosure? + if (entry->enclosures().count() > 0) { + processEnclosure(entry->enclosures()[0], entry, url); } Q_EMIT entryAdded(url, entry->id());