WP Comics - fixes (#2791)

WP Comics - fixes
This commit is contained in:
Mike 2020-04-24 08:27:02 -04:00 committed by GitHub
parent 33d1ccd2a7
commit 90f191bc00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 19 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: WP-Comics'
pkgNameSuffix = 'all.wpcomics'
extClass = '.WPComicsFactory'
extVersionCode = 4
extVersionCode = 5
libVersion = '1.2'
}

View File

@ -111,6 +111,8 @@ abstract class WPComics(
}
}
private val currentYear by lazy { Calendar.getInstance(Locale.US)[1].toString().takeLast(2) }
private fun String?.toDate(): Long {
return try {
if (this?.contains("ago", ignoreCase = true) == true) {
@ -126,7 +128,15 @@ abstract class WPComics(
calendar.timeInMillis
} else {
dateFormat.parse(if (gmtOffset == null) this?.substringAfterLast(" ") else "$this $gmtOffset").time
(if (gmtOffset == null) this?.substringAfterLast(" ") else "$this $gmtOffset")?.let {
// timestamp has year
if (Regex("""\d+/\d+/\d\d""").find(it)?.value != null) {
dateFormat.parse(it).time
} else {
// MangaSum - timestamp sometimes doesn't have year (current year implied)
dateFormat.parse("$it/$currentYear").time
}
} ?: 0L
}
} catch (_: Exception) {
0L

View File

@ -20,28 +20,20 @@ class WPComicsFactory : SourceFactory {
)
}
private class ManhuaPlus : WPComics("Manhua Plus", "https://manhuaplus.com", "en")
private class ManhuaPlus : WPComics("Manhua Plus", "https://manhuaplus.com", "en") {
override val pageListSelector: String = "div.chapter-detail img, ${super.pageListSelector}"
}
private class ManhuaES : WPComics("Manhua ES", "https://manhuaes.com", "en", SimpleDateFormat("HH:mm - dd/MM/yyyy Z", Locale.US), "+0700") {
override val popularPath = "category-comics/manga"
override fun popularMangaFromElement(element: Element): SManga {
return SManga.create().apply {
element.select("div.overlay a").let {
title = it.attr("title")
setUrlWithoutDomain(it.attr("href"))
}
thumbnail_url = element.select("div.image img").attr("abs:src")
}
}
override fun latestUpdatesFromElement(element: Element): SManga {
return SManga.create().apply {
element.select("a.head").let {
element.select("div.overlay a:has(h2)").let {
title = it.text()
setUrlWithoutDomain(it.attr("href"))
}
thumbnail_url = element.select("img").attr("abs:src")
thumbnail_url = element.select("img").firstOrNull()?.attr("abs:src")
}
}
@ -50,10 +42,6 @@ private class ManhuaES : WPComics("Manhua ES", "https://manhuaes.com", "en", Sim
private class MangaSum : WPComics("MangaSum", "https://mangasum.com", "en", SimpleDateFormat("MM/dd/yy", Locale.US), null) {
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = GET("$baseUrl/genres?keyword=$query&page=$page", headers)
/**
* TODO - chapter dates come in 3 flavors: relative dates less than a month, time + month/day (current year is implied),
* and MM/dd/yy; see about getting all 3 working (currently at 2/3)
*/
}
private class XoxoComics : WPComics("XOXO Comics", "https://xoxocomics.com", "en", SimpleDateFormat("MM/dd/yy", Locale.US), null) {