Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
upgrade kemono all artist list api.
Browse files Browse the repository at this point in the history
  • Loading branch information
WhichWho committed Sep 19, 2022
1 parent c6e43ab commit 81f3f96
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/main/kotlin/loli/ball/kemono/bean/Artist.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import kotlinx.serialization.Serializable
@Serializable
data class SimpleArtist(
val id: String, //作者id
val indexed: String = "", //创建日期
val indexed: Float = 0f, //创建日期
val name: String = "", //作者名称
val service: String, //隶属于的服务器 详见ArtistService
val updated: String = "", //更新日期
val updated: Float = 0f, //更新日期
//以下内容为解析、计算获得
var indexedTimestamp: Long = 0, //创建时间戳
var updatedTimestamp: Long = 0, //更新时间戳
var icon: String = "" //作者头像
var icon: String = "", //作者头像
// 2022-08-18 新增字段
val favorited: Int = 0, //收藏人数
)

//作者概述 包含首页缩略图
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/loli/ball/kemono/factory/ArtistFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ object ArtistFactory {
val artistList = Json.decodeFromString<List<SimpleArtist>>(json)
artistList.forEach {
try {
it.indexedTimestamp = GTMDateParser.parse(it.indexed).time
it.updatedTimestamp = GTMDateParser.parse(it.updated).time
it.indexedTimestamp = it.indexed.toLong() * 1000L
it.updatedTimestamp = it.updated.toLong() * 1000L
it.icon = "$BASE_URL/icons/${it.service}/${it.id}"
} catch (e: Exception) {
println("error parse $it")
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/loli/ball/kemono/network/AccountNetwork.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ object AccountNetwork {
fun FavoritePostItem.unFavorite() = unFavoritePost(service, user, id)

fun FavoriteArtistItem.toSimpleArtist() =
SimpleArtist(id, indexed, name, service, updated, indexedTimestamp, updatedTimestamp, icon)
SimpleArtist(id, indexedTimestamp.toFloat(), name, service, updatedTimestamp.toFloat(), indexedTimestamp, updatedTimestamp, icon)

fun FavoriteArtistItem.toArtist() =
this.toSimpleArtist().toArtist()
Expand Down

0 comments on commit 81f3f96

Please sign in to comment.