diff --git a/app/src/main/java/exh/md/handlers/ApiMangaParser.kt b/app/src/main/java/exh/md/handlers/ApiMangaParser.kt index 191ebcd0a..0146fb94c 100644 --- a/app/src/main/java/exh/md/handlers/ApiMangaParser.kt +++ b/app/src/main/java/exh/md/handlers/ApiMangaParser.kt @@ -71,7 +71,7 @@ class ApiMangaParser(private val langs: List) { fun parseIntoMetadata(metadata: MangaDexSearchMetadata, input: Response, forceLatestCover: Boolean) { with(metadata) { try { - val networkApiManga = MdUtil.jsonParser.decodeFromString(ApiMangaSerializer.serializer(), input.body!!.string()) + val networkApiManga = MdUtil.jsonParser.decodeFromString(input.body!!.string()) val networkManga = networkApiManga.manga mdId = MdUtil.getMangaId(input.request.url.toString()) mdUrl = input.request.url.toString() @@ -207,7 +207,7 @@ class ApiMangaParser(private val langs: List) { fun chapterListParse(jsonData: String): List { val now = System.currentTimeMillis() - val networkApiManga = MdUtil.jsonParser.decodeFromString(ApiMangaSerializer.serializer(), jsonData) + val networkApiManga = MdUtil.jsonParser.decodeFromString(jsonData) val networkManga = networkApiManga.manga val networkChapters = networkApiManga.chapter if (networkChapters.isNullOrEmpty()) { diff --git a/app/src/main/java/exh/md/handlers/FollowsHandler.kt b/app/src/main/java/exh/md/handlers/FollowsHandler.kt index bdd5d4df1..662fc4d5c 100644 --- a/app/src/main/java/exh/md/handlers/FollowsHandler.kt +++ b/app/src/main/java/exh/md/handlers/FollowsHandler.kt @@ -19,6 +19,7 @@ import exh.metadata.metadata.MangaDexSearchMetadata import exh.util.floor import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext +import kotlinx.serialization.decodeFromString import okhttp3.CacheControl import okhttp3.FormBody import okhttp3.Headers @@ -47,12 +48,11 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere private fun followsParseMangaPage(response: Response, forceHd: Boolean = false): MetadataMangasPage { val followsPageResult = try { MdUtil.jsonParser.decodeFromString( - FollowsPageResult.serializer(), response.body?.string().orEmpty() ) } catch (e: Exception) { XLog.e("error parsing follows", e) - FollowsPageResult(emptyList()) + FollowsPageResult() } if (followsPageResult.result.isEmpty()) { @@ -78,12 +78,11 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere private fun followStatusParse(response: Response): Track { val followsPageResult = try { MdUtil.jsonParser.decodeFromString( - FollowsPageResult.serializer(), response.body?.string().orEmpty() ) } catch (e: Exception) { XLog.e("error parsing follows", e) - FollowsPageResult(emptyList()) + FollowsPageResult() } val track = Track.create(TrackManager.MDLIST) if (followsPageResult.result.isEmpty()) { @@ -173,8 +172,7 @@ class FollowsHandler(val client: OkHttpClient, val headers: Headers, val prefere "${MdUtil.baseUrl}/ajax/actions.ajax.php?function=manga_rating&id=$mangaID&rating=${track.score.toInt()}", headers ) - ) - .await() + ).await() withContext(Dispatchers.IO) { response.body?.string().isNullOrEmpty() } } diff --git a/app/src/main/java/exh/md/handlers/serializers/ApiMangaSerializer.kt b/app/src/main/java/exh/md/handlers/serializers/ApiMangaSerializer.kt index 7484f62a8..ac2e27a44 100644 --- a/app/src/main/java/exh/md/handlers/serializers/ApiMangaSerializer.kt +++ b/app/src/main/java/exh/md/handlers/serializers/ApiMangaSerializer.kt @@ -28,6 +28,31 @@ data class MangaSerializer( val title: String ) +@Serializable +data class MangaSerializerTwo( + val artist: List, + val author: List, + val mainCover: String, + val description: String, + val publication: Publication, + val tags: List, + // val covers: List, + val isHentai: Boolean, + // val lang_flag: String, + // val lang_name: String, + val lastChapter: String? = null, + val links: LinksSerializer? = null, + val rating: RatingSerializerTwo? = null, + val title: String +) + +@Serializable +data class Publication( + val language: String, + val status: Int, + val demographic: Int +) + @Serializable data class LinksSerializer( val al: String? = null, @@ -47,6 +72,13 @@ data class RatingSerializer( val users: String? = null ) +@Serializable +data class RatingSerializerTwo( + val bayesian: Float? = null, + val mean: Float? = null, + val users: Int? = null +) + @Serializable data class ChapterSerializer( val volume: String? = null, @@ -62,6 +94,22 @@ data class ChapterSerializer( val timestamp: Long ) +@Serializable +data class ChapterSerializerTwo( + val volume: String? = null, + val chapter: String? = null, + val title: String? = null, + val language: String, + val groups: List = emptyList(), + val timestamp: Long +) + +@Serializable +data class GroupSerializer( + val id: Int, + val name: String? = null +) + @Serializable data class CoversResult( val covers: List = emptyList(),