WP Comics - add NetTruyen (#3522)

This commit is contained in:
Mike 2020-06-13 21:07:19 -04:00 committed by GitHub
parent 5087fdbf61
commit 67592c4ba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 96 additions and 2 deletions

View File

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

View File

@ -3,12 +3,14 @@ package eu.kanade.tachiyomi.extension.all.wpcomics
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceFactory import eu.kanade.tachiyomi.source.SourceFactory
import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Locale import java.util.Locale
import okhttp3.HttpUrl
import okhttp3.Request import okhttp3.Request
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
@ -18,7 +20,8 @@ class WPComicsFactory : SourceFactory {
ManhuaES(), ManhuaES(),
MangaSum(), MangaSum(),
XoxoComics(), XoxoComics(),
NhatTruyen() NhatTruyen(),
NetTruyen()
) )
} }
@ -68,3 +71,94 @@ private class NhatTruyen : WPComics("NhatTruyen", "http://nhattruyen.com", "vi",
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = GET("$baseUrl/the-loai?keyword=$query&page=$page", headers) 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()) override fun imageRequest(page: Page): Request = GET(page.imageUrl!!, headersBuilder().add("Referer", baseUrl).build())
} }
private class NetTruyen : WPComics("NetTruyen", "http://www.nettruyen.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"
)
}