From cfbd2a48d4b5701f687ec9539e431e7a203db742 Mon Sep 17 00:00:00 2001 From: cssxsh Date: Tue, 2 Apr 2024 12:12:15 +0800 Subject: [PATCH] fix: api, close #116 --- src/main/kotlin/xyz/cssxsh/bilibili/BiliClient.kt | 2 +- src/main/kotlin/xyz/cssxsh/bilibili/api/Api.kt | 2 +- src/main/kotlin/xyz/cssxsh/bilibili/data/Dynamic.kt | 4 ++-- src/main/kotlin/xyz/cssxsh/bilibili/data/User.kt | 8 ++++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/xyz/cssxsh/bilibili/BiliClient.kt b/src/main/kotlin/xyz/cssxsh/bilibili/BiliClient.kt index b7e3270e..8d44d544 100644 --- a/src/main/kotlin/xyz/cssxsh/bilibili/BiliClient.kt +++ b/src/main/kotlin/xyz/cssxsh/bilibili/BiliClient.kt @@ -24,7 +24,7 @@ open class BiliClient(private val timeout: Long = 15_000L) : Closeable { prettyPrint = true ignoreUnknownKeys = System.getProperty(JSON_IGNORE, "true").toBoolean() isLenient = true - allowStructuredMapKeys = true + coerceInputValues = true } val DefaultIgnore: suspend (Throwable) -> Boolean = { it is IOException } diff --git a/src/main/kotlin/xyz/cssxsh/bilibili/api/Api.kt b/src/main/kotlin/xyz/cssxsh/bilibili/api/Api.kt index 9b96cbb7..cf063862 100644 --- a/src/main/kotlin/xyz/cssxsh/bilibili/api/Api.kt +++ b/src/main/kotlin/xyz/cssxsh/bilibili/api/Api.kt @@ -29,7 +29,7 @@ const val SPACE_INFO = "https://api.bilibili.com/x/space/wbi/acc/info" // Video const val VIDEO_USER = "https://api.bilibili.com/x/space/wbi/arc/search" -const val VIDEO_INFO = "https://api.bilibili.com/x/web-interface/view" +const val VIDEO_INFO = "https://api.bilibili.com/x/web-interface/wbi/view" // Dynamic const val DYNAMIC_HISTORY = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history" diff --git a/src/main/kotlin/xyz/cssxsh/bilibili/data/Dynamic.kt b/src/main/kotlin/xyz/cssxsh/bilibili/data/Dynamic.kt index 9a0ed51a..c975fe40 100644 --- a/src/main/kotlin/xyz/cssxsh/bilibili/data/Dynamic.kt +++ b/src/main/kotlin/xyz/cssxsh/bilibili/data/Dynamic.kt @@ -176,7 +176,7 @@ data class DynamicDescribe( @SerialName("uid") val uid: Long = 0, @SerialName("user_profile") - val profile: UserProfile = UserProfile(), + val profile: UserProfile = UserProfile.Empty, @SerialName("view") val view: Long = 0 ) { @@ -511,7 +511,7 @@ data class DynamicReply( @SerialName("origin") override val card: String = "null", @SerialName("origin_user") - val originUser: UserProfile = UserProfile(), + val originUser: UserProfile = UserProfile.Empty, @SerialName("user") val user: UserSimple, @Transient diff --git a/src/main/kotlin/xyz/cssxsh/bilibili/data/User.kt b/src/main/kotlin/xyz/cssxsh/bilibili/data/User.kt index 8c394e3a..2eaa0c1c 100644 --- a/src/main/kotlin/xyz/cssxsh/bilibili/data/User.kt +++ b/src/main/kotlin/xyz/cssxsh/bilibili/data/User.kt @@ -57,7 +57,7 @@ data class BiliUserInfo( @SerialName("sign") override val sign: String, @SerialName("top_photo") - val topPhoto: String, + val topPhoto: String ) : UserInfo { override val live: String get() = liveRoom?.link ?: "未开通直播间" @@ -91,7 +91,11 @@ data class UserProfile( val rank: String? = null, @SerialName("sign") val sign: String? = null -) +) { + companion object { + val Empty = UserProfile() + } +} @Serializable data class UserOfficial(