Add support for EH Visited exported data in batch add

This commit is contained in:
Jobobby04
2020-05-18 13:00:13 -04:00
parent c069d75ede
commit b0251b8177
3 changed files with 33 additions and 7 deletions

View File

@@ -1,12 +1,16 @@
package exh.ui.batchadd
import android.util.Log
import com.jakewharton.rxrelay.BehaviorRelay
import com.jakewharton.rxrelay.ReplayRelay
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
import exh.GalleryAddEvent
import exh.GalleryAdder
import exh.metadata.nullIfBlank
import kotlin.concurrent.thread
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
class BatchAddPresenter : BasePresenter<BatchAddController>() {
@@ -19,7 +23,25 @@ class BatchAddPresenter : BasePresenter<BatchAddController>() {
fun addGalleries(galleries: String) {
eventRelay = ReplayRelay.create()
val splitGalleries = galleries.split("\n").mapNotNull {
val regex =
"""[0-9]*?\.[a-z0-9]*?:""".toRegex()
val testedGalleries: String
testedGalleries = if (regex.containsMatchIn(galleries)) {
regex.findAll(galleries).map { galleryKeys ->
val LinkParts = galleryKeys.value.split(".")
val Link = "${if (Injekt.get<PreferencesHelper>().enableExhentai().get()) {
"https://exhentai.org/g/"
} else {
"https://e-hentai.org/g/"
}}${LinkParts[0]}/${LinkParts[1].replace(":", "")}"
Log.d("Batch Add", Link)
Link
}.joinToString(separator = "\n")
} else {
galleries
}
val splitGalleries = testedGalleries.split("\n").mapNotNull {
it.trim().nullIfBlank()
}