[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'
pkgNameSuffix = 'vi.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 {
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")
val image = unscrambleImage(response.body!!.byteStream(), drmData)

View File

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

View File

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