Mangadex fixes
This commit is contained in:
@@ -2,6 +2,10 @@ package exh.md.utils
|
||||
|
||||
import exh.md.dto.ListCallDto
|
||||
import exh.util.under
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import kotlinx.serialization.json.contentOrNull
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
|
||||
suspend fun <T> mdListCall(request: suspend (offset: Int) -> ListCallDto<T>): List<T> {
|
||||
val results = mutableListOf<T>()
|
||||
@@ -15,3 +19,9 @@ suspend fun <T> mdListCall(request: suspend (offset: Int) -> ListCallDto<T>): Li
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
fun JsonElement.asMdMap(): Map<String, String> {
|
||||
return runCatching {
|
||||
jsonObject.map { it.key to it.value.jsonPrimitive.contentOrNull.orEmpty() }.toMap()
|
||||
}.getOrElse { emptyMap() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user