Fix wrong title parsing at Golden Mangás. (#3082)
This commit is contained in:
parent
d418ae93b2
commit
7cfd2858c9
|
@ -5,7 +5,7 @@ ext {
|
|||
appName = 'Tachiyomi: Golden Mangás'
|
||||
pkgNameSuffix = 'pt.goldenmangas'
|
||||
extClass = '.GoldenMangas'
|
||||
extVersionCode = 3
|
||||
extVersionCode = 4
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class GoldenMangas : ParsedHttpSource() {
|
|||
|
||||
override val name = "Golden Mangás"
|
||||
|
||||
override val baseUrl = "https://goldenmanga.top"
|
||||
override val baseUrl = "https://goldenmangas.online"
|
||||
|
||||
override val lang = "pt-BR"
|
||||
|
||||
|
@ -43,11 +43,11 @@ class GoldenMangas : ParsedHttpSource() {
|
|||
|
||||
override fun popularMangaRequest(page: Int): Request = GET(baseUrl, headers)
|
||||
|
||||
override fun popularMangaSelector(): String = "div.itemmanga"
|
||||
override fun popularMangaSelector(): String = "div#maisLidos div.itemmanga"
|
||||
|
||||
override fun popularMangaFromElement(element: Element): SManga = SManga.create().apply {
|
||||
title = removeLanguage(element.select("h3").first().text())
|
||||
thumbnail_url = baseUrl + element.select("img").first()?.attr("src")
|
||||
title = element.select("h3").first().text().withoutLanguage()
|
||||
thumbnail_url = element.select("img").first()?.attr("abs:src")
|
||||
url = element.attr("href")
|
||||
}
|
||||
|
||||
|
@ -62,10 +62,10 @@ class GoldenMangas : ParsedHttpSource() {
|
|||
|
||||
override fun latestUpdatesFromElement(element: Element): SManga = SManga.create().apply {
|
||||
val infoElement = element.select("div.col-sm-10.col-xs-8 h3").first()
|
||||
val thumb = element.select("a:first-child div img").first().attr("src")
|
||||
val thumb = element.select("a:first-child div img").first().attr("abs:src")
|
||||
|
||||
title = removeLanguage(infoElement.text())
|
||||
thumbnail_url = baseUrl + thumb.replace("w=80&h=120", "w=380&h=600")
|
||||
title = infoElement.text().withoutLanguage()
|
||||
thumbnail_url = thumb.replace("w=80&h=120", "w=380&h=600")
|
||||
url = element.select("a:first-child").attr("href")
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,8 @@ class GoldenMangas : ParsedHttpSource() {
|
|||
override fun searchMangaSelector() = "div.mangas.col-lg-2 a"
|
||||
|
||||
override fun searchMangaFromElement(element: Element): SManga = SManga.create().apply {
|
||||
title = removeLanguage(element.select("h3").first().text())
|
||||
thumbnail_url = baseUrl + element.select("img").first().attr("src")
|
||||
title = element.select("h3").first().text().withoutLanguage()
|
||||
thumbnail_url = element.select("img").first().attr("abs:src")
|
||||
url = element.attr("href")
|
||||
}
|
||||
|
||||
|
@ -97,15 +97,15 @@ class GoldenMangas : ParsedHttpSource() {
|
|||
val firstColumn = infoElement.select("div.col-sm-4.text-right > img").first()
|
||||
val secondColumn = infoElement.select("div.col-sm-8").first()
|
||||
|
||||
title = removeLanguage(secondColumn.select("h2:eq(1)").text())
|
||||
author = removeLabel(secondColumn.select("h5:eq(3)").text())
|
||||
artist = removeLabel(secondColumn.select("h5:eq(4)").text())
|
||||
title = secondColumn.select("h2:eq(0)").text().withoutLanguage()
|
||||
author = secondColumn.select("h5:eq(3)")!!.text().withoutLabel()
|
||||
artist = secondColumn.select("h5:eq(4)")!!.text().withoutLabel()
|
||||
genre = secondColumn.select("h5:eq(2) a")
|
||||
.filter { it.text().isNotEmpty() }
|
||||
.joinToString { it.text() }
|
||||
status = parseStatus(secondColumn.select("h5:eq(5) a").text().orEmpty())
|
||||
description = document.select("#manga_capitulo_descricao").text()
|
||||
thumbnail_url = baseUrl + firstColumn.attr("src")
|
||||
thumbnail_url = firstColumn.attr("abs:src")
|
||||
}
|
||||
|
||||
private fun parseStatus(status: String) = when {
|
||||
|
@ -120,36 +120,48 @@ class GoldenMangas : ParsedHttpSource() {
|
|||
val firstColumn = element.select("a > div.col-sm-5")
|
||||
val secondColumn = element.select("div.col-sm-5.text-right a[href^='http']")
|
||||
|
||||
name = firstColumn.select("div.col-sm-5").first().text().substringBefore("(").trim()
|
||||
name = firstColumn.select("div.col-sm-5").first().text()
|
||||
.substringBefore("(").trim()
|
||||
scanlator = secondColumn?.joinToString { it.text() }
|
||||
date_upload = parseChapterDate(firstColumn.select("div.col-sm-5 span[style]").first().text())
|
||||
date_upload = DATE_FORMATTER.tryParseTime(firstColumn.select("div.col-sm-5 span[style]").first().text())
|
||||
url = element.select("a").first().attr("href")
|
||||
}
|
||||
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
val chapImages = document.select("div.col-sm-12[id^='capitulos_images']").first()
|
||||
val pages = chapImages.select("img[pag]")
|
||||
val chapterUrl = document.location()
|
||||
val chapterImages = document.select("div.col-sm-12[id^='capitulos_images']").first()
|
||||
|
||||
return pages
|
||||
.mapIndexed { i, element -> Page(i, "", baseUrl + element.attr("src")) }
|
||||
return chapterImages.select("img[pag]")
|
||||
.mapIndexed { i, element -> Page(i, chapterUrl, element.attr("abs:src")) }
|
||||
}
|
||||
|
||||
override fun imageUrlParse(document: Document) = ""
|
||||
|
||||
private fun removeLanguage(text: String): String = text.replace(FLAG_REGEX, "").trim()
|
||||
override fun imageRequest(page: Page): Request {
|
||||
val newHeaders = headersBuilder()
|
||||
.set("Referer", page.url)
|
||||
.build()
|
||||
|
||||
private fun removeLabel(text: String?): String = text!!.substringAfter(":").trim()
|
||||
return GET(page.imageUrl!!, newHeaders)
|
||||
}
|
||||
|
||||
private fun parseChapterDate(date: String): Long {
|
||||
private fun String.withoutLanguage(): String = replace(FLAG_REGEX, "").trim()
|
||||
|
||||
private fun String.withoutLabel(): String = substringAfter(":").trim()
|
||||
|
||||
private fun SimpleDateFormat.tryParseTime(date: String): Long {
|
||||
return try {
|
||||
SimpleDateFormat("(dd/MM/yyyy)", Locale.ENGLISH).parse(date).time
|
||||
parse(date).time
|
||||
} catch (e: ParseException) {
|
||||
0L
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36"
|
||||
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
|
||||
|
||||
private val FLAG_REGEX = "\\((Pt[-/]br|Scan)\\)".toRegex(RegexOption.IGNORE_CASE)
|
||||
|
||||
private val DATE_FORMATTER by lazy { SimpleDateFormat("(dd/MM/yyyy)", Locale.ENGLISH) }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue