MangaKisa - fix chapters (#3124)

MangaKisa - fix chapters
This commit is contained in:
Mike 2020-05-11 22:01:19 -04:00 committed by GitHub
parent bcf2943576
commit 6c4818232d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 42 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: MangaKisa'
pkgNameSuffix = 'en.mangakisa'
extClass = '.MangaKisa'
extVersionCode = 2
extVersionCode = 3
libVersion = '1.2'
}

View File

@ -13,7 +13,6 @@ 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.util.Calendar
import java.util.concurrent.TimeUnit
import okhttp3.OkHttpClient
import okhttp3.Request
@ -74,15 +73,10 @@ class MangaKisa : ConfigurableSource, ParsedHttpSource() {
return GET(uri.toString(), headers)
}
override fun mangaDetailsRequest(manga: SManga) = GET(baseUrl + manga.url, headers)
override fun chapterListRequest(manga: SManga) = mangaDetailsRequest(manga)
override fun pageListRequest(chapter: SChapter) = GET(baseUrl + chapter.url, headers)
override fun popularMangaFromElement(element: Element) = mangaFromElement(element)
override fun latestUpdatesFromElement(element: Element) = mangaFromElement(element)
override fun searchMangaFromElement(element: Element) = mangaFromElement(element)
private fun mangaFromElement(element: Element): SManga {
private fun mangaFromElement(element: Element): SManga {
val manga = SManga.create()
manga.setUrlWithoutDomain(element.select(".an").first().attr("href"))
manga.title = element.select("img").attr("alt").trim()
@ -91,31 +85,11 @@ class MangaKisa : ConfigurableSource, ParsedHttpSource() {
}
override fun chapterFromElement(element: Element): SChapter {
val chapter = SChapter.create()
chapter.setUrlWithoutDomain("/" + element.select("a").attr("href"))
chapter.chapter_number = element.select("[class*=infoept2] > div").text().toFloat()
chapter.name = "Chapter " + element.select("[class*=infoept2] > div").text().trim()
chapter.date_upload = parseRelativeDate(element.select("[class*=infoept3] > div").text()) ?: 0
return chapter
}
private fun parseRelativeDate(date: String): Long? {
val trimmedDate = date.split(" ")
if (trimmedDate[2] != "ago") return null
val number = trimmedDate[0].toIntOrNull() ?: return null
// Map English and other language units to Java units
val javaUnit = when (trimmedDate[1].removeSuffix("s")) {
"year" -> Calendar.YEAR
"month" -> Calendar.MONTH
"day" -> Calendar.DAY_OF_MONTH
"hr" -> Calendar.HOUR
"min" -> Calendar.MINUTE
"second" -> Calendar.SECOND
else -> return null
return SChapter.create().apply {
setUrlWithoutDomain(element.attr("abs:href"))
name = element.text()
date_upload = "${element.select("time").attr("time")}000".toLongOrNull() ?: 0
}
return Calendar.getInstance().apply { add(javaUnit, -number) }.timeInMillis
}
override fun mangaDetailsParse(document: Document): SManga {
@ -124,28 +98,22 @@ class MangaKisa : ConfigurableSource, ParsedHttpSource() {
manga.artist = document.select(".textc > a[href*=authors]").text().trim()
manga.author = document.select(".textc > a[href*=authors]").text().trim()
manga.description = document.select(".infodes2").first().text()
val glist = document.select("a.infoan[href*=genres]").map { it.text() }
manga.genre = glist.joinToString(", ")
manga.genre = document.select("a.infoan[href*=genres]").joinToString(", ") { it.text() }
manga.status = when (document.select(".textc:contains(Ongoing), .textc:contains(Completed)")?.first()?.text()) {
"Ongoing" -> SManga.ONGOING
"Completed" -> SManga.COMPLETED
else -> SManga.UNKNOWN
}
manga.thumbnail_url = baseUrl + "/" + document.select(".infopicbox > img").attr("src")
manga.thumbnail_url = document.select(".infopicbox > img").attr("abs:src")
return manga
}
override fun pageListParse(document: Document): List<Page> {
val pages = mutableListOf<Page>()
document.select("img")?.forEach {
pages.add(Page(pages.size, "", it.attr("src")))
return document.select("div.vertical_div > div img").mapIndexed { i, img ->
Page(i, "", img.attr("abs:src"))
}
return pages
}
override fun imageUrlRequest(page: Page) = throw Exception("Not used")
override fun imageUrlParse(document: Document) = throw Exception("Not used")
// Filter List Code