MyReadingManga Misc Updates (#13532)
* Reorder Sort Filters * Cache Filters from Latest if needed
This commit is contained in:
parent
5467390997
commit
21b399555e
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'MyReadingManga'
|
extName = 'MyReadingManga'
|
||||||
pkgNameSuffix = 'all.myreadingmanga'
|
pkgNameSuffix = 'all.myreadingmanga'
|
||||||
extClass = '.MyReadingMangaFactory'
|
extClass = '.MyReadingMangaFactory'
|
||||||
extVersionCode = 45
|
extVersionCode = 46
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,10 +41,7 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun popularMangaParse(response: Response): MangasPage {
|
override fun popularMangaParse(response: Response): MangasPage {
|
||||||
if (!filtersCached) {
|
cacheAssistant()
|
||||||
cachedPagesUrls.onEach { filterAssist(it.value) }
|
|
||||||
filtersCached = true
|
|
||||||
}
|
|
||||||
return searchMangaParse(response)
|
return searchMangaParse(response)
|
||||||
}
|
}
|
||||||
override fun popularMangaNextPageSelector() = throw Exception("Not used")
|
override fun popularMangaNextPageSelector() = throw Exception("Not used")
|
||||||
|
@ -60,6 +57,10 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
|
||||||
override fun latestUpdatesNextPageSelector() = "li.pagination-next"
|
override fun latestUpdatesNextPageSelector() = "li.pagination-next"
|
||||||
override fun latestUpdatesSelector() = "article"
|
override fun latestUpdatesSelector() = "article"
|
||||||
override fun latestUpdatesFromElement(element: Element) = buildManga(element.select("a[rel]").first(), element.select("a.entry-image-link img").first())
|
override fun latestUpdatesFromElement(element: Element) = buildManga(element.select("a[rel]").first(), element.select("a.entry-image-link img").first())
|
||||||
|
override fun latestUpdatesParse(response: Response): MangasPage {
|
||||||
|
cacheAssistant()
|
||||||
|
return super.latestUpdatesParse(response)
|
||||||
|
}
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
|
@ -74,7 +75,7 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
|
||||||
filter.addToUri(uri, "wpsolr_fq[${i - indexModifier}]")
|
filter.addToUri(uri, "wpsolr_fq[${i - indexModifier}]")
|
||||||
}
|
}
|
||||||
if (filter is SearchSortTypeList) {
|
if (filter is SearchSortTypeList) {
|
||||||
uri.appendQueryParameter("wpsolr_sort", listOf("sort_by_random", "sort_by_date_desc", "sort_by_date_asc", "sort_by_relevancy_desc")[filter.state])
|
uri.appendQueryParameter("wpsolr_sort", listOf("sort_by_date_desc", "sort_by_date_asc", "sort_by_random", "sort_by_relevancy_desc")[filter.state])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uri.appendQueryParameter("wpsolr_page", page.toString())
|
uri.appendQueryParameter("wpsolr_page", page.toString())
|
||||||
|
@ -233,6 +234,13 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
|
||||||
return response.body!!.string()
|
return response.body!!.string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun cacheAssistant() {
|
||||||
|
if (!filtersCached) {
|
||||||
|
cachedPagesUrls.onEach { filterAssist(it.value) }
|
||||||
|
filtersCached = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Returns page from cache to reduce calls to website
|
// Returns page from cache to reduce calls to website
|
||||||
private fun getCache(url: String): Document? {
|
private fun getCache(url: String): Document? {
|
||||||
val response = client.newCall(GET(url, headers, CacheControl.FORCE_CACHE)).execute()
|
val response = client.newCall(GET(url, headers, CacheControl.FORCE_CACHE)).execute()
|
||||||
|
@ -285,7 +293,7 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
|
||||||
private class CatFilter(CATID: Array<String>) : UriSelectFilter("Categories", "categories", arrayOf("Any", *CATID))
|
private class CatFilter(CATID: Array<String>) : UriSelectFilter("Categories", "categories", arrayOf("Any", *CATID))
|
||||||
private class PairingFilter(PAIR: Array<String>) : UriSelectFilter("Pairing", "pairing_str", arrayOf("Any", *PAIR))
|
private class PairingFilter(PAIR: Array<String>) : UriSelectFilter("Pairing", "pairing_str", arrayOf("Any", *PAIR))
|
||||||
private class ScanGroupFilter(GROUP: Array<String>) : UriSelectFilter("Scanlation Group", "group_str", arrayOf("Any", *GROUP))
|
private class ScanGroupFilter(GROUP: Array<String>) : UriSelectFilter("Scanlation Group", "group_str", arrayOf("Any", *GROUP))
|
||||||
private class SearchSortTypeList : Filter.Select<String>("Sort by", arrayOf("Random", "Newest", "Oldest", "More relevant"))
|
private class SearchSortTypeList : Filter.Select<String>("Sort by", arrayOf("Newest", "Oldest", "Random", "More relevant"))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that creates a select filter. Each entry in the dropdown has a name and a display name.
|
* Class that creates a select filter. Each entry in the dropdown has a name and a display name.
|
||||||
|
|
Loading…
Reference in New Issue