From 287e50c228a2ff5b256117380a576083f8c3e241 Mon Sep 17 00:00:00 2001 From: mat <4396128+yawks@users.noreply.github.com> Date: Sun, 13 Dec 2020 17:10:36 +0100 Subject: [PATCH] Handle pictures from rss "enclosures" and "media:content" tags for Entry --- .../main/java/net/frju/flym/data/entities/Entry.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/java/net/frju/flym/data/entities/Entry.kt b/app/src/main/java/net/frju/flym/data/entities/Entry.kt index 30384c0a4..b73e26d4b 100644 --- a/app/src/main/java/net/frju/flym/data/entities/Entry.kt +++ b/app/src/main/java/net/frju/flym/data/entities/Entry.kt @@ -76,7 +76,19 @@ fun SyndEntry.toDbFormat(context: Context, feed: Feed): Entry { } item.description = contents.getOrNull(0)?.value ?: description?.value item.link = link + + enclosures?.forEach { if (it.type.contains("image")) { item.imageLink = it.url } } + if (item.imageLink == null) { + foreignMarkup?.forEach { + if (it.namespace?.prefix == "media" && it.name == "content") { + it.attributes.forEach { mc -> + if (mc.name == "url") item.imageLink = mc.value + } + } + } + } //TODO item.imageLink = null + item.author = author val date = publishedDate ?: updatedDate