naver: fix author parsing and handle on hiatus status (#18188)

* naver: fix author parsing

* simplify joinToString

* handle on hiatus status

* use when expression

* adjust order of checks for status

i have found a couple entries that have both rest and finished set to true.
those entires are all definitely on hiatus so let's give the rest flag prio
This commit is contained in:
metonym 2023-09-30 07:32:43 -07:00 committed by GitHub
parent ca0b8788dd
commit f8373acc61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 14 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Naver Comic'
pkgNameSuffix = 'ko.navercomic'
extClass = '.NaverComicFactory'
extVersionCode = 3
extVersionCode = 4
}
apply from: "$rootDir/common.gradle"

View File

@ -108,16 +108,18 @@ abstract class NaverComicBase(protected val mType: String) : ParsedHttpSource()
override fun mangaDetailsParse(response: Response): SManga {
val manga = json.decodeFromString<Manga>(response.body.string())
val authors = manga.author.run {
setOf(writers, painters, originAuthors).flatten().map { it.name }
}.joinToString()
val authors = manga.communityArtists.joinToString { it.name }
return SManga.create().apply {
title = manga.titleName
author = authors
description = manga.synopsis
thumbnail_url = manga.thumbnailUrl
status = if (manga.finished) SManga.COMPLETED else SManga.ONGOING
status = when {
manga.rest -> SManga.ON_HIATUS
manga.finished -> SManga.COMPLETED
else -> SManga.ONGOING
}
}
}
@ -215,7 +217,8 @@ data class Manga(
val titleName: String,
val titleId: Int,
val finished: Boolean,
val author: AuthorList,
val rest: Boolean,
val communityArtists: List<Author>,
val synopsis: String,
)
@ -228,15 +231,8 @@ data class MangaChallenge(
val author: String,
)
@Serializable
data class AuthorList(
val writers: List<Author>,
val painters: List<Author>,
val originAuthors: List<Author>,
)
@Serializable
data class Author(
val id: Int,
val artistId: Int,
val name: String,
)