Update WPComicsFactory.kt

Add new source: TruyenChon
This commit is contained in:
haruki-takeshi 2020-07-06 21:24:29 +07:00 committed by GitHub
parent be61615f4a
commit d2eb843215
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 91 additions and 0 deletions

View File

@ -182,3 +182,94 @@ private class NetTruyen : WPComics("NetTruyen", "http://www.nettruyen.com", "vi"
"xuyen-khong" to "Xuyên Không"
)
}
private class TruyenChon : WPComics("TruyenChon", "http://truyenchon.com", "vi", SimpleDateFormat("dd/MM/yy", Locale.getDefault()), null) {
override fun imageRequest(page: Page): Request = GET(page.imageUrl!!, headersBuilder().add("Referer", baseUrl).build())
// search and filters taken from old extension (1.2.5)
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
var url = HttpUrl.parse("$baseUrl/tim-truyen?")!!.newBuilder()
(if (filters.isEmpty()) getFilterList() else filters).forEach { filter ->
when (filter) {
is Genre -> {
url = if (filter.state == 0) url else
HttpUrl.parse(url.toString()
.replace("tim-truyen?",
"tim-truyen/${getGenreList().map { it.first }[filter.state]}?"))!!
.newBuilder()
}
is Status -> {
url.addQueryParameter("status", if (filter.state == 0) "hajau" else filter.state.toString())
url.addQueryParameter("sort", "0")
}
}
}
url.addQueryParameter("keyword", query)
return GET(url.toString(), headers)
}
private fun getStatusList() = arrayOf("Tất cả", "Đang tiến hành", "Đã hoàn thành", "Tạm ngừng")
private class Status(status: Array<String>) : Filter.Select<String>("Status", status)
private class Genre(genreList: Array<String>) : Filter.Select<String>("Thể loại", genreList)
override fun getFilterList() = FilterList(
Status(getStatusList()),
Genre(getGenreList().map { it.second }.toTypedArray())
)
private fun getGenreList() = arrayOf(
"tim-truyen" to "Tất cả",
"action" to "Action",
"adult" to "Adult",
"adventure" to "Adventure",
"anime" to "Anime",
"chuyen-sinh" to "Chuyển Sinh",
"comedy" to "Comedy",
"comic" to "Comic",
"cooking" to "Cooking",
"co-dai" to "Cổ Đại",
"doujinshi" to "Doujinshi",
"drama" to "Drama",
"dam-my" to "Đam Mỹ",
"ecchi" to "Ecchi",
"fantasy" to "Fantasy",
"gender-bender" to "Gender Bender",
"harem" to "Harem",
"historical" to "Historical",
"horror" to "Horror",
"josei" to "Josei",
"live-action" to "Live action",
"manga" to "Manga",
"manhua" to "Manhua",
"manhwa" to "Manhwa",
"martial-arts" to "Martial Arts",
"mature" to "Mature",
"mecha" to "Mecha",
"mystery" to "Mystery",
"ngon-tinh" to "Ngôn Tình",
"one-shot" to "One shot",
"psychological" to "Psychological",
"romance" to "Romance",
"school-life" to "School Life",
"sci-fi" to "Sci-fi",
"seinen" to "Seinen",
"shoujo" to "Shoujo",
"shoujo-ai" to "Shoujo Ai",
"shounen" to "Shounen",
"shounen-ai" to "Shounen Ai",
"slice-of-life" to "Slice of Life",
"smut" to "Smut",
"soft-yaoi" to "Soft Yaoi",
"soft-yuri" to "Soft Yuri",
"sports" to "Sports",
"supernatural" to "Supernatural",
"thieu-nhi" to "Thiếu Nhi",
"tragedy" to "Tragedy",
"trinh-tham" to "Trinh Thám",
"truyen-scan" to "Truyện scan",
"truyen-mau" to "Truyện Màu",
"webtoon" to "Webtoon",
"xuyen-khong" to "Xuyên Không"
)
}