Revert GoldenMangás to previous design. (#4359)

This commit is contained in:
Alessandro Jean 2020-09-12 18:18:14 -03:00 committed by GitHub
parent adc47a56b9
commit 4ca49a5c08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 66 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Golden Mangás'
pkgNameSuffix = 'pt.goldenmangas'
extClass = '.GoldenMangas'
extVersionCode = 7
extVersionCode = 8
libVersion = '1.2'
}

View File

@ -6,7 +6,6 @@ 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 java.text.ParseException
import java.text.SimpleDateFormat
import java.util.Locale
@ -15,7 +14,6 @@ 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
@ -47,15 +45,12 @@ class GoldenMangas : ParsedHttpSource() {
override fun popularMangaRequest(page: Int): Request = GET(baseUrl, headers)
override fun popularMangaSelector(): String =
"div.section:contains(Mais Lídos) + div.section div.manga_item div.andro_product-thumb a"
override fun popularMangaSelector(): String = "div#maisLidos div.itemmanga"
override fun popularMangaFromElement(element: Element): SManga = SManga.create().apply {
title = element.select("img").attr("alt")
.substringAfter("online ")
.withoutLanguage()
thumbnail_url = element.select("img").attr("abs:data-src")
url = "/" + element.attr("href")
title = element.select("h3").text().withoutLanguage()
thumbnail_url = element.select("img").attr("abs:src")
url = element.attr("href")
}
override fun popularMangaNextPageSelector(): String? = null
@ -65,91 +60,69 @@ class GoldenMangas : ParsedHttpSource() {
return GET("$baseUrl$path", headers)
}
override fun latestUpdatesSelector() = "div.row.atualizacoes div.manga_item div.andro_product"
override fun latestUpdatesSelector() = "div.col-sm-12.atualizacao > div.row"
override fun latestUpdatesFromElement(element: Element): SManga = SManga.create().apply {
val titleElement = element.select("h5.andro_product-title > a")
val infoElement = element.select("div.col-sm-10.col-xs-8 h3").first()
val thumbElement = element.select("a:first-child div img").first()
title = titleElement.text().withoutLanguage()
thumbnail_url = element.select("div.andro_product-thumb img").attr("abs:src")
url = "/" + titleElement.attr("href")
title = infoElement.text().withoutLanguage()
thumbnail_url = thumbElement.attr("abs:src")
.replace("w=80&h=120", "w=380&h=600")
url = element.select("a:first-child").attr("href")
}
override fun latestUpdatesNextPageSelector() = "ul.pagination li.active + li"
override fun latestUpdatesNextPageSelector() = "ul.pagination li:last-child a"
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val newHeaders = headers.newBuilder()
.set("Referer", "$baseUrl/mangas")
.build()
val url = HttpUrl.parse("$baseUrl/manga")!!.newBuilder()
val url = HttpUrl.parse("$baseUrl/mangas")!!.newBuilder()
.addQueryParameter("busca", query)
.toString()
return GET(url, newHeaders)
}
override fun searchMangaSelector() = "div.container div.row:contains(Resultados) div.andro_product"
override fun searchMangaSelector() = "div.mangas.col-lg-2 a"
override fun searchMangaFromElement(element: Element): SManga = SManga.create().apply {
val titleElement = element.select("p.andro_product-title a")
title = titleElement.text().withoutLanguage()
thumbnail_url = element.select("div.andro_product-thumb img").attr("abs:data-src")
url = "/" + titleElement.attr("href")
title = element.select("h3").text().withoutLanguage()
thumbnail_url = element.select("img").attr("abs:src")
url = element.attr("href")
}
override fun searchMangaNextPageSelector(): String? = null
override fun mangaDetailsParse(document: Document): SManga = SManga.create().apply {
val infoElement = document.select("div.andro_subheader + div.section div.row").first()
val firstColumn = infoElement.select("div.col-md-3 div.andro_product-single-thumb > img").first()
val secondColumn = infoElement.select("div.col-md-9 div.andro_product-single-content").first()
val metadata = secondColumn.select("div.row:eq(2) ul.andro_product-meta").first()
val infoElement = document.select("div.row > div.col-sm-8 > div.row").first()
val firstColumn = infoElement.select("div.col-sm-4.text-right > img").first()
val secondColumn = infoElement.select("div.col-sm-8").first()
title = secondColumn.select("div.row:eq(0) h3").text().withoutLanguage()
author = metadata.select("li:eq(1) div a").text().trim()
artist = metadata.select("li:eq(2) div a").text().trim()
genre = metadata.select("li:eq(0) div a").joinToString { it.text() }
status = metadata.select("li:eq(3) div a").text().toStatus()
description = secondColumn.select("div.row:eq(3) p").text().trim()
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 = secondColumn.select("h5:eq(5) a").text().toStatus()
description = document.select("#manga_capitulo_descricao").text()
thumbnail_url = firstColumn.attr("abs:src")
}
/**
* Need to override the method to get the API endpoint URL that
* uses the manga id to return the chapter list.
*/
override fun chapterListParse(response: Response): List<SChapter> {
val chapterScript = response.asJsoup()
.select("script:containsData(capitulos_cache.php)")
.first()
val chapterEndpointUrl = chapterScript.data()
.substringAfter("url: \"")
.substringBefore("\"")
val chapterListHeaders = headersBuilder()
.set("Accept", "*/*")
.set("Referer", response.request().url().toString())
.set("X-Requested-With", "XMLHttpRequest")
.build()
val chapterRequest = GET("$baseUrl/$chapterEndpointUrl", chapterListHeaders)
val chapterResponse = client.newCall(chapterRequest).execute()
return super.chapterListParse(chapterResponse)
}
override fun chapterListSelector() = "div.andro_single-pagination-item div.row"
override fun chapterListSelector() = "ul#capitulos li.row"
override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply {
val firstColumn = element.select("div.col-sm-7").first()
val secondColumn = element.select("div.col-sm-5 a")
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("b").first().text()
scanlator = secondColumn.joinToString { it.text() }
date_upload = firstColumn.select("span[style]").last().text().toDate()
url = "/" + firstColumn.select("a").attr("href")
name = firstColumn.select("div.col-sm-5").first().text()
.substringBefore("(").trim()
scanlator = secondColumn?.joinToString { it.text() }
date_upload = firstColumn.select("div.col-sm-5 span[style]").text().toDate()
url = element.select("a").attr("href")
}
override fun pageListRequest(chapter: SChapter): Request {
@ -161,7 +134,9 @@ class GoldenMangas : ParsedHttpSource() {
}
override fun pageListParse(document: Document): List<Page> {
return document.select("div.container_images_img img.img-responsive")
val chapterImages = document.select("div.col-sm-12[id^='capitulos_images']").first()
return chapterImages.select("img[pag]")
.mapIndexed { i, element ->
Page(i, document.location(), element.attr("abs:src"))
}
@ -191,13 +166,16 @@ class GoldenMangas : ParsedHttpSource() {
contains("Completo") -> SManga.COMPLETED
else -> SManga.UNKNOWN
}
private fun String.withoutLabel(): String = substringAfter(":").trim()
private fun String.withoutLanguage(): String = replace(FLAG_REGEX, "").trim()
companion object {
private const val ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
private const val ACCEPT_IMAGE = "image/webp,image/apng,image/*,*/*;q=0.8"
private const val ACCEPT_LANGUAGE = "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7,es;q=0.6,gl;q=0.5"
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36"
private val FLAG_REGEX = "\\((Pt[-/]br|Scan)\\)".toRegex(RegexOption.IGNORE_CASE)