Dua Leo Truyen: Update to new site (#1498)
* Dua Leo Truyen: Update URL * It's more than a simple URL change * Fix description
This commit is contained in:
parent
0624b1aa3e
commit
29a8d5ead9
|
@ -1,7 +1,7 @@
|
||||||
ext {
|
ext {
|
||||||
extName = "Dua Leo Truyen"
|
extName = "Dua Leo Truyen"
|
||||||
extClass = ".DuaLeoTruyen"
|
extClass = ".DuaLeoTruyen"
|
||||||
extVersionCode = 1
|
extVersionCode = 2
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,17 +14,19 @@ import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
class DuaLeoTruyen : ParsedHttpSource() {
|
class DuaLeoTruyen : ParsedHttpSource() {
|
||||||
|
|
||||||
override val name = "Dưa Leo Truyện"
|
override val name = "Dưa Leo Truyện"
|
||||||
|
|
||||||
override val baseUrl = "https://dualeotruyenme.com"
|
override val baseUrl = "https://dualeotruyennet.com"
|
||||||
|
|
||||||
override val lang = "vi"
|
override val lang = "vi"
|
||||||
|
|
||||||
override val supportsLatest = false
|
override val supportsLatest = true
|
||||||
|
|
||||||
override val client = network.cloudflareClient.newBuilder()
|
override val client = network.cloudflareClient.newBuilder()
|
||||||
.rateLimitHost(baseUrl.toHttpUrl(), 2)
|
.rateLimitHost(baseUrl.toHttpUrl(), 2)
|
||||||
|
@ -33,31 +35,31 @@ class DuaLeoTruyen : ParsedHttpSource() {
|
||||||
override fun headersBuilder() = super.headersBuilder()
|
override fun headersBuilder() = super.headersBuilder()
|
||||||
.add("Referer", "$baseUrl/")
|
.add("Referer", "$baseUrl/")
|
||||||
|
|
||||||
override fun popularMangaRequest(page: Int) = GET("$baseUrl/truyen-tranh-moi.html?page=$page", headers)
|
override fun popularMangaRequest(page: Int) = GET("$baseUrl/top-ngay.html?page=$page", headers)
|
||||||
|
|
||||||
override fun popularMangaSelector() = "div.product-grid > div"
|
override fun popularMangaSelector() = ".box_list > .li_truyen"
|
||||||
|
|
||||||
override fun popularMangaFromElement(element: Element) = SManga.create().apply {
|
override fun popularMangaFromElement(element: Element) = SManga.create().apply {
|
||||||
setUrlWithoutDomain(element.selectFirst("a")!!.attr("href"))
|
setUrlWithoutDomain(element.selectFirst("a")!!.attr("href"))
|
||||||
title = element.selectFirst(".comics-item-title")!!.text()
|
title = element.selectFirst(".name")!!.text()
|
||||||
thumbnail_url = element.selectFirst("img.card-img-top")?.absUrl("src")
|
thumbnail_url = element.selectFirst("img")?.absUrl("data-src")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun popularMangaNextPageSelector() = "ul.pagination li.page-item:contains(Next):not(.disabled)"
|
override fun popularMangaNextPageSelector() = "div.page_redirect > a.active:not(:last-child)"
|
||||||
|
|
||||||
override fun latestUpdatesRequest(page: Int) = throw UnsupportedOperationException()
|
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/truyen-moi-cap-nhat.html?page=$page", headers)
|
||||||
|
|
||||||
override fun latestUpdatesSelector() = throw UnsupportedOperationException()
|
override fun latestUpdatesSelector() = popularMangaSelector()
|
||||||
|
|
||||||
override fun latestUpdatesFromElement(element: Element) = throw UnsupportedOperationException()
|
override fun latestUpdatesFromElement(element: Element) = popularMangaFromElement(element)
|
||||||
|
|
||||||
override fun latestUpdatesNextPageSelector() = throw UnsupportedOperationException()
|
override fun latestUpdatesNextPageSelector() = popularMangaNextPageSelector()
|
||||||
|
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
val url = baseUrl.toHttpUrl().newBuilder().apply {
|
val url = baseUrl.toHttpUrl().newBuilder().apply {
|
||||||
if (query.isNotEmpty()) {
|
if (query.isNotEmpty()) {
|
||||||
addPathSegment("tim-kiem")
|
addPathSegment("tim-kiem.html")
|
||||||
addQueryParameter("search", query)
|
addQueryParameter("key", query)
|
||||||
} else {
|
} else {
|
||||||
val genreFilter = filters.ifEmpty { getFilterList() }
|
val genreFilter = filters.ifEmpty { getFilterList() }
|
||||||
.filterIsInstance<GenreFilter>()
|
.filterIsInstance<GenreFilter>()
|
||||||
|
@ -80,33 +82,35 @@ class DuaLeoTruyen : ParsedHttpSource() {
|
||||||
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
|
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
|
||||||
|
|
||||||
override fun mangaDetailsParse(document: Document) = SManga.create().apply {
|
override fun mangaDetailsParse(document: Document) = SManga.create().apply {
|
||||||
val statusText = document.selectFirst(".card-body dt:contains(Trạng thái) + dd")?.text()
|
val statusText = document.selectFirst(".info-item:has(.fa-rss)")
|
||||||
|
?.text()
|
||||||
|
?.removePrefix("Tình trang: ")
|
||||||
|
|
||||||
title = document.selectFirst(".card-title")!!.text()
|
title = document.selectFirst(".box_info_right h1")!!.text()
|
||||||
description = document.selectFirst(".comics-description .inner")?.text()
|
description = document.selectFirst(".story-detail-info")?.text()
|
||||||
genre = document.select(".cate-item").joinToString { it.text() }
|
genre = document.select("ul.list-tag-story li a").joinToString { it.text() }
|
||||||
status = when (statusText) {
|
status = when (statusText) {
|
||||||
"Đang phát hành" -> SManga.ONGOING
|
"Đang cập nhật" -> SManga.ONGOING
|
||||||
"Đã đủ bộ" -> SManga.COMPLETED
|
"Full" -> SManga.COMPLETED
|
||||||
else -> SManga.UNKNOWN
|
else -> SManga.UNKNOWN
|
||||||
}
|
}
|
||||||
thumbnail_url = document.selectFirst("img.img-fluid")?.absUrl("src")
|
thumbnail_url = document.selectFirst(".box_info_left img")?.absUrl("src")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun chapterListSelector() = ".list-chapters > .item"
|
override fun chapterListSelector() = ".list-chapters .chapter-item"
|
||||||
|
|
||||||
override fun chapterFromElement(element: Element) = SChapter.create().apply {
|
override fun chapterFromElement(element: Element) = SChapter.create().apply {
|
||||||
element.selectFirst(".episode-title a")!!.let {
|
element.selectFirst(".chap_name a")!!.let {
|
||||||
setUrlWithoutDomain(it.attr("href"))
|
setUrlWithoutDomain(it.attr("href"))
|
||||||
name = it.text()
|
name = it.text()
|
||||||
}
|
}
|
||||||
date_upload = element.selectFirst(".episode-date span")?.let { parseRelativeDate(it.text()) } ?: 0L
|
date_upload = element.selectFirst(".chap_update")?.let { parseDate(it.text()) } ?: 0L
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
countView(document)
|
countView(document)
|
||||||
|
|
||||||
return document.select("img.chapter-img").mapIndexed { i, it ->
|
return document.select(".content_view_chap img").mapIndexed { i, it ->
|
||||||
Page(i, imageUrl = it.absUrl("data-original"))
|
Page(i, imageUrl = it.absUrl("data-original"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,22 +123,25 @@ class DuaLeoTruyen : ParsedHttpSource() {
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun countView(document: Document) {
|
private fun countView(document: Document) {
|
||||||
val chapterId = document.selectFirst("input#chapter_id")!!.`val`()
|
val chapterId = document.selectFirst("input[name=chap]")!!.`val`()
|
||||||
val comicsId = document.selectFirst("input#comics_id")!!.`val`()
|
val comicsId = document.selectFirst("input[name=truyen]")!!.`val`()
|
||||||
val token = document.selectFirst("meta[name=_token]")!!.attr("content")
|
|
||||||
val form = FormBody.Builder()
|
val form = FormBody.Builder()
|
||||||
.add("_token", token)
|
.add("action", "update_view_chap")
|
||||||
.add("comics_id", comicsId)
|
.add("truyen", comicsId)
|
||||||
.add("chapter_id", chapterId)
|
.add("chap", chapterId)
|
||||||
.build()
|
.build()
|
||||||
val request = POST("$baseUrl/ajax/increase-view-chapter", headers, form)
|
val request = POST("$baseUrl/process.php", headers, form)
|
||||||
|
|
||||||
client.newCall(request).execute().close()
|
client.newCall(request).execute().close()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseRelativeDate(date: String): Long {
|
private fun parseDate(date: String): Long {
|
||||||
val dateParts = date.split(" ")
|
val dateParts = date.split(" ")
|
||||||
|
|
||||||
|
if (dateParts.size == 1) {
|
||||||
|
return DATE_FORMAT.parse(date)!!.time
|
||||||
|
}
|
||||||
|
|
||||||
val calendar = Calendar.getInstance().apply {
|
val calendar = Calendar.getInstance().apply {
|
||||||
val amount = -dateParts[0].toInt()
|
val amount = -dateParts[0].toInt()
|
||||||
val field = when (dateParts[1]) {
|
val field = when (dateParts[1]) {
|
||||||
|
@ -156,39 +163,48 @@ class DuaLeoTruyen : ParsedHttpSource() {
|
||||||
|
|
||||||
private class Genre(val name: String, val path: String)
|
private class Genre(val name: String, val path: String)
|
||||||
|
|
||||||
private class GenreFilter(val genre: List<Genre>) : Filter.Select<String>("Thể loại", genre.map { it.name }.toTypedArray())
|
private class GenreFilter(val genre: List<Genre>) : Filter.Select<String>(
|
||||||
|
"Thể loại",
|
||||||
|
genre.map { it.name }.toTypedArray(),
|
||||||
|
)
|
||||||
|
|
||||||
// copy([...document.querySelectorAll(".dropdown-menu .dropdown-item")].map((e) => `Genre("${e.textContent.trim()}", "${new URL(e).pathname.replace("/", "")}"),`).join("\n"))
|
// copy([...document.querySelectorAll(".sub_menu .li_sub a")].map((e) => `Genre("${e.textContent.trim()}", "${new URL(e).pathname.replace("/", "")}"),`).join("\n"))
|
||||||
// "Tất cả" and "Truyện full" are custom genres that are lumped in to make my life easier.
|
// "Tất cả" and "Truyện full" are custom genres that are lumped in to make my life easier.
|
||||||
private fun getGenreList() = listOf(
|
private fun getGenreList() = listOf(
|
||||||
Genre("Tất cả", "truyen-tranh-moi.html"),
|
Genre("Top Ngày", "top-ngay.html"),
|
||||||
|
Genre("Top Tuần", "top-tuan.html"),
|
||||||
|
Genre("Top Tháng", "top-thang.html"),
|
||||||
|
Genre("Top Năm", "top-nam.html"),
|
||||||
Genre("Truyện full", "truyen-hoan-thanh.html"),
|
Genre("Truyện full", "truyen-hoan-thanh.html"),
|
||||||
Genre("18+", "the-loai/18-.html"),
|
Genre("Truyện mới", "truyen-tranh-moi.html"),
|
||||||
Genre("ABO", "the-loai/abo.html"),
|
|
||||||
Genre("Bách Hợp", "the-loai/bach-hop.html"),
|
|
||||||
Genre("BoyLove", "the-loai/boylove.html"),
|
|
||||||
Genre("Chuyển Sinh", "the-loai/chuyen-sinh.html"),
|
|
||||||
Genre("Cổ Đại", "the-loai/co-dai.html"),
|
|
||||||
Genre("Doujinshi", "the-loai/doujinshi.html"),
|
|
||||||
Genre("Drama", "the-loai/drama.html"),
|
|
||||||
Genre("Đam Mỹ", "the-loai/dam-my.html"),
|
|
||||||
Genre("Echi", "the-loai/echi.html"),
|
|
||||||
Genre("GirlLove", "the-loai/girllove.html"),
|
|
||||||
Genre("Hài Hước", "the-loai/hai-huoc.html"),
|
|
||||||
Genre("Hành Động", "the-loai/hanh-dong.html"),
|
|
||||||
Genre("Harem", "the-loai/harem.html"),
|
|
||||||
Genre("Hentai", "the-loai/hentai.html"),
|
|
||||||
Genre("Kịch Tính", "the-loai/kich-tinh.html"),
|
|
||||||
Genre("Lãng Mạn", "the-loai/lang-man.html"),
|
|
||||||
Genre("Manga", "the-loai/manga.html"),
|
Genre("Manga", "the-loai/manga.html"),
|
||||||
Genre("Manhua", "the-loai/manhua.html"),
|
Genre("Manhua", "the-loai/manhua.html"),
|
||||||
Genre("Manhwa", "the-loai/manhwa.html"),
|
Genre("Manhwa", "the-loai/manhwa.html"),
|
||||||
Genre("Người Thú", "the-loai/nguoi-thu.html"),
|
Genre("18+", "the-loai/18-.html"),
|
||||||
Genre("Oneshot", "the-loai/oneshot.html"),
|
Genre("Đam Mỹ", "the-loai/dam-my.html"),
|
||||||
Genre("Phiêu Lưu", "the-loai/phieu-luu.html"),
|
Genre("Harem", "the-loai/harem.html"),
|
||||||
Genre("Tình Cảm", "the-loai/tinh-cam.html"),
|
|
||||||
Genre("Truyện Màu", "the-loai/truyen-mau.html"),
|
Genre("Truyện Màu", "the-loai/truyen-mau.html"),
|
||||||
|
Genre("BoyLove", "the-loai/boylove.html"),
|
||||||
|
Genre("GirlLove", "the-loai/girllove.html"),
|
||||||
|
Genre("Phiêu lưu", "the-loai/phieu-luu.html"),
|
||||||
Genre("Yaoi", "the-loai/yaoi.html"),
|
Genre("Yaoi", "the-loai/yaoi.html"),
|
||||||
|
Genre("Hài Hước", "the-loai/hai-huoc.html"),
|
||||||
|
Genre("Bách Hợp", "the-loai/bach-hop.html"),
|
||||||
|
Genre("Chuyển Sinh", "the-loai/chuyen-sinh.html"),
|
||||||
|
Genre("Drama", "the-loai/drama.html"),
|
||||||
|
Genre("Hành Động", "the-loai/hanh-dong.html"),
|
||||||
|
Genre("Kịch Tính", "the-loai/kich-tinh.html"),
|
||||||
|
Genre("Cổ Đại", "the-loai/co-dai.html"),
|
||||||
|
Genre("Echi", "the-loai/echi.html"),
|
||||||
|
Genre("Hentai", "the-loai/hentai.html"),
|
||||||
|
Genre("Lãng Mạn", "the-loai/lang-man.html"),
|
||||||
|
Genre("Người Thú", "the-loai/nguoi-thu.html"),
|
||||||
|
Genre("Tình Cảm", "the-loai/tinh-cam.html"),
|
||||||
Genre("Yuri", "the-loai/yuri.html"),
|
Genre("Yuri", "the-loai/yuri.html"),
|
||||||
|
Genre("Oneshot", "the-loai/oneshot.html"),
|
||||||
|
Genre("Doujinshi", "the-loai/doujinshi.html"),
|
||||||
|
Genre("ABO", "the-loai/abo.html"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val DATE_FORMAT = SimpleDateFormat("dd/MM/yyyy", Locale.ROOT)
|
||||||
|
|
Loading…
Reference in New Issue