Cleanup
This commit is contained in:
parent
319c41905e
commit
acefd33e2e
@ -71,7 +71,7 @@ class ApiMangaParser(private val langs: List<String>) {
|
||||
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<ApiMangaSerializer>(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<String>) {
|
||||
|
||||
fun chapterListParse(jsonData: String): List<SChapter> {
|
||||
val now = System.currentTimeMillis()
|
||||
val networkApiManga = MdUtil.jsonParser.decodeFromString(ApiMangaSerializer.serializer(), jsonData)
|
||||
val networkApiManga = MdUtil.jsonParser.decodeFromString<ApiMangaSerializer>(jsonData)
|
||||
val networkManga = networkApiManga.manga
|
||||
val networkChapters = networkApiManga.chapter
|
||||
if (networkChapters.isNullOrEmpty()) {
|
||||
|
@ -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() }
|
||||
}
|
||||
|
@ -28,6 +28,31 @@ data class MangaSerializer(
|
||||
val title: String
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class MangaSerializerTwo(
|
||||
val artist: List<String>,
|
||||
val author: List<String>,
|
||||
val mainCover: String,
|
||||
val description: String,
|
||||
val publication: Publication,
|
||||
val tags: List<Int>,
|
||||
// val covers: List<String>,
|
||||
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<GroupSerializer> = emptyList(),
|
||||
val timestamp: Long
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class GroupSerializer(
|
||||
val id: Int,
|
||||
val name: String? = null
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class CoversResult(
|
||||
val covers: List<String> = emptyList(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user