parent
dc8bb59564
commit
dae633bc1f
|
@ -5,7 +5,7 @@ ext {
|
||||||
appName = 'Tachiyomi: BlogTruyen'
|
appName = 'Tachiyomi: BlogTruyen'
|
||||||
pkgNameSuffix = 'vi.blogtruyen'
|
pkgNameSuffix = 'vi.blogtruyen'
|
||||||
extClass = '.BlogTruyen'
|
extClass = '.BlogTruyen'
|
||||||
extVersionCode = 6
|
extVersionCode = 7
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,24 +3,27 @@ package eu.kanade.tachiyomi.extension.vi.blogtruyen
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.source.model.Filter
|
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.MangasPage
|
||||||
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 eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||||
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
|
import okhttp3.Headers
|
||||||
import okhttp3.HttpUrl
|
import okhttp3.HttpUrl
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
|
import okhttp3.Response
|
||||||
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.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.Locale
|
||||||
|
|
||||||
|
|
||||||
class BlogTruyen : ParsedHttpSource() {
|
class BlogTruyen : ParsedHttpSource() {
|
||||||
|
|
||||||
override val name = "BlogTruyen"
|
override val name = "BlogTruyen"
|
||||||
|
|
||||||
override val baseUrl = "https://blogtruyen.com"
|
override val baseUrl = "https://blogtruyen.vn"
|
||||||
|
|
||||||
override val lang = "vi"
|
override val lang = "vi"
|
||||||
|
|
||||||
|
@ -28,6 +31,8 @@ class BlogTruyen : ParsedHttpSource() {
|
||||||
|
|
||||||
override val client: OkHttpClient = network.cloudflareClient
|
override val client: OkHttpClient = network.cloudflareClient
|
||||||
|
|
||||||
|
override fun headersBuilder(): Headers.Builder = super.headersBuilder().add("Referer", baseUrl)
|
||||||
|
|
||||||
override fun popularMangaSelector() = "div.list span.tiptip.fs-12.ellipsis"
|
override fun popularMangaSelector() = "div.list span.tiptip.fs-12.ellipsis"
|
||||||
|
|
||||||
override fun latestUpdatesSelector() = "section.list-mainpage.listview > div > div > div > div.fl-l"
|
override fun latestUpdatesSelector() = "section.list-mainpage.listview > div > div > div > div.fl-l"
|
||||||
|
@ -40,20 +45,37 @@ class BlogTruyen : ParsedHttpSource() {
|
||||||
return GET("$baseUrl/page-$page", headers)
|
return GET("$baseUrl/page-$page", headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun popularMangaFromElement(element: Element): SManga {
|
override fun popularMangaParse(response: Response): MangasPage {
|
||||||
|
val document = response.asJsoup()
|
||||||
|
|
||||||
|
val imgURL = document.select("img").map { it.attr("abs:src") }
|
||||||
|
val mangas = document.select(popularMangaSelector()).mapIndexed { index, element -> popularMangaFromElement(element, imgURL[index]) }
|
||||||
|
|
||||||
|
val hasNextPage = popularMangaNextPageSelector().let { selector ->
|
||||||
|
document.select(selector).first()
|
||||||
|
} != null
|
||||||
|
|
||||||
|
return MangasPage(mangas, hasNextPage)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun popularMangaFromElement(element: Element, imgURL: String): SManga {
|
||||||
val manga = SManga.create()
|
val manga = SManga.create()
|
||||||
element.select("a").first().let {
|
element.select("a").first().let {
|
||||||
manga.setUrlWithoutDomain(it.attr("href"))
|
manga.setUrlWithoutDomain(it.attr("href"))
|
||||||
manga.title = it.text().trim()
|
manga.title = it.text().trim()
|
||||||
|
manga.thumbnail_url = imgURL
|
||||||
}
|
}
|
||||||
return manga
|
return manga
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun popularMangaFromElement(element: Element): SManga = throw Exception("Not Used")
|
||||||
|
|
||||||
override fun latestUpdatesFromElement(element: Element): SManga {
|
override fun latestUpdatesFromElement(element: Element): SManga {
|
||||||
val manga = SManga.create()
|
val manga = SManga.create()
|
||||||
element.select("a").first().let {
|
element.select("a").first().let {
|
||||||
manga.setUrlWithoutDomain(it.attr("href"))
|
manga.setUrlWithoutDomain(it.attr("href"))
|
||||||
manga.title = element.select("img").first().attr("alt").toString().trim()
|
manga.title = element.select("img").first().attr("alt").toString().trim()
|
||||||
|
manga.thumbnail_url = element.select("img").first().attr("abs:src")
|
||||||
}
|
}
|
||||||
return manga
|
return manga
|
||||||
}
|
}
|
||||||
|
@ -77,19 +99,19 @@ class BlogTruyen : ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is Author -> {
|
is Author -> {
|
||||||
if (!filter.state.isEmpty()) {
|
if (filter.state.isNotEmpty()) {
|
||||||
aut = filter.state
|
aut = filter.state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (genres.isNotEmpty()) temp = temp + "/" + genres.joinToString(",")
|
if (genres.isNotEmpty()) temp = temp + "/" + genres.joinToString(",")
|
||||||
else temp = temp + "/-1"
|
else temp = "$temp/-1"
|
||||||
if (genresEx.isNotEmpty()) temp = temp + "/" + genresEx.joinToString(",")
|
if (genresEx.isNotEmpty()) temp = temp + "/" + genresEx.joinToString(",")
|
||||||
else temp = temp + "/-1"
|
else temp = "$temp/-1"
|
||||||
val url = HttpUrl.parse(temp)!!.newBuilder()
|
val url = HttpUrl.parse(temp)!!.newBuilder()
|
||||||
url.addQueryParameter("txt", query)
|
url.addQueryParameter("txt", query)
|
||||||
if (!aut.isEmpty()) url.addQueryParameter("aut", aut)
|
if (aut.isNotEmpty()) url.addQueryParameter("aut", aut)
|
||||||
url.addQueryParameter("p", page.toString())
|
url.addQueryParameter("p", page.toString())
|
||||||
return GET(url.toString().replace("m.", ""), headers)
|
return GET(url.toString().replace("m.", ""), headers)
|
||||||
}
|
}
|
||||||
|
@ -114,7 +136,7 @@ class BlogTruyen : ParsedHttpSource() {
|
||||||
return manga
|
return manga
|
||||||
}
|
}
|
||||||
|
|
||||||
fun parseStatus(status: String) = when {
|
private fun parseStatus(status: String) = when {
|
||||||
status.contains("Đang tiến hành") -> SManga.ONGOING
|
status.contains("Đang tiến hành") -> SManga.ONGOING
|
||||||
status.contains("Đã hoàn thành") -> SManga.COMPLETED
|
status.contains("Đã hoàn thành") -> SManga.COMPLETED
|
||||||
else -> SManga.UNKNOWN
|
else -> SManga.UNKNOWN
|
||||||
|
@ -129,7 +151,7 @@ class BlogTruyen : ParsedHttpSource() {
|
||||||
chapter.setUrlWithoutDomain(urlElement.attr("href"))
|
chapter.setUrlWithoutDomain(urlElement.attr("href"))
|
||||||
chapter.name = urlElement.attr("title").trim()
|
chapter.name = urlElement.attr("title").trim()
|
||||||
chapter.date_upload = element.select("span.publishedDate").first()?.text()?.let {
|
chapter.date_upload = element.select("span.publishedDate").first()?.text()?.let {
|
||||||
SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.ENGLISH).parse(it).time
|
SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.ENGLISH).parse(it)?.time ?: 0
|
||||||
} ?: 0
|
} ?: 0
|
||||||
return chapter
|
return chapter
|
||||||
}
|
}
|
||||||
|
@ -145,16 +167,8 @@ class BlogTruyen : ParsedHttpSource() {
|
||||||
return pages
|
return pages
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageRequest(page: Page): Request {
|
|
||||||
val imgHeaders = headersBuilder().add("Referer", page.url).build()
|
|
||||||
return GET(page.imageUrl!!, imgHeaders)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun imageUrlRequest(page: Page) = GET(page.url)
|
|
||||||
|
|
||||||
override fun imageUrlParse(document: Document) = ""
|
override fun imageUrlParse(document: Document) = ""
|
||||||
|
|
||||||
var status = arrayOf("Sao cũng được", "Đang tiến hành", "Đã hoàn thành", "Tạm ngưng")
|
|
||||||
|
|
||||||
private class Status : Filter.Select<String>("Status", arrayOf("Sao cũng được", "Đang tiến hành", "Đã hoàn thành", "Tạm ngưng"))
|
private class Status : Filter.Select<String>("Status", arrayOf("Sao cũng được", "Đang tiến hành", "Đã hoàn thành", "Tạm ngưng"))
|
||||||
private class Author : Filter.Text("Tác giả")
|
private class Author : Filter.Text("Tác giả")
|
||||||
|
|
Loading…
Reference in New Issue