[RU]NudeMoon webview mobile site (#13927)
* update site url * Parse mobile site version Fix a lot if error * Fix detail cover load * Add sort by chapter name(server return sorted by upload date) * fix warnings and date parse in some case * Another date fix * replace client.newCall to chapterListParse as @alessandrojean requested https://github.com/tachiyomiorg/tachiyomi-extensions/pull/13914#discussion_r999480012 * version code change * Force mobile site version in webview * Move cookie set to class init * Remove sort by chapter name It create more problem than solve User can choose sort by chapter number in app when necessary
This commit is contained in:
parent
d0f26eff13
commit
ffa4d9e45a
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'Nude-Moon'
|
extName = 'Nude-Moon'
|
||||||
pkgNameSuffix = 'ru.nudemoon'
|
pkgNameSuffix = 'ru.nudemoon'
|
||||||
extClass = '.Nudemoon'
|
extClass = '.Nudemoon'
|
||||||
extVersionCode = 10
|
extVersionCode = 11
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.extension.ru.nudemoon
|
package eu.kanade.tachiyomi.extension.ru.nudemoon
|
||||||
|
|
||||||
|
import android.webkit.CookieManager
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.source.model.Filter
|
import eu.kanade.tachiyomi.source.model.Filter
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
|
@ -26,6 +27,12 @@ class Nudemoon : ParsedHttpSource() {
|
||||||
|
|
||||||
override val supportsLatest = true
|
override val supportsLatest = true
|
||||||
|
|
||||||
|
private val cookieManager by lazy { CookieManager.getInstance() }
|
||||||
|
|
||||||
|
init {
|
||||||
|
cookieManager.setCookie(baseUrl, "nm_mobile=1; Domain=" + baseUrl.split("//")[1])
|
||||||
|
}
|
||||||
|
|
||||||
private val cookiesHeader by lazy {
|
private val cookiesHeader by lazy {
|
||||||
val cookies = mutableMapOf<String, String>()
|
val cookies = mutableMapOf<String, String>()
|
||||||
cookies["NMfYa"] = "1"
|
cookies["NMfYa"] = "1"
|
||||||
|
@ -145,13 +152,16 @@ class Nudemoon : ParsedHttpSource() {
|
||||||
override fun chapterListSelector() = popularMangaSelector()
|
override fun chapterListSelector() = popularMangaSelector()
|
||||||
|
|
||||||
override fun chapterListParse(response: Response): List<SChapter> = mutableListOf<SChapter>().apply {
|
override fun chapterListParse(response: Response): List<SChapter> = mutableListOf<SChapter>().apply {
|
||||||
|
val floatRegex = Regex("^([+-]?\\d*\\.?\\d*)\$")
|
||||||
val document = response.asJsoup()
|
val document = response.asJsoup()
|
||||||
|
|
||||||
if (document.select("td.button a:contains(Все главы)").isEmpty()) {
|
val allPageElement = document.select("td.button a:contains(Все главы)")
|
||||||
|
|
||||||
|
if (allPageElement.isEmpty()) {
|
||||||
add(chapterFromElement(document))
|
add(chapterFromElement(document))
|
||||||
} else {
|
} else {
|
||||||
var pageListDocument: Document
|
var pageListDocument: Document
|
||||||
val pageListLink = document.select("td.button a:contains(Все главы)").attr("href")
|
val pageListLink = allPageElement.attr("href")
|
||||||
client.newCall(
|
client.newCall(
|
||||||
GET(baseUrl + pageListLink, headers)
|
GET(baseUrl + pageListLink, headers)
|
||||||
).execute().run {
|
).execute().run {
|
||||||
|
@ -161,24 +171,26 @@ class Nudemoon : ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
pageListDocument = this.asJsoup()
|
pageListDocument = this.asJsoup()
|
||||||
}
|
}
|
||||||
pageListDocument.select("table.news_pic2").sortedByDescending { it.selectFirst("tr[valign=top] a:has(h2) h2").text() }.forEach {
|
pageListDocument.select("table.news_pic2")
|
||||||
val chapter = SChapter.create()
|
.forEach {
|
||||||
val nameAndUrl = it.select("tr[valign=top] a:has(h2)")
|
val chapter = SChapter.create()
|
||||||
chapter.name = nameAndUrl.select("h2").text()
|
val nameAndUrl = it.select("tr[valign=top] a:has(h2)")
|
||||||
chapter.setUrlWithoutDomain(nameAndUrl.attr("abs:href"))
|
chapter.name = nameAndUrl.select("h2").text()
|
||||||
chapter.scanlator = it.select("tr[valign=top] td[align=left] a[href*=perevod]").text()
|
chapter.setUrlWithoutDomain(nameAndUrl.attr("abs:href"))
|
||||||
chapter.date_upload = it.selectFirst("tr[valign=top] td[align=left] span.small2").text().let {
|
val informBlock = it.select("tr[valign=top] td[align=left]")
|
||||||
textDate ->
|
chapter.scanlator = informBlock.select("a[href*=perevod]").text()
|
||||||
try {
|
chapter.date_upload = informBlock.select("span.small2")
|
||||||
SimpleDateFormat("d MMMM yyyy", Locale("ru")).parse(textDate.replace("Май", "Мая"))?.time ?: 0L
|
.text().replace("Май", "Мая").let {
|
||||||
} catch (e: Exception) {
|
textDate ->
|
||||||
0
|
try {
|
||||||
}
|
SimpleDateFormat("d MMMM yyyy", Locale("ru")).parse(textDate)?.time ?: 0L
|
||||||
|
} catch (e: Exception) {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chapter.chapter_number = floatRegex.find(chapter.name).toString().toFloatOrNull() ?: -1f
|
||||||
|
add(chapter)
|
||||||
}
|
}
|
||||||
val floatRegex = Regex("^([+-]?\\d*\\.?\\d*)\$")
|
|
||||||
chapter.chapter_number = floatRegex.find(chapter.name).toString().toFloatOrNull() ?: -1f
|
|
||||||
add(chapter)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue