[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'
|
||||
pkgNameSuffix = 'ru.nudemoon'
|
||||
extClass = '.Nudemoon'
|
||||
extVersionCode = 10
|
||||
extVersionCode = 11
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.kanade.tachiyomi.extension.ru.nudemoon
|
||||
|
||||
import android.webkit.CookieManager
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
|
@ -26,6 +27,12 @@ class Nudemoon : ParsedHttpSource() {
|
|||
|
||||
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 {
|
||||
val cookies = mutableMapOf<String, String>()
|
||||
cookies["NMfYa"] = "1"
|
||||
|
@ -145,13 +152,16 @@ class Nudemoon : ParsedHttpSource() {
|
|||
override fun chapterListSelector() = popularMangaSelector()
|
||||
|
||||
override fun chapterListParse(response: Response): List<SChapter> = mutableListOf<SChapter>().apply {
|
||||
val floatRegex = Regex("^([+-]?\\d*\\.?\\d*)\$")
|
||||
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))
|
||||
} else {
|
||||
var pageListDocument: Document
|
||||
val pageListLink = document.select("td.button a:contains(Все главы)").attr("href")
|
||||
val pageListLink = allPageElement.attr("href")
|
||||
client.newCall(
|
||||
GET(baseUrl + pageListLink, headers)
|
||||
).execute().run {
|
||||
|
@ -161,24 +171,26 @@ class Nudemoon : ParsedHttpSource() {
|
|||
}
|
||||
pageListDocument = this.asJsoup()
|
||||
}
|
||||
pageListDocument.select("table.news_pic2").sortedByDescending { it.selectFirst("tr[valign=top] a:has(h2) h2").text() }.forEach {
|
||||
val chapter = SChapter.create()
|
||||
val nameAndUrl = it.select("tr[valign=top] a:has(h2)")
|
||||
chapter.name = nameAndUrl.select("h2").text()
|
||||
chapter.setUrlWithoutDomain(nameAndUrl.attr("abs:href"))
|
||||
chapter.scanlator = it.select("tr[valign=top] td[align=left] a[href*=perevod]").text()
|
||||
chapter.date_upload = it.selectFirst("tr[valign=top] td[align=left] span.small2").text().let {
|
||||
textDate ->
|
||||
try {
|
||||
SimpleDateFormat("d MMMM yyyy", Locale("ru")).parse(textDate.replace("Май", "Мая"))?.time ?: 0L
|
||||
} catch (e: Exception) {
|
||||
0
|
||||
}
|
||||
pageListDocument.select("table.news_pic2")
|
||||
.forEach {
|
||||
val chapter = SChapter.create()
|
||||
val nameAndUrl = it.select("tr[valign=top] a:has(h2)")
|
||||
chapter.name = nameAndUrl.select("h2").text()
|
||||
chapter.setUrlWithoutDomain(nameAndUrl.attr("abs:href"))
|
||||
val informBlock = it.select("tr[valign=top] td[align=left]")
|
||||
chapter.scanlator = informBlock.select("a[href*=perevod]").text()
|
||||
chapter.date_upload = informBlock.select("span.small2")
|
||||
.text().replace("Май", "Мая").let {
|
||||
textDate ->
|
||||
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