In batch add and deeplink, only use enabled sources
This commit is contained in:
parent
a439ffcafc
commit
f1a4811030
@ -7,6 +7,7 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.online.UrlImportableSource
|
import eu.kanade.tachiyomi.source.online.UrlImportableSource
|
||||||
import eu.kanade.tachiyomi.source.online.all.EHentai
|
import eu.kanade.tachiyomi.source.online.all.EHentai
|
||||||
@ -14,6 +15,8 @@ import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
|||||||
import eu.kanade.tachiyomi.util.lang.awaitSingle
|
import eu.kanade.tachiyomi.util.lang.awaitSingle
|
||||||
import exh.source.getMainSource
|
import exh.source.getMainSource
|
||||||
import exh.util.executeOnIO
|
import exh.util.executeOnIO
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class GalleryAdder {
|
class GalleryAdder {
|
||||||
@ -22,6 +25,11 @@ class GalleryAdder {
|
|||||||
|
|
||||||
private val sourceManager: SourceManager by injectLazy()
|
private val sourceManager: SourceManager by injectLazy()
|
||||||
|
|
||||||
|
private val filters: Pair<Set<String>, Set<Long>> = run {
|
||||||
|
val preferences = Injekt.get<PreferencesHelper>()
|
||||||
|
preferences.enabledLanguages().get() to preferences.disabledSources().get().map { it.toLong() }.toSet()
|
||||||
|
}
|
||||||
|
|
||||||
private val logger = XLog.tag("GalleryAdder").enableStackTrace(2).build()
|
private val logger = XLog.tag("GalleryAdder").enableStackTrace(2).build()
|
||||||
|
|
||||||
fun pickSource(url: String): List<UrlImportableSource> {
|
fun pickSource(url: String): List<UrlImportableSource> {
|
||||||
@ -30,7 +38,7 @@ class GalleryAdder {
|
|||||||
.map { it.getMainSource() }
|
.map { it.getMainSource() }
|
||||||
.filterIsInstance<UrlImportableSource>()
|
.filterIsInstance<UrlImportableSource>()
|
||||||
.filter {
|
.filter {
|
||||||
try {
|
it.lang in filters.first && it.id !in filters.second && try {
|
||||||
it.matchesUri(uri)
|
it.matchesUri(uri)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
false
|
false
|
||||||
@ -63,7 +71,7 @@ class GalleryAdder {
|
|||||||
.map { it.getMainSource() }
|
.map { it.getMainSource() }
|
||||||
.filterIsInstance<UrlImportableSource>()
|
.filterIsInstance<UrlImportableSource>()
|
||||||
.find {
|
.find {
|
||||||
try {
|
it.lang in filters.first && it.id !in filters.second && try {
|
||||||
it.matchesUri(uri)
|
it.matchesUri(uri)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
false
|
false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user