Kemono: fix image loading (#13692)
This commit is contained in:
parent
0fe977a99b
commit
34cf6a50b9
|
@ -20,7 +20,6 @@ import okhttp3.Response
|
|||
import org.jsoup.nodes.Element
|
||||
import org.jsoup.select.Evaluator
|
||||
import rx.Observable
|
||||
import rx.Single
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
@ -35,6 +34,9 @@ open class Kemono(
|
|||
|
||||
override val client = network.client.newBuilder().rateLimit(2).build()
|
||||
|
||||
override fun headersBuilder() = super.headersBuilder()
|
||||
.add("Referer", "$baseUrl/")
|
||||
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
private val preferences by lazy {
|
||||
|
@ -69,7 +71,7 @@ open class Kemono(
|
|||
|
||||
override fun latestUpdatesParse(response: Response) = popularMangaParse(response)
|
||||
|
||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> = Single.create<MangasPage> { subscriber ->
|
||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> = Observable.fromCallable {
|
||||
val baseUrl = this.baseUrl
|
||||
val response = client.newCall(GET("$baseUrl/api/creators", headers)).execute()
|
||||
val result = response.parseAs<List<KemonoCreatorDto>>()
|
||||
|
@ -77,8 +79,8 @@ open class Kemono(
|
|||
.sortedByDescending { it.updatedDate }
|
||||
.map { it.toSManga(baseUrl) }
|
||||
.filterUnsupported()
|
||||
subscriber.onSuccess(MangasPage(result, false))
|
||||
}.toObservable()
|
||||
MangasPage(result, false)
|
||||
}
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList) = throw UnsupportedOperationException("Not used.")
|
||||
override fun searchMangaParse(response: Response) = throw UnsupportedOperationException("Not used.")
|
||||
|
@ -87,7 +89,7 @@ open class Kemono(
|
|||
|
||||
override fun mangaDetailsParse(response: Response) = throw UnsupportedOperationException("Not used.")
|
||||
|
||||
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> = Single.create<List<SChapter>> {
|
||||
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> = Observable.fromCallable {
|
||||
KemonoPostDto.dateFormat.timeZone = when (manga.author) {
|
||||
"Pixiv Fanbox", "Fantia" -> TimeZone.getTimeZone("GMT+09:00")
|
||||
else -> TimeZone.getTimeZone("GMT")
|
||||
|
@ -104,8 +106,8 @@ open class Kemono(
|
|||
offset += POST_PAGE_SIZE
|
||||
hasNextPage = page.size == POST_PAGE_SIZE
|
||||
}
|
||||
it.onSuccess(result)
|
||||
}.toObservable()
|
||||
result
|
||||
}
|
||||
|
||||
override fun chapterListParse(response: Response) = throw UnsupportedOperationException("Not used.")
|
||||
|
||||
|
|
|
@ -56,14 +56,14 @@ class KemonoPostDto(
|
|||
) {
|
||||
val images: List<String>
|
||||
get() = buildList(attachments.size + 1) {
|
||||
file.path?.let { add(it) }
|
||||
attachments.mapTo(this) { it.path }
|
||||
if (file.path != null) add(KemonoAttachmentDto(file.name!!, file.path))
|
||||
addAll(attachments)
|
||||
}.filter {
|
||||
when (it.substringAfterLast('.').lowercase()) {
|
||||
when (it.name.substringAfterLast('.').lowercase()) {
|
||||
"png", "jpg", "gif", "jpeg", "webp" -> true
|
||||
else -> false
|
||||
}
|
||||
}.distinct()
|
||||
}.distinctBy { it.path }.map { it.toString() }
|
||||
|
||||
fun toSChapter() = SChapter.create().apply {
|
||||
url = "/$service/user/$user/post/$id"
|
||||
|
@ -78,10 +78,12 @@ class KemonoPostDto(
|
|||
}
|
||||
|
||||
@Serializable
|
||||
class KemonoFileDto(val path: String? = null)
|
||||
class KemonoFileDto(val name: String? = null, val path: String? = null)
|
||||
|
||||
@Serializable
|
||||
class KemonoAttachmentDto(val path: String)
|
||||
class KemonoAttachmentDto(val name: String, val path: String) {
|
||||
override fun toString() = "$path?f=$name"
|
||||
}
|
||||
|
||||
private fun getApiDateFormat() =
|
||||
SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.ENGLISH)
|
||||
|
|
|
@ -6,7 +6,7 @@ import generator.ThemeSourceGenerator
|
|||
class KemonoGenerator : ThemeSourceGenerator {
|
||||
override val themeClass = "Kemono"
|
||||
override val themePkg = "kemono"
|
||||
override val baseVersionCode = 2
|
||||
override val baseVersionCode = 3
|
||||
override val sources = listOf(
|
||||
SingleLang("Kemono", "https://kemono.party", "all", isNsfw = true),
|
||||
SingleLang("Coomer", "https://coomer.party", "all", isNsfw = true)
|
||||
|
|
Loading…
Reference in New Issue