From b3a4bf46971d593e09b75f2921435f8aabcc89c8 Mon Sep 17 00:00:00 2001 From: Vetle Ledaal Date: Sun, 21 Jul 2024 10:26:40 +0200 Subject: [PATCH] MangaNoon: update domain (#4138) * MangaNoon: update domain `dateFormat` is wrong, doesn't translate cleanly so left as-is. Set NSFW to false, all the 18+ series checked had at most implied intimacy. * use parseChapterDate() from Galaxy --- src/ar/manganoon/build.gradle | 5 +- .../extension/ar/manganoon/MangaNoon.kt | 87 +++++++++++++++++-- 2 files changed, 85 insertions(+), 7 deletions(-) diff --git a/src/ar/manganoon/build.gradle b/src/ar/manganoon/build.gradle index 5b5d9f7be..7bbd3d8bd 100644 --- a/src/ar/manganoon/build.gradle +++ b/src/ar/manganoon/build.gradle @@ -2,8 +2,9 @@ ext { extName = 'MangaNoon' extClass = '.MangaNoon' themePkg = 'mangathemesia' - baseUrl = 'https://manjanoon.org' - overrideVersionCode = 2 + baseUrl = 'https://manjanoon.co' + overrideVersionCode = 3 + isNsfw = false } apply from: "$rootDir/common.gradle" diff --git a/src/ar/manganoon/src/eu/kanade/tachiyomi/extension/ar/manganoon/MangaNoon.kt b/src/ar/manganoon/src/eu/kanade/tachiyomi/extension/ar/manganoon/MangaNoon.kt index cab224007..6dd918f5c 100644 --- a/src/ar/manganoon/src/eu/kanade/tachiyomi/extension/ar/manganoon/MangaNoon.kt +++ b/src/ar/manganoon/src/eu/kanade/tachiyomi/extension/ar/manganoon/MangaNoon.kt @@ -1,12 +1,89 @@ package eu.kanade.tachiyomi.extension.ar.manganoon import eu.kanade.tachiyomi.multisrc.mangathemesia.MangaThemesia -import java.text.SimpleDateFormat -import java.util.Locale +import eu.kanade.tachiyomi.source.model.SChapter +import org.jsoup.nodes.Element +import java.util.Calendar class MangaNoon : MangaThemesia( "مانجا نون", - "https://manjanoon.org", + "https://manjanoon.co", "ar", - dateFormat = SimpleDateFormat("MMM d, yyy", Locale("ar")), -) +) { + + override fun chapterFromElement(element: Element): SChapter { + return super.chapterFromElement(element).apply { + date_upload = element.selectFirst(".chapterdate")?.text().parseChapterDate() + } + } + + // From Galaxy + override fun String?.parseChapterDate(): Long { + this ?: return 0L + + val number = Regex("""(\d+)""").find(this)?.value?.toIntOrNull() ?: 0 + val cal = Calendar.getInstance() + + return when { + listOf("second", "ثانية").any { contains(it, true) } -> { + cal.apply { add(Calendar.SECOND, -number) }.timeInMillis + } + + contains("دقيقتين", true) -> { + cal.apply { add(Calendar.MINUTE, -2) }.timeInMillis + } + listOf("minute", "دقائق").any { contains(it, true) } -> { + cal.apply { add(Calendar.MINUTE, -number) }.timeInMillis + } + + contains("ساعتان", true) -> { + cal.apply { add(Calendar.HOUR, -2) }.timeInMillis + } + listOf("hour", "ساعات").any { contains(it, true) } -> { + cal.apply { add(Calendar.HOUR, -number) }.timeInMillis + } + + contains("يوم", true) -> { + cal.apply { add(Calendar.DAY_OF_YEAR, -1) }.timeInMillis + } + contains("يومين", true) -> { + cal.apply { add(Calendar.DAY_OF_YEAR, -2) }.timeInMillis + } + listOf("day", "أيام").any { contains(it, true) } -> { + cal.apply { add(Calendar.DAY_OF_YEAR, -number) }.timeInMillis + } + + contains("أسبوع", true) -> { + cal.apply { add(Calendar.WEEK_OF_YEAR, -1) }.timeInMillis + } + contains("أسبوعين", true) -> { + cal.apply { add(Calendar.WEEK_OF_YEAR, -2) }.timeInMillis + } + listOf("week", "أسابيع").any { contains(it, true) } -> { + cal.apply { add(Calendar.WEEK_OF_YEAR, -number) }.timeInMillis + } + + contains("شهر", true) -> { + cal.apply { add(Calendar.MONTH, -1) }.timeInMillis + } + contains("شهرين", true) -> { + cal.apply { add(Calendar.MONTH, -2) }.timeInMillis + } + listOf("month", "أشهر").any { contains(it, true) } -> { + cal.apply { add(Calendar.MONTH, -number) }.timeInMillis + } + + contains("سنة", true) -> { + cal.apply { add(Calendar.YEAR, -1) }.timeInMillis + } + contains("سنتان", true) -> { + cal.apply { add(Calendar.YEAR, -2) }.timeInMillis + } + listOf("year", "سنوات").any { contains(it, true) } -> { + cal.apply { add(Calendar.YEAR, -number) }.timeInMillis + } + + else -> 0L + } + } +}