Update selectors and show a blocking message if no results found. (#6699)
This commit is contained in:
parent
9b3d6752b9
commit
7855257372
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'Mangá Host'
|
extName = 'Mangá Host'
|
||||||
pkgNameSuffix = 'pt.mangahost'
|
pkgNameSuffix = 'pt.mangahost'
|
||||||
extClass = '.MangaHost'
|
extClass = '.MangaHost'
|
||||||
extVersionCode = 23
|
extVersionCode = 24
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.asObservable
|
import eu.kanade.tachiyomi.network.asObservable
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
|
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
|
@ -31,7 +32,7 @@ class MangaHost : ParsedHttpSource() {
|
||||||
|
|
||||||
override val name = "Mangá Host"
|
override val name = "Mangá Host"
|
||||||
|
|
||||||
override val baseUrl = "https://mangahosted.com"
|
override val baseUrl = "https://mangahostz.com"
|
||||||
|
|
||||||
override val lang = "pt-BR"
|
override val lang = "pt-BR"
|
||||||
|
|
||||||
|
@ -48,15 +49,14 @@ class MangaHost : ParsedHttpSource() {
|
||||||
.add("Referer", baseUrl)
|
.add("Referer", baseUrl)
|
||||||
.add("User-Agent", USER_AGENT)
|
.add("User-Agent", USER_AGENT)
|
||||||
|
|
||||||
private fun genericMangaFromElement(element: Element): SManga =
|
private fun genericMangaFromElement(element: Element): SManga = SManga.create().apply {
|
||||||
SManga.create().apply {
|
val thumbnailEl = element.select("img")
|
||||||
val thumbnailEl = element.select("img")
|
val thumbnailAttr = if (thumbnailEl.hasAttr("data-path")) "data-path" else "src"
|
||||||
val thumbnailAttr = if (thumbnailEl.hasAttr("data-path")) "data-path" else "src"
|
|
||||||
|
|
||||||
title = element.attr("title").withoutLanguage()
|
title = element.attr("title").withoutLanguage()
|
||||||
thumbnail_url = thumbnailEl.attr(thumbnailAttr).toLargeUrl()
|
thumbnail_url = thumbnailEl.attr(thumbnailAttr).toLargeUrl()
|
||||||
setUrlWithoutDomain(element.attr("href"))
|
setUrlWithoutDomain(element.attr("href"))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun popularMangaRequest(page: Int): Request {
|
override fun popularMangaRequest(page: Int): Request {
|
||||||
val listPath = if (page == 1) "" else "/mais-visualizados/page/${page - 1}"
|
val listPath = if (page == 1) "" else "/mais-visualizados/page/${page - 1}"
|
||||||
|
@ -68,6 +68,16 @@ class MangaHost : ParsedHttpSource() {
|
||||||
return GET("$baseUrl/mangas/mais-visualizados$pageStr", newHeaders)
|
return GET("$baseUrl/mangas/mais-visualizados$pageStr", newHeaders)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun popularMangaParse(response: Response): MangasPage {
|
||||||
|
val results = super.popularMangaParse(response)
|
||||||
|
|
||||||
|
if (results.mangas.isEmpty()) {
|
||||||
|
throw Exception(BLOCK_MESSAGE)
|
||||||
|
}
|
||||||
|
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
|
||||||
override fun popularMangaSelector(): String = "div#dados div.manga-block div.manga-block-left a"
|
override fun popularMangaSelector(): String = "div#dados div.manga-block div.manga-block-left a"
|
||||||
|
|
||||||
override fun popularMangaFromElement(element: Element): SManga = genericMangaFromElement(element)
|
override fun popularMangaFromElement(element: Element): SManga = genericMangaFromElement(element)
|
||||||
|
@ -84,7 +94,17 @@ class MangaHost : ParsedHttpSource() {
|
||||||
return GET("$baseUrl/lancamentos$pageStr", newHeaders)
|
return GET("$baseUrl/lancamentos$pageStr", newHeaders)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun latestUpdatesSelector() = "div#dados div.line-lancamentos div.column-img a"
|
override fun latestUpdatesParse(response: Response): MangasPage {
|
||||||
|
val results = super.latestUpdatesParse(response)
|
||||||
|
|
||||||
|
if (results.mangas.isEmpty()) {
|
||||||
|
throw Exception(BLOCK_MESSAGE)
|
||||||
|
}
|
||||||
|
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun latestUpdatesSelector() = "div#dados div.w-row div.column-img a"
|
||||||
|
|
||||||
override fun latestUpdatesFromElement(element: Element): SManga = genericMangaFromElement(element)
|
override fun latestUpdatesFromElement(element: Element): SManga = genericMangaFromElement(element)
|
||||||
|
|
||||||
|
@ -117,6 +137,7 @@ class MangaHost : ParsedHttpSource() {
|
||||||
|
|
||||||
override fun mangaDetailsParse(document: Document): SManga = SManga.create().apply {
|
override fun mangaDetailsParse(document: Document): SManga = SManga.create().apply {
|
||||||
val infoElement = document.select("div.box-content div.w-row div.w-col:eq(1) article")
|
val infoElement = document.select("div.box-content div.w-row div.w-col:eq(1) article")
|
||||||
|
.firstOrNull() ?: throw Exception(BLOCK_MESSAGE)
|
||||||
|
|
||||||
author = infoElement.select("div.text li div:contains(Autor:)").textWithoutLabel()
|
author = infoElement.select("div.text li div:contains(Autor:)").textWithoutLabel()
|
||||||
artist = infoElement.select("div.text li div:contains(Arte:)").textWithoutLabel()
|
artist = infoElement.select("div.text li div:contains(Arte:)").textWithoutLabel()
|
||||||
|
@ -142,8 +163,18 @@ class MangaHost : ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
|
val chapters = super.chapterListParse(response)
|
||||||
|
|
||||||
|
if (chapters.isEmpty()) {
|
||||||
|
throw Exception(BLOCK_MESSAGE)
|
||||||
|
}
|
||||||
|
|
||||||
|
return chapters
|
||||||
|
}
|
||||||
|
|
||||||
override fun chapterListSelector(): String =
|
override fun chapterListSelector(): String =
|
||||||
"article.article > section.clearfix div.chapters div.cap div.card.pop"
|
"article section.clearfix div.chapters div.cap div.card.pop"
|
||||||
|
|
||||||
override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply {
|
override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply {
|
||||||
name = element.select("div.pop-title").text().withoutLanguage()
|
name = element.select("div.pop-title").text().withoutLanguage()
|
||||||
|
@ -199,7 +230,7 @@ class MangaHost : ParsedHttpSource() {
|
||||||
private fun blockMessageIntercept(chain: Interceptor.Chain): Response {
|
private fun blockMessageIntercept(chain: Interceptor.Chain): Response {
|
||||||
val response = chain.proceed(chain.request())
|
val response = chain.proceed(chain.request())
|
||||||
|
|
||||||
if (!response.isSuccessful && response.code() == 403) {
|
if (response.code() == 403 || response.code() == 1020) {
|
||||||
response.close()
|
response.close()
|
||||||
throw Exception(BLOCK_MESSAGE)
|
throw Exception(BLOCK_MESSAGE)
|
||||||
}
|
}
|
||||||
|
@ -224,9 +255,9 @@ class MangaHost : ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.toStatus() = when {
|
private fun String.toStatus() = when (this) {
|
||||||
contains("Ativo") -> SManga.ONGOING
|
"Ativo" -> SManga.ONGOING
|
||||||
contains("Completo") -> SManga.COMPLETED
|
"Completo" -> SManga.COMPLETED
|
||||||
else -> SManga.UNKNOWN
|
else -> SManga.UNKNOWN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,9 +277,9 @@ class MangaHost : ParsedHttpSource() {
|
||||||
|
|
||||||
private val LANG_REGEX = "( )?\\((PT-)?BR\\)".toRegex()
|
private val LANG_REGEX = "( )?\\((PT-)?BR\\)".toRegex()
|
||||||
private val IMAGE_REGEX = "_(small|medium|xmedium)\\.".toRegex()
|
private val IMAGE_REGEX = "_(small|medium|xmedium)\\.".toRegex()
|
||||||
private val CDN_REGEX = "/mangas_files/.*\\.jpg".toRegex()
|
|
||||||
|
|
||||||
private const val BLOCK_MESSAGE = "O site está bloqueando o Tachiyomi. Migre para outra fonte caso o problema persistir."
|
private const val BLOCK_MESSAGE = "O site está bloqueando o Tachiyomi. " +
|
||||||
|
"Migre para outra fonte caso o problema persistir."
|
||||||
|
|
||||||
private val DATE_FORMAT by lazy {
|
private val DATE_FORMAT by lazy {
|
||||||
SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH)
|
SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH)
|
||||||
|
|
Loading…
Reference in New Issue