fix mangaYu issue (#5376)

mangaYu tweaking their theme
This commit is contained in:
Riztard Lanthorn 2021-01-11 20:52:05 +07:00 committed by GitHub
parent be626fe8eb
commit dc583a62aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 15 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'MangaYu' extName = 'MangaYu'
pkgNameSuffix = 'id.mangayu' pkgNameSuffix = 'id.mangayu'
extClass = '.MangaYu' extClass = '.MangaYu'
extVersionCode = 1 extVersionCode = 2
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -22,7 +22,7 @@ class MangaYu : ParsedHttpSource() {
override val baseUrl = "https://mangayu.com" override val baseUrl = "https://mangayu.com"
override val lang = "id" override val lang = "id"
override val supportsLatest = true override val supportsLatest = true
private val dateFormat: SimpleDateFormat = SimpleDateFormat("MMM d, yyyy", Locale.US) private val dateFormat: SimpleDateFormat = SimpleDateFormat("dd MMM yyyy", Locale.US)
protected fun Element.imgAttr(): String = if (this.hasAttr("data-src")) this.attr("abs:data-src") else this.attr("abs:src") protected fun Element.imgAttr(): String = if (this.hasAttr("data-src")) this.attr("abs:data-src") else this.attr("abs:src")
@ -35,8 +35,8 @@ class MangaYu : ParsedHttpSource() {
} }
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val url = HttpUrl.parse("$baseUrl/search")!!.newBuilder() val url = HttpUrl.parse("$baseUrl/manga?")!!.newBuilder()
.addQueryParameter("query", query) .addQueryParameter("search", query)
.addQueryParameter("page", page.toString()) .addQueryParameter("page", page.toString())
val newUrl = null val newUrl = null
filters.forEach { filter -> filters.forEach { filter ->
@ -50,16 +50,15 @@ class MangaYu : ParsedHttpSource() {
return GET(url.toString(), headers) return GET(url.toString(), headers)
} }
override fun popularMangaSelector() = ".box-grid .card > div.card-body" override fun popularMangaSelector() = ".row .col-md-8 .row .col-md-6"
override fun latestUpdatesSelector() = popularMangaSelector() override fun latestUpdatesSelector() = popularMangaSelector()
override fun searchMangaSelector() = popularMangaSelector() override fun searchMangaSelector() = popularMangaSelector()
override fun popularMangaFromElement(element: Element): SManga { override fun popularMangaFromElement(element: Element): SManga {
val manga = SManga.create() val manga = SManga.create()
manga.thumbnail_url = element.select("div.img-box a img").attr("src") manga.setUrlWithoutDomain(element.select(".detail a.link").attr("href"))
manga.title = element.select("a.link-manga").text() manga.title = element.select(".detail a.link").text()
val item = element.select(".img-box a") manga.thumbnail_url = element.select(".cover a img").attr("src")
manga.setUrlWithoutDomain(item.attr("href"))
return manga return manga
} }
@ -86,14 +85,12 @@ class MangaYu : ParsedHttpSource() {
else -> SManga.UNKNOWN else -> SManga.UNKNOWN
} }
override fun chapterListSelector() = "div.chapter-list a" override fun chapterListSelector() = "div.list-group-item a"
override fun chapterFromElement(element: Element) = SChapter.create().apply { override fun chapterFromElement(element: Element) = SChapter.create().apply {
setUrlWithoutDomain(element.attr("href")) setUrlWithoutDomain(element.attr("href"))
// timeStamp to remove child timestamp inside chapter name name = element.select("div.d-flex").text()
val timeStamp = element.select("a.list-chapter i").text() date_upload = parseChapterDate(element.select("span.text-white-50").text()) ?: 0
name = element.select("a.list-chapter").text().substringBefore(timeStamp)
date_upload = timeStamp.let { parseChapterDate(it) } ?: 0
} }
fun parseChapterDate(date: String): Long { fun parseChapterDate(date: String): Long {
@ -134,7 +131,7 @@ class MangaYu : ParsedHttpSource() {
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
val pages = mutableListOf<Page>() val pages = mutableListOf<Page>()
var i = 0 var i = 0
document.select("div.row img.ch-img").forEach { element -> document.select(".chapter-image img").forEach { element ->
val url = element.attr("src") val url = element.attr("src")
i++ i++
if (url.isNotEmpty()) { if (url.isNotEmpty()) {