[CuuTruyen] Make cover URLs nullable (#15084)

* [CuuTruyen] Make cover URLs nullable

* bump

* final newline
This commit is contained in:
beerpsi 2023-01-24 17:46:09 +07:00 committed by GitHub
parent 731a406861
commit c3f56aa521
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 10 deletions

View File

@ -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 = 2 extVersionCode = 3
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -25,7 +25,10 @@ class CuuTruyenImageInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response { override fun intercept(chain: Interceptor.Chain): Response {
val response = chain.proceed(chain.request()) val response = chain.proceed(chain.request())
var drmData = chain.request().url.queryParameter(KEY) ?: return response if (response.request.url.fragment?.contains(KEY) != true) {
return response
}
var drmData = response.request.url.fragment!!.substringAfter("$KEY=")
drmData = drmData.replace("\n", "\\n") drmData = drmData.replace("\n", "\\n")
val image = unscrambleImage(response.body!!.byteStream(), drmData) val image = unscrambleImage(response.body!!.byteStream(), drmData)

View File

@ -52,9 +52,10 @@ data class PageDto(
) { ) {
fun toPage(): Page { fun toPage(): Page {
val dto = this@PageDto val dto = this@PageDto
val url = imageUrl.toHttpUrl().newBuilder().apply { val url = imageUrl.toHttpUrl().newBuilder()
addQueryParameter(CuuTruyenImageInterceptor.KEY, dto.drmData) .fragment("${CuuTruyenImageInterceptor.KEY}=$drmData")
}.build().toString() .build()
.toString()
return Page(dto.order, imageUrl = url) return Page(dto.order, imageUrl = url)
} }
} }

View File

@ -20,11 +20,11 @@ data class TeamDto(
data class MangaDto( data class MangaDto(
val id: Int, val id: Int,
val name: String, val name: String,
@SerialName("cover_url") val coverUrl: String, @SerialName("cover_url") val coverUrl: String? = null,
@SerialName("cover_mobile_url") val coverMobileUrl: String, @SerialName("cover_mobile_url") val coverMobileUrl: String? = null,
val author: AuthorDto? = null, val author: AuthorDto? = null,
val author_name: String? = null, @SerialName("author_name") val authorName: String? = null,
val description: String? = null, val description: String? = null,
val team: TeamDto? = null, val team: TeamDto? = null,
@ -33,7 +33,7 @@ data class MangaDto(
val dto = this@MangaDto val dto = this@MangaDto
url = "/mangas/${dto.id}" url = "/mangas/${dto.id}"
title = dto.name title = dto.name
author = dto.author?.name ?: dto.author_name author = dto.author?.name ?: dto.authorName
description = "" description = ""
if (dto.team != null) { if (dto.team != null) {