* refactor: use NoResultsException * refactor: cleanup RecommendationPagingSources * refactor: turn wake/wifi lock functions into reusable extensions * feat: implement batch recommendation (initial version) * fix: serialization issues * fix: wrong source id * refactor: increase performance using virtual paging * refactor: update string * refactor: handle 404 of MD source correctly * style: add newline * refactor: create universal throttle manager * refactor: throttle requests * chore: remove unused strings * feat: rank recommendations by match count * feat: add badges indicating match count to batch recommendations * fix: handle rec search with no results * fix: validate flags in pre-search bottom sheet * feat: implement 'hide library entries' for recommendation search using custom SmartSearchEngine for library items * style: run spotless * fix: cancel button * fix: racing condition causing loss of state
28 lines
996 B
Kotlin
28 lines
996 B
Kotlin
package exh.smartsearch
|
|
|
|
import eu.kanade.domain.manga.model.toDomainManga
|
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
|
import eu.kanade.tachiyomi.source.model.FilterList
|
|
import eu.kanade.tachiyomi.source.model.SManga
|
|
import tachiyomi.domain.manga.model.Manga
|
|
|
|
class SmartSourceSearchEngine(
|
|
extraSearchParams: String? = null,
|
|
) : BaseSmartSearchEngine<SManga>(extraSearchParams) {
|
|
|
|
override fun getTitle(result: SManga) = result.originalTitle
|
|
|
|
suspend fun smartSearch(source: CatalogueSource, title: String): Manga? =
|
|
smartSearch(makeSearchAction(source), title).let {
|
|
it?.toDomainManga(source.id)
|
|
}
|
|
|
|
suspend fun normalSearch(source: CatalogueSource, title: String): Manga? =
|
|
normalSearch(makeSearchAction(source), title).let {
|
|
it?.toDomainManga(source.id)
|
|
}
|
|
|
|
private fun makeSearchAction(source: CatalogueSource): SearchAction<SManga> =
|
|
{ query -> source.getSearchManga(1, query, FilterList()).mangas }
|
|
}
|