Fix NullPointerException in Cosplaytele (#5708)

* fix #5232

* lint
This commit is contained in:
Chaos Pjeles 2024-10-27 08:07:14 +01:00 committed by Draff
parent 17fc1acd6c
commit dc64c90e7e
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 8 additions and 8 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'CosplayTele' extName = 'CosplayTele'
extClass = '.CosplayTele' extClass = '.CosplayTele'
extVersionCode = 2 extVersionCode = 3
isNsfw = true isNsfw = true
} }

View File

@ -66,17 +66,17 @@ class CosplayTele : ParsedHttpSource() {
} }
private val popularPageLimit = 20 private val popularPageLimit = 20
override fun popularMangaRequest(page: Int) = GET("$baseUrl/wp-json/wordpress-popular-posts/v1/popular-posts?offset=${page * popularPageLimit}&limit=$popularPageLimit&range=last7days")
override fun popularMangaRequest(page: Int) = GET("$baseUrl/wp-json/wordpress-popular-posts/v1/popular-posts?offset=${page * popularPageLimit}&limit=$popularPageLimit&range=last7days&embed=true&_embed=wp:featuredmedia&_fields=title,link,_embedded,_links.wp:featuredmedia")
override fun popularMangaSelector(): String = "" override fun popularMangaSelector(): String = ""
override fun popularMangaParse(response: Response): MangasPage { override fun popularMangaParse(response: Response): MangasPage {
val jsonObject = json.decodeFromString<JsonArray>(response.body.string()) val respObject = json.decodeFromString<JsonArray>(response.body.string())
val mangas = jsonObject.map { item -> val mangas = respObject.map { item ->
val head = item.jsonObject["yoast_head_json"]!!.jsonObject
SManga.create().apply { SManga.create().apply {
title = head["og_title"]!!.jsonPrimitive.content title = item.jsonObject!!["title"]!!.jsonObject!!["rendered"]!!.jsonPrimitive.content
thumbnail_url = head["og_image"]!!.jsonArray[0].jsonObject["url"]!!.jsonPrimitive.content thumbnail_url = item.jsonObject!!["_embedded"]!!.jsonObject!!["wp:featuredmedia"]!!.jsonArray[0]!!.jsonObject["source_url"]!!.jsonPrimitive.content
setUrlWithoutDomain(head["og_url"]!!.jsonPrimitive.content) setUrlWithoutDomain(item.jsonObject!!["link"]!!.jsonPrimitive.content)
} }
} }
return MangasPage(mangas, mangas.size >= popularPageLimit) return MangasPage(mangas, mangas.size >= popularPageLimit)