Update GM URL and selectors (#17227)

Update GM URL and selectors.
This commit is contained in:
Alessandro Jean 2023-07-22 18:16:58 -03:00 committed by GitHub
parent 852a689669
commit dcf73cedee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 23 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Golden Mangás' extName = 'Golden Mangás'
pkgNameSuffix = 'pt.goldenmangas' pkgNameSuffix = 'pt.goldenmangas'
extClass = '.GoldenMangas' extClass = '.GoldenMangas'
extVersionCode = 17 extVersionCode = 18
isNsfw = true isNsfw = true
} }

View File

@ -8,9 +8,10 @@ import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import okhttp3.Headers import okhttp3.Headers
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
@ -24,7 +25,7 @@ class GoldenMangas : ParsedHttpSource() {
override val name = "Golden Mangás" override val name = "Golden Mangás"
override val baseUrl = "https://goldenmangas.top" override val baseUrl = "https://goldenmanga.top"
override val lang = "pt-BR" override val lang = "pt-BR"
@ -47,8 +48,8 @@ class GoldenMangas : ParsedHttpSource() {
override fun popularMangaSelector(): String = "div#maisLidos div.itemmanga" override fun popularMangaSelector(): String = "div#maisLidos div.itemmanga"
override fun popularMangaFromElement(element: Element): SManga = SManga.create().apply { override fun popularMangaFromElement(element: Element): SManga = SManga.create().apply {
title = element.select("h3").text().withoutLanguage() title = element.selectFirst("h3")!!.text().withoutLanguage()
thumbnail_url = element.select("img").attr("abs:src") thumbnail_url = element.selectFirst("img")!!.absUrl("src")
url = element.attr("href") url = element.attr("href")
} }
@ -62,12 +63,12 @@ class GoldenMangas : ParsedHttpSource() {
override fun latestUpdatesSelector() = "div.col-sm-12.atualizacao > div.row" override fun latestUpdatesSelector() = "div.col-sm-12.atualizacao > div.row"
override fun latestUpdatesFromElement(element: Element): SManga = SManga.create().apply { override fun latestUpdatesFromElement(element: Element): SManga = SManga.create().apply {
val infoElement = element.select("div.col-sm-10.col-xs-8 h3").first()!! val infoElement = element.selectFirst("div.col-sm-10.col-xs-8 h3")!!
val thumbElement = element.select("a:first-child div img").first()!! val thumbElement = element.selectFirst("a:first-child div img")!!
title = infoElement.text().withoutLanguage() title = infoElement.text().withoutLanguage()
thumbnail_url = thumbElement.attr("abs:src") thumbnail_url = thumbElement.absUrl("src")
.replace("w=80&h=120", "w=380&h=600") .replace("w=100&h=140", "w=380&h=600")
url = element.select("a:first-child").attr("href") url = element.select("a:first-child").attr("href")
} }
@ -78,7 +79,7 @@ class GoldenMangas : ParsedHttpSource() {
.set("Referer", "$baseUrl/mangas") .set("Referer", "$baseUrl/mangas")
.build() .build()
val url = "$baseUrl/mangas".toHttpUrlOrNull()!!.newBuilder() val url = "$baseUrl/mangas".toHttpUrl().newBuilder()
.addQueryParameter("busca", query) .addQueryParameter("busca", query)
.toString() .toString()
@ -88,17 +89,28 @@ class GoldenMangas : ParsedHttpSource() {
override fun searchMangaSelector() = "div.mangas.col-lg-2 a" override fun searchMangaSelector() = "div.mangas.col-lg-2 a"
override fun searchMangaFromElement(element: Element): SManga = SManga.create().apply { override fun searchMangaFromElement(element: Element): SManga = SManga.create().apply {
title = element.select("h3").text().withoutLanguage() title = element.selectFirst("h3")!!.text().withoutLanguage()
thumbnail_url = element.select("img").attr("abs:src") thumbnail_url = element.selectFirst("img")!!.absUrl("src")
url = element.attr("href") url = element.attr("href")
} }
override fun searchMangaNextPageSelector(): String? = null override fun searchMangaNextPageSelector(): String? = null
override fun mangaDetailsParse(response: Response): SManga {
val mangaResult = runCatching { super.mangaDetailsParse(response) }
val manga = mangaResult.getOrNull()
if (manga?.title.isNullOrEmpty()) {
throw Exception(MIGRATE_WARNING)
}
return manga!!
}
override fun mangaDetailsParse(document: Document): SManga = SManga.create().apply { override fun mangaDetailsParse(document: Document): SManga = SManga.create().apply {
val infoElement = document.select("div.row > div.col-sm-8 > div.row").first()!! val infoElement = document.selectFirst("div.row > div.col-sm-8 > div.row")!!
val firstColumn = infoElement.select("div.col-sm-4.text-right > img").first()!! val firstColumn = infoElement.selectFirst("div.col-sm-4.text-right > img")!!
val secondColumn = infoElement.select("div.col-sm-8").first()!! val secondColumn = infoElement.selectFirst("div.col-sm-8")!!
title = secondColumn.select("h2:eq(0)").text().withoutLanguage() title = secondColumn.select("h2:eq(0)").text().withoutLanguage()
author = secondColumn.select("h5:contains(Autor)").text().withoutLabel() author = secondColumn.select("h5:contains(Autor)").text().withoutLabel()
@ -111,14 +123,24 @@ class GoldenMangas : ParsedHttpSource() {
thumbnail_url = firstColumn.attr("abs:src") thumbnail_url = firstColumn.attr("abs:src")
} }
override fun chapterListParse(response: Response): List<SChapter> {
val chaptersResult = runCatching { super.chapterListParse(response) }
val chapterList = chaptersResult.getOrNull()
if (chapterList.isNullOrEmpty()) {
throw Exception(MIGRATE_WARNING)
}
return chapterList
}
override fun chapterListSelector() = "ul#capitulos li.row" override fun chapterListSelector() = "ul#capitulos li.row"
override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply { override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply {
val firstColumn = element.select("a > div.col-sm-5") val firstColumn = element.selectFirst("a > div.col-sm-5")!!
val secondColumn = element.select("div.col-sm-5.text-right a[href^='http']") val secondColumn = element.select("div.col-sm-5.text-right a:not([href^='/'])")
name = firstColumn.select("div.col-sm-5").first()!!.text() name = firstColumn.text().substringBefore("(").trim()
.substringBefore("(").trim()
scanlator = secondColumn.joinToString { it.text() } scanlator = secondColumn.joinToString { it.text() }
date_upload = firstColumn.select("div.col-sm-5 span[style]").text().toDate() date_upload = firstColumn.select("div.col-sm-5 span[style]").text().toDate()
url = element.select("a").attr("href") url = element.select("a").attr("href")
@ -133,11 +155,9 @@ class GoldenMangas : ParsedHttpSource() {
} }
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
val chapterImages = document val chapterImages = document.selectFirst("div.col-sm-12[id^='capitulos_images']:has(img[pag])")
.select("div.col-sm-12[id^='capitulos_images']:has(img[pag])")
.firstOrNull()
val isNovel = document.select(".block_text_border").firstOrNull() !== null val isNovel = document.selectFirst(".block_text_border") !== null
if (chapterImages == null && isNovel) { if (chapterImages == null && isNovel) {
throw Exception(CHAPTER_IS_NOVEL_ERROR) throw Exception(CHAPTER_IS_NOVEL_ERROR)
@ -187,6 +207,8 @@ class GoldenMangas : ParsedHttpSource() {
private const val CHAPTER_IS_NOVEL_ERROR = private const val CHAPTER_IS_NOVEL_ERROR =
"O capítulo é uma novel em formato de texto e não possui imagens." "O capítulo é uma novel em formato de texto e não possui imagens."
private const val MIGRATE_WARNING = "Migre o item da Golden Mangás para Golden Mangás para atualizar a URL."
private val DATE_FORMATTER by lazy { private val DATE_FORMATTER by lazy {
SimpleDateFormat("(dd/MM/yyyy)", Locale.ENGLISH) SimpleDateFormat("(dd/MM/yyyy)", Locale.ENGLISH)
} }