From 1643ca33a8aea29988bdd857df13a0331a8cdd2e Mon Sep 17 00:00:00 2001 From: Yang Date: Mon, 25 Dec 2023 04:04:59 +1100 Subject: [PATCH] Add `audioUrl` to `TalkingKotlin`. --- .../kstreamlined/backend/client/dto/TalkingKotlinDTOs.kt | 8 ++++++++ .../datafetcher/mapper/TalkingKotlinEntryMapper.kt | 1 + src/main/resources/schema/kstreamlined.graphqls | 2 ++ .../kstreamlined/backend/client/FakeFeedClient.kt | 1 + .../kstreamlined/backend/client/RealFeedClientTest.kt | 2 ++ .../backend/datafetcher/FeedEntryDataFetcherTest.kt | 1 + .../datafetcher/mapper/TalkingKotlinEntryMapperTest.kt | 2 ++ 7 files changed, 17 insertions(+) diff --git a/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/client/dto/TalkingKotlinDTOs.kt b/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/client/dto/TalkingKotlinDTOs.kt index 77a48f8..dd5f160 100644 --- a/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/client/dto/TalkingKotlinDTOs.kt +++ b/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/client/dto/TalkingKotlinDTOs.kt @@ -33,8 +33,16 @@ data class TalkingKotlinItem( @XmlElement(true) @XmlSerialName(value = "summary", namespace = Namespace.itunes, prefix = "") val summary: String, + val enclosure: Enclosure, val image: Image, ) { + @XmlSerialName("enclosure", "", "") + @Serializable + data class Enclosure( + @XmlElement(false) + val url: String, + ) + @XmlSerialName("image", Namespace.itunes, "") @Serializable data class Image( diff --git a/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/TalkingKotlinEntryMapper.kt b/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/TalkingKotlinEntryMapper.kt index 419bbb3..8d75e15 100644 --- a/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/TalkingKotlinEntryMapper.kt +++ b/src/main/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/TalkingKotlinEntryMapper.kt @@ -15,6 +15,7 @@ fun TalkingKotlinItem.toTalkingKotlinEntry(): TalkingKotlin { .toInstant(), contentUrl = link, thumbnailUrl = image.href, + audioUrl = enclosure.url, summary = summary, duration = duration.toFormattedDuration(), ) diff --git a/src/main/resources/schema/kstreamlined.graphqls b/src/main/resources/schema/kstreamlined.graphqls index 915dbfc..425bb5d 100644 --- a/src/main/resources/schema/kstreamlined.graphqls +++ b/src/main/resources/schema/kstreamlined.graphqls @@ -75,6 +75,8 @@ type TalkingKotlin implements FeedEntry { publishTime: Instant! "Url of the content." contentUrl: String! + "Url of the podcast audio file." + audioUrl: String! "Url of the podcast thumbnail." thumbnailUrl: String! "Summary of the podcast." diff --git a/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/client/FakeFeedClient.kt b/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/client/FakeFeedClient.kt index 3fd5ecc..b422890 100644 --- a/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/client/FakeFeedClient.kt +++ b/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/client/FakeFeedClient.kt @@ -123,6 +123,7 @@ val DummyTalkingKotlinItem = TalkingKotlinItem( pubDate = "Tue, 28 Jun 2022 16:00:27 +0000", summary = "We chat with Raul, Simon, and Alejandro to learn how Arrow adds functional paradigms and safety to Kotlin, and how it aims to influence the future of the language.", duration = "00:57:44", + enclosure = TalkingKotlinItem.Enclosure(url = "https://feeds.soundcloud.com/stream/1295949565-user-38099918-arrow-analysis.mp3"), image = TalkingKotlinItem.Image(href = "https://i1.sndcdn.com/artworks-yEP8SdbEZOJcmVay-AWlLHQ-t3000x3000.jpg"), ) diff --git a/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/client/RealFeedClientTest.kt b/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/client/RealFeedClientTest.kt index cab4f1a..ceeefe6 100644 --- a/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/client/RealFeedClientTest.kt +++ b/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/client/RealFeedClientTest.kt @@ -213,6 +213,7 @@ class RealFeedClientTest { pubDate = "Tue, 28 Jun 2022 16:00:27 +0000", summary = "We chat with Raul, Simon, and Alejandro to learn how Arrow adds functional paradigms and safety to Kotlin, and how it aims to influence the future of the language.", duration = "00:57:44", + enclosure = TalkingKotlinItem.Enclosure(url = "https://feeds.soundcloud.com/stream/1295949565-user-38099918-arrow-analysis.mp3"), image = TalkingKotlinItem.Image(href = "https://i1.sndcdn.com/artworks-yEP8SdbEZOJcmVay-AWlLHQ-t3000x3000.jpg"), ), TalkingKotlinItem( @@ -222,6 +223,7 @@ class RealFeedClientTest { pubDate = "Tue, 19 Apr 2022 16:00:24 +0000", summary = "We talked to Rares Vlasceanu and Catalin Costache from Adobe about how they handle 70 000 000 000 events per day with the help of Kotlin and Ktor.", duration = "00:51:09", + enclosure = TalkingKotlinItem.Enclosure(url = "https://feeds.soundcloud.com/stream/1253069788-user-38099918-70-billion-events-per-day-adobe-kotlin.mp3"), image = TalkingKotlinItem.Image(href = "https://i1.sndcdn.com/artworks-ANd7JtyjHYkhAUsQ-XU8I0Q-t3000x3000.jpg"), ), ) diff --git a/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/FeedEntryDataFetcherTest.kt b/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/FeedEntryDataFetcherTest.kt index 1af9e7f..3da4322 100644 --- a/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/FeedEntryDataFetcherTest.kt +++ b/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/FeedEntryDataFetcherTest.kt @@ -49,6 +49,7 @@ class FeedEntryDataFetcherTest { description } ... on TalkingKotlin { + audioUrl thumbnailUrl summary duration diff --git a/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/TalkingKotlinEntryMapperTest.kt b/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/TalkingKotlinEntryMapperTest.kt index 0919322..47fe3ac 100644 --- a/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/TalkingKotlinEntryMapperTest.kt +++ b/src/test/kotlin/io/github/reactivecircus/kstreamlined/backend/datafetcher/mapper/TalkingKotlinEntryMapperTest.kt @@ -15,6 +15,7 @@ class TalkingKotlinEntryMapperTest { title = "Podcast title", publishTime = Instant.parse("2022-11-22T16:30:09Z"), contentUrl = "url", + audioUrl = "audio-url", thumbnailUrl = "image-url", summary = "summary", duration = "43min.", @@ -26,6 +27,7 @@ class TalkingKotlinEntryMapperTest { link = "url", duration = "00:43:14", summary = "summary", + enclosure = TalkingKotlinItem.Enclosure(url = "audio-url"), image = TalkingKotlinItem.Image(href = "image-url"), ).toTalkingKotlinEntry()