HentaiCosplay: fix pages and remove keyword filter (#1009)
This commit is contained in:
parent
00e4bed8ab
commit
97dde3f788
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'Hentai Cosplay'
|
extName = 'Hentai Cosplay'
|
||||||
extClass = '.HentaiCosplay'
|
extClass = '.HentaiCosplay'
|
||||||
extVersionCode = 1
|
extVersionCode = 2
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package eu.kanade.tachiyomi.extension.all.hentaicosplay
|
package eu.kanade.tachiyomi.extension.all.hentaicosplay
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.source.model.Filter
|
import eu.kanade.tachiyomi.source.model.Filter
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
@ -68,9 +67,6 @@ class HentaiCosplay : HttpSource() {
|
|||||||
title = element.selectFirst("span:not(.posted)")!!.text()
|
title = element.selectFirst("span:not(.posted)")!!.text()
|
||||||
element.selectFirst("span.posted")
|
element.selectFirst("span.posted")
|
||||||
?.text()?.also { dateCache[url] = it }
|
?.text()?.also { dateCache[url] = it }
|
||||||
update_strategy = UpdateStrategy.ONLY_FETCH_ONCE
|
|
||||||
status = SManga.COMPLETED
|
|
||||||
initialized = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val hasNextPage = document.selectFirst("a.paginator_page[rel=next]") != null
|
val hasNextPage = document.selectFirst("a.paginator_page[rel=next]") != null
|
||||||
@ -89,9 +85,6 @@ class HentaiCosplay : HttpSource() {
|
|||||||
title = element.select(".image-list-item-title").text()
|
title = element.select(".image-list-item-title").text()
|
||||||
element.selectFirst(".image-list-item-regist-date")
|
element.selectFirst(".image-list-item-regist-date")
|
||||||
?.text()?.also { dateCache[url] = it }
|
?.text()?.also { dateCache[url] = it }
|
||||||
update_strategy = UpdateStrategy.ONLY_FETCH_ONCE
|
|
||||||
status = SManga.COMPLETED
|
|
||||||
initialized = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val hasNextPage = document.selectFirst("div.wp-pagenavi > a[rel=next]") != null
|
val hasNextPage = document.selectFirst("div.wp-pagenavi > a[rel=next]") != null
|
||||||
@ -127,11 +120,6 @@ class HentaiCosplay : HttpSource() {
|
|||||||
return GET("$baseUrl${filter.selected}page/$page/", headers)
|
return GET("$baseUrl${filter.selected}page/$page/", headers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is KeywordFilter -> {
|
|
||||||
if (filter.selected.isNotEmpty()) {
|
|
||||||
return GET("$baseUrl${filter.selected}page/$page/", headers)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,11 +130,9 @@ class HentaiCosplay : HttpSource() {
|
|||||||
|
|
||||||
override fun searchMangaParse(response: Response) = popularMangaParse(response)
|
override fun searchMangaParse(response: Response) = popularMangaParse(response)
|
||||||
|
|
||||||
private var keyWordCache: List<Pair<String, String>> = emptyList()
|
|
||||||
private var tagCache: List<Pair<String, String>> = emptyList()
|
private var tagCache: List<Pair<String, String>> = emptyList()
|
||||||
|
|
||||||
private fun fetchFilters() {
|
private fun fetchFilters() {
|
||||||
if (keyWordCache.isEmpty()) fetchKeywords()
|
|
||||||
if (tagCache.isEmpty()) fetchTags()
|
if (tagCache.isEmpty()) fetchTags()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,35 +156,7 @@ class HentaiCosplay : HttpSource() {
|
|||||||
}
|
}
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(
|
.subscribe()
|
||||||
{},
|
|
||||||
{
|
|
||||||
Log.e(name, it.stackTraceToString())
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun fetchKeywords() {
|
|
||||||
Single.fromCallable {
|
|
||||||
client.newCall(GET("$baseUrl/ranking-keyword/", headers))
|
|
||||||
.execute().asJsoup()
|
|
||||||
.run {
|
|
||||||
keyWordCache = buildList {
|
|
||||||
add(Pair("", ""))
|
|
||||||
select("#tags a").map {
|
|
||||||
add(Pair(it.text(), it.attr("href")))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(Schedulers.io())
|
|
||||||
.subscribe(
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
Log.e(name, it.stackTraceToString())
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private abstract class SelectFilter(
|
private abstract class SelectFilter(
|
||||||
@ -212,29 +170,30 @@ class HentaiCosplay : HttpSource() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class TagFilter(name: String, options: List<Pair<String, String>>) : SelectFilter(name, options)
|
private class TagFilter(name: String, options: List<Pair<String, String>>) : SelectFilter(name, options)
|
||||||
private class KeywordFilter(name: String, options: List<Pair<String, String>>) : SelectFilter(name, options)
|
|
||||||
|
|
||||||
override fun getFilterList(): FilterList {
|
override fun getFilterList(): FilterList {
|
||||||
return if (keyWordCache.isEmpty()) {
|
return if (tagCache.isEmpty()) {
|
||||||
FilterList(Filter.Header("Press reset to attempt to load filters"))
|
FilterList(Filter.Header("Press reset to attempt to load filters"))
|
||||||
} else {
|
} else {
|
||||||
FilterList(
|
FilterList(
|
||||||
Filter.Header("Ignored with text search"),
|
Filter.Header("Ignored with text search"),
|
||||||
Filter.Header("Tag Filtered is preferred over Keyword filter"),
|
|
||||||
Filter.Separator(),
|
Filter.Separator(),
|
||||||
TagFilter("Ranked Tags", tagCache),
|
TagFilter("Ranked Tags", tagCache),
|
||||||
KeywordFilter("Ranked Keywords", keyWordCache),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fetchMangaDetails(manga: SManga) = Observable.fromCallable {
|
override fun mangaDetailsParse(response: Response): SManga {
|
||||||
manga.apply { initialized = true }
|
val document = response.asJsoup()
|
||||||
|
|
||||||
|
return SManga.create().apply {
|
||||||
|
genre = document.select("#detail_tag a[href*=/tag/]").eachText().joinToString()
|
||||||
|
update_strategy = UpdateStrategy.ONLY_FETCH_ONCE
|
||||||
|
status = SManga.COMPLETED
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mangaDetailsParse(response: Response) = throw UnsupportedOperationException()
|
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> = Observable.fromCallable {
|
||||||
|
|
||||||
override fun fetchChapterList(manga: SManga) = Observable.fromCallable {
|
|
||||||
SChapter.create().apply {
|
SChapter.create().apply {
|
||||||
name = "Gallery"
|
name = "Gallery"
|
||||||
url = manga.url.removeSuffix("/").plus("/attachment/1/")
|
url = manga.url.removeSuffix("/").plus("/attachment/1/")
|
||||||
@ -248,6 +207,7 @@ class HentaiCosplay : HttpSource() {
|
|||||||
|
|
||||||
override fun pageListParse(response: Response): List<Page> {
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
val document = response.asJsoup()
|
val document = response.asJsoup()
|
||||||
|
val pageUrl = document.location().substringBeforeLast("/1/")
|
||||||
|
|
||||||
val totalPages = document.selectFirst("#right_sidebar > h3, #title > h2")
|
val totalPages = document.selectFirst("#right_sidebar > h3, #title > h2")
|
||||||
?.text()?.trim()
|
?.text()?.trim()
|
||||||
@ -255,21 +215,23 @@ class HentaiCosplay : HttpSource() {
|
|||||||
?.toIntOrNull()
|
?.toIntOrNull()
|
||||||
?: return emptyList()
|
?: return emptyList()
|
||||||
|
|
||||||
val imgUrl = document.selectFirst("#display_image_detail img, #detail_list img")
|
val pages = (1..totalPages).map {
|
||||||
?.absUrl("src")
|
Page(it, "$pageUrl/$it/")
|
||||||
?.replace("http://", "https://")
|
|
||||||
?.run { replace(hdRegex, "/") }
|
|
||||||
?: return emptyList()
|
|
||||||
|
|
||||||
val imgUrlPrefix = imgUrl.substringBeforeLast("/")
|
|
||||||
val ext = imgUrl.substringAfterLast(".")
|
|
||||||
|
|
||||||
return (1..totalPages).map {
|
|
||||||
Page(it, "", "$imgUrlPrefix/$it.$ext")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageUrlParse(response: Response) = throw UnsupportedOperationException()
|
pages[0].imageUrl = imageUrlParse(document)
|
||||||
|
|
||||||
|
return pages
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun imageUrlParse(response: Response) = imageUrlParse(response.asJsoup())
|
||||||
|
|
||||||
|
private fun imageUrlParse(document: Document): String {
|
||||||
|
return document.selectFirst("#display_image_detail img, #detail_list img")!!
|
||||||
|
.absUrl("src")
|
||||||
|
.replace("http://", "https://")
|
||||||
|
.replace(hdRegex, "/")
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val tagNumRegex = Regex("""(\(\d+\))""")
|
private val tagNumRegex = Regex("""(\(\d+\))""")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user