Fix MH not working due to theme change. (#12117)

This commit is contained in:
Alessandro Jean 2022-06-07 20:49:48 -03:00 committed by GitHub
parent 1c873f63ab
commit 1bab1f6b55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 37 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Mundo Hentai' extName = 'Mundo Hentai'
pkgNameSuffix = 'pt.mundohentai' pkgNameSuffix = 'pt.mundohentai'
extClass = '.MundoHentai' extClass = '.MundoHentai'
extVersionCode = 4 extVersionCode = 5
isNsfw = true isNsfw = true
} }

View File

@ -26,6 +26,9 @@ class MundoHentai : ParsedHttpSource() {
override val supportsLatest = false override val supportsLatest = false
// They changed their website theme and URLs.
override val versionId: Int = 2
override val client: OkHttpClient = network.cloudflareClient.newBuilder() override val client: OkHttpClient = network.cloudflareClient.newBuilder()
.rateLimit(1, 2, TimeUnit.SECONDS) .rateLimit(1, 2, TimeUnit.SECONDS)
.build() .build()
@ -35,33 +38,31 @@ class MundoHentai : ParsedHttpSource() {
private fun genericMangaFromElement(element: Element): SManga = private fun genericMangaFromElement(element: Element): SManga =
SManga.create().apply { SManga.create().apply {
title = element.select("div.menu a.title").text() title = element.select("span.thumb-titulo").text()
thumbnail_url = element.attr("style") thumbnail_url = element.select("img.attachment-post-thumbnail").attr("src")
.substringAfter("url(\"") setUrlWithoutDomain(element.select("a:has(span.thumb-imagem)").attr("href"))
.substringBefore("\")")
url = element.select("a.absolute").attr("href")
} }
// The source does not have a popular list page, so we use the Doujin list instead. // The source does not have a popular list page, so we use the Doujin list instead.
override fun popularMangaRequest(page: Int): Request { override fun popularMangaRequest(page: Int): Request {
val newHeaders = headersBuilder() val newHeaders = headersBuilder()
.set("Referer", if (page == 1) baseUrl else "$baseUrl/tipo/doujin/${page - 1}") .set("Referer", if (page == 1) baseUrl else "$baseUrl/category/doujinshi/page/${page - 1}")
.build() .build()
val pageStr = if (page != 1) "/$page" else "" val pageStr = if (page != 1) "page/$page" else ""
return GET("$baseUrl/tipo/doujin$pageStr", newHeaders) return GET("$baseUrl/category/doujinshi/$pageStr", newHeaders)
} }
override fun popularMangaSelector(): String = "ul.post-list li div.card:has(a.absolute[href^=/])" override fun popularMangaSelector(): String = "div.lista > ul > li div.thumb-conteudo:has(a[href^=$baseUrl]:has(span.thumb-imagem)):not(:contains(Tufos))"
override fun popularMangaFromElement(element: Element): SManga = genericMangaFromElement(element) override fun popularMangaFromElement(element: Element): SManga = genericMangaFromElement(element)
override fun popularMangaNextPageSelector() = "div.buttons:not(:has(a.selected + a.material-icons))" override fun popularMangaNextPageSelector() = "ul.paginacao li.next"
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
if (query.isNotEmpty()) { if (query.isNotEmpty()) {
val url = "$baseUrl/search".toHttpUrlOrNull()!!.newBuilder() val url = baseUrl.toHttpUrlOrNull()!!.newBuilder()
.addQueryParameter("q", query) .addQueryParameter("s", query)
.toString() .toString()
return GET(url, headers) return GET(url, headers)
@ -75,53 +76,41 @@ class MundoHentai : ParsedHttpSource() {
} }
val newHeaders = headersBuilder() val newHeaders = headersBuilder()
.set("Referer", if (page == 1) "$baseUrl/categories" else "$baseUrl/tags/$tagSlug/${page - 1}") .set("Referer", if (page == 1) "$baseUrl/tags" else "$baseUrl/tag/$tagSlug/page/${page - 1}")
.build() .build()
val pageStr = if (page != 1) "/$page" else "" val pageStr = if (page != 1) "page/$page" else ""
return GET("$baseUrl/tags/$tagSlug$pageStr", newHeaders) return GET("$baseUrl/tag/$tagSlug/$pageStr", newHeaders)
} }
override fun searchMangaSelector() = popularMangaSelector() + ":not(:has(div.right-tape))" override fun searchMangaSelector() = popularMangaSelector() + ":not(:has(span.selo-tipo:contains(Legendado)))"
override fun searchMangaFromElement(element: Element): SManga = genericMangaFromElement(element) override fun searchMangaFromElement(element: Element): SManga = genericMangaFromElement(element)
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector() override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
override fun mangaDetailsParse(document: Document): SManga { override fun mangaDetailsParse(document: Document): SManga {
val post = document.select("div.post") val post = document.select("div.post-box")
return SManga.create().apply { return SManga.create().apply {
author = post.select("div.tags div.tag:contains(Artista:) a.value").text() author = post.select("ul.post-itens li:contains(Artista:) a").text()
genre = post.select("div.tags div.tag:contains(Tags:) a.value").joinToString { it.text() } genre = post.select("ul.post-itens li:contains(Tags:) a").joinToString { it.text() }
description = post.select("div.tags div.tag:contains(Tipo:)").text() description = post.select("ul.post-itens li:contains(Cor:)").text()
.plus("\n" + post.select("div.tags div.tag:contains(Cor:)").text())
status = SManga.COMPLETED status = SManga.COMPLETED
thumbnail_url = post.select("div.cover img").attr("src") thumbnail_url = post.select("div.post-capa img").attr("src")
} }
} }
override fun chapterListSelector(): String = "div.post header.data div.float-buttons a.read" override fun chapterListSelector(): String = "div.post-box"
override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply { override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply {
name = "Capítulo" name = "Capítulo"
scanlator = element.parent().parent()
.select("div.tags div.tag:contains(Tradutor:) a.value")
.text()
chapter_number = 1f chapter_number = 1f
url = element.attr("href") setUrlWithoutDomain(element.ownerDocument().location())
}
override fun pageListRequest(chapter: SChapter): Request {
val newHeader = headersBuilder()
.set("Referer", "$baseUrl${chapter.url}".substringBeforeLast("/"))
.build()
return GET(baseUrl + chapter.url, newHeader)
} }
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
return document.select("div.gallery > img") return document.select("div.listaImagens ul.post-fotos img")
.mapIndexed { i, el -> .mapIndexed { i, el ->
Page(i, document.location(), el.attr("src")) Page(i, document.location(), el.attr("src"))
} }