CuuTruyen: General improvements (#14869)
* CuuTruyen: General improvements * switch to app's json instance
This commit is contained in:
parent
6cbee38a9a
commit
5aa52e1059
@ -6,7 +6,7 @@ ext {
|
|||||||
extName = 'Cứu Truyện'
|
extName = 'Cứu Truyện'
|
||||||
pkgNameSuffix = 'vi.cuutruyen'
|
pkgNameSuffix = 'vi.cuutruyen'
|
||||||
extClass = '.CuuTruyen'
|
extClass = '.CuuTruyen'
|
||||||
extVersionCode = 1
|
extVersionCode = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
@ -20,13 +20,13 @@ import eu.kanade.tachiyomi.source.online.HttpSource
|
|||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import okhttp3.CacheControl
|
import okhttp3.CacheControl
|
||||||
import okhttp3.Headers
|
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
class CuuTruyen : HttpSource(), ConfigurableSource {
|
class CuuTruyen : HttpSource(), ConfigurableSource {
|
||||||
|
|
||||||
@ -43,8 +43,9 @@ class CuuTruyen : HttpSource(), ConfigurableSource {
|
|||||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun headersBuilder() = Headers.Builder()
|
private val json: Json by injectLazy()
|
||||||
.add("Referer", "$baseUrl/")
|
|
||||||
|
override fun headersBuilder() = super.headersBuilder().add("Referer", "$baseUrl/")
|
||||||
|
|
||||||
override val client = network.client.newBuilder()
|
override val client = network.client.newBuilder()
|
||||||
.rateLimit(3)
|
.rateLimit(3)
|
||||||
@ -94,12 +95,16 @@ class CuuTruyen : HttpSource(), ConfigurableSource {
|
|||||||
if (id.toIntOrNull() == null) {
|
if (id.toIntOrNull() == null) {
|
||||||
throw Exception("ID tìm kiếm không hợp lệ (phải là một số).")
|
throw Exception("ID tìm kiếm không hợp lệ (phải là một số).")
|
||||||
}
|
}
|
||||||
|
val url = "/mangas/$id"
|
||||||
fetchMangaDetails(
|
fetchMangaDetails(
|
||||||
SManga.create().apply {
|
SManga.create().apply {
|
||||||
url = "/mangas/$id"
|
this.url = url
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.map { MangasPage(listOf(it), false) }
|
.map {
|
||||||
|
it.url = url
|
||||||
|
MangasPage(listOf(it), false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else -> super.fetchSearchManga(page, query, filters)
|
else -> super.fetchSearchManga(page, query, filters)
|
||||||
}
|
}
|
||||||
@ -153,11 +158,7 @@ class CuuTruyen : HttpSource(), ConfigurableSource {
|
|||||||
return chapterDto.data.pages!!.map { it.toPage() }
|
return chapterDto.data.pages!!.map { it.toPage() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageUrlParse(response: Response): String = throw Exception("Not used")
|
override fun imageUrlParse(response: Response): String = throw UnsupportedOperationException("Not used")
|
||||||
|
|
||||||
private val json = Json {
|
|
||||||
ignoreUnknownKeys = true
|
|
||||||
}
|
|
||||||
|
|
||||||
private inline fun <reified T> Response.parseAs(): T = use {
|
private inline fun <reified T> Response.parseAs(): T = use {
|
||||||
json.decodeFromString(body?.string().orEmpty())
|
json.decodeFromString(body?.string().orEmpty())
|
||||||
|
File diff suppressed because one or more lines are too long
@ -20,7 +20,7 @@ class CuuTruyenUrlActivity : Activity() {
|
|||||||
startActivity(
|
startActivity(
|
||||||
Intent().apply {
|
Intent().apply {
|
||||||
action = "eu.kanade.tachiyomi.SEARCH"
|
action = "eu.kanade.tachiyomi.SEARCH"
|
||||||
putExtra("query", "id:$id")
|
putExtra("query", "${CuuTruyen.PREFIX_ID_SEARCH}$id")
|
||||||
putExtra("filter", packageName)
|
putExtra("filter", packageName)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -55,6 +55,6 @@ data class PageDto(
|
|||||||
val url = imageUrl.toHttpUrl().newBuilder().apply {
|
val url = imageUrl.toHttpUrl().newBuilder().apply {
|
||||||
addQueryParameter(CuuTruyenImageInterceptor.KEY, dto.drmData)
|
addQueryParameter(CuuTruyenImageInterceptor.KEY, dto.drmData)
|
||||||
}.build().toString()
|
}.build().toString()
|
||||||
return Page(dto.order, "", url)
|
return Page(dto.order, imageUrl = url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,7 @@ data class MangaDto(
|
|||||||
if (dto.team != null) {
|
if (dto.team != null) {
|
||||||
description += "Nhóm dịch: ${dto.team.name}\n\n"
|
description += "Nhóm dịch: ${dto.team.name}\n\n"
|
||||||
}
|
}
|
||||||
if (dto.description != null) {
|
description += dto.description ?: ""
|
||||||
description += dto.description
|
|
||||||
}
|
|
||||||
|
|
||||||
thumbnail_url = dto.coverUrl
|
thumbnail_url = dto.coverUrl
|
||||||
if (coverQuality == "cover_url") {
|
if (coverQuality == "cover_url") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user