MyReadingManga Chapter Names Parsing (#1379)

* Update build.gradle

* Adds chapter names

Now parses chapter names from website if available.

* Found an exception, added backup

Found an exception on one of the mangas not listing all chapters in chapter list. Reverted to Ch. Page Number system in case chapter title is returned empty.

* Added exception handling

Additional volume listings also appeared in the chapter-class. Added an additional filter for the correct manga and a null exception.

* Addational null handling on names just in case.
This commit is contained in:
happywillow0 2019-08-09 18:37:32 -04:00 committed by Eugene
parent 242fd69a02
commit 9fae259e03
1 changed files with 8 additions and 4 deletions

View File

@ -139,13 +139,17 @@ open class MyReadingManga(override val lang: String) : ParsedHttpSource() {
val chapters = mutableListOf<SChapter>()
val date = parseDate(document.select(".entry-time").attr("datetime").substringBefore("T"))
val mangaUrl = document.baseUri()
val chfirstname = document.select(".chapter-class a[href*=$mangaUrl]")?.first()?.text()?.ifEmpty { "Ch. 1" }?.capitalize() ?:"Ch. 1"
//create first chapter since its on main manga page
chapters.add(createChapter("1", document.baseUri(), date))
chapters.add(createChapter("1", document.baseUri(), date, chfirstname))
//see if there are multiple chapters or not
document.select(chapterListSelector())?.let { it ->
it.forEach {
if (!it.text().contains("Next »", true)) {
chapters.add(createChapter(it.text(), document.baseUri(), date))
val pageNumber = it.text()
val chname = document.select(".chapter-class a[href$=/$pageNumber/]")?.text()?.ifEmpty { "Ch. $pageNumber" }?.capitalize() ?:"Ch. $pageNumber"
chapters.add(createChapter(it.text(), document.baseUri(), date, chname))
}
}
}
@ -158,10 +162,10 @@ open class MyReadingManga(override val lang: String) : ParsedHttpSource() {
return SimpleDateFormat("yyyy-MM-dd").parse(date).time
}
private fun createChapter(pageNumber: String, mangaUrl: String, date: Long): SChapter {
private fun createChapter(pageNumber: String, mangaUrl: String, date: Long, chname: String): SChapter {
val chapter = SChapter.create()
chapter.setUrlWithoutDomain("$mangaUrl/$pageNumber")
chapter.name = "Ch. $pageNumber"
chapter.name = chname
chapter.date_upload = date
return chapter
}