MMRCMS - fix Mangas.pw chapters (#3892)

This commit is contained in:
Mike 2020-07-25 17:51:46 -04:00 committed by GitHub
parent 69ba77f792
commit 83c6ec46db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'My Manga Reader CMS (Many sources)'
pkgNameSuffix = 'all.mmrcms'
extClass = '.MyMangaReaderCMSSources'
extVersionCode = 44
extVersionCode = 45
libVersion = '1.2'
}

View File

@ -280,6 +280,11 @@ class MyMangaReaderCMSSource(
private fun chapterListSelector() = "ul[class^=chapters] > li:not(.btn), table.table tr"
// Some websites add characters after "chapters" thus the need of checking classes that starts with "chapters"
/**
* titleWrapper can have multiple "a" elements, filter to the first that contains letters (i.e. not "" or # as is possible)
*/
private val urlRegex = Regex("""[a-zA-z]""")
/**
* Returns a chapter from the given element.
*
@ -291,7 +296,9 @@ class MyMangaReaderCMSSource(
try {
val titleWrapper = element.select("[class^=chapter-title-rtl]").first()
// Some websites add characters after "..-rtl" thus the need of checking classes that starts with that
val url = titleWrapper.getElementsByTag("a").attr("href")
val url = titleWrapper.getElementsByTag("a")
.first { it.attr("href").contains(urlRegex) }
.attr("href")
// Ensure chapter actually links to a manga
// Some websites use the chapters box to link to post announcements
@ -327,7 +334,7 @@ class MyMangaReaderCMSSource(
private fun parseDate(dateText: String): Long {
return try {
DATE_FORMAT.parse(dateText).time
DATE_FORMAT.parse(dateText)?.time ?: 0
} catch (e: ParseException) {
0L
}