dsh-shlr-bilitoolkit 0.1.26 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apis/dynamic.d.ts +0 -1
- package/dist/apis/dynamic.js +5 -9
- package/package.json +1 -1
package/dist/apis/dynamic.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ import { Dynamic } from "../models.js";
|
|
|
8
8
|
export declare class DynamicAPI {
|
|
9
9
|
private client;
|
|
10
10
|
constructor(client: BiliClient);
|
|
11
|
-
private _detailCache;
|
|
12
11
|
detail(dynamicId: string | number): Promise<Dynamic>;
|
|
13
12
|
feed(page?: number, offset?: string, type?: string): Promise<[Dynamic[], string, boolean]>;
|
|
14
13
|
space(uid: number, offset?: string): Promise<[Dynamic[], string, boolean, number]>;
|
package/dist/apis/dynamic.js
CHANGED
|
@@ -26,19 +26,15 @@ export class DynamicAPI {
|
|
|
26
26
|
client;
|
|
27
27
|
constructor(client) {
|
|
28
28
|
this.client = client;
|
|
29
|
-
this._detailCache = {};
|
|
30
29
|
}
|
|
31
|
-
_detailCache;
|
|
32
30
|
async detail(dynamicId) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return cached;
|
|
31
|
+
// 动态 id 常超出 JS 安全整数范围(>2^53),绝不能过 Number,否则丢精度、接口报 4101105
|
|
32
|
+
// 不做内存缓存:动态可能被删/改,缓存会返回脏数据,而它只省 HTTP、不省 LLM token。
|
|
33
|
+
const id = String(dynamicId);
|
|
37
34
|
const payload = await this.client.get(endpoints.DYNAMIC_DETAIL, { id, features: FEATURES }, { Referer: `https://t.bilibili.com/${id}` });
|
|
38
35
|
const dynamic = Dynamic.fromApi((payload?.data ?? {}).item);
|
|
39
36
|
if (!dynamic)
|
|
40
37
|
throw new BiliApiError("未找到该动态");
|
|
41
|
-
this._detailCache[id] = dynamic;
|
|
42
38
|
return dynamic;
|
|
43
39
|
}
|
|
44
40
|
async feed(page = 1, offset, type = "all") {
|
|
@@ -182,7 +178,7 @@ export class DynamicAPI {
|
|
|
182
178
|
}
|
|
183
179
|
async repost(dynamicId, text = "") {
|
|
184
180
|
const form = {
|
|
185
|
-
dynamic_id: String(
|
|
181
|
+
dynamic_id: String(dynamicId),
|
|
186
182
|
content: text || "",
|
|
187
183
|
csrf: this.client.csrf,
|
|
188
184
|
csrf_token: this.client.csrf,
|
|
@@ -192,7 +188,7 @@ export class DynamicAPI {
|
|
|
192
188
|
}
|
|
193
189
|
async thumb(dynamicId, liked = true) {
|
|
194
190
|
const body = JSON.stringify({
|
|
195
|
-
dyn_id_str: String(
|
|
191
|
+
dyn_id_str: String(dynamicId),
|
|
196
192
|
up: liked ? 1 : 2,
|
|
197
193
|
});
|
|
198
194
|
await this.client.post(endpoints.DYNAMIC_THUMB, body, {
|