Blog truyen - Thumbnail Fix (#2473)

Blog truyen - Thumbnail Fix
This commit is contained in:
happywillow0 2020-03-22 09:21:53 -04:00 committed by GitHub
parent dc8bb59564
commit dae633bc1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 19 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: BlogTruyen'
pkgNameSuffix = 'vi.blogtruyen'
extClass = '.BlogTruyen'
extVersionCode = 6
extVersionCode = 7
libVersion = '1.2'
}

View File

@ -3,24 +3,27 @@ package eu.kanade.tachiyomi.extension.vi.blogtruyen
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.Filter
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.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Headers
import okhttp3.HttpUrl
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import java.text.SimpleDateFormat
import java.util.*
import java.util.Locale
class BlogTruyen : ParsedHttpSource() {
override val name = "BlogTruyen"
override val baseUrl = "https://blogtruyen.com"
override val baseUrl = "https://blogtruyen.vn"
override val lang = "vi"
@ -28,6 +31,8 @@ class BlogTruyen : ParsedHttpSource() {
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 latestUpdatesSelector() = "section.list-mainpage.listview > div > div > div > div.fl-l"
@ -40,20 +45,37 @@ class BlogTruyen : ParsedHttpSource() {
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()
element.select("a").first().let {
manga.setUrlWithoutDomain(it.attr("href"))
manga.title = it.text().trim()
manga.thumbnail_url = imgURL
}
return manga
}
override fun popularMangaFromElement(element: Element): SManga = throw Exception("Not Used")
override fun latestUpdatesFromElement(element: Element): SManga {
val manga = SManga.create()
element.select("a").first().let {
manga.setUrlWithoutDomain(it.attr("href"))
manga.title = element.select("img").first().attr("alt").toString().trim()
manga.thumbnail_url = element.select("img").first().attr("abs:src")
}
return manga
}
@ -77,19 +99,19 @@ class BlogTruyen : ParsedHttpSource() {
}
}
is Author -> {
if (!filter.state.isEmpty()) {
if (filter.state.isNotEmpty()) {
aut = filter.state
}
}
}
}
if (genres.isNotEmpty()) temp = temp + "/" + genres.joinToString(",")
else temp = temp + "/-1"
else temp = "$temp/-1"
if (genresEx.isNotEmpty()) temp = temp + "/" + genresEx.joinToString(",")
else temp = temp + "/-1"
else temp = "$temp/-1"
val url = HttpUrl.parse(temp)!!.newBuilder()
url.addQueryParameter("txt", query)
if (!aut.isEmpty()) url.addQueryParameter("aut", aut)
if (aut.isNotEmpty()) url.addQueryParameter("aut", aut)
url.addQueryParameter("p", page.toString())
return GET(url.toString().replace("m.", ""), headers)
}
@ -114,7 +136,7 @@ class BlogTruyen : ParsedHttpSource() {
return manga
}
fun parseStatus(status: String) = when {
private fun parseStatus(status: String) = when {
status.contains("Đang tiến hành") -> SManga.ONGOING
status.contains("Đã hoàn thành") -> SManga.COMPLETED
else -> SManga.UNKNOWN
@ -129,7 +151,7 @@ class BlogTruyen : ParsedHttpSource() {
chapter.setUrlWithoutDomain(urlElement.attr("href"))
chapter.name = urlElement.attr("title").trim()
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
return chapter
}
@ -145,16 +167,8 @@ class BlogTruyen : ParsedHttpSource() {
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) = ""
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 Author : Filter.Text("Tác giả")