Fix HentaiRead (#6408)
* Fix HentaiRead * Change to Regex * Added Description
This commit is contained in:
parent
1c31319402
commit
023b928462
|
@ -3,7 +3,7 @@ ext {
|
||||||
extClass = '.Hentairead'
|
extClass = '.Hentairead'
|
||||||
themePkg = 'madara'
|
themePkg = 'madara'
|
||||||
baseUrl = 'https://hentairead.com'
|
baseUrl = 'https://hentairead.com'
|
||||||
overrideVersionCode = 8
|
overrideVersionCode = 9
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,3 +12,28 @@ class Result(
|
||||||
val id: Int,
|
val id: Int,
|
||||||
val text: String,
|
val text: String,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class ImageBaseUrlDto(
|
||||||
|
val baseUrl: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class PagesDto(
|
||||||
|
val data: Data,
|
||||||
|
) {
|
||||||
|
@Serializable
|
||||||
|
class Data(
|
||||||
|
val chapter: Chapter,
|
||||||
|
) {
|
||||||
|
@Serializable
|
||||||
|
class Chapter(
|
||||||
|
val images: List<Image>,
|
||||||
|
) {
|
||||||
|
@Serializable
|
||||||
|
class Image(
|
||||||
|
val src: String,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.extension.en.hentairead
|
package eu.kanade.tachiyomi.extension.en.hentairead
|
||||||
|
|
||||||
|
import android.util.Base64
|
||||||
import eu.kanade.tachiyomi.multisrc.madara.Madara
|
import eu.kanade.tachiyomi.multisrc.madara.Madara
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
|
@ -8,7 +9,6 @@ import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.model.UpdateStrategy
|
import eu.kanade.tachiyomi.source.model.UpdateStrategy
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
|
@ -185,18 +185,27 @@ class Hentairead : Madara("HentaiRead", "https://hentairead.com", "en", dateForm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// chapterExtraData = ({...});
|
||||||
|
private val chapterExtraDataRegex = Regex("""= (\{[^;]+)""")
|
||||||
|
|
||||||
|
// window.mMjM5MjM2 = '(eyJkYX...);
|
||||||
|
private val pagesDataRegex = Regex(""".(ey\S+).\s""")
|
||||||
|
|
||||||
// From ManhwaHentai - modified
|
// From ManhwaHentai - modified
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
launchIO { countViews(document) }
|
launchIO { countViews(document) }
|
||||||
|
|
||||||
val pages = document.selectFirst("[id=single-chapter-js-extra]")?.data()
|
val pageBaseUrl = document.selectFirst("[id=single-chapter-js-extra]")?.data()
|
||||||
?.substringAfter(":[")
|
?.let { chapterExtraDataRegex.find(it)?.groups }?.get(1)?.value
|
||||||
?.substringBefore("],")
|
?.let { json.decodeFromString<ImageBaseUrlDto>(it).baseUrl }
|
||||||
?.let { json.decodeFromString<List<PageDto>>("[$it]") }
|
|
||||||
|
val pages = document.selectFirst("[id=single-chapter-js-before]")?.data()
|
||||||
|
?.let { pagesDataRegex.find(it)?.groups }?.get(1)?.value
|
||||||
|
?.let { json.decodeFromString<PagesDto>(String(Base64.decode(it, Base64.DEFAULT))) }
|
||||||
?: throw Exception("Failed to find page list. Non-English entries are not supported.")
|
?: throw Exception("Failed to find page list. Non-English entries are not supported.")
|
||||||
|
|
||||||
return pages.mapIndexed { idx, page ->
|
return pages.data.chapter.images.mapIndexed { idx, page ->
|
||||||
Page(idx, document.location(), page.src)
|
Page(idx, document.location(), "$pageBaseUrl/${page.src}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,8 +247,3 @@ class Hentairead : Madara("HentaiRead", "https://hentairead.com", "en", dateForm
|
||||||
return json.decodeFromString(body.string())
|
return json.decodeFromString(body.string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
|
||||||
class PageDto(
|
|
||||||
val src: String,
|
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in New Issue