Change referer header and rewrite parts of the code (#1356)
Improvements for UnionMangás
This commit is contained in:
parent
859504636f
commit
5e808c0dbb
|
@ -5,7 +5,7 @@ ext {
|
||||||
appName = 'Tachiyomi: Union Mangás'
|
appName = 'Tachiyomi: Union Mangás'
|
||||||
pkgNameSuffix = 'pt.unionmangas'
|
pkgNameSuffix = 'pt.unionmangas'
|
||||||
extClass = '.UnionMangas'
|
extClass = '.UnionMangas'
|
||||||
extVersionCode = 6
|
extVersionCode = 7
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,23 +29,20 @@ class UnionMangas : ParsedHttpSource() {
|
||||||
|
|
||||||
// Sometimes the site is very slow.
|
// Sometimes the site is very slow.
|
||||||
override val client =
|
override val client =
|
||||||
network.client.newBuilder()
|
network.cloudflareClient.newBuilder()
|
||||||
.connectTimeout(3, TimeUnit.MINUTES)
|
.connectTimeout(3, TimeUnit.MINUTES)
|
||||||
.readTimeout(3, TimeUnit.MINUTES)
|
.readTimeout(3, TimeUnit.MINUTES)
|
||||||
.writeTimeout(3, TimeUnit.MINUTES)
|
.writeTimeout(3, TimeUnit.MINUTES)
|
||||||
.build()
|
|
||||||
|
|
||||||
private val catalogHeaders = Headers.Builder()
|
|
||||||
.apply {
|
|
||||||
add("User-Agent", USER_AGENT)
|
|
||||||
add("Origin", baseUrl)
|
|
||||||
add("Referer", "$baseUrl/ini")
|
|
||||||
}
|
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
override fun headersBuilder(): Headers.Builder = Headers.Builder()
|
||||||
|
.add("User-Agent", USER_AGENT)
|
||||||
|
.add("Origin", baseUrl)
|
||||||
|
.add("Referer", "$baseUrl/ne")
|
||||||
|
|
||||||
override fun popularMangaRequest(page: Int): Request {
|
override fun popularMangaRequest(page: Int): Request {
|
||||||
val pageStr = if (page != 1) "/$page" else ""
|
val pageStr = if (page != 1) "/$page" else ""
|
||||||
return GET("$baseUrl/lista-mangas/visualizacoes$pageStr", catalogHeaders)
|
return GET("$baseUrl/lista-mangas/visualizacoes$pageStr", headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun popularMangaSelector(): String = "div.bloco-manga"
|
override fun popularMangaSelector(): String = "div.bloco-manga"
|
||||||
|
@ -60,37 +57,35 @@ class UnionMangas : ParsedHttpSource() {
|
||||||
|
|
||||||
override fun latestUpdatesRequest(page: Int): Request {
|
override fun latestUpdatesRequest(page: Int): Request {
|
||||||
val form = FormBody.Builder()
|
val form = FormBody.Builder()
|
||||||
.add("pagina", page.toString())
|
.add("pagina", page.toString())
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val newHeaders = catalogHeaders.newBuilder()
|
val newHeaders = headers.newBuilder()
|
||||||
.set("X-Requested-With", "XMLHttpRequest")
|
.set("X-Requested-With", "XMLHttpRequest")
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
return POST("$baseUrl/assets/noticias.php", newHeaders, form)
|
return POST("$baseUrl/assets/noticias.php", newHeaders, form)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun latestUpdatesSelector() = "div.row[style] div.col-md-12[style]"
|
override fun latestUpdatesSelector() = "div.row[style] div.col-md-12[style]"
|
||||||
|
|
||||||
override fun latestUpdatesFromElement(element: Element): SManga {
|
override fun latestUpdatesFromElement(element: Element): SManga = SManga.create().apply {
|
||||||
val infoElement = element.select("a.link-titulo")
|
val infoElement = element.select("a.link-titulo")
|
||||||
|
|
||||||
return SManga.create().apply {
|
title = removeLanguage(infoElement.last().text())
|
||||||
title = removeLanguage(infoElement.last().text())
|
thumbnail_url = infoElement.first()?.select("img")?.attr("src")
|
||||||
thumbnail_url = infoElement.first()?.select("img")?.attr("src")
|
setUrlWithoutDomain(infoElement.last().attr("href"))
|
||||||
setUrlWithoutDomain(infoElement.last().attr("href"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun latestUpdatesNextPageSelector() = "div#linha-botao-mais"
|
override fun latestUpdatesNextPageSelector() = "div#linha-botao-mais"
|
||||||
|
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
val newHeaders = catalogHeaders.newBuilder()
|
val newHeaders = headers.newBuilder()
|
||||||
.set("X-Requested-With", "XMLHttpRequest")
|
.set("X-Requested-With", "XMLHttpRequest")
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val url = HttpUrl.parse("$baseUrl/assets/busca.php")!!.newBuilder()
|
val url = HttpUrl.parse("$baseUrl/assets/busca.php")!!.newBuilder()
|
||||||
.addQueryParameter("q", query)
|
.addQueryParameter("q", query)
|
||||||
|
|
||||||
return GET(url.toString(), newHeaders)
|
return GET(url.toString(), newHeaders)
|
||||||
}
|
}
|
||||||
|
@ -109,7 +104,7 @@ class UnionMangas : ParsedHttpSource() {
|
||||||
setUrlWithoutDomain("$baseUrl/manga/${obj["url"].string}")
|
setUrlWithoutDomain("$baseUrl/manga/${obj["url"].string}")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mangaDetailsRequest(manga: SManga): Request = GET(baseUrl + manga.url, catalogHeaders)
|
override fun mangaDetailsRequest(manga: SManga): Request = GET(baseUrl + manga.url, headers)
|
||||||
|
|
||||||
override fun mangaDetailsParse(document: Document): SManga {
|
override fun mangaDetailsParse(document: Document): SManga {
|
||||||
val infoElement = document.select("div.tamanho-bloco-perfil").first()
|
val infoElement = document.select("div.tamanho-bloco-perfil").first()
|
||||||
|
@ -138,30 +133,28 @@ class UnionMangas : ParsedHttpSource() {
|
||||||
else -> SManga.UNKNOWN
|
else -> SManga.UNKNOWN
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun chapterListRequest(manga: SManga): Request = GET(baseUrl + manga.url, catalogHeaders)
|
override fun chapterListRequest(manga: SManga): Request = GET(baseUrl + manga.url, headers)
|
||||||
|
|
||||||
override fun chapterListSelector() = "div.row.lancamento-linha"
|
override fun chapterListSelector() = "div.row.lancamento-linha"
|
||||||
|
|
||||||
override fun chapterFromElement(element: Element): SChapter {
|
override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply {
|
||||||
val firstColumn = element.select("div.col-md-6:eq(0)")
|
val firstColumn = element.select("div.col-md-6:eq(0)")
|
||||||
val secondColumn = element.select("div.col-md-6:eq(1)")
|
val secondColumn = element.select("div.col-md-6:eq(1)")
|
||||||
|
|
||||||
return SChapter.create().apply {
|
name = firstColumn.select("a").first().text()
|
||||||
name = firstColumn.select("a").first().text()
|
scanlator = secondColumn?.text()
|
||||||
scanlator = secondColumn?.text()
|
date_upload = parseChapterDate(firstColumn.select("span").last()!!.text())
|
||||||
date_upload = parseChapterDate(firstColumn.select("span").last()!!.text())
|
setUrlWithoutDomain(firstColumn.select("a").first().attr("href"))
|
||||||
setUrlWithoutDomain(firstColumn.select("a").first().attr("href"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListRequest(chapter: SChapter): Request = GET(baseUrl + chapter.url, catalogHeaders)
|
override fun pageListRequest(chapter: SChapter): Request = GET(baseUrl + chapter.url, headers)
|
||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
val pages = document.select("img.img-responsive.img-manga")
|
val pages = document.select("img.img-responsive.img-manga")
|
||||||
|
|
||||||
return pages
|
return pages
|
||||||
.filter { it.attr("src").contains("leitor") }
|
.filter { it.attr("src").contains("leitor") }
|
||||||
.mapIndexed { i, element -> Page(i, "", element.absUrl("src"))}
|
.mapIndexed { i, element -> Page(i, "", element.absUrl("src"))}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageUrlParse(document: Document) = ""
|
override fun imageUrlParse(document: Document) = ""
|
||||||
|
|
Loading…
Reference in New Issue