This commit is contained in:
Jobobby04
2020-08-24 17:25:10 -04:00
parent 166aebdf25
commit 80960d87f2
14 changed files with 43 additions and 96 deletions
@@ -54,7 +54,7 @@ class EHentaiUpdateHelper(context: Context) {
// Accept oldest chain
val chainsWithAccepted = chainsObservable.map { chains ->
val acceptedChain = chains.minBy { it.manga.id!! }!!
val acceptedChain = chains.minByOrNull { it.manga.id!! }!!
acceptedChain to chains
}
@@ -91,7 +91,7 @@ class EHentaiUpdateHelper(context: Context) {
.fold(accepted.chapters) { curChapters, chapter ->
val existing = curChapters.find { it.url == chapter.url }
val newLastPageRead = chainsAsChapters.maxBy { it.last_page_read }?.last_page_read
val newLastPageRead = chainsAsChapters.maxByOrNull { it.last_page_read }?.last_page_read
when {
existing != null -> {
@@ -151,7 +151,7 @@ class EHentaiUpdateWorker : JobService(), CoroutineScope {
return@mapNotNull null
}
val chapter = db.getChaptersByMangaId(manga.id!!).asRxSingle().await().minBy {
val chapter = db.getChaptersByMangaId(manga.id!!).asRxSingle().await().minByOrNull {
it.date_upload
}
@@ -7,21 +7,15 @@ import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.SManga
import exh.util.await
import info.debatty.java.stringsimilarity.NormalizedLevenshtein
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.async
import kotlinx.coroutines.supervisorScope
import rx.schedulers.Schedulers
import uy.kohesive.injekt.injectLazy
class SmartSearchEngine(
parentContext: CoroutineContext,
private val extraSearchParams: String? = null
) : CoroutineScope {
override val coroutineContext: CoroutineContext = parentContext + Job() + Dispatchers.Default
) {
private val db: DatabaseHelper by injectLazy()
private val normalizedLevenshtein = NormalizedLevenshtein()
@@ -52,7 +46,7 @@ class SmartSearchEngine(
}.flatMap { it.await() }
}
return eligibleManga.maxBy { it.dist }?.manga
return eligibleManga.maxByOrNull { it.dist }?.manga
}
suspend fun normalSearch(source: CatalogueSource, title: String): SManga? {
@@ -74,7 +68,7 @@ class SmartSearchEngine(
}
}
return eligibleManga.maxBy { it.dist }?.manga
return eligibleManga.maxByOrNull { it.dist }?.manga
}
private fun getSmartSearchQueries(cleanedTitle: String): List<String> {
@@ -21,7 +21,7 @@ class SmartSearchPresenter(private val source: CatalogueSource?, private val con
val smartSearchChannel = Channel<SearchResults>()
private val smartSearchEngine = SmartSearchEngine(scope.coroutineContext)
private val smartSearchEngine = SmartSearchEngine()
override fun onCreate(savedState: Bundle?) {
super.onCreate(savedState)
+2 -2
View File
@@ -3,7 +3,7 @@ package exh.util
import com.elvishew.xlog.XLog
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Response
import okhttp3.ResponseBody
import okhttp3.ResponseBody.Companion.toResponseBody
import org.jsoup.nodes.Document
fun Response.interceptAsHtml(block: (Document) -> Unit): Response {
@@ -13,7 +13,7 @@ fun Response.interceptAsHtml(block: (Document) -> Unit): Response {
) {
val bodyString = body.string()
val rebuiltResponse = newBuilder()
.body(ResponseBody.create(body.contentType(), bodyString))
.body(bodyString.toResponseBody(body.contentType()))
.build()
try {
// Search for captcha