AsuraScans: Fix pages not found (#6134)
* fix chapter pages * fix chapter name * merge nextjs chunks
This commit is contained in:
parent
ad8db484bd
commit
ae5842be87
|
@ -1,7 +1,7 @@
|
||||||
ext {
|
ext {
|
||||||
extName = 'Asura Scans'
|
extName = 'Asura Scans'
|
||||||
extClass = '.AsuraScans'
|
extClass = '.AsuraScans'
|
||||||
extVersionCode = 41
|
extVersionCode = 42
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -245,7 +245,9 @@ class AsuraScans : ParsedHttpSource(), ConfigurableSource {
|
||||||
|
|
||||||
override fun chapterFromElement(element: Element) = SChapter.create().apply {
|
override fun chapterFromElement(element: Element) = SChapter.create().apply {
|
||||||
setUrlWithoutDomain(element.selectFirst("a")!!.attr("abs:href").toPermSlugIfNeeded())
|
setUrlWithoutDomain(element.selectFirst("a")!!.attr("abs:href").toPermSlugIfNeeded())
|
||||||
name = element.selectFirst("h3")!!.text()
|
val chNumber = element.selectFirst("h3 > a")!!.ownText()
|
||||||
|
val chTitle = element.select("h3 > a > span").joinToString(" ") { it.ownText() }
|
||||||
|
name = if (chTitle.isBlank()) chNumber else "$chNumber - $chTitle"
|
||||||
date_upload = try {
|
date_upload = try {
|
||||||
val text = element.selectFirst("h3 + h3")!!.ownText()
|
val text = element.selectFirst("h3 + h3")!!.ownText()
|
||||||
val cleanText = text.replace(CLEAN_DATE_REGEX, "$1")
|
val cleanText = text.replace(CLEAN_DATE_REGEX, "$1")
|
||||||
|
@ -265,9 +267,11 @@ class AsuraScans : ParsedHttpSource(), ConfigurableSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
return document.select("div > img[alt*=chapter]").mapIndexed { i, element ->
|
val scriptData = document.select("script:containsData(self.__next_f.push)")
|
||||||
Page(i, imageUrl = element.attr("abs:src"))
|
.joinToString("") { it.data().substringAfter("\"").substringBeforeLast("\"") }
|
||||||
}
|
val pagesData = PAGES_REGEX.find(scriptData)?.groupValues?.get(1) ?: throw Exception("Failed to find chapter pages")
|
||||||
|
val pageList = json.decodeFromString<List<PageDto>>(pagesData.unescape()).sortedBy { it.order }
|
||||||
|
return pageList.mapIndexed { i, page -> Page(i, imageUrl = page.url) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageUrlParse(document: Document) = throw UnsupportedOperationException()
|
override fun imageUrlParse(document: Document) = throw UnsupportedOperationException()
|
||||||
|
@ -311,7 +315,13 @@ class AsuraScans : ParsedHttpSource(), ConfigurableSource {
|
||||||
return this.replace(slug, absSlug)
|
return this.replace(slug, absSlug)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun String.unescape(): String {
|
||||||
|
return UNESCAPE_REGEX.replace(this, "$1")
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private val UNESCAPE_REGEX = """\\(.)""".toRegex()
|
||||||
|
private val PAGES_REGEX = """\\"pages\\":(\[.*?])""".toRegex()
|
||||||
private val CLEAN_DATE_REGEX = """(\d+)(st|nd|rd|th)""".toRegex()
|
private val CLEAN_DATE_REGEX = """(\d+)(st|nd|rd|th)""".toRegex()
|
||||||
private val OLD_FORMAT_MANGA_REGEX = """^/manga/(\d+-)?([^/]+)/?$""".toRegex()
|
private val OLD_FORMAT_MANGA_REGEX = """^/manga/(\d+-)?([^/]+)/?$""".toRegex()
|
||||||
private val OLD_FORMAT_CHAPTER_REGEX = """^/(\d+-)?[^/]*-chapter-\d+(-\d+)*/?$""".toRegex()
|
private val OLD_FORMAT_CHAPTER_REGEX = """^/(\d+-)?[^/]*-chapter-\d+(-\d+)*/?$""".toRegex()
|
||||||
|
|
|
@ -14,3 +14,9 @@ class FilterItemDto(
|
||||||
val id: Int,
|
val id: Int,
|
||||||
val name: String,
|
val name: String,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class PageDto(
|
||||||
|
val order: Int,
|
||||||
|
val url: String,
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue