Pixiv: fix chapter numbers and series details (#18113)

This commit is contained in:
Solitai7e 2023-09-23 22:56:36 +00:00 committed by GitHub
parent 7f1dc922a0
commit 5e96403f74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 5 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Pixiv'
pkgNameSuffix = 'all.pixiv'
extClass = '.PixivFactory'
extVersionCode = 7
extVersionCode = 8
isNsfw = true
}

View File

@ -298,7 +298,9 @@ class Pixiv(override val lang: String) : HttpSource() {
val (id, isSeries) = parseSMangaUrl(manga.url)
if (isSeries) {
val series = ApiCall("/touch/ajax/illust/series/$id").executeApi<PixivSeries>()
val series = ApiCall("/touch/ajax/illust/series/$id")
.executeApi<PixivSeriesDetails>().series!!
val illusts = getSeriesIllustsCached(id)
if (series.id != null && series.userId != null) {
@ -316,7 +318,8 @@ class Pixiv(override val lang: String) : HttpSource() {
val tags = illusts.flatMap { it.tags ?: emptyList() }.toSet()
if (tags.isNotEmpty()) manga.genre = tags.joinToString()
(series.coverImage ?: illusts.firstOrNull()?.url)?.let { manga.thumbnail_url = it }
val coverImage = series.coverImage?.let { if (it.isString) it.content else null }
(coverImage ?: illusts.firstOrNull()?.url)?.let { manga.thumbnail_url = it }
} else {
val illust = getIllustCached(id)
@ -349,7 +352,7 @@ class Pixiv(override val lang: String) : HttpSource() {
setUrlWithoutDomain("/artworks/${illust.id!!}")
name = illust.title ?: "(null)"
date_upload = (illust.upload_timestamp ?: 0) * 1000
chapter_number = i.toFloat()
chapter_number = (illusts.size - i).toFloat()
}
}

View File

@ -1,5 +1,6 @@
package eu.kanade.tachiyomi.extension.all.pixiv
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonPrimitive
@Serializable
internal data class PixivApiResponse<T>(
@ -59,10 +60,15 @@ internal data class PixivAuthorDetails(
val user_name: String? = null,
)
@Serializable
internal data class PixivSeriesDetails(
val series: PixivSeries?,
)
@Serializable
internal data class PixivSeries(
val caption: String? = null,
val coverImage: String? = null,
val coverImage: JsonPrimitive? = null,
val id: String? = null,
val title: String? = null,
val userId: String? = null,