diff --git a/lib-multisrc/keyoapp/build.gradle.kts b/lib-multisrc/keyoapp/build.gradle.kts index dc076cc37..9dce2478c 100644 --- a/lib-multisrc/keyoapp/build.gradle.kts +++ b/lib-multisrc/keyoapp/build.gradle.kts @@ -2,4 +2,4 @@ plugins { id("lib-multisrc") } -baseVersionCode = 1 +baseVersionCode = 2 diff --git a/lib-multisrc/keyoapp/src/eu/kanade/tachiyomi/multisrc/keyoapp/Keyoapp.kt b/lib-multisrc/keyoapp/src/eu/kanade/tachiyomi/multisrc/keyoapp/Keyoapp.kt index 9fa1b40c5..9e893c943 100644 --- a/lib-multisrc/keyoapp/src/eu/kanade/tachiyomi/multisrc/keyoapp/Keyoapp.kt +++ b/lib-multisrc/keyoapp/src/eu/kanade/tachiyomi/multisrc/keyoapp/Keyoapp.kt @@ -19,7 +19,9 @@ import okhttp3.Response import org.jsoup.nodes.Document import org.jsoup.nodes.Element import uy.kohesive.injekt.injectLazy +import java.text.ParseException import java.text.SimpleDateFormat +import java.util.Calendar import java.util.Locale abstract class Keyoapp( @@ -38,6 +40,8 @@ abstract class Keyoapp( private val json: Json by injectLazy() + private val dateFormat = SimpleDateFormat("MMM d, yyyy", Locale.ENGLISH) + // Popular override fun popularMangaRequest(page: Int): Request = GET(baseUrl, headers) @@ -206,7 +210,7 @@ abstract class Keyoapp( // Chapter list - override fun chapterListSelector(): String = "#chapters > a" + override fun chapterListSelector(): String = "#chapters > a:not(:has(.text-sm span:matches(Upcoming)))" override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply { setUrlWithoutDomain(element.selectFirst("a[href]")!!.attr("href")) @@ -259,13 +263,40 @@ abstract class Keyoapp( } private fun String.parseDate(): Long { - return runCatching { DATE_FORMATTER.parse(this)?.time } - .getOrNull() ?: 0L - } - - companion object { - private val DATE_FORMATTER by lazy { - SimpleDateFormat("MMM d, yyyy", Locale.ENGLISH) + return if (this.contains("ago")) { + this.parseRelativeDate() + } else { + try { + dateFormat.parse(this)!!.time + } catch (_: ParseException) { + 0L + } } } + + private fun String.parseRelativeDate(): Long { + val now = Calendar.getInstance().apply { + set(Calendar.HOUR_OF_DAY, 0) + set(Calendar.MINUTE, 0) + set(Calendar.SECOND, 0) + set(Calendar.MILLISECOND, 0) + } + + val relativeDate = this.split(" ").firstOrNull() + ?.replace("one", "1") + ?.replace("a", "1") + ?.toIntOrNull() + ?: return 0L + + when { + "second" in this -> now.add(Calendar.SECOND, -relativeDate) // parse: 30 seconds ago + "minute" in this -> now.add(Calendar.MINUTE, -relativeDate) // parses: "42 minutes ago" + "hour" in this -> now.add(Calendar.HOUR, -relativeDate) // parses: "1 hour ago" and "2 hours ago" + "day" in this -> now.add(Calendar.DAY_OF_YEAR, -relativeDate) // parses: "2 days ago" + "week" in this -> now.add(Calendar.WEEK_OF_YEAR, -relativeDate) // parses: "2 weeks ago" + "month" in this -> now.add(Calendar.MONTH, -relativeDate) // parses: "2 months ago" + "year" in this -> now.add(Calendar.YEAR, -relativeDate) // parse: "2 years ago" + } + return now.timeInMillis + } } diff --git a/src/en/blackoutscans/build.gradle b/src/en/blackoutscans/build.gradle new file mode 100644 index 000000000..6af07e1cf --- /dev/null +++ b/src/en/blackoutscans/build.gradle @@ -0,0 +1,9 @@ +ext { + extName = 'Blackout Scans' + extClass = '.BlackoutScans' + themePkg = 'keyoapp' + baseUrl = 'https://blackoutscans.com' + overrideVersionCode = 0 +} + +apply from: "$rootDir/common.gradle" diff --git a/src/en/blackoutscans/res/mipmap-hdpi/ic_launcher.png b/src/en/blackoutscans/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..6c39980c8 Binary files /dev/null and b/src/en/blackoutscans/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/en/blackoutscans/res/mipmap-mdpi/ic_launcher.png b/src/en/blackoutscans/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..dffc76ea6 Binary files /dev/null and b/src/en/blackoutscans/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/en/blackoutscans/res/mipmap-xhdpi/ic_launcher.png b/src/en/blackoutscans/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..c7b1942c7 Binary files /dev/null and b/src/en/blackoutscans/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/en/blackoutscans/res/mipmap-xxhdpi/ic_launcher.png b/src/en/blackoutscans/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..7b77a5826 Binary files /dev/null and b/src/en/blackoutscans/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/en/blackoutscans/res/mipmap-xxxhdpi/ic_launcher.png b/src/en/blackoutscans/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..0adc25662 Binary files /dev/null and b/src/en/blackoutscans/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/en/blackoutscans/src/eu/kanade/tachiyomi/extension/en/blackoutscans/BlackoutScans.kt b/src/en/blackoutscans/src/eu/kanade/tachiyomi/extension/en/blackoutscans/BlackoutScans.kt new file mode 100644 index 000000000..b75b81992 --- /dev/null +++ b/src/en/blackoutscans/src/eu/kanade/tachiyomi/extension/en/blackoutscans/BlackoutScans.kt @@ -0,0 +1,5 @@ +package eu.kanade.tachiyomi.extension.en.blackoutscans + +import eu.kanade.tachiyomi.multisrc.keyoapp.Keyoapp + +class BlackoutScans : Keyoapp("Blackout Scans", "https://blackoutscans.com", "en")