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()
}

View File

@ -19,7 +19,7 @@
android:id="@+id/input_title_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Enter the galleries to add (separated by a new line):"
android:text="@string/eh_batch_add_title"
android:textAppearance="@style/TextAppearance.Medium.Title"
android:visibility="visible"
app:layout_constraintLeft_toLeftOf="parent"
@ -31,7 +31,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Example:\n\nhttp://e-hentai.org/g/12345/1a2b3c4e\nhttp://g.e-hentai.org/g/67890/6f7g8h9i\nhttp://exhentai.org/g/13579/1a3b5c7e\nhttps://exhentai.org/g/24680/2f4g6h8i\n"
android:hint="@string/eh_batch_add_description"
android:inputType="textMultiLine"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="@+id/btn_add_galleries"
@ -43,7 +43,7 @@
android:id="@+id/btn_add_galleries"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Add Galleries"
android:text="@string/eh_batch_add_button"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@+id/galleries_box"
@ -58,7 +58,7 @@
android:layout_marginTop="0dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="0dp"
android:text="Adding galleries..."
android:text="@string/eh_batch_add_adding_galleries"
android:textAppearance="@style/TextAppearance.Medium.Title"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
@ -71,7 +71,6 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="0dp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/progress_dismiss_btn"
@ -98,7 +97,7 @@
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="0dp"
android:text="Finish"
android:text="@string/eh_batch_add_finish"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@+id/btn_add_galleries"
app:layout_constraintHorizontal_bias="0.0"

View File

@ -99,6 +99,11 @@
<string name="eh_force_sync_reset_message">Resetting the sync state can cause your next sync to be extremely slow.</string>
<string name="eh_show_update_statistics_dialog">Collecting statistics…</string>
<string name="eh_saved_searches">Saved Searches</string>
<string name="eh_batch_add_description">Example:\n\nhttp://e-hentai.org/g/12345/1a2b3c4e\nhttp://g.e-hentai.org/g/67890/6f7g8h9i\nhttp://exhentai.org/g/13579/1a3b5c7e\nhttps://exhentai.org/g/24680/2f4g6h8i\n\nIt also supports E-H Visited exported data\n</string>
<string name="eh_batch_add_title">Enter the galleries to add (separated by a new line):</string>
<string name="eh_batch_add_button">Add Galleries</string>
<string name="eh_batch_add_adding_galleries">Adding galleries…</string>
<string name="eh_batch_add_finish">Finish</string>
<!-- AZ -->
<string name="az_recommends">See Recommendations</string>