|
|
@@ -7,6 +7,7 @@ import io.ktor.client.call.*
|
|
|
import io.ktor.client.plugins.contentnegotiation.*
|
|
|
import io.ktor.client.request.*
|
|
|
import io.ktor.serialization.kotlinx.json.*
|
|
|
+import kotlinx.datetime.LocalDate
|
|
|
import kotlinx.serialization.json.Json
|
|
|
|
|
|
private const val baseImageUrl = "https://apod.nasa.gov/"
|
|
|
@@ -20,11 +21,11 @@ class ThumbnailApi {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- suspend fun getThumbnails(): List<Thumbnail> =
|
|
|
- httpClient.get("https://sirekanian.com/apod/json/2022-10-01.json")
|
|
|
+ suspend fun getThumbnails(date: LocalDate): List<Thumbnail> =
|
|
|
+ httpClient.get("https://sirekanian.com/apod/json/$date.json")
|
|
|
.body<List<NasaMedia>>()
|
|
|
.filter { it.media_type == "image" && it.url.startsWith(baseImageUrl) }
|
|
|
- .map { Thumbnail(baseThumbnailUrl + it.url.removePrefix(baseImageUrl)) }
|
|
|
+ .map { Thumbnail(baseThumbnailUrl + it.url.removePrefix(baseImageUrl), date) }
|
|
|
.reversed()
|
|
|
|
|
|
}
|