From aa2bb8af05643c29361d264fa4c5c57d3c64ae39 Mon Sep 17 00:00:00 2001 From: CodeSpoof <42744253+CodeSpoof@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:03:11 +0100 Subject: [PATCH] Update Nicomanga.kt Request moved to Parsing --- .../extension/ja/nicomanga/Nicomanga.kt | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/ja/nicomanga/src/eu/kanade/tachiyomi/extension/ja/nicomanga/Nicomanga.kt b/src/ja/nicomanga/src/eu/kanade/tachiyomi/extension/ja/nicomanga/Nicomanga.kt index 78641c4b..f7480691 100644 --- a/src/ja/nicomanga/src/eu/kanade/tachiyomi/extension/ja/nicomanga/Nicomanga.kt +++ b/src/ja/nicomanga/src/eu/kanade/tachiyomi/extension/ja/nicomanga/Nicomanga.kt @@ -12,7 +12,6 @@ import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.Response import org.jsoup.Jsoup -import org.jsoup.nodes.Element import java.net.URL class Nicomanga : HttpSource() { @@ -53,7 +52,7 @@ class Nicomanga : HttpSource() { val relURL = manga.selectFirst(".series-title a")?.attr("href") ?: "" setUrlWithoutDomain(URL(URL(baseUrl), relURL).toString()) title = manga.selectFirst(".series-title")?.text() ?: "" - thumbnail_url = Nicomanga.thumbnailURLRegex.find(manga.selectFirst(".img-in-ratio.lazyloaded")?.attr("style") ?: "")?.groupValues?.get(1) + thumbnail_url = thumbnailURLRegex.find(manga.selectFirst(".img-in-ratio.lazyloaded")?.attr("style") ?: "")?.groupValues?.get(1) } } return MangasPage(mangas, hasNextPage) @@ -104,7 +103,7 @@ class Nicomanga : HttpSource() { val doc = Jsoup.parse(response.body.string()) author = doc.select("ul.manga-info a[href^=\"manga-author\"]").joinToString { it.text() } genre = doc.select("ul.manga-info a[href^=\"manga-list-genre\"]").joinToString { it.text() } - val statusText = Nicomanga.statusRegex.find(doc.select(".manga-info li:has(i.fa-spinner) a").attr("href"))?.groupValues?.get(0) ?: "" + val statusText = statusRegex.find(doc.select(".manga-info li:has(i.fa-spinner) a").attr("href"))?.groupValues?.get(0) ?: "" status = when (statusText) { "on-going" -> { SManga.ONGOING @@ -119,7 +118,7 @@ class Nicomanga : HttpSource() { } override fun chapterListRequest(manga: SManga): Request { - val slug = Nicomanga.urlRegex.find(manga.url)?.groupValues?.get(0) ?: "" + val slug = urlRegex.find(manga.url)?.groupValues?.get(0) ?: "" return GET("$baseUrl/app/manga/controllers/cont.Listchapterapi.php?slug=$slug") } @@ -131,7 +130,7 @@ class Nicomanga : HttpSource() { SChapter.create().apply { name = chapter.attr("title").trim() setUrlWithoutDomain(URL(URL(baseUrl), chapter.attr("href")).toString()) - chapter_number = Nicomanga.floatRegex.find(chapter.attr("title").trim())?.groupValues?.get(0)?.toFloat() ?: (lastNum + 0.01f) + chapter_number = floatRegex.find(chapter.attr("title").trim())?.groupValues?.get(0)?.toFloat() ?: (lastNum + 0.01f) lastNum = chapter_number } } @@ -139,16 +138,15 @@ class Nicomanga : HttpSource() { } override fun pageListRequest(chapter: SChapter): Request { - val r = client.newCall(GET(getChapterUrl(chapter))).execute() - val id = Nicomanga.chapterIdRegex.find(r.body.string())?.groupValues?.get(0) ?: throw Exception("chapter-id not found") - val headers = headersBuilder().set("referer", getChapterUrl(chapter)).build() - return GET("$baseUrl/app/manga/controllers/cont.imgsList.php?cid=$id", headers) + return GET(getChapterUrl(chapter)) } override fun pageListParse(response: Response): List { - val doc = Jsoup.parse(response.body.string()) + val id = chapterIdRegex.find(response.body.string())?.groupValues?.get(0) ?: throw Exception("chapter-id not found") + val headers = headersBuilder().set("referer", response.request.url.toUrl().toString()).build() + val r = client.newCall(GET("$baseUrl/app/manga/controllers/cont.imgsList.php?cid=$id", headers)).execute() + val doc = Jsoup.parse(r.body.string()) val pages = ArrayList() - // Nicovideo will refuse to serve any pages if the user has not logged in val pageList = doc.select("img.chapter-img") for ((i, page) in pageList.withIndex()) { val url = page.attr("data-src")