Minor cleanup
This commit is contained in:
@@ -8,8 +8,7 @@ import eu.kanade.tachiyomi.util.lang.withIOContext
|
||||
import exh.GalleryAddEvent
|
||||
import exh.GalleryAdder
|
||||
import exh.log.xLogE
|
||||
import exh.util.dropEmpty
|
||||
import exh.util.trimAll
|
||||
import exh.util.trimOrNull
|
||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ensureActive
|
||||
@@ -30,25 +29,21 @@ class BatchAddPresenter : BasePresenter<BatchAddController>() {
|
||||
|
||||
fun addGalleries(context: Context, galleries: String) {
|
||||
eventFlow = MutableSharedFlow(1)
|
||||
val regex =
|
||||
"""[0-9]*?\.[a-z0-9]*?:""".toRegex()
|
||||
|
||||
val testedGalleries = if (regex.containsMatchIn(galleries)) {
|
||||
val splitGalleries = if (ehVisitedRegex.containsMatchIn(galleries)) {
|
||||
val url = if (preferences.enableExhentai().get()) {
|
||||
"https://exhentai.org/g/"
|
||||
} else {
|
||||
"https://e-hentai.org/g/"
|
||||
}
|
||||
regex.findAll(galleries).map { galleryKeys ->
|
||||
ehVisitedRegex.findAll(galleries).map { galleryKeys ->
|
||||
val linkParts = galleryKeys.value.split(".")
|
||||
url + linkParts[0] + "/" + linkParts[1].replace(":", "")
|
||||
}.joinToString(separator = "\n")
|
||||
}.toList()
|
||||
} else {
|
||||
galleries
|
||||
galleries.split("\n")
|
||||
.mapNotNull(String::trimOrNull)
|
||||
}
|
||||
val splitGalleries = testedGalleries.split("\n")
|
||||
.trimAll()
|
||||
.dropEmpty()
|
||||
|
||||
progressFlow.value = 0
|
||||
progressTotalFlow.value = splitGalleries.size
|
||||
@@ -92,5 +87,7 @@ class BatchAddPresenter : BasePresenter<BatchAddController>() {
|
||||
const val STATE_IDLE = 0
|
||||
const val STATE_INPUT_TO_PROGRESS = 1
|
||||
const val STATE_PROGRESS_TO_INPUT = 2
|
||||
|
||||
val ehVisitedRegex = """[0-9]*?\.[a-z0-9]*?:""".toRegex()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user