Update extension mangakawaii after the new version of Website (#4623)

* Update extension mangakawaii after the new version of Website

* Fix change from comment

Co-authored-by: Duchesne Lucas <lucas.duchesne@soprabanking.com>
This commit is contained in:
Angelghost 2020-10-17 00:10:30 +02:00 committed by GitHub
parent 0af6ecdb26
commit 5d73b434df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 20 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Mangakawaii'
pkgNameSuffix = 'fr.mangakawaii'
extClass = '.MangaKawaii'
extVersionCode = 10
extVersionCode = 11
libVersion = '1.2'
}

View File

@ -28,21 +28,23 @@ class MangaKawaii : ParsedHttpSource() {
return Headers.Builder().add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0")
}
override fun popularMangaSelector() = "a.manga-block-item__content"
override fun latestUpdatesSelector() = ".manga-list li div.updates__left"
override fun popularMangaSelector() = "a.hot-manga__item "
override fun latestUpdatesSelector() = ".section__list-group li div.section__list-group-left"
override fun searchMangaSelector() = "h1 + ul a[href*=manga]"
override fun chapterListSelector() = "div.chapter-item.volume-0, div.chapter-item.volume-"
override fun chapterListSelector() = "tr.chapter-item.volume-0, tr.chapter-item.volume-, tr.volume-0"
override fun popularMangaNextPageSelector() = "a[rel=next]"
override fun latestUpdatesNextPageSelector(): String? = null
override fun searchMangaNextPageSelector() = "no selector"
override fun popularMangaRequest(page: Int) =
GET("$baseUrl/filterLists?page=$page&sortBy=views&asc=false", headersBuilder().add("X-Requested-With", "XMLHttpRequest").build())
override fun popularMangaRequest(page: Int) = GET("$baseUrl/liste-manga/filterMangaList?page=$page&sortBy=views&asc=false", headersBuilder().add("X-Requested-With", "XMLHttpRequest").build())
override fun latestUpdatesRequest(page: Int) = GET(baseUrl, headers)
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val uri = Uri.parse("$baseUrl/search").buildUpon()
.appendQueryParameter("query", query)
.appendQueryParameter("search_type", "manga")
return GET(uri.toString(), headers)
}
@ -53,11 +55,13 @@ class MangaKawaii : ParsedHttpSource() {
manga.thumbnail_url = element.select("a").attr("abs:data-background-image")
return manga
}
override fun latestUpdatesFromElement(element: Element): SManga = SManga.create().apply {
title = element.select(" a").attr("title")
title = element.select(" a").text().trim()
setUrlWithoutDomain(element.select("a").attr("href"))
thumbnail_url = element.select("img").attr("data-src")
}
override fun searchMangaFromElement(element: Element): SManga {
val manga = SManga.create()
manga.url = element.select("a").attr("href")
@ -67,10 +71,11 @@ class MangaKawaii : ParsedHttpSource() {
override fun chapterFromElement(element: Element): SChapter {
val chapter = SChapter.create()
chapter.url = element.select("a.list-item__title").attr("href")
chapter.name = element.select("a.list-item__title").text().trim()
chapter.chapter_number = element.select("a.list-item__title").text().substringAfter("Chapitre").replace(Regex("""[,-]"""), ".").trim().toFloatOrNull() ?: -1F
chapter.date_upload = parseDate(element.select("div.chapter-item__date").text())
chapter.url = element.select("td.table__chapter").select("a").attr("href")
chapter.name = element.select("td.table__chapter").select("span").text().trim()
chapter.chapter_number = element.select("td.table__chapter").select("span").text().substringAfter("Chapitre").replace(Regex("""[,-]"""), ".").trim().toFloatOrNull()
?: -1F
chapter.date_upload = parseDate(element.select("td.table__date").text())
return chapter
}
@ -80,13 +85,13 @@ class MangaKawaii : ParsedHttpSource() {
override fun mangaDetailsParse(document: Document): SManga {
val manga = SManga.create()
manga.thumbnail_url = document.select("img.manga__cover").attr("abs:src")
manga.thumbnail_url = document.select("div.manga-view__header-image").select("img").attr("abs:src")
manga.description = document.select("div.info-desc__content").text()
manga.author = document.select("a[href*=author]").text()
manga.artist = document.select("a[href*=artist]").text()
val glist = document.select("a[href*=category]").map { it.text() }
manga.genre = glist.joinToString(", ")
manga.status = when (document.select("span.label.label-success").text()) {
manga.status = when (document.select("span.badge.bg-success.text-uppercase").text()) {
"En Cours" -> SManga.ONGOING
"Terminé" -> SManga.COMPLETED
else -> SManga.UNKNOWN
@ -96,17 +101,16 @@ class MangaKawaii : ParsedHttpSource() {
override fun pageListParse(response: Response): List<Page> {
val body = response.asJsoup()
val element = body.select("script:containsData(Imagesrc)").toString()
val regex = "(data-src).*[\"]".toRegex()
val match = regex.findAll(element).map { it.value.substringAfter("data-src\", \" ").substringBefore("\"").trim() }
// throw Exception(match.elementAt(1))
var div = body.select("div#all")
var elements = div.select("img")
val pages = mutableListOf<Page>()
for (i in 0 until match.count()) {
pages.add(Page(i, "", match.elementAt(i)))
for (i in 0 until elements.count()) {
pages.add(Page(i, "", elements[i].attr("data-src").trim()))
}
return pages
}
override fun pageListParse(document: Document): List<Page> = throw Exception("Not used")
override fun imageUrlParse(document: Document): String = throw Exception("Not used")
}