Fix Mukudoujin chapter number (#9729)

* Add MikuDoujin
* Add MikuDoujin V.1.2.1

* Update MikuDoujin.kt

* Update MikuDoujin
* Add ability to search using genre

* Add Rh2PlusManga
* Add Rh2PlusManga V.1.12.2
* Use Madara multi-source themes

* Change MikuDoujin gradle and Add Rh2PlusManga generator.
* update file to suggestion.
* add Rh2PlusManga to MadaraGenerator.kt.

* Fix Thai Madara source time format and MikuDoujin pages selector.
* add Thai relative time wordlist to Madara parseRelativeDate.
* change Rh2PlusManga and Mangauptocat date format.
* change Mangauptocat base url.
* change MikuDoujin pageListParse selector.

* Fix MikuDoujin Chapter number.
* fix MikuDoujin when try to fetch chapter name with non numeric ending word.
This commit is contained in:
Promchai Chooseang 2021-11-04 17:32:42 +07:00 committed by GitHub
parent 5695e7e470
commit f7620bc174
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'MikuDoujin'
pkgNameSuffix = 'th.mikudoujin'
extClass = '.MikuDoujin'
extVersionCode = 2
extVersionCode = 3
isNsfw = true
}

View File

@ -143,7 +143,9 @@ class MikuDoujin : ParsedHttpSource() {
override fun chapterListSelector() = "table.table-episode tr"
override fun chapterFromElement(element: Element): SChapter {
override fun chapterFromElement(element: Element): SChapter = throw Exception("Unused")
private fun chapterFromElementWithIndex(element: Element, idx: Int, manga: SManga): SChapter {
val chapter = SChapter.create()
element.select("td a").let {
chapter.setUrlWithoutDomain(it.attr("href"))
@ -151,7 +153,15 @@ class MikuDoujin : ParsedHttpSource() {
if (chapter.name.isEmpty()) {
chapter.chapter_number = 0.0f
} else {
chapter.chapter_number = chapter.name.split(" ").last().toFloat()
val lastWord = chapter.name.split(" ").last()
try {
chapter.chapter_number = lastWord.toFloat()
} catch (ex: NumberFormatException) {
if (lastWord == "จบ") {
manga.status = SManga.COMPLETED
}
chapter.chapter_number = (idx + 1).toFloat()
}
}
}
@ -167,6 +177,7 @@ class MikuDoujin : ParsedHttpSource() {
val mangaDocument = it.asJsoup()
if (mangaDocument.select(chapterListSelector()).isEmpty()) {
manga.status = SManga.COMPLETED
val createdChapter = SChapter.create().apply {
url = manga.url
name = "Chapter 1"
@ -174,9 +185,10 @@ class MikuDoujin : ParsedHttpSource() {
}
chList = listOf(createdChapter)
} else {
chList = mangaDocument.select(chapterListSelector()).map { Chapter ->
chapterFromElement(Chapter)
}
chList =
mangaDocument.select(chapterListSelector()).mapIndexed { idx, Chapter ->
chapterFromElementWithIndex(Chapter, idx, manga)
}
}
chList
}