From 73481f18176c15977ba31a34637daafc9e78afa3 Mon Sep 17 00:00:00 2001 From: Riztard Lanthorn Date: Wed, 31 Mar 2021 21:04:48 +0700 Subject: [PATCH] KSGroupScans: add source (#6362) --- .../fmreader/ksgroupscans/src/KSGroupScans.kt | 67 +++++++++++++++++++ .../multisrc/fmreader/FMReaderGenerator.kt | 1 + 2 files changed, 68 insertions(+) create mode 100644 multisrc/overrides/fmreader/ksgroupscans/src/KSGroupScans.kt diff --git a/multisrc/overrides/fmreader/ksgroupscans/src/KSGroupScans.kt b/multisrc/overrides/fmreader/ksgroupscans/src/KSGroupScans.kt new file mode 100644 index 000000000..27b0bb585 --- /dev/null +++ b/multisrc/overrides/fmreader/ksgroupscans/src/KSGroupScans.kt @@ -0,0 +1,67 @@ +package eu.kanade.tachiyomi.extension.en.ksgroupscans + +import eu.kanade.tachiyomi.multisrc.fmreader.FMReader +import eu.kanade.tachiyomi.source.model.SChapter +import org.jsoup.nodes.Element +import java.util.Calendar + + +class KSGroupScans : FMReader("KSGroupScans", "https://ksgroupscans.com", "en") { + override fun chapterFromElement(element: Element, mangaTitle: String): SChapter { + return SChapter.create().apply { + element.select(chapterUrlSelector).first().let { + setUrlWithoutDomain(it.attr("abs:href")) + name = element.select(".chapter-name").text() + } + date_upload = element.select(chapterTimeSelector).let { if (it.hasText()) parseChapterDate(it.text()) else 0 } + } + } + + private fun parseChapterDate(date: String): Long { + val value = date.split(' ')[dateValueIndex].toInt() + val dateWord = date.split(' ')[dateWordIndex].let { + if (it.contains("(")) { + it.substringBefore("(") + } else { + it.substringBefore("s") + } + } + + // languages: en, vi, es, tr + return when (dateWord) { + "min", "minute", "phút", "minuto", "dakika" -> Calendar.getInstance().apply { + add(Calendar.MINUTE, value * -1) + set(Calendar.SECOND, 0) + set(Calendar.MILLISECOND, 0) + }.timeInMillis + "hour", "giờ", "hora", "saat" -> Calendar.getInstance().apply { + add(Calendar.HOUR_OF_DAY, value * -1) + set(Calendar.SECOND, 0) + set(Calendar.MILLISECOND, 0) + }.timeInMillis + "day", "ngày", "día", "gün" -> Calendar.getInstance().apply { + add(Calendar.DATE, value * -1) + set(Calendar.SECOND, 0) + set(Calendar.MILLISECOND, 0) + }.timeInMillis + "week", "tuần", "semana", "hafta" -> Calendar.getInstance().apply { + add(Calendar.DATE, value * 7 * -1) + set(Calendar.SECOND, 0) + set(Calendar.MILLISECOND, 0) + }.timeInMillis + "month", "tháng", "mes", "ay" -> Calendar.getInstance().apply { + add(Calendar.MONTH, value * -1) + set(Calendar.SECOND, 0) + set(Calendar.MILLISECOND, 0) + }.timeInMillis + "year", "năm", "año", "yıl" -> Calendar.getInstance().apply { + add(Calendar.YEAR, value * -1) + set(Calendar.SECOND, 0) + set(Calendar.MILLISECOND, 0) + }.timeInMillis + else -> { + return 0 + } + } + } +} diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/fmreader/FMReaderGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/fmreader/FMReaderGenerator.kt index 5d091e0ac..073fb3ef3 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/fmreader/FMReaderGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/fmreader/FMReaderGenerator.kt @@ -54,6 +54,7 @@ class FMReaderGenerator : ThemeSourceGenerator { ), SingleLang("RawLH", "https://lovehug.net", "ja"), SingleLang("Say Truyen", "https://saytruyen.com", "vi"), + SingleLang("KSGroupScans", "https://ksgroupscans.com", "en"), ) companion object {