Update 'UM' selectors (again) and add block message. (#6634)
This commit is contained in:
		
							parent
							
								
									87cfe3f5b1
								
							
						
					
					
						commit
						91ad434ffa
					
				@ -5,7 +5,7 @@ ext {
 | 
			
		||||
    extName = 'Union Mangás'
 | 
			
		||||
    pkgNameSuffix = 'pt.unionmangas'
 | 
			
		||||
    extClass = '.UnionMangas'
 | 
			
		||||
    extVersionCode = 21
 | 
			
		||||
    extVersionCode = 22
 | 
			
		||||
    libVersion = '1.2'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,10 @@
 | 
			
		||||
package eu.kanade.tachiyomi.extension.pt.unionmangas
 | 
			
		||||
 | 
			
		||||
import com.github.salomonbrys.kotson.array
 | 
			
		||||
import com.github.salomonbrys.kotson.nullObj
 | 
			
		||||
import com.github.salomonbrys.kotson.obj
 | 
			
		||||
import com.github.salomonbrys.kotson.string
 | 
			
		||||
import com.google.gson.JsonElement
 | 
			
		||||
import com.google.gson.JsonObject
 | 
			
		||||
import com.google.gson.JsonParser
 | 
			
		||||
import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor
 | 
			
		||||
@ -50,7 +52,7 @@ class UnionMangas : ParsedHttpSource() {
 | 
			
		||||
    override fun headersBuilder(): Headers.Builder = Headers.Builder()
 | 
			
		||||
        .add("Accept", ACCEPT)
 | 
			
		||||
        .add("Accept-Language", ACCEPT_LANGUAGE)
 | 
			
		||||
        .add("Referer", "$baseUrl/inicial")
 | 
			
		||||
        .add("Referer", "$baseUrl/home")
 | 
			
		||||
 | 
			
		||||
    override fun popularMangaRequest(page: Int): Request {
 | 
			
		||||
        val listPath = if (page == 1) "" else "/visualizacoes/${page - 1}"
 | 
			
		||||
@ -62,7 +64,17 @@ class UnionMangas : ParsedHttpSource() {
 | 
			
		||||
        return GET("$baseUrl/lista-mangas/visualizacoes$pageStr", newHeaders)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun popularMangaSelector(): String = "div.lista-mangas"
 | 
			
		||||
    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.col-md-3.col-xs-6:has(img.img-thumbnail)"
 | 
			
		||||
 | 
			
		||||
    override fun popularMangaFromElement(element: Element): SManga = SManga.create().apply {
 | 
			
		||||
        title = element.select("div[id^=bloco-tooltip] > b").first().text().withoutLanguage()
 | 
			
		||||
@ -88,6 +100,16 @@ class UnionMangas : ParsedHttpSource() {
 | 
			
		||||
        return POST("$baseUrl/assets/noticias.php", newHeaders, form)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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.row[style] div.col-md-12[style]"
 | 
			
		||||
 | 
			
		||||
    override fun latestUpdatesFromElement(element: Element): SManga = SManga.create().apply {
 | 
			
		||||
@ -112,7 +134,7 @@ class UnionMangas : ParsedHttpSource() {
 | 
			
		||||
            .build()
 | 
			
		||||
 | 
			
		||||
        val url = HttpUrl.parse("$baseUrl/assets/busca.php")!!.newBuilder()
 | 
			
		||||
            .addQueryParameter("pesquisa", query)
 | 
			
		||||
            .addQueryParameter("titulo", query)
 | 
			
		||||
 | 
			
		||||
        return GET(url.toString(), newHeaders)
 | 
			
		||||
    }
 | 
			
		||||
@ -127,7 +149,8 @@ class UnionMangas : ParsedHttpSource() {
 | 
			
		||||
            return MangasPage(listOf(manga), false)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        val result = response.asJsonObject()
 | 
			
		||||
        val result = response.asJson().nullObj
 | 
			
		||||
            ?: throw Exception(BLOCK_MESSAGE)
 | 
			
		||||
 | 
			
		||||
        val mangas = result["items"].array
 | 
			
		||||
            .map { searchMangaFromObject(it.obj) }
 | 
			
		||||
@ -148,7 +171,8 @@ class UnionMangas : ParsedHttpSource() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun mangaDetailsParse(document: Document): SManga = SManga.create().apply {
 | 
			
		||||
        val infoElement = document.select("div.perfil-manga").first()
 | 
			
		||||
        val infoElement = document.select("div.perfil-manga").firstOrNull()
 | 
			
		||||
            ?: throw Exception(BLOCK_MESSAGE)
 | 
			
		||||
        val rowInfo = infoElement.select("div.row:eq(2)").first()
 | 
			
		||||
 | 
			
		||||
        title = infoElement.select("h2").first().text().withoutLanguage()
 | 
			
		||||
@ -160,6 +184,16 @@ class UnionMangas : ParsedHttpSource() {
 | 
			
		||||
        thumbnail_url = infoElement.select(".img-thumbnail").first().attr("src")
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun chapterListParse(response: Response): List<SChapter> {
 | 
			
		||||
        val results = super.chapterListParse(response)
 | 
			
		||||
 | 
			
		||||
        if (results.isEmpty()) {
 | 
			
		||||
            throw Exception(BLOCK_MESSAGE)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return results
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun chapterListSelector() = "div.row.capitulos"
 | 
			
		||||
 | 
			
		||||
    override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply {
 | 
			
		||||
@ -221,7 +255,7 @@ class UnionMangas : ParsedHttpSource() {
 | 
			
		||||
 | 
			
		||||
    private fun Element.textWithoutLabel(): String = text()!!.substringAfter(":").trim()
 | 
			
		||||
 | 
			
		||||
    private fun Response.asJsonObject(): JsonObject = JSON_PARSER.parse(body()!!.string()).obj
 | 
			
		||||
    private fun Response.asJson(): JsonElement = JSON_PARSER.parse(body()!!.string())
 | 
			
		||||
 | 
			
		||||
    companion object {
 | 
			
		||||
        private const val ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9," +
 | 
			
		||||
@ -232,6 +266,9 @@ class UnionMangas : ParsedHttpSource() {
 | 
			
		||||
        private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
 | 
			
		||||
            "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36"
 | 
			
		||||
 | 
			
		||||
        private const val BLOCK_MESSAGE = "O site está bloqueando o Tachiyomi. " +
 | 
			
		||||
            "Migre para outra fonte caso o problema persistir."
 | 
			
		||||
 | 
			
		||||
        private val JSON_PARSER by lazy { JsonParser() }
 | 
			
		||||
 | 
			
		||||
        private val DATE_FORMATTER by lazy {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user