PTNF: fix mangaId, fix pagination, script order (#2964)
* PTNF: fix mangaId, fix pagination, script order * actually use the most common mangaId
This commit is contained in:
parent
5d6d9463b7
commit
3873976886
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'Plot Twist No Fansub'
|
extName = 'Plot Twist No Fansub'
|
||||||
extClass = '.PlotTwistNoFansub'
|
extClass = '.PlotTwistNoFansub'
|
||||||
extVersionCode = 4
|
extVersionCode = 5
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,19 +138,26 @@ class PlotTwistNoFansub : ParsedHttpSource(), ConfigurableSource {
|
|||||||
|
|
||||||
override fun chapterListParse(response: Response): List<SChapter> {
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
val document = response.asJsoup()
|
val document = response.asJsoup()
|
||||||
val mangaId = document.selectFirst(".chapters-container .row.itemlist p[data-mangaid]")!!.attr("data-mangaid")
|
|
||||||
|
val mangaIds = listOfNotNull(
|
||||||
|
MANGAID1_REGEX.find(document.html())?.groupValues?.get(1),
|
||||||
|
document.selectFirst("link[rel=shortlink]")?.attr("href")?.substringAfterLast("="),
|
||||||
|
document.selectFirst("body")?.classNames()?.filter { it.startsWith("postid-") }?.getOrNull(0)?.substringAfterLast("-"),
|
||||||
|
document.selectFirst(".td-post-views span")?.classNames()?.filter { it.startsWith("td-nr-views-") }?.getOrNull(0)?.substringAfterLast("-"),
|
||||||
|
) + document.select("*[data-mangaid]").map { it.attr("data-mangaid") }
|
||||||
|
|
||||||
|
val mangaId = mangaIds.groupingBy { it }.eachCount().maxBy { it.value }.key
|
||||||
|
|
||||||
val key = getKey(document)
|
val key = getKey(document)
|
||||||
val url = "$baseUrl/wp-admin/admin-ajax.php"
|
val url = "$baseUrl/wp-admin/admin-ajax.php"
|
||||||
val formBody = FormBody.Builder()
|
|
||||||
.add("action", key)
|
|
||||||
.add("manga_id", mangaId)
|
|
||||||
|
|
||||||
var page = 1
|
var page = 1
|
||||||
val chapterList = mutableListOf<SChapter>()
|
val chapterList = mutableListOf<SChapter>()
|
||||||
|
|
||||||
do {
|
do {
|
||||||
val body = formBody
|
val body = FormBody.Builder()
|
||||||
|
.add("action", key)
|
||||||
|
.add("manga_id", mangaId)
|
||||||
.add("pageNumber", page.toString())
|
.add("pageNumber", page.toString())
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
@ -217,21 +224,17 @@ class PlotTwistNoFansub : ParsedHttpSource(), ConfigurableSource {
|
|||||||
private fun getKey(document: Document): String {
|
private fun getKey(document: Document): String {
|
||||||
val customPriorityWant = listOf("custom")
|
val customPriorityWant = listOf("custom")
|
||||||
val customPriorityJunk = listOf("bootstrap", "pagi", "reader", "jquery")
|
val customPriorityJunk = listOf("bootstrap", "pagi", "reader", "jquery")
|
||||||
|
val customPriorityJunk2 = listOf("multilanguage-", "ad-", "td-", "bj-", "html-", "gd-")
|
||||||
|
|
||||||
document.select("script[src*=\"wp-content/plugins/\"]")
|
document.select("script[src*=\"wp-content/plugins/\"]")
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.map { it.attr("src") }
|
.map { it.attr("src") }
|
||||||
.filterNot { it.contains("wp-content/plugins/multilanguage-") }
|
|
||||||
.filterNot { it.contains("wp-content/plugins/ad-") }
|
|
||||||
.filterNot { it.contains("wp-content/plugins/td-") }
|
|
||||||
.filterNot { it.contains("wp-content/plugins/bj-") }
|
|
||||||
.filterNot { it.contains("wp-content/plugins/html-") }
|
|
||||||
.filterNot { it.contains("wp-content/plugins/gd-") }
|
|
||||||
.sortedWith(
|
.sortedWith(
|
||||||
compareBy<String> { url ->
|
compareBy<String> { url ->
|
||||||
when {
|
when {
|
||||||
customPriorityWant.any { url.contains(it) } -> 0
|
customPriorityWant.any { url.contains(it) } -> 0
|
||||||
customPriorityJunk.any { url.contains(it) } -> 2
|
customPriorityJunk.any { url.contains(it) } -> 2
|
||||||
|
customPriorityJunk2.any { url.contains(it) } -> 3
|
||||||
else -> 1
|
else -> 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -254,6 +257,7 @@ class PlotTwistNoFansub : ParsedHttpSource(), ConfigurableSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private val MANGAID1_REGEX = ""","manid":"(\d+)",""".toRegex()
|
||||||
private val UNESCAPE_REGEX = """\\(.)""".toRegex()
|
private val UNESCAPE_REGEX = """\\(.)""".toRegex()
|
||||||
private val CHAPTER_PAGES_REGEX = """obj\s*=\s*(.*)\s*;""".toRegex()
|
private val CHAPTER_PAGES_REGEX = """obj\s*=\s*(.*)\s*;""".toRegex()
|
||||||
private val ACTION_REGEX = """action:\s*?(['"])([^\r\n]+?)\1""".toRegex()
|
private val ACTION_REGEX = """action:\s*?(['"])([^\r\n]+?)\1""".toRegex()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user