Delegate Mangadex (Part 1)

This commit is contained in:
Jobobby04
2020-08-19 18:20:05 -04:00
parent 9efb1482f9
commit 64bb34b50d
3 changed files with 12 additions and 9 deletions
+8
View File
@@ -3,6 +3,7 @@ package exh
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.online.all.Hitomi
import eu.kanade.tachiyomi.source.online.all.MangaDex
import eu.kanade.tachiyomi.source.online.all.NHentai
import eu.kanade.tachiyomi.source.online.all.PervEden
import eu.kanade.tachiyomi.source.online.english.EightMuses
@@ -41,6 +42,7 @@ private val DELEGATED_LEWD_SOURCES = listOf(
private val hitomiClass = listOf(Hitomi::class)
private val nHentaiClass = listOf(NHentai::class)
private val mangaDexClass = listOf(MangaDex::class)
// Used to speed up isLewdSource
val lewdDelegatedSourceIds by lazy {
@@ -61,6 +63,12 @@ val nHentaiSourceIds by lazy {
}.map { it.value.sourceId }.sorted()
}
val mangaDexSourceIds by lazy {
SourceManager.currentDelegatedSources.filter {
it.value.newSourceClass in mangaDexClass
}.map { it.value.sourceId }.sorted()
}
// This method MUST be fast!
fun isLewdSource(source: Long) = source in 6900..6999 ||
lewdDelegatedSourceIds.binarySearch(source) >= 0