vgperson: fix chapter name (#531)

This commit is contained in:
beerpsi 2024-01-23 22:15:11 +07:00 committed by Draff
parent 7ae0c27e21
commit d976177365
2 changed files with 51 additions and 56 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'vgperson'
extClass = '.Vgperson'
extVersionCode = 5
extVersionCode = 6
}
apply from: "$rootDir/common.gradle"

View File

@ -3,14 +3,13 @@ package eu.kanade.tachiyomi.extension.en.vgperson
import android.os.Build.VERSION
import eu.kanade.tachiyomi.AppInfo
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.asObservableSuccess
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 okhttp3.Headers
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.Response
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
@ -27,14 +26,12 @@ class Vgperson : ParsedHttpSource() {
override val baseUrl = "https://vgperson.com/other/mangaviewer.php"
private val userAgent = "Mozilla/5.0 " +
"(Android ${VERSION.RELEASE}; Mobile) " +
"Tachiyomi/${AppInfo.getVersionName()}"
private val userAgent =
"Mozilla/5.0 (Android ${VERSION.RELEASE}; Mobile) Tachiyomi/${AppInfo.getVersionName()}"
override fun headersBuilder() = Headers.Builder().apply {
add("User-Agent", userAgent)
add("Referer", baseUrl)
}
override fun headersBuilder() = super.headersBuilder()
.add("User-Agent", userAgent)
.add("Referer", baseUrl)
override fun popularMangaSelector() = ".content a[href^=?m]"
@ -48,63 +45,66 @@ class Vgperson : ParsedHttpSource() {
thumbnail_url = getCover(title)
}
override fun fetchMangaDetails(manga: SManga): Observable<SManga> =
client.newCall(mangaDetailsRequest(manga)).asObservableSuccess().map {
mangaDetailsParse(it).apply {
url = manga.url
title = manga.title
thumbnail_url = manga.thumbnail_url
initialized = true
}
}
override fun mangaDetailsParse(document: Document) = SManga.create().apply {
title = document.selectFirst(".title")!!.text()
thumbnail_url = getCover(title)
status = when (document.select("div.content .complete").text()) {
"(Complete)" -> SManga.COMPLETED
"(Series in Progress)" -> SManga.ONGOING
else -> SManga.UNKNOWN
}
description = document.select(".content").first()!!
.childNodes().drop(5).takeWhile {
it.nodeName() != "table"
}.joinToString("") {
if (it is TextNode) {
it.text()
} else {
when ((it as Element).tagName()) {
"br" -> "\n"
else -> it.text()
}
description = document.select(".content").first()!!.childNodes().drop(5).takeWhile {
it.nodeName() != "table"
}.joinToString("") {
if (it is TextNode) {
it.text()
} else {
when ((it as Element).tagName()) {
"br" -> "\n"
else -> it.text()
}
}
}
}
override fun chapterListSelector() = ".chaptertable tbody tr"
override fun chapterFromElement(element: Element) = SChapter.create().apply {
element.select("td > a").first()!!.let {
element.selectFirst("td > a")!!.let {
name = it.text()
setUrlWithoutDomain(it.attr("abs:href"))
url = it.attr("href")
}
// append the name if it exists & remove the occasional hyphen
element.select(".chaptername").first()?.let {
element.selectFirst("td:last-child:not(:first-child)")?.let {
name += " - ${it.text().substringAfter("- ")}"
}
val fullUrl = "$baseUrl$url".toHttpUrl()
// hardcode special chapter numbers for Three Days of Happiness
chapter_number = url.substringAfterLast("c=").toFloatOrNull()
?: (16.5f + "0.${url.substringAfterLast("b=")}".toFloat())
chapter_number = fullUrl.queryParameter("c")?.toFloat()
?: (16.5f + fullUrl.queryParameter("b")!!.toFloat() / 10)
scanlator = "vgperson"
date_upload = 0L
}
override fun chapterListParse(response: Response) =
super.chapterListParse(response).sortedByDescending(SChapter::chapter_number)
override fun chapterListParse(response: Response) = super.chapterListParse(response).reversed()
override fun pageListParse(document: Document) =
document.select("img").mapIndexed { i, img -> Page(i, "", img.attr("src")) }
document.select("img").mapIndexed { i, img ->
Page(i, imageUrl = img.attr("src"))
}
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> = fetchPopularManga(1)
.map { mp -> MangasPage(mp.mangas.filter { it.title.contains(query, ignoreCase = true) }, false) }
override fun fetchSearchManga(
page: Int,
query: String,
filters: FilterList,
): Observable<MangasPage> = fetchPopularManga(1).map { mp ->
MangasPage(
mp.mangas.filter { it.title.contains(query, ignoreCase = true) },
false,
)
}
// get known manga covers from imgur
private fun getCover(title: String) = when (title) {
@ -114,29 +114,24 @@ class Vgperson : ParsedHttpSource() {
else -> null
}?.let { "https://i.imgur.com/$it" }
override fun latestUpdatesSelector() = ""
override fun latestUpdatesSelector() = throw UnsupportedOperationException()
override fun latestUpdatesNextPageSelector(): String? = null
override fun latestUpdatesNextPageSelector() = throw UnsupportedOperationException()
override fun latestUpdatesRequest(page: Int) =
throw UnsupportedOperationException()
override fun latestUpdatesRequest(page: Int) = throw UnsupportedOperationException()
override fun latestUpdatesFromElement(element: Element) =
throw UnsupportedOperationException()
override fun latestUpdatesFromElement(element: Element) = throw UnsupportedOperationException()
override fun searchMangaSelector() = ""
override fun searchMangaSelector() = throw UnsupportedOperationException()
override fun searchMangaNextPageSelector(): String? = null
override fun searchMangaNextPageSelector() = throw UnsupportedOperationException()
override fun searchMangaRequest(page: Int, query: String, filters: FilterList) =
throw UnsupportedOperationException()
override fun searchMangaFromElement(element: Element) =
throw UnsupportedOperationException()
override fun searchMangaFromElement(element: Element) = throw UnsupportedOperationException()
override fun searchMangaParse(response: Response) =
throw UnsupportedOperationException()
override fun searchMangaParse(response: Response) = throw UnsupportedOperationException()
override fun imageUrlParse(document: Document) =
throw UnsupportedOperationException()
override fun imageUrlParse(document: Document) = throw UnsupportedOperationException()
}