|
|
|
@ -8,6 +8,10 @@ import io.legado.app.constant.BookType |
|
|
|
|
import io.legado.app.data.entities.rule.* |
|
|
|
|
import io.legado.app.help.SourceAnalyzer |
|
|
|
|
import io.legado.app.utils.* |
|
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
|
import kotlinx.coroutines.sync.Mutex |
|
|
|
|
import kotlinx.coroutines.sync.withLock |
|
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
|
import kotlinx.parcelize.IgnoredOnParcel |
|
|
|
|
import kotlinx.parcelize.Parcelize |
|
|
|
|
import java.io.InputStream |
|
|
|
@ -89,14 +93,25 @@ data class BookSource( |
|
|
|
|
return bookSourceUrl |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@delegate:Transient |
|
|
|
|
@delegate:Ignore |
|
|
|
|
@Ignore |
|
|
|
|
@IgnoredOnParcel |
|
|
|
|
val exploreKinds: List<ExploreKind> by lazy { |
|
|
|
|
val exploreUrl = exploreUrl ?: return@lazy emptyList() |
|
|
|
|
private var exploreKinds: List<ExploreKind>? = null |
|
|
|
|
|
|
|
|
|
@Ignore |
|
|
|
|
@IgnoredOnParcel |
|
|
|
|
private val mutex = Mutex() |
|
|
|
|
|
|
|
|
|
suspend fun exploreKinds(): List<ExploreKind> { |
|
|
|
|
exploreKinds?.let { return it } |
|
|
|
|
val exploreUrl = exploreUrl |
|
|
|
|
if (exploreUrl.isNullOrBlank()) { |
|
|
|
|
return emptyList() |
|
|
|
|
} |
|
|
|
|
mutex.withLock { |
|
|
|
|
exploreKinds?.let { return it } |
|
|
|
|
val kinds = arrayListOf<ExploreKind>() |
|
|
|
|
var ruleStr = exploreUrl |
|
|
|
|
if (ruleStr.isNotBlank()) { |
|
|
|
|
var ruleStr: String = exploreUrl |
|
|
|
|
withContext(IO) { |
|
|
|
|
kotlin.runCatching { |
|
|
|
|
if (exploreUrl.startsWith("<js>", false) |
|
|
|
|
|| exploreUrl.startsWith("@js:", false) |
|
|
|
@ -128,7 +143,16 @@ data class BookSource( |
|
|
|
|
it.printOnDebug() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return@lazy kinds |
|
|
|
|
exploreKinds = kinds |
|
|
|
|
return kinds |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
suspend fun clearExploreKindsCache() { |
|
|
|
|
withContext(IO) { |
|
|
|
|
ACache.get("explore").remove(bookSourceUrl) |
|
|
|
|
exploreKinds = null |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun hashCode(): Int { |
|
|
|
|