Fix chapter images not loading at Yes Mangás. (#3968)
This commit is contained in:
parent
274d5fa8ac
commit
bc514f7bd3
@ -5,7 +5,7 @@ ext {
|
|||||||
extName = 'YES Mangás'
|
extName = 'YES Mangás'
|
||||||
pkgNameSuffix = 'pt.yesmangas'
|
pkgNameSuffix = 'pt.yesmangas'
|
||||||
extClass = '.YesMangas'
|
extClass = '.YesMangas'
|
||||||
extVersionCode = 3
|
extVersionCode = 4
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
|||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
import okhttp3.HttpUrl
|
import okhttp3.HttpUrl
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import org.jsoup.Jsoup
|
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import org.jsoup.select.Elements
|
||||||
|
|
||||||
class YesMangas : ParsedHttpSource() {
|
class YesMangas : ParsedHttpSource() {
|
||||||
|
|
||||||
@ -36,9 +36,8 @@ class YesMangas : ParsedHttpSource() {
|
|||||||
override fun popularMangaSelector(): String = "div#destaques div.three.columns a.img"
|
override fun popularMangaSelector(): String = "div#destaques div.three.columns a.img"
|
||||||
|
|
||||||
override fun popularMangaFromElement(element: Element): SManga = SManga.create().apply {
|
override fun popularMangaFromElement(element: Element): SManga = SManga.create().apply {
|
||||||
title = element.attr("title").replace(LANG_REGEX, "")
|
title = element.attr("title").withoutLanguage()
|
||||||
thumbnail_url = element.select("img").attr("data-path")
|
thumbnail_url = element.select("img").attr("data-path").toLargeUrl()
|
||||||
.replace("xmedium", "xlarge")
|
|
||||||
url = element.attr("href")
|
url = element.attr("href")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,9 +48,8 @@ class YesMangas : ParsedHttpSource() {
|
|||||||
override fun latestUpdatesSelector(): String = "div#lancamentos table.u-full-width tbody tr td:eq(0) a"
|
override fun latestUpdatesSelector(): String = "div#lancamentos table.u-full-width tbody tr td:eq(0) a"
|
||||||
|
|
||||||
override fun latestUpdatesFromElement(element: Element): SManga = SManga.create().apply {
|
override fun latestUpdatesFromElement(element: Element): SManga = SManga.create().apply {
|
||||||
title = element.attr("title").replace(LANG_REGEX, "")
|
title = element.attr("title").withoutLanguage()
|
||||||
thumbnail_url = element.select("img").attr("data-path")
|
thumbnail_url = element.select("img").attr("data-path").toLargeUrl()
|
||||||
.replace("xmedium", "xlarge")
|
|
||||||
setUrlWithoutDomain(element.attr("href"))
|
setUrlWithoutDomain(element.attr("href"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,67 +65,74 @@ class YesMangas : ParsedHttpSource() {
|
|||||||
override fun searchMangaSelector(): String = "tbody#leituras tr td:eq(0) a"
|
override fun searchMangaSelector(): String = "tbody#leituras tr td:eq(0) a"
|
||||||
|
|
||||||
override fun searchMangaFromElement(element: Element): SManga = SManga.create().apply {
|
override fun searchMangaFromElement(element: Element): SManga = SManga.create().apply {
|
||||||
title = element.select("img").attr("alt").replace(LANG_REGEX, "")
|
title = element.attr("title").withoutLanguage()
|
||||||
thumbnail_url = element.select("img").attr("data-path")
|
thumbnail_url = element.select("img").attr("data-path").toLargeUrl()
|
||||||
.replace("medium", "xlarge")
|
|
||||||
setUrlWithoutDomain(element.attr("href"))
|
setUrlWithoutDomain(element.attr("href"))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun searchMangaNextPageSelector(): String? = null
|
override fun searchMangaNextPageSelector(): String? = null
|
||||||
|
|
||||||
override fun mangaDetailsParse(document: Document): SManga {
|
override fun mangaDetailsParse(document: Document): SManga = SManga.create().apply {
|
||||||
val container = document.select("div#descricao")
|
val container = document.select("div#descricao").first()
|
||||||
val statusEl = container.select("ul li:contains(Status)")
|
|
||||||
val authorEl = container.select("ul li:contains(Autor)")
|
|
||||||
val artistEl = container.select("ul li:contains(Desenho)")
|
|
||||||
val genresEl = container.select("ul li:contains(Categorias)")
|
|
||||||
val synopsis = container.select("article")
|
|
||||||
|
|
||||||
return SManga.create().apply {
|
author = container.select("ul li:contains(Autor)").textWithoutLabel()
|
||||||
status = parseStatus(removeLabel(statusEl.text()))
|
artist = container.select("ul li:contains(Desenho)").textWithoutLabel()
|
||||||
author = removeLabel(authorEl.text())
|
genre = container.select("ul li:contains(Categorias)").textWithoutLabel()
|
||||||
artist = removeLabel(artistEl.text())
|
status = container.select("ul li:contains(Status)").text().toStatus()
|
||||||
description = synopsis.text().substringBefore("Relacionados")
|
description = container.select("article").text()
|
||||||
genre = removeLabel(genresEl.text())
|
.substringBefore("Relacionados")
|
||||||
thumbnail_url = container.select("img").first().attr("data-path")
|
thumbnail_url = container.select("img").first()
|
||||||
}
|
.attr("data-path")
|
||||||
}
|
.toLargeUrl()
|
||||||
|
|
||||||
private fun parseStatus(status: String) = when {
|
|
||||||
status.contains("Completo") -> SManga.COMPLETED
|
|
||||||
status.contains("Ativo") -> SManga.ONGOING
|
|
||||||
else -> SManga.UNKNOWN
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun chapterListSelector(): String = "div#capitulos a.button"
|
override fun chapterListSelector(): String = "div#capitulos a.button"
|
||||||
|
|
||||||
override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply {
|
override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply {
|
||||||
setUrlWithoutDomain(element.attr("href"))
|
|
||||||
chapter_number = element.text().toFloatOrNull() ?: 1f
|
|
||||||
name = element.attr("title").substringAfter(" - ")
|
name = element.attr("title").substringAfter(" - ")
|
||||||
|
chapter_number = element.text().toFloatOrNull() ?: 1f
|
||||||
|
setUrlWithoutDomain(element.attr("href"))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun pageListRequest(chapter: SChapter): Request {
|
||||||
|
val newHeaders = headersBuilder()
|
||||||
|
.set("Referer", baseUrl + chapter.url.substringBeforeLast("/"))
|
||||||
|
.build()
|
||||||
|
|
||||||
|
return GET(baseUrl + chapter.url, newHeaders)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
val script = document.select("script").last().data()
|
return document.select("div.read-slideshow a img")
|
||||||
val images = script.substringAfter(SCRIPT_BEGIN).substringBefore(SCRIPT_END)
|
.mapIndexed { i, el -> Page(i, document.location(), el.attr("src")) }
|
||||||
.replace(SCRIPT_REGEX.toRegex(), "")
|
|
||||||
|
|
||||||
val newDocument = Jsoup.parse(images)
|
|
||||||
|
|
||||||
return newDocument.select("a img")
|
|
||||||
.mapIndexed { i, el -> Page(i, "", el.attr("src")) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageUrlParse(document: Document): String = ""
|
override fun imageUrlParse(document: Document): String = ""
|
||||||
|
|
||||||
private fun removeLabel(info: String) = info.substringAfter(":")
|
override fun imageRequest(page: Page): Request {
|
||||||
|
val newHeaders = headersBuilder()
|
||||||
|
.set("Referer", page.url)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
return GET(page.imageUrl!!, newHeaders)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun String.withoutLanguage(): String = replace(LANG_REGEX, "")
|
||||||
|
|
||||||
|
private fun String.toLargeUrl(): String = replace(IMAGE_REGEX, ".")
|
||||||
|
|
||||||
|
private fun Elements.textWithoutLabel(): String = text()!!.substringAfter(":").trim()
|
||||||
|
|
||||||
|
private fun String.toStatus() = when {
|
||||||
|
contains("Completo") -> SManga.COMPLETED
|
||||||
|
contains("Ativo") -> SManga.ONGOING
|
||||||
|
else -> SManga.UNKNOWN
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
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/84.0.4147.105 Safari/537.36"
|
||||||
private val LANG_REGEX = "( )?\\((PT-)?BR\\)".toRegex()
|
|
||||||
|
|
||||||
private const val SCRIPT_BEGIN = "var images = ["
|
private val LANG_REGEX = "( )?\\((PT-)?BR\\)".toRegex()
|
||||||
private const val SCRIPT_END = "];"
|
private val IMAGE_REGEX = "_(small|medium|xmedium|xlarge)\\.".toRegex()
|
||||||
private const val SCRIPT_REGEX = "[\",]"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user