dsh-shlr-bilitoolkit 0.1.23 → 0.1.24
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.js +29 -6
- package/dist/endpoints.d.ts +1 -0
- package/dist/endpoints.js +1 -0
- package/package.json +1 -1
package/dist/apis/dynamic.js
CHANGED
|
@@ -12,6 +12,16 @@ import { Dynamic } from "../models.js";
|
|
|
12
12
|
import { guessImageType } from "../util.js";
|
|
13
13
|
const FEATURES = "itemOpusStyle";
|
|
14
14
|
const REFERER = "https://t.bilibili.com/";
|
|
15
|
+
// 动态详情里的 type 是字符串枚举,删除接口要的是数字码
|
|
16
|
+
const DYN_TYPE_CODE = {
|
|
17
|
+
DYNAMIC_TYPE_NONE: 0,
|
|
18
|
+
DYNAMIC_TYPE_FORWARD: 1,
|
|
19
|
+
DYNAMIC_TYPE_DRAW: 2,
|
|
20
|
+
DYNAMIC_TYPE_WORD: 4,
|
|
21
|
+
DYNAMIC_TYPE_AV: 8,
|
|
22
|
+
DYNAMIC_TYPE_ARTICLE: 64,
|
|
23
|
+
DYNAMIC_TYPE_MUSIC: 256,
|
|
24
|
+
};
|
|
15
25
|
export class DynamicAPI {
|
|
16
26
|
client;
|
|
17
27
|
constructor(client) {
|
|
@@ -191,12 +201,25 @@ export class DynamicAPI {
|
|
|
191
201
|
}, false, { csrf: this.client.csrf }, true);
|
|
192
202
|
}
|
|
193
203
|
async delete(dynamicId) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
204
|
+
// 动态 id 常超出 JS 安全整数范围(>2^53),必须全程按字符串传递,不能过 Number
|
|
205
|
+
const id = String(dynamicId);
|
|
206
|
+
// 删除接口需要 dyn_type(数字码)+ rid_str,都要先从动态详情取
|
|
207
|
+
let rawType;
|
|
208
|
+
let ridStr = "0";
|
|
209
|
+
try {
|
|
210
|
+
const resp = await this.client.http.get(`${endpoints.DYNAMIC_DETAIL}?id=${encodeURIComponent(id)}`, { headers: { Referer: REFERER } });
|
|
211
|
+
const item = resp?.data?.data?.item ?? {};
|
|
212
|
+
rawType = item?.type;
|
|
213
|
+
ridStr = String(item?.basic?.rid_str ?? item?.basic?.rid ?? "0");
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
// 详情取不到:rid_str 用默认值,类型仍必须能确定
|
|
217
|
+
}
|
|
218
|
+
const dynType = typeof rawType === "number" ? rawType : DYN_TYPE_CODE[String(rawType)];
|
|
219
|
+
if (dynType == null) {
|
|
220
|
+
throw new BiliApiError(`无法确定该动态的类型码(原始 type=${JSON.stringify(rawType)}),暂不支持删除`);
|
|
221
|
+
}
|
|
222
|
+
await this.client.post(endpoints.DYNAMIC_DELETE_V2, { dyn_id_str: id, dyn_type: dynType, rid_str: ridStr }, { Referer: REFERER }, false, { platform: "web", csrf: this.client.csrf }, true);
|
|
200
223
|
}
|
|
201
224
|
static dynamicId(payload) {
|
|
202
225
|
const data = payload?.data ?? {};
|
package/dist/endpoints.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export declare const DYNAMIC_FEED_SPACE = "https://api.bilibili.com/x/polymer/we
|
|
|
45
45
|
export declare const DYNAMIC_DETAIL = "https://api.bilibili.com/x/polymer/web-dynamic/v1/detail";
|
|
46
46
|
export declare const DYNAMIC_CREATE = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create";
|
|
47
47
|
export declare const DYNAMIC_CREATE_V2 = "https://api.bilibili.com/x/dynamic/feed/create/dyn";
|
|
48
|
+
export declare const DYNAMIC_DELETE_V2 = "https://api.bilibili.com/x/dynamic/feed/operate/remove";
|
|
48
49
|
export declare const DYNAMIC_REPUBLISH = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/republish";
|
|
49
50
|
export declare const DYNAMIC_DELETE = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/rm_dynamic";
|
|
50
51
|
export declare const DYNAMIC_THUMB = "https://api.bilibili.com/x/dynamic/feed/dyn/thumb";
|
package/dist/endpoints.js
CHANGED
|
@@ -57,6 +57,7 @@ export const DYNAMIC_FEED_SPACE = `${API_BASE}/x/polymer/web-dynamic/v1/feed/spa
|
|
|
57
57
|
export const DYNAMIC_DETAIL = `${API_BASE}/x/polymer/web-dynamic/v1/detail`;
|
|
58
58
|
export const DYNAMIC_CREATE = `${VC_BASE}/dynamic_svr/v1/dynamic_svr/create`;
|
|
59
59
|
export const DYNAMIC_CREATE_V2 = `${API_BASE}/x/dynamic/feed/create/dyn`;
|
|
60
|
+
export const DYNAMIC_DELETE_V2 = `${API_BASE}/x/dynamic/feed/operate/remove`;
|
|
60
61
|
export const DYNAMIC_REPUBLISH = `${VC_BASE}/dynamic_svr/v1/dynamic_svr/republish`;
|
|
61
62
|
export const DYNAMIC_DELETE = `${VC_BASE}/dynamic_svr/v1/dynamic_svr/rm_dynamic`;
|
|
62
63
|
export const DYNAMIC_THUMB = `${API_BASE}/x/dynamic/feed/dyn/thumb`;
|