From 2f7c187c357e133ddc4096b9f928c4c44c69994c Mon Sep 17 00:00:00 2001 From: Seishirou101 <57241064+Seishirou101@users.noreply.github.com> Date: Sun, 19 Dec 2021 15:17:18 +0000 Subject: [PATCH] add logic to fix null error for nepnep (#10148) * add logic to fix null error * suggested fix --- .../java/eu/kanade/tachiyomi/multisrc/nepnep/NepNep.kt | 7 ++++--- .../eu/kanade/tachiyomi/multisrc/nepnep/NepNepGenerator.kt | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/nepnep/NepNep.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/nepnep/NepNep.kt index 3b24acc72..6e123b88a 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/nepnep/NepNep.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/nepnep/NepNep.kt @@ -284,7 +284,6 @@ abstract class NepNep( override fun chapterListParse(response: Response): List { val vmChapters = response.asJsoup().select("script:containsData(MainFunction)").first().data() .substringAfter("vm.Chapters = ").substringBefore(";") - return json.parseToJsonElement(vmChapters).jsonArray.map { json -> val indexChapter = json.getString("Chapter")!! SChapter.create().apply { @@ -303,8 +302,10 @@ abstract class NepNep( override fun pageListParse(response: Response): List { val document = response.asJsoup() - val script = document.select("script:containsData(MainFunction)").first().data() - val curChapter = json.parseToJsonElement(script.substringAfter("vm.CurChapter = ").substringBefore(";")).jsonObject + val script = document.selectFirst("script:containsData(MainFunction)")?.data() + ?: client.newCall(GET(document.location().removeSuffix(".html"), headers)) + .execute().asJsoup().selectFirst("script:containsData(MainFunction)").data() + val curChapter = json.parseToJsonElement(script!!.substringAfter("vm.CurChapter = ").substringBefore(";")).jsonObject val pageTotal = curChapter.getString("Page")!!.toInt() diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/nepnep/NepNepGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/nepnep/NepNepGenerator.kt index 6d9517311..53b798902 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/nepnep/NepNepGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/nepnep/NepNepGenerator.kt @@ -9,7 +9,7 @@ class NepNepGenerator : ThemeSourceGenerator { override val themeClass = "NepNep" - override val baseVersionCode: Int = 6 + override val baseVersionCode: Int = 7 override val sources = listOf( SingleLang("MangaSee", "https://mangasee123.com", "en", overrideVersionCode = 20),