parent
9d7f8c9357
commit
844b32f560
|
@ -5,7 +5,7 @@ ext {
|
|||
appName = 'Tachiyomi: WP-Comics'
|
||||
pkgNameSuffix = 'all.wpcomics'
|
||||
extClass = '.WPComicsFactory'
|
||||
extVersionCode = 5
|
||||
extVersionCode = 6
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ abstract class WPComics(
|
|||
|
||||
override val client: OkHttpClient = network.cloudflareClient
|
||||
|
||||
private fun List<String>.doesInclude(thisWord: String): Boolean = this.any { it.contains(thisWord, ignoreCase = true) }
|
||||
|
||||
// Popular
|
||||
|
||||
open val popularPath = "hot"
|
||||
|
@ -92,12 +94,16 @@ abstract class WPComics(
|
|||
}
|
||||
}
|
||||
|
||||
private fun String?.toStatus() = when {
|
||||
private fun String?.toStatus(): Int {
|
||||
val ongoingWords = listOf("Ongoing", "Updating", "Đang tiến hành")
|
||||
val completedWords = listOf("Complete", "Hoàn thành")
|
||||
return when {
|
||||
this == null -> SManga.UNKNOWN
|
||||
this.contains("Updating", ignoreCase = true) -> SManga.ONGOING
|
||||
this.contains("Complete", ignoreCase = true) -> SManga.COMPLETED
|
||||
ongoingWords.doesInclude(this) -> SManga.ONGOING
|
||||
completedWords.doesInclude(this) -> SManga.COMPLETED
|
||||
else -> SManga.UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
// Chapters
|
||||
|
||||
|
@ -116,21 +122,29 @@ abstract class WPComics(
|
|||
private val currentYear by lazy { Calendar.getInstance(Locale.US)[1].toString().takeLast(2) }
|
||||
|
||||
private fun String?.toDate(): Long {
|
||||
this ?: return 0
|
||||
|
||||
val secondWords = listOf("second", "giây")
|
||||
val minuteWords = listOf("minute", "phút")
|
||||
val hourWords = listOf("hour", "giờ")
|
||||
val dayWords = listOf("day", "ngày")
|
||||
val agoWords = listOf("ago", "trước")
|
||||
|
||||
return try {
|
||||
if (this?.contains("ago", ignoreCase = true) == true) {
|
||||
if (agoWords.any { this.contains(it, ignoreCase = true) }) {
|
||||
val trimmedDate = this.substringBefore(" ago").removeSuffix("s").split(" ")
|
||||
val calendar = Calendar.getInstance()
|
||||
|
||||
when (trimmedDate[1]) {
|
||||
"day" -> calendar.apply { add(Calendar.DAY_OF_MONTH, -trimmedDate[0].toInt()) }
|
||||
"hour" -> calendar.apply { add(Calendar.HOUR_OF_DAY, -trimmedDate[0].toInt()) }
|
||||
"minute" -> calendar.apply { add(Calendar.MINUTE, -trimmedDate[0].toInt()) }
|
||||
"second" -> calendar.apply { add(Calendar.SECOND, -trimmedDate[0].toInt()) }
|
||||
when {
|
||||
dayWords.doesInclude(trimmedDate[1]) -> calendar.apply { add(Calendar.DAY_OF_MONTH, -trimmedDate[0].toInt()) }
|
||||
hourWords.doesInclude(trimmedDate[1]) -> calendar.apply { add(Calendar.HOUR_OF_DAY, -trimmedDate[0].toInt()) }
|
||||
minuteWords.doesInclude(trimmedDate[1]) -> calendar.apply { add(Calendar.MINUTE, -trimmedDate[0].toInt()) }
|
||||
secondWords.doesInclude(trimmedDate[1]) -> calendar.apply { add(Calendar.SECOND, -trimmedDate[0].toInt()) }
|
||||
}
|
||||
|
||||
calendar.timeInMillis
|
||||
} else {
|
||||
(if (gmtOffset == null) this?.substringAfterLast(" ") else "$this $gmtOffset")?.let {
|
||||
(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
|
||||
|
@ -138,7 +152,7 @@ abstract class WPComics(
|
|||
// MangaSum - timestamp sometimes doesn't have year (current year implied)
|
||||
dateFormat.parse("$it/$currentYear").time
|
||||
}
|
||||
} ?: 0L
|
||||
}
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
0L
|
||||
|
|
|
@ -4,6 +4,7 @@ import eu.kanade.tachiyomi.network.GET
|
|||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceFactory
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import java.text.SimpleDateFormat
|
||||
|
@ -16,7 +17,8 @@ class WPComicsFactory : SourceFactory {
|
|||
ManhuaPlus(),
|
||||
ManhuaES(),
|
||||
MangaSum(),
|
||||
XoxoComics()
|
||||
XoxoComics(),
|
||||
NhatTruyen()
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -61,3 +63,8 @@ private class XoxoComics : WPComics("XOXO Comics", "https://xoxocomics.com", "en
|
|||
}
|
||||
override fun pageListRequest(chapter: SChapter): Request = GET(baseUrl + "${chapter.url}/all")
|
||||
}
|
||||
|
||||
private class NhatTruyen : WPComics("NhatTruyen", "http://nhattruyen.com", "vi", SimpleDateFormat("dd/MM/yy", Locale.getDefault()), null) {
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = GET("$baseUrl/the-loai?keyword=$query&page=$page", headers)
|
||||
override fun imageRequest(page: Page): Request = GET(page.imageUrl!!, headersBuilder().add("Referer", baseUrl).build())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue