dsh-shlr-bilitoolkit 0.1.24 → 0.1.25
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/video.js +10 -1
- package/package.json +1 -1
package/dist/apis/video.js
CHANGED
|
@@ -12,21 +12,30 @@ export class VideoAPI {
|
|
|
12
12
|
}
|
|
13
13
|
async *iterRecommend(pages = 1, pageSize = 10) {
|
|
14
14
|
const seen = new Set();
|
|
15
|
+
// 推荐流里混有广告(goto=ad)、直播、OGV 等非普通视频项,会被过滤掉,
|
|
16
|
+
// 所以按上限多抓一些做补偿,尽量让「要几条给几条」。
|
|
17
|
+
// 注意:B 站对 ps 有上限(约 30),给大了会 -400。
|
|
18
|
+
const ps = 30;
|
|
15
19
|
for (let page = 1; page <= pages; page++) {
|
|
16
20
|
const payload = await this.client.get(endpoints.RCMD_FEED, {
|
|
17
21
|
fresh_idx: page,
|
|
18
22
|
fresh_idx_1h: page,
|
|
19
23
|
feed_version: 1,
|
|
20
|
-
ps
|
|
24
|
+
ps,
|
|
21
25
|
});
|
|
22
26
|
const items = payload?.data?.item ?? [];
|
|
23
27
|
let added = 0;
|
|
24
28
|
for (const item of items) {
|
|
29
|
+
// 只保留普通视频(goto=av):排除广告 / 直播 / OGV / 推广等
|
|
30
|
+
if (item?.goto && item.goto !== "av")
|
|
31
|
+
continue;
|
|
25
32
|
const video = Video.fromFeedItem(item);
|
|
26
33
|
if (video && !seen.has(video.bvid)) {
|
|
27
34
|
seen.add(video.bvid);
|
|
28
35
|
added += 1;
|
|
29
36
|
yield video;
|
|
37
|
+
if (seen.size >= pageSize * pages)
|
|
38
|
+
return;
|
|
30
39
|
}
|
|
31
40
|
}
|
|
32
41
|
if (!added)
|