Skip to content

Commit

Permalink
Show updated podcast covers
Browse files Browse the repository at this point in the history
  • Loading branch information
soygabimoreno committed Jan 4, 2024
1 parent dc164fe commit 874af7f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ private fun Article.getEpisodeUrl(): String {
}

private fun Article.getEpisodeCoverUrl(): String {
val episodeNumber = getEpisodeNumber()
if (episodeNumber == INVALID_EPISODE_NUMBER) return ""
return "$GABI_MORENO_WEB_BASE_URL/$PODCAST_COVER_PREFIX${getEpisodeNumber()}$PODCAST_COVER_SUFFIX"
return if (itunesArticleData?.image != null) {
this.itunesArticleData?.image!!
} else {
""
}
}

private fun Article.getEpisodeNumber(): String {
Expand Down Expand Up @@ -114,10 +116,6 @@ private const val HOURS_MINUTES_SECONDS_PATTERN = "HH:mm:ss"
private const val ONE_MINUTE_IN_SECONDS = 60
private const val ONE_HOUR_IN_SECONDS = 60 * ONE_MINUTE_IN_SECONDS

@VisibleForTesting
internal const val PODCAST_COVER_PREFIX =
"images/podcast-los-androides/cover-podcast-los-androides-"

@VisibleForTesting
internal const val PODCAST_COVER_SUFFIX = ".png"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package soy.gabimoreno.data.remote.mapper

import com.prof.rssparser.*
import com.prof.rssparser.Article
import com.prof.rssparser.Channel
import com.prof.rssparser.Image
import com.prof.rssparser.ItunesArticleData
import com.prof.rssparser.ItunesChannelData
import com.prof.rssparser.ItunesOwner
import org.amshove.kluent.shouldBe
import org.amshove.kluent.shouldBeEqualTo
import org.junit.Test
import soy.gabimoreno.domain.model.GABI_MORENO_WEB_BASE_URL
import java.util.*
import java.util.Date

class PodcastMapperKtTest {

Expand Down Expand Up @@ -130,8 +135,7 @@ private const val EPISODE_ID = "guid"
private const val EPISODE_NUMBER = "1234"
private const val EPISODE_URL = "$GABI_MORENO_WEB_BASE_URL/$EPISODE_NUMBER"
private const val EPISODE_AUDIO_URL = "audio"
private const val EPISODE_IMAGE_URL =
"$GABI_MORENO_WEB_BASE_URL/$PODCAST_COVER_PREFIX$EPISODE_NUMBER$PODCAST_COVER_SUFFIX"
private const val EPISODE_IMAGE_URL = "episodeImageUrl"
private const val EPISODE_TITLE = "$EPISODE_NUMBER. Title"
private const val EPISODE_AUDIO_LENGTH_IN_SECONDS = 896
private const val EPISODE_AUDIO_LENGTH_IN_TIME_FORMATTED = "01:51:15"
Expand Down
13 changes: 7 additions & 6 deletions gabimoreno/src/test/java/soy/gabimoreno/fake/FakeChannel.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package soy.gabimoreno.fake

import com.prof.rssparser.*
import com.prof.rssparser.Article
import com.prof.rssparser.Channel
import com.prof.rssparser.Image
import com.prof.rssparser.ItunesArticleData
import com.prof.rssparser.ItunesChannelData
import com.prof.rssparser.ItunesOwner
import soy.gabimoreno.data.remote.mapper.ANCHOR_MESSAGE
import soy.gabimoreno.data.remote.mapper.IVOOX_URL
import soy.gabimoreno.data.remote.mapper.PODCAST_COVER_PREFIX
import soy.gabimoreno.data.remote.mapper.PODCAST_COVER_SUFFIX
import soy.gabimoreno.domain.model.GABI_MORENO_WEB_BASE_URL

fun buildChannel(url: String): Channel {
return Channel(
Expand Down Expand Up @@ -83,8 +85,7 @@ private fun buildItunesArticleData(duration: String?) = ItunesArticleData(
private const val EPISODE_ID = "guid"
private const val EPISODE_NUMBER = "1234"
private const val EPISODE_AUDIO_URL = "audio"
private const val EPISODE_IMAGE_URL =
"$GABI_MORENO_WEB_BASE_URL/$PODCAST_COVER_PREFIX$EPISODE_NUMBER$PODCAST_COVER_SUFFIX"
private const val EPISODE_IMAGE_URL = "episodeImageUrl"
private const val EPISODE_TITLE = "$EPISODE_NUMBER. Title"
private const val EPISODE_AUDIO_LENGTH_IN_SECONDS = 896
private const val EPISODE_AUDIO_LENGTH_IN_TIME_FORMATTED = "01:51:15"
Expand Down

0 comments on commit 874af7f

Please sign in to comment.