add blackoutscans (#1367)

This commit is contained in:
Secozzi 2024-02-19 03:24:03 +00:00 committed by Draff
parent a03bb1f780
commit 166dbec86f
9 changed files with 54 additions and 9 deletions

View File

@ -2,4 +2,4 @@ plugins {
id("lib-multisrc") id("lib-multisrc")
} }
baseVersionCode = 1 baseVersionCode = 2

View File

@ -19,7 +19,9 @@ import okhttp3.Response
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.text.ParseException
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale import java.util.Locale
abstract class Keyoapp( abstract class Keyoapp(
@ -38,6 +40,8 @@ abstract class Keyoapp(
private val json: Json by injectLazy() private val json: Json by injectLazy()
private val dateFormat = SimpleDateFormat("MMM d, yyyy", Locale.ENGLISH)
// Popular // Popular
override fun popularMangaRequest(page: Int): Request = GET(baseUrl, headers) override fun popularMangaRequest(page: Int): Request = GET(baseUrl, headers)
@ -206,7 +210,7 @@ abstract class Keyoapp(
// Chapter list // 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 { override fun chapterFromElement(element: Element): SChapter = SChapter.create().apply {
setUrlWithoutDomain(element.selectFirst("a[href]")!!.attr("href")) setUrlWithoutDomain(element.selectFirst("a[href]")!!.attr("href"))
@ -259,13 +263,40 @@ abstract class Keyoapp(
} }
private fun String.parseDate(): Long { private fun String.parseDate(): Long {
return runCatching { DATE_FORMATTER.parse(this)?.time } return if (this.contains("ago")) {
.getOrNull() ?: 0L this.parseRelativeDate()
} } else {
try {
companion object { dateFormat.parse(this)!!.time
private val DATE_FORMATTER by lazy { } catch (_: ParseException) {
SimpleDateFormat("MMM d, yyyy", Locale.ENGLISH) 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
}
} }

View File

@ -0,0 +1,9 @@
ext {
extName = 'Blackout Scans'
extClass = '.BlackoutScans'
themePkg = 'keyoapp'
baseUrl = 'https://blackoutscans.com'
overrideVersionCode = 0
}
apply from: "$rootDir/common.gradle"

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -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")