Update MangaYabu to match the new layout. (#3116)
Update MangaYabu to match the new layout
This commit is contained in:
parent
50204b6354
commit
bcf2943576
|
@ -5,7 +5,7 @@ ext {
|
|||
appName = 'Tachiyomi: MangaYabu!'
|
||||
pkgNameSuffix = 'pt.mangayabu'
|
||||
extClass = '.MangaYabu'
|
||||
extVersionCode = 2
|
||||
extVersionCode = 3
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@ import eu.kanade.tachiyomi.source.model.Page
|
|||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||
import java.text.ParseException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import okhttp3.FormBody
|
||||
import okhttp3.Headers
|
||||
import okhttp3.Request
|
||||
|
@ -33,21 +36,16 @@ class MangaYabu : ParsedHttpSource() {
|
|||
.add("Origin", baseUrl)
|
||||
.add("Referer", baseUrl)
|
||||
|
||||
override fun fetchPopularManga(page: Int): Observable<MangasPage> {
|
||||
return super.fetchPopularManga(page)
|
||||
.map {
|
||||
MangasPage(it.mangas.distinctBy { m -> m.url }, it.hasNextPage)
|
||||
}
|
||||
}
|
||||
|
||||
override fun popularMangaRequest(page: Int): Request = GET(baseUrl, headers)
|
||||
|
||||
override fun popularMangaSelector(): String = "div.loop-content div.owl-carousel div.video a.clip-link"
|
||||
override fun popularMangaSelector(): String = "main.home div.features:contains(Populares) div.feature > a"
|
||||
|
||||
override fun popularMangaFromElement(element: Element): SManga = SManga.create().apply {
|
||||
title = element.attr("title").substringBefore(" –")
|
||||
thumbnail_url = element.select("span.clip img")!!.attr("src")
|
||||
url = mapChapterToMangaUrl(element.attr("href"))
|
||||
val thumb = element.select("img").first()!!
|
||||
|
||||
title = thumb.attr("alt").withoutFlags()
|
||||
thumbnail_url = thumb.attr("src")
|
||||
setUrlWithoutDomain(element.attr("href"))
|
||||
}
|
||||
|
||||
override fun popularMangaNextPageSelector(): String? = null
|
||||
|
@ -59,78 +57,88 @@ class MangaYabu : ParsedHttpSource() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun latestUpdatesRequest(page: Int): Request {
|
||||
val pagePath = if (page == 1) "" else "/page/$page"
|
||||
return GET("$baseUrl$pagePath", headers)
|
||||
}
|
||||
override fun latestUpdatesRequest(page: Int): Request = GET(baseUrl, headers)
|
||||
|
||||
override fun latestUpdatesSelector() = "div.loop-content.phpvibe-video-list.miau div.video a.clip-link"
|
||||
override fun latestUpdatesSelector() = "main.home div.features:contains(Lançamentos) div.feature > a"
|
||||
|
||||
override fun latestUpdatesFromElement(element: Element): SManga = SManga.create().apply {
|
||||
val image = element.select("span.clip img")!!
|
||||
val thumb = element.select("img").first()!!
|
||||
|
||||
title = image.attr("alt").substringBefore(" –")
|
||||
thumbnail_url = image.attr("src")
|
||||
title = thumb.attr("alt").substringBefore(" –").withoutFlags()
|
||||
thumbnail_url = thumb.attr("src")
|
||||
url = mapChapterToMangaUrl(element.attr("href"))
|
||||
}
|
||||
|
||||
override fun latestUpdatesNextPageSelector() = "div#pagination a div.item.icon i:contains(arrow_forward_ios)"
|
||||
override fun latestUpdatesNextPageSelector(): String? = null
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
val newHeaders = headers.newBuilder()
|
||||
.set("X-Requested-With", "XMLHttpRequest")
|
||||
.build()
|
||||
|
||||
val form = FormBody.Builder()
|
||||
.add("action", "data_fetch")
|
||||
.add("search_keyword", query)
|
||||
.build()
|
||||
|
||||
val newHeaders = headers.newBuilder()
|
||||
.add("X-Requested-With", "XMLHttpRequest")
|
||||
.add("Content-Length", form.contentLength().toString())
|
||||
.add("Content-Type", form.contentType().toString())
|
||||
.build()
|
||||
|
||||
return POST("$baseUrl/wp-admin/admin-ajax.php", newHeaders, form)
|
||||
}
|
||||
|
||||
override fun searchMangaSelector() = "ul li.gsuggested a"
|
||||
|
||||
override fun searchMangaFromElement(element: Element): SManga = SManga.create().apply {
|
||||
title = element.select("div.contento span.search-name")!!.text()
|
||||
thumbnail_url = "$baseUrl/${element.select("img.search-thumb")!!.attr("src")}"
|
||||
title = element.select("div.contento span.search-name").first()!!.text()
|
||||
thumbnail_url = element.select("img.search-thumb")!!.attr("src")
|
||||
setUrlWithoutDomain(element.attr("href"))
|
||||
}
|
||||
|
||||
override fun searchMangaNextPageSelector(): String? = null
|
||||
|
||||
override fun mangaDetailsParse(document: Document): SManga {
|
||||
val infoElement = document.select("div#channel-content div.row").first()!!
|
||||
val statusStr = infoElement.select("div.left20 p:contains(Status)")!!.text()
|
||||
.substringAfter("Status: ")
|
||||
val infoElement = document.select("div.manga-single-list div.manga-info").first()!!
|
||||
val statusStr = infoElement.select("div.manga-status").first()!!.textWithoutLabel()
|
||||
|
||||
return SManga.create().apply {
|
||||
title = infoElement.select("div.left20 h1")!!.text()
|
||||
title = infoElement.select("div.manga-title h1")!!.text()
|
||||
status = when (statusStr) {
|
||||
"Em lançamento" -> SManga.ONGOING
|
||||
"Completo" -> SManga.COMPLETED
|
||||
else -> SManga.UNKNOWN
|
||||
}
|
||||
description = infoElement.select("div.left20 p[style] + p").first()!!.text()
|
||||
thumbnail_url = infoElement.select("div.mleft20 img.channel-img")!!.attr("src")
|
||||
genre = infoElement.select("div.manga-genres").first()!!.textWithoutLabel()
|
||||
.replace(" ,", ",")
|
||||
description = document.select("div.manga-synopsis").first()!!.text()
|
||||
thumbnail_url = infoElement.select("div.manga-cover img")!!.attr("src")
|
||||
}
|
||||
}
|
||||
|
||||
override fun chapterListSelector() = "div.loop-content div.chap-holder a.chapter-link"
|
||||
override fun chapterListSelector() = "div.manga-single-list div.manga-chapters div.single-chapter"
|
||||
|
||||
override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply {
|
||||
name = "Capítulo " + element.select("small")!!.text()
|
||||
chapter_number = element.select("small")!!.text().toFloatOrNull() ?: 0f
|
||||
setUrlWithoutDomain(element.attr("href"))
|
||||
name = element.select("a").first()!!.text()
|
||||
date_upload = DATE_FORMATTER.tryParseTime(element.select("small")!!.text())
|
||||
setUrlWithoutDomain(element.select("a").first()!!.attr("href"))
|
||||
}
|
||||
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
return document.select("img.img-responsive.img-manga")
|
||||
.mapIndexed { i, element -> Page(i, "", element.absUrl("src")) }
|
||||
return document.select("div.manga-pages img.img-responsive.img-manga")
|
||||
.mapIndexed { i, element ->
|
||||
Page(i, document.location(), element.attr("abs:src"))
|
||||
}
|
||||
}
|
||||
|
||||
override fun imageUrlParse(document: Document) = ""
|
||||
|
||||
override fun imageRequest(page: Page): Request {
|
||||
val newHeaders = headersBuilder()
|
||||
.set("Referer", page.url)
|
||||
.build()
|
||||
|
||||
return GET(page.imageUrl!!, newHeaders)
|
||||
}
|
||||
|
||||
/**
|
||||
* Some mangas doesn't use the same slug from the chapter url, and
|
||||
* since the site doesn't have a proper popular list yet, we have
|
||||
|
@ -147,8 +155,24 @@ class MangaYabu : ParsedHttpSource() {
|
|||
return "/manga/" + (SLUG_EXCEPTIONS[chapterSlug] ?: chapterSlug)
|
||||
}
|
||||
|
||||
private fun String.withoutFlags(): String = replace(FLAG_REGEX, "").trim()
|
||||
|
||||
private fun Element.textWithoutLabel(): String = text()!!.substringAfter(":").trim()
|
||||
|
||||
private fun SimpleDateFormat.tryParseTime(date: String): Long {
|
||||
return try {
|
||||
parse(date).time
|
||||
} catch (e: ParseException) {
|
||||
0L
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36"
|
||||
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
|
||||
|
||||
private val FLAG_REGEX = "\\((Pt[-/]br|Scan)\\)".toRegex(RegexOption.IGNORE_CASE)
|
||||
|
||||
private val DATE_FORMATTER by lazy { SimpleDateFormat("dd/MM/yy", Locale.ENGLISH) }
|
||||
|
||||
private val SLUG_EXCEPTIONS = mapOf(
|
||||
"the-promised-neverland-yakusoku-no-neverland" to "yakusoku-no-neverland-the-promised-neverland"
|
||||
|
|
Loading…
Reference in New Issue