NineAnime: fix chapter pages (#18376)

* NineAnime: fix chapter pages

Closes #13315

* NineAnime: fix WebView of chapter

* NineAnime: Calls moved to pageListParse
This commit is contained in:
Renzo Martin Poggio 2023-10-05 16:50:17 -03:00 committed by GitHub
parent 52ea2259db
commit fa085065ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'NineAnime'
pkgNameSuffix = 'en.nineanime'
extClass = '.NineAnime'
extVersionCode = 3
extVersionCode = 4
}
apply from: "$rootDir/common.gradle"

View File

@ -7,6 +7,7 @@ import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Headers
import okhttp3.OkHttpClient
import okhttp3.Request
@ -31,6 +32,10 @@ class NineAnime : ParsedHttpSource() {
.followRedirects(true)
.build()
companion object {
private const val PAGES_URL = "https://www.glanceoflife.com"
}
// not necessary for normal usage but added in an attempt to fix usage with VPN (see #3476)
override fun headersBuilder(): Headers.Builder = Headers.Builder()
.add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) Gecko/20100101 Firefox/77")
@ -118,6 +123,10 @@ class NineAnime : ParsedHttpSource() {
return GET(baseUrl + "${manga.url}?waring=1", headers)
}
override fun getChapterUrl(chapter: SChapter): String {
return baseUrl + chapter.url
}
override fun chapterListSelector() = "ul.detail-chlist li"
override fun chapterFromElement(element: Element): SChapter {
@ -151,12 +160,21 @@ class NineAnime : ParsedHttpSource() {
// Pages
override fun pageListRequest(chapter: SChapter): Request {
val id: String = chapter.url.substring(chapter.url.lastIndexOf("/", chapter.url.length - 2))
val pageListHeaders = headersBuilder().add("Referer", "$baseUrl/manga/").build()
return GET(baseUrl + chapter.url, pageListHeaders)
return GET("$PAGES_URL/c/nineanime$id", pageListHeaders)
}
override fun pageListParse(document: Document): List<Page> {
val script = document.select("script:containsData(all_imgs_url)").firstOrNull()?.data()
val pageListHeaders = headersBuilder().add("Referer", "$baseUrl/manga/").build()
val scripturl = document.select("script").firstOrNull()?.data()
val link = scripturl?.split("\"")?.get(1)
val pages = client.newCall(GET(PAGES_URL + link, pageListHeaders)).execute().asJsoup()
val script = pages.select("script:containsData(all_imgs_url)").firstOrNull()?.data()
?: throw Exception("all_imgsurl not found")
return Regex(""""(http.*)",""").findAll(script).mapIndexed { i, mr ->
Page(i, "", mr.groupValues[1])