diff --git a/src/fr/mangakawaii/build.gradle b/src/fr/mangakawaii/build.gradle index 12c800582..6706ef5d6 100644 --- a/src/fr/mangakawaii/build.gradle +++ b/src/fr/mangakawaii/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Mangakawaii' pkgNameSuffix = 'fr.mangakawaii' extClass = '.MangaKawaii' - extVersionCode = 32 + extVersionCode = 33 } dependencies { diff --git a/src/fr/mangakawaii/src/eu/kanade/tachiyomi/extension/fr/mangakawaii/MangaKawaii.kt b/src/fr/mangakawaii/src/eu/kanade/tachiyomi/extension/fr/mangakawaii/MangaKawaii.kt index 2502061f0..c7be9ad33 100644 --- a/src/fr/mangakawaii/src/eu/kanade/tachiyomi/extension/fr/mangakawaii/MangaKawaii.kt +++ b/src/fr/mangakawaii/src/eu/kanade/tachiyomi/extension/fr/mangakawaii/MangaKawaii.kt @@ -16,6 +16,7 @@ import okhttp3.Response import org.jsoup.nodes.Document import org.jsoup.nodes.Element import java.text.SimpleDateFormat +import java.util.Calendar import java.util.Locale import java.util.concurrent.TimeUnit import kotlin.math.absoluteValue @@ -101,6 +102,16 @@ class MangaKawaii : ParsedHttpSource() { "Terminé" -> SManga.COMPLETED else -> SManga.UNKNOWN } + + // add alternative name to manga description + document.select("span[itemprop=name alternativeHeadline]").joinToString { it.ownText() }.let { + if (it.isNotBlank()) { + description = when { + description.isNullOrBlank() -> "Alternative Names: $it" + else -> "$description\n\nAlternative Names: $it" + } + } + } } // Chapter list @@ -109,31 +120,45 @@ class MangaKawaii : ParsedHttpSource() { override fun chapterListParse(response: Response): List { val document = response.asJsoup() - var mangaDocument = document - val visibleChapters = document.select(".table__chapter>a") + val visibleChapters = document.select("tr[class*='volume-']") if (!visibleChapters.isEmpty()) { - // There is chapters, but the complete list isn't displayed here - // To avoid getting the whole list, let's instead go to a manga page to get the list of links - val someChapter = visibleChapters[0].attr("href") + // There is chapters, but the complete list isn't always displayed here + // To get the whole list, let's instead go to a manga page to get the list of links + val someChapter = visibleChapters[0].select(".table__chapter > a").attr("href") + val mangaDocument = client.newCall(GET("$baseUrl$someChapter", headers)).execute().asJsoup() + val notVisibleChapters = mangaDocument.select("#dropdownMenuOffset+ul li") - mangaDocument = client.newCall(GET("$baseUrl$someChapter", headers)).execute().asJsoup() - - return mangaDocument.select("#dropdownMenuOffset+ul li").mapIndexed { i, it -> - SChapter.create().apply { - url = it.select("a").attr("href").replace(baseUrl, "") - chapter_number = i.toFloat() - name = it.select("a").text() - date_upload = 0 - scanlator = "" + // If not everything is displayed + if (visibleChapters.count() < notVisibleChapters.count()) { + return notVisibleChapters.map { + SChapter.create().apply { + setUrlWithoutDomain(it.select("a").attr("href")) + name = it.select("a").text() + date_upload = today + } + } + } else { + return visibleChapters.map { + SChapter.create().apply { + setUrlWithoutDomain(it.select("td.table__chapter > a").attr("href")) + name = it.select("td.table__chapter > a span").text() + date_upload = parseDate(it.select("td.table__date").text()) + } } } } - - return mutableListOf() + return mutableListOf() } + private val today = Calendar.getInstance().apply { + set(Calendar.HOUR_OF_DAY, 0) + set(Calendar.MINUTE, 0) + set(Calendar.SECOND, 0) + set(Calendar.MILLISECOND, 0) + }.timeInMillis + private fun parseDate(date: String): Long { - return SimpleDateFormat("dd.MM.yyyy", Locale.US).parse(date)?.time ?: 0L + return SimpleDateFormat("dd.MM.yyyy", Locale.US).parse(date)?.time ?: today } // Pages @@ -142,12 +167,12 @@ class MangaKawaii : ParsedHttpSource() { val mangaSlug = Regex("""var oeuvre_slug = "([^"]*)";""").find(document.toString())?.groupValues?.get(1) val pages = mutableListOf() - Regex(""""page_image":"([^"]*)"""").findAll(document.toString())?.asIterable().mapIndexed { i, it -> + Regex(""""page_image":"([^"]*)"""").findAll(document.toString()).asIterable().mapIndexed { i, it -> pages.add( Page( i, - cdnUrl + "/uploads/manga/" + mangaSlug + "/chapters_fr/" + chapterSlug + "/" + it?.groupValues?.get(1), - cdnUrl + "/uploads/manga/" + mangaSlug + "/chapters_fr/" + chapterSlug + "/" + it?.groupValues?.get(1) + cdnUrl + "/uploads/manga/" + mangaSlug + "/chapters_fr/" + chapterSlug + "/" + it.groupValues[1], + cdnUrl + "/uploads/manga/" + mangaSlug + "/chapters_fr/" + chapterSlug + "/" + it.groupValues[1] ) ) }