specific-ai-cli 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.en.md +177 -0
- package/README.ja.md +177 -0
- package/README.ko.md +177 -0
- package/README.md +174 -2
- package/README.zh-TW.md +177 -0
- package/assets/banner.txt +3 -0
- package/dist/cli/argv.js +98 -0
- package/dist/cli/commands/auth.js +11 -0
- package/dist/cli/commands/config.js +23 -0
- package/dist/cli/commands/doctor.js +134 -0
- package/dist/cli/commands/platforms.js +24 -0
- package/dist/cli/commands/version.js +4 -0
- package/dist/cli/confirm.js +22 -0
- package/dist/cli/dispatch.js +440 -0
- package/dist/cli/help.js +223 -0
- package/dist/cli/hints.js +60 -0
- package/dist/cli/main.js +18 -0
- package/dist/cli/output.js +66 -0
- package/dist/core/auth-handlers.js +41 -0
- package/dist/core/auth-store.js +119 -0
- package/dist/core/capabilities.js +163 -0
- package/dist/core/config.js +121 -0
- package/dist/core/cookies.js +164 -0
- package/dist/core/errors.js +37 -0
- package/dist/core/files.js +89 -0
- package/dist/core/fsutil.js +52 -0
- package/dist/core/hash.js +4 -0
- package/dist/core/http.js +331 -0
- package/dist/core/image.js +280 -0
- package/dist/core/log.js +40 -0
- package/dist/core/login.js +191 -0
- package/dist/core/mp4.js +130 -0
- package/dist/core/normalize.js +207 -0
- package/dist/core/options.js +110 -0
- package/dist/core/paths.js +38 -0
- package/dist/core/pb.js +59 -0
- package/dist/core/py.js +181 -0
- package/dist/core/rand.js +131 -0
- package/dist/core/registry.js +129 -0
- package/dist/core/schemas.js +41 -0
- package/dist/core/stream.js +104 -0
- package/dist/core/toolkit.js +35 -0
- package/dist/core/vm.js +73 -0
- package/dist/core/vocab.js +157 -0
- package/dist/platforms/_shared/impaas.js +410 -0
- package/dist/platforms/bilibili/index.js +216 -0
- package/dist/platforms/bilibili/web/api.js +806 -0
- package/dist/platforms/bilibili/web/client.js +311 -0
- package/dist/platforms/bilibili/web/commands.js +783 -0
- package/dist/platforms/bilibili/web/ddddocr.js +342 -0
- package/dist/platforms/bilibili/web/gaia.js +130 -0
- package/dist/platforms/bilibili/web/geetest-manual.js +154 -0
- package/dist/platforms/bilibili/web/geetest-vision.js +232 -0
- package/dist/platforms/bilibili/web/geetest.js +450 -0
- package/dist/platforms/bilibili/web/normalize.js +234 -0
- package/dist/platforms/bilibili/web/profile.js +135 -0
- package/dist/platforms/bilibili/web/resolve.js +112 -0
- package/dist/platforms/bilibili/web/sign.js +223 -0
- package/dist/platforms/bilibili/web/upos.js +102 -0
- package/dist/platforms/douyin/index.js +142 -0
- package/dist/platforms/douyin/web/api.js +863 -0
- package/dist/platforms/douyin/web/client.js +413 -0
- package/dist/platforms/douyin/web/commands.js +712 -0
- package/dist/platforms/douyin/web/creator.js +601 -0
- package/dist/platforms/douyin/web/crypto.js +247 -0
- package/dist/platforms/douyin/web/dtrait.js +190 -0
- package/dist/platforms/douyin/web/im.js +502 -0
- package/dist/platforms/douyin/web/image.js +5 -0
- package/dist/platforms/douyin/web/live.js +225 -0
- package/dist/platforms/douyin/web/mssdk.js +148 -0
- package/dist/platforms/douyin/web/normalize.js +326 -0
- package/dist/platforms/douyin/web/passport.js +1247 -0
- package/dist/platforms/douyin/web/profile.js +221 -0
- package/dist/platforms/douyin/web/proto.js +26 -0
- package/dist/platforms/douyin/web/resolve.js +88 -0
- package/dist/platforms/douyin/web/sign.js +436 -0
- package/dist/platforms/douyin/web/tos.js +78 -0
- package/dist/platforms/index.js +17 -0
- package/dist/platforms/jd/index.js +67 -0
- package/dist/platforms/jd/web/aks.js +115 -0
- package/dist/platforms/jd/web/api.js +549 -0
- package/dist/platforms/jd/web/chat.js +132 -0
- package/dist/platforms/jd/web/client.js +470 -0
- package/dist/platforms/jd/web/commands.js +557 -0
- package/dist/platforms/jd/web/jcap/helper.js +90 -0
- package/dist/platforms/jd/web/jcap/host.js +107 -0
- package/dist/platforms/jd/web/jcap/lsd.js +300 -0
- package/dist/platforms/jd/web/jcap/solver.js +995 -0
- package/dist/platforms/jd/web/jcap.js +150 -0
- package/dist/platforms/jd/web/js.js +420 -0
- package/dist/platforms/jd/web/login.js +775 -0
- package/dist/platforms/jd/web/normalize.js +297 -0
- package/dist/platforms/jd/web/profile.js +256 -0
- package/dist/platforms/jd/web/util.js +175 -0
- package/dist/platforms/jd/web/webm.js +133 -0
- package/dist/platforms/kuaishou/index.js +98 -0
- package/dist/platforms/kuaishou/web/api.js +694 -0
- package/dist/platforms/kuaishou/web/captcha-crypto.js +134 -0
- package/dist/platforms/kuaishou/web/captcha-fp.js +180 -0
- package/dist/platforms/kuaishou/web/captcha.js +273 -0
- package/dist/platforms/kuaishou/web/client.js +487 -0
- package/dist/platforms/kuaishou/web/commands.js +863 -0
- package/dist/platforms/kuaishou/web/gap.js +144 -0
- package/dist/platforms/kuaishou/web/gdfp.js +376 -0
- package/dist/platforms/kuaishou/web/gql.js +11 -0
- package/dist/platforms/kuaishou/web/live.js +125 -0
- package/dist/platforms/kuaishou/web/normalize.js +241 -0
- package/dist/platforms/kuaishou/web/oracle.js +329 -0
- package/dist/platforms/kuaishou/web/profile.js +259 -0
- package/dist/platforms/kuaishou/web/resolve.js +84 -0
- package/dist/platforms/kuaishou/web/session.js +592 -0
- package/dist/platforms/kuaishou/web/sign.js +568 -0
- package/dist/platforms/taobao/index.js +56 -0
- package/dist/platforms/taobao/web/api.js +96 -0
- package/dist/platforms/taobao/web/client.js +102 -0
- package/dist/platforms/taobao/web/commands.js +172 -0
- package/dist/platforms/taobao/web/im.js +68 -0
- package/dist/platforms/taobao/web/normalize.js +103 -0
- package/dist/platforms/taobao/web/profile.js +85 -0
- package/dist/platforms/taobao/web/resolve.js +51 -0
- package/dist/platforms/taobao/web/sign.js +35 -0
- package/dist/platforms/tiktok/index.js +120 -0
- package/dist/platforms/tiktok/web/api.js +1234 -0
- package/dist/platforms/tiktok/web/client.js +362 -0
- package/dist/platforms/tiktok/web/commands.js +821 -0
- package/dist/platforms/tiktok/web/im.js +133 -0
- package/dist/platforms/tiktok/web/jsrun.js +126 -0
- package/dist/platforms/tiktok/web/normalize.js +286 -0
- package/dist/platforms/tiktok/web/profile.js +169 -0
- package/dist/platforms/tiktok/web/resolve.js +156 -0
- package/dist/platforms/tiktok/web/sign.js +585 -0
- package/dist/platforms/tiktok/web/upload.js +805 -0
- package/dist/platforms/tiktok/web/wire.js +490 -0
- package/dist/platforms/weibo/index.js +91 -0
- package/dist/platforms/weibo/web/api.js +206 -0
- package/dist/platforms/weibo/web/client.js +155 -0
- package/dist/platforms/weibo/web/commands.js +202 -0
- package/dist/platforms/weibo/web/normalize.js +137 -0
- package/dist/platforms/weibo/web/profile.js +246 -0
- package/dist/platforms/weibo/web/resolve.js +60 -0
- package/dist/platforms/weibo/web/sign.js +85 -0
- package/dist/platforms/x/index.js +107 -0
- package/dist/platforms/x/web/api.js +443 -0
- package/dist/platforms/x/web/article.js +212 -0
- package/dist/platforms/x/web/client.js +202 -0
- package/dist/platforms/x/web/commands.js +363 -0
- package/dist/platforms/x/web/graphql.js +108 -0
- package/dist/platforms/x/web/normalize.js +235 -0
- package/dist/platforms/x/web/profile.js +99 -0
- package/dist/platforms/x/web/resolve.js +44 -0
- package/dist/platforms/x/web/transaction.js +171 -0
- package/dist/platforms/xhs/index.js +101 -0
- package/dist/platforms/xhs/web/api.js +278 -0
- package/dist/platforms/xhs/web/client.js +540 -0
- package/dist/platforms/xhs/web/commands.js +1046 -0
- package/dist/platforms/xhs/web/creator-api.js +609 -0
- package/dist/platforms/xhs/web/creator.js +203 -0
- package/dist/platforms/xhs/web/js.js +194 -0
- package/dist/platforms/xhs/web/login.js +230 -0
- package/dist/platforms/xhs/web/normalize.js +166 -0
- package/dist/platforms/xhs/web/profile.js +127 -0
- package/dist/platforms/xhs/web/push.js +361 -0
- package/dist/platforms/xhs/web/resolve.js +69 -0
- package/dist/platforms/xhs/web/state.js +368 -0
- package/dist/platforms/xianyu/index.js +59 -0
- package/dist/platforms/xianyu/web/api.js +312 -0
- package/dist/platforms/xianyu/web/client.js +134 -0
- package/dist/platforms/xianyu/web/commands.js +305 -0
- package/dist/platforms/xianyu/web/im.js +73 -0
- package/dist/platforms/xianyu/web/normalize.js +123 -0
- package/dist/platforms/xianyu/web/profile.js +146 -0
- package/dist/platforms/xianyu/web/resolve.js +48 -0
- package/dist/platforms/xianyu/web/sign.js +79 -0
- package/package.json +77 -4
- package/static/douyin/Live.proto +194 -0
- package/static/douyin/Request.proto +89 -0
- package/static/douyin/Response.proto +46 -0
- package/static/douyin/acrawler_runtime/ac_vm.js +2 -0
- package/static/douyin/acrawler_runtime/browser_window_shape.json +1 -0
- package/static/douyin/acrawler_runtime/canvas_actual_exact.json +1 -0
- package/static/douyin/acrawler_runtime/run_ac_node.js +1005 -0
- package/static/douyin/acrawler_runtime/runner_window_keys_baseline.txt +240 -0
- package/static/douyin/challenge_profile.json +801 -0
- package/static/douyin/challenge_template_runner.js +217 -0
- package/static/douyin/dtrait_profile.json +66 -0
- package/static/douyin/mstoken_common_profile.json +1 -0
- package/static/douyin/mstoken_profile.json +214 -0
- package/static/jd/h5st5_env.js +750 -0
- package/static/jd/h5st5_lib.js +5 -0
- package/static/jd/h5st5_server.js +49 -0
- package/static/jd/jcap/env/env_core.js +512 -0
- package/static/jd/jcap/env/run.js +1307 -0
- package/static/jd/jcap/run/jcap_ujb96b.js +39 -0
- package/static/jd/package.json +4 -0
- package/static/jd/pc_tk_lib.js +1 -0
- package/static/jd/pc_tk_server.js +63 -0
- package/static/jd/summer_cryptico_runner.js +50 -0
- package/static/jd/webm/env/run.js +453 -0
- package/static/jd/webm/run/jdwebm-riskhandle.js +49 -0
- package/static/kuaishou/bundles/weapon/kwf-0.0.2.2cee19b4b7dec496.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-0-0.0.1-obfuscated.4b7f3de1ab0ddcc2.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-1-0.0.1-obfuscated.346ebdb1c78df316.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-10-0.0.1-obfuscated.a33db41897b983af.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-11-0.0.1-obfuscated.5e0a90af726d8a7e.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-12-0.0.1-obfuscated.20ea29345706ec8c.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-13-0.0.1-obfuscated.6b74e9640ff18648.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-14-0.0.1-obfuscated.551e4429d156bf66.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-15-0.0.1-obfuscated.8625b087aaba4a60.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-16-0.0.1-obfuscated.d5ffa4020f3be99a.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-17-0.0.1-obfuscated.6d13e19b22f50a80.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-18-0.0.1-obfuscated.6d31405044166289.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-19-0.0.1-obfuscated.a9a8d925942f19e4.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-2-0.0.1-obfuscated.b849a136ae4a6b3e.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-3-0.0.1-obfuscated.f9e77ebf6186e2ac.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-4-0.0.1-obfuscated.2c3c155aa52ceb0e.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-5-0.0.1-obfuscated.4e553d17691b3c5a.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-6-0.0.1-obfuscated.f73ddd3ff13e1217.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-7-0.0.1-obfuscated.1628b8729beaab7e.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-8-0.0.1-obfuscated.6da6baef7aa81fff.js +1 -0
- package/static/kuaishou/bundles/weapon/kws-9-0.0.1-obfuscated.8645d55e5323b743.js +1 -0
- package/static/kuaishou/fixtures/current_follow_script_813.network-response +2 -0
- package/static/kuaishou/fixtures/live_ws_maps.json +61 -0
- package/static/kuaishou/fixtures/live_ws_proto.json +1342 -0
- package/static/kuaishou/js/cp-kwf.js +1 -0
- package/static/kuaishou/tools/kwf_oracle.js +799 -0
- package/static/kuaishou/tools/kws_oracle.js +885 -0
- package/static/kuaishou/tools/like_token_oracle.js +70 -0
- package/static/taobao/taobao_js_20260407.js +570 -0
- package/static/tiktok/Tiktok_Request.json +597 -0
- package/static/tiktok/package.json +3 -0
- package/static/tiktok/shop_bsid/core.js +1 -0
- package/static/tiktok/shop_bsid/env_core.js +512 -0
- package/static/tiktok/shop_bsid/loader.js +1 -0
- package/static/tiktok/shop_bsid/run.js +753 -0
- package/static/tiktok/shop_bsid/sign.js +100 -0
- package/static/tiktok/shop_bsid/webmssdk.js +1 -0
- package/static/tiktok/shop_bsid/webmssdk_ex.js +1 -0
- package/static/tiktok/signing/env/env_core.js +512 -0
- package/static/tiktok/signing/env/sign.js +455 -0
- package/static/tiktok/signing/sdk_config.json +230 -0
- package/static/tiktok/signing/source/webmssdk.js +1 -0
- package/static/tiktok/signing/source/webmssdk_ex.js +1 -0
- package/static/tiktok/signing/source/webmssdk_legacy.js +1 -0
- package/static/x/graphql.json +7777 -0
- package/static/x/transaction_l1.json +12 -0
- package/static/xhs/package.json +3 -0
- package/static/xhs/xhs_core/js/b1.js +210 -0
- package/static/xhs/xhs_core/js/mns.js +340 -0
- package/static/xhs/xhs_core/js/mns_0101_keystream.json +5 -0
- package/static/xhs/xhs_core/js/mns_keystreams.json +1 -0
- package/static/xhs/xhs_core/js/sign.js +225 -0
- package/static/xhs/xhs_core/js/websectiga_cli.js +220 -0
- package/static/xhs/xhs_core/js/websectiga_env.js +512 -0
- package/static/xhs/xhs_core/js/xs_common.js +79 -0
- package/static/xhs/xhs_creator/js/profile.js +115 -0
- package/static/xhs/xhs_creator/js/rap_fingerprint_creator.json +6 -0
- package/static/xhs/xhs_creator/js/reference_profile.json +282 -0
- package/static/xhs/xhs_creator/js/xhs_creator_sign.js +29 -0
- package/static/xhs/xhs_creator/js/xhs_creator_signature.js +23 -0
- package/static/xhs/xhs_pc/js/aes_decrypt.js +22 -0
- package/static/xhs/xhs_pc/js/aes_encrypt.js +30 -0
- package/static/xhs/xhs_pc/js/b1.js +9 -0
- package/static/xhs/xhs_pc/js/deflate.js +320 -0
- package/static/xhs/xhs_pc/js/mns.js +4 -0
- package/static/xhs/xhs_pc/js/profile.js +141 -0
- package/static/xhs/xhs_pc/js/rap.js +173 -0
- package/static/xhs/xhs_pc/js/rap_cli.js +30 -0
- package/static/xhs/xhs_pc/js/rap_crypto.js +73 -0
- package/static/xhs/xhs_pc/js/rap_fingerprint_template.json +8 -0
- package/static/xhs/xhs_pc/js/reference_profile.json +262 -0
- package/static/xhs/xhs_pc/js/sign.js +6 -0
- package/static/xhs/xhs_pc/js/web_ssk.js +82 -0
- package/static/xhs/xhs_pc/js/xs_common.js +4 -0
- package/static/xianyu/et_f.js +2 -0
- package/static/xianyu/gen_tfstk.js +410 -0
- package/static/xianyu/goofish_js_version_2.js +568 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import * as n from '../../../core/normalize.js';
|
|
2
|
+
import { jsonLoads } from '../../../core/py.js';
|
|
3
|
+
import { LIVE, WWW } from './profile.js';
|
|
4
|
+
/** 抖音原始对象 → 归一化类型(AGENTS 6.2)。用户 id 用 sec_uid:它能直接拼出主页 URL,也是各接口的入参。 */
|
|
5
|
+
export const userUrl = (secUid) => `${WWW}/user/${secUid}`;
|
|
6
|
+
export const liveUrl = (webRid) => `${LIVE}/${webRid}`;
|
|
7
|
+
export const itemUrl = (id, image = false) => `${WWW}/${image ? 'note' : 'video'}/${id}`;
|
|
8
|
+
const first = (v) => n.url(v?.url_list?.[0]);
|
|
9
|
+
export function ref(secUid, name) {
|
|
10
|
+
return n.userRef({ id: secUid, name, url: secUid ? userUrl(secUid) : null });
|
|
11
|
+
}
|
|
12
|
+
export function authorRef(u) {
|
|
13
|
+
if (!u)
|
|
14
|
+
return null;
|
|
15
|
+
return ref(u.sec_uid || u.sec_user_id, u.nickname);
|
|
16
|
+
}
|
|
17
|
+
/** 图文:aweme_type 68,或带 images。 */
|
|
18
|
+
export function isImage(v) {
|
|
19
|
+
return v?.aweme_type === 68 || (Array.isArray(v?.images) && v.images.length > 0);
|
|
20
|
+
}
|
|
21
|
+
/** 作品的媒体:视频取 play_addr,图文取每张图(上游 handle_work_info 的 video_addr / images)。 */
|
|
22
|
+
export function awemeMedia(v) {
|
|
23
|
+
if (isImage(v)) {
|
|
24
|
+
return (v.images ?? [])
|
|
25
|
+
.map((img, i) => {
|
|
26
|
+
const url = n.url(img?.url_list?.at(-1) ?? img?.url_list?.[0]);
|
|
27
|
+
return url ? n.media({ id: String(i + 1), type: 'image', url, width: n.count(img.width), height: n.count(img.height) }, img) : null;
|
|
28
|
+
})
|
|
29
|
+
.filter(Boolean);
|
|
30
|
+
}
|
|
31
|
+
const video = v?.video ?? {};
|
|
32
|
+
const url = first(video.play_addr);
|
|
33
|
+
if (!url)
|
|
34
|
+
return [];
|
|
35
|
+
const duration = n.seconds(v.duration ?? video.duration);
|
|
36
|
+
return [
|
|
37
|
+
n.media({
|
|
38
|
+
id: n.idOrNull(video.play_addr?.uri),
|
|
39
|
+
type: 'video',
|
|
40
|
+
url,
|
|
41
|
+
width: n.count(video.width ?? video.play_addr?.width),
|
|
42
|
+
height: n.count(video.height ?? video.play_addr?.height),
|
|
43
|
+
duration: duration == null ? null : duration / 1000,
|
|
44
|
+
}, video.play_addr),
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
export function aweme(v) {
|
|
48
|
+
const image = isImage(v);
|
|
49
|
+
const stats = v.statistics ?? {};
|
|
50
|
+
return n.item({
|
|
51
|
+
id: n.id(v.aweme_id),
|
|
52
|
+
kind: image ? 'image' : 'video',
|
|
53
|
+
url: itemUrl(v.aweme_id, image),
|
|
54
|
+
title: n.str(v.item_title),
|
|
55
|
+
text: n.str(v.desc),
|
|
56
|
+
author: authorRef(v.author),
|
|
57
|
+
created_at: n.time(v.create_time),
|
|
58
|
+
cover: first(v.video?.cover) ?? first(v.video?.origin_cover) ?? (image ? first(v.images?.[0]) : null),
|
|
59
|
+
media: awemeMedia(v),
|
|
60
|
+
stats: {
|
|
61
|
+
views: n.count(stats.play_count) || null,
|
|
62
|
+
likes: n.count(stats.digg_count),
|
|
63
|
+
comments: n.count(stats.comment_count),
|
|
64
|
+
collects: n.count(stats.collect_count),
|
|
65
|
+
shares: n.count(stats.share_count),
|
|
66
|
+
},
|
|
67
|
+
}, v);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 创作者中心作品列表(work_list)里的状态。上游 get_preview_video_list 只用到 timer.status(0 = 定时未发布)、
|
|
71
|
+
* is_pinned、status_value;审核 / 私密取 aweme 通用的 status 对象。定时未到点的作品 6.2 没有单独取值,按 draft(尚未公开)。
|
|
72
|
+
*/
|
|
73
|
+
export function workStatus(v) {
|
|
74
|
+
const s = v?.status ?? {};
|
|
75
|
+
if (v?.timer && v.timer.status === 0)
|
|
76
|
+
return 'draft';
|
|
77
|
+
if (s.in_reviewing)
|
|
78
|
+
return 'reviewing';
|
|
79
|
+
if (s.is_prohibited)
|
|
80
|
+
return 'rejected';
|
|
81
|
+
if (Number(s.private_status) === 1 || s.is_private === true || s.self_see === true)
|
|
82
|
+
return 'private';
|
|
83
|
+
return 'published';
|
|
84
|
+
}
|
|
85
|
+
/** 作品列表(item list)的一条:aweme 结构,加上 status。 */
|
|
86
|
+
export function work(v) {
|
|
87
|
+
const it = aweme(v);
|
|
88
|
+
it.status = workStatus(v);
|
|
89
|
+
if (!it.cover)
|
|
90
|
+
it.cover = first(v.video?.optimized_cover) ?? null;
|
|
91
|
+
return it;
|
|
92
|
+
}
|
|
93
|
+
export function user(u) {
|
|
94
|
+
return n.user({
|
|
95
|
+
id: n.id(u.sec_uid),
|
|
96
|
+
name: n.str(u.nickname),
|
|
97
|
+
handle: n.str(u.unique_id) ?? n.str(u.short_id),
|
|
98
|
+
avatar: first(u.avatar_larger) ?? first(u.avatar_300x300) ?? first(u.avatar_medium) ?? first(u.avatar_thumb),
|
|
99
|
+
url: u.sec_uid ? userUrl(u.sec_uid) : null,
|
|
100
|
+
bio: n.str(u.signature),
|
|
101
|
+
stats: {
|
|
102
|
+
followers: n.count(u.follower_count ?? u.mplatform_followers_count),
|
|
103
|
+
following: n.count(u.following_count),
|
|
104
|
+
items: n.count(u.aweme_count),
|
|
105
|
+
likes: n.count(u.total_favorited),
|
|
106
|
+
},
|
|
107
|
+
}, u);
|
|
108
|
+
}
|
|
109
|
+
export function comment(c, itemId) {
|
|
110
|
+
const parent = c.reply_id && c.reply_id !== '0' ? n.id(c.reply_id) : null;
|
|
111
|
+
return n.comment({
|
|
112
|
+
id: n.id(c.cid),
|
|
113
|
+
item_id: n.id(c.aweme_id ?? itemId),
|
|
114
|
+
parent_id: parent,
|
|
115
|
+
author: authorRef(c.user),
|
|
116
|
+
text: String(c.text ?? ''),
|
|
117
|
+
created_at: n.time(c.create_time),
|
|
118
|
+
stats: { likes: n.count(c.digg_count), replies: n.count(c.reply_comment_total) },
|
|
119
|
+
}, c);
|
|
120
|
+
}
|
|
121
|
+
/** 商品评价(get_product_comments 的 data.Comments,大写驼峰)。 */
|
|
122
|
+
export function productComment(c, productId) {
|
|
123
|
+
const u = c.User ?? c.user ?? {};
|
|
124
|
+
return n.comment({
|
|
125
|
+
id: n.id(c.CommentId ?? c.comment_id ?? c.Id ?? c.id),
|
|
126
|
+
item_id: productId,
|
|
127
|
+
author: n.userRef({ id: u.Id ?? u.SecUid ?? u.Nickname ?? u.NickName, name: u.NickName ?? u.Nickname ?? u.nickname }),
|
|
128
|
+
text: String(c.Content ?? c.content ?? ''),
|
|
129
|
+
created_at: n.time(c.CommentTime ?? c.CreateTime ?? c.create_time),
|
|
130
|
+
stats: { likes: n.count(c.LikeCount ?? c.like_count), replies: n.count(c.ReplyCount ?? c.reply_count) },
|
|
131
|
+
}, c);
|
|
132
|
+
}
|
|
133
|
+
/** 搜索结果里的直播(live/search 的 data 项,房间信息在 lives.rawdata 的 JSON 串里)。 */
|
|
134
|
+
export function searchLive(item) {
|
|
135
|
+
const lives = item?.lives ?? item;
|
|
136
|
+
let room = {};
|
|
137
|
+
try {
|
|
138
|
+
room = typeof lives?.rawdata === 'string' ? jsonLoads(lives.rawdata) : (lives?.rawdata ?? {});
|
|
139
|
+
}
|
|
140
|
+
catch { }
|
|
141
|
+
const owner = room.owner ?? lives?.author ?? {};
|
|
142
|
+
const webRid = owner.web_rid ?? room.web_rid ?? /"web_rid":"(\d+)"/.exec(JSON.stringify(lives ?? {}))?.[1];
|
|
143
|
+
if (!webRid)
|
|
144
|
+
return null;
|
|
145
|
+
return n.live({
|
|
146
|
+
id: String(webRid),
|
|
147
|
+
url: liveUrl(webRid),
|
|
148
|
+
title: n.str(room.title),
|
|
149
|
+
status: room.status === 4 ? 'offline' : 'live',
|
|
150
|
+
host: authorRef(owner),
|
|
151
|
+
cover: first(room.cover),
|
|
152
|
+
stats: { viewers: n.count(room.user_count ?? room.stats?.total_user) },
|
|
153
|
+
}, item);
|
|
154
|
+
}
|
|
155
|
+
/** room/web/enter 的响应 → Live。 */
|
|
156
|
+
export function roomEnter(body, webRid) {
|
|
157
|
+
const room = body?.data?.data?.[0] ?? {};
|
|
158
|
+
const owner = room.owner ?? body?.data?.user ?? {};
|
|
159
|
+
return n.live({
|
|
160
|
+
id: webRid,
|
|
161
|
+
url: liveUrl(webRid),
|
|
162
|
+
title: n.str(room.title),
|
|
163
|
+
status: Number(room.status ?? body?.data?.room_status) === 2 ? 'live' : 'offline',
|
|
164
|
+
host: authorRef(owner),
|
|
165
|
+
cover: first(room.cover),
|
|
166
|
+
stats: { viewers: n.count(room.user_count_str ?? room.stats?.user_count_str ?? room.room_view_stats?.display_value) },
|
|
167
|
+
}, body);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* room/web/enter 的拉流地址 → Media[]:优先 live_core_sdk_data 里各清晰度的 flv / hls(带分辨率),
|
|
171
|
+
* 没有时退回 flv_pull_url / hls_pull_url_map。未开播时没有 stream_url,返回空数组。
|
|
172
|
+
*/
|
|
173
|
+
export function liveStreams(body) {
|
|
174
|
+
const stream = body?.data?.data?.[0]?.stream_url ?? {};
|
|
175
|
+
const out = [];
|
|
176
|
+
const seen = new Set();
|
|
177
|
+
const push = (id, url, raw, size) => {
|
|
178
|
+
const u = n.url(url);
|
|
179
|
+
if (!u || seen.has(u))
|
|
180
|
+
return;
|
|
181
|
+
seen.add(u);
|
|
182
|
+
const [w, h] = /^(\d+)x(\d+)$/.exec(size ?? '')?.slice(1).map(Number) ?? [];
|
|
183
|
+
out.push(n.media({ id, type: 'video', url: u, width: w ?? null, height: h ?? null }, raw));
|
|
184
|
+
};
|
|
185
|
+
let data = null;
|
|
186
|
+
try {
|
|
187
|
+
const raw = stream.live_core_sdk_data?.pull_data?.stream_data;
|
|
188
|
+
data = (typeof raw === 'string' ? jsonLoads(raw) : raw)?.data ?? null;
|
|
189
|
+
}
|
|
190
|
+
catch { }
|
|
191
|
+
for (const [quality, v] of Object.entries(data ?? {})) {
|
|
192
|
+
let params = {};
|
|
193
|
+
try {
|
|
194
|
+
params = typeof v?.main?.sdk_params === 'string' ? jsonLoads(v.main.sdk_params) : (v?.main?.sdk_params ?? {});
|
|
195
|
+
}
|
|
196
|
+
catch { }
|
|
197
|
+
push(`${quality}.flv`, v?.main?.flv, v, params.resolution);
|
|
198
|
+
push(`${quality}.hls`, v?.main?.hls, v, params.resolution);
|
|
199
|
+
}
|
|
200
|
+
for (const [quality, u] of Object.entries(stream.flv_pull_url ?? {}))
|
|
201
|
+
push(`${quality}.flv`, u, stream);
|
|
202
|
+
for (const [quality, u] of Object.entries(stream.hls_pull_url_map ?? {}))
|
|
203
|
+
push(`${quality}.hls`, u, stream);
|
|
204
|
+
if (stream.hls_pull_url)
|
|
205
|
+
push('hls', stream.hls_pull_url, stream);
|
|
206
|
+
return out;
|
|
207
|
+
}
|
|
208
|
+
/** 贡献榜 / 千票榜的一行(ranks[] 或 list[]:user、rank、score)。 */
|
|
209
|
+
export function rankRow(x, i) {
|
|
210
|
+
const u = x?.user ?? x?.user_info ?? {};
|
|
211
|
+
const who = authorRef(u) ?? n.userRef({ id: u.id_str ?? u.id, name: u.nickname }) ?? { id: '', name: null, url: null };
|
|
212
|
+
return n.rank({ rank: Number(x?.rank ?? x?.seat_index ?? i + 1), user: who, score: n.count(x?.score ?? x?.value) }, x);
|
|
213
|
+
}
|
|
214
|
+
/** 千票榜的列表字段随版本不同,按常见的几个字段名找。 */
|
|
215
|
+
export function rankRows(body) {
|
|
216
|
+
const d = body?.data ?? {};
|
|
217
|
+
const list = d.ranks ?? d.list ?? d.seats ?? d.seats_list ?? d.user_list ?? d.rank_list ?? [];
|
|
218
|
+
return list.map(rankRow);
|
|
219
|
+
}
|
|
220
|
+
/** 商品评价的标签(comment/counter 的 counter_info):各种命名里找 (id, name)。 */
|
|
221
|
+
export function commentLabels(body) {
|
|
222
|
+
const out = [];
|
|
223
|
+
const visit = (v) => {
|
|
224
|
+
if (Array.isArray(v))
|
|
225
|
+
return v.forEach(visit);
|
|
226
|
+
if (!v || typeof v !== 'object')
|
|
227
|
+
return;
|
|
228
|
+
const id = v.tag_id ?? v.TagId ?? v.TagID ?? v.id ?? v.Id;
|
|
229
|
+
const name = v.tag_name ?? v.TagName ?? v.name ?? v.Name ?? v.text ?? v.Text;
|
|
230
|
+
if (id != null && name != null && typeof name === 'string')
|
|
231
|
+
out.push({ id: String(id), name, count: n.count(v.count ?? v.Count ?? v.num ?? v.Num) });
|
|
232
|
+
for (const x of Object.values(v))
|
|
233
|
+
if (x && typeof x === 'object')
|
|
234
|
+
visit(x);
|
|
235
|
+
};
|
|
236
|
+
visit(body?.counter_info ?? body?.data?.counter_info ?? body?.data ?? body);
|
|
237
|
+
return out;
|
|
238
|
+
}
|
|
239
|
+
/** 直播间商品(promotions 项)→ Item(kind goods)。url 带上 product_id / shop_id,供 comment list 直接使用。 */
|
|
240
|
+
export function promotion(p) {
|
|
241
|
+
const promotionId = n.id(p.promotion_id);
|
|
242
|
+
const url = productUrl(promotionId, p.product_id, p.shop_id);
|
|
243
|
+
const cover = n.url(p.cover ?? p.cover_url ?? p.images?.[0]?.url_list?.[0]);
|
|
244
|
+
return n.item({
|
|
245
|
+
id: promotionId,
|
|
246
|
+
kind: 'goods',
|
|
247
|
+
url,
|
|
248
|
+
title: n.str(p.title),
|
|
249
|
+
cover,
|
|
250
|
+
price: n.price(Number(p.min_price ?? p.price) / 100),
|
|
251
|
+
status: p.status === 2 || p.in_stock === false ? 'off_shelf' : 'on_sale',
|
|
252
|
+
}, p);
|
|
253
|
+
}
|
|
254
|
+
export function productUrl(promotionId, productId, shopId) {
|
|
255
|
+
const q = new URLSearchParams({ id: String(productId ?? promotionId) });
|
|
256
|
+
q.set('promotion_id', String(promotionId));
|
|
257
|
+
if (shopId != null && shopId !== '')
|
|
258
|
+
q.set('shop_id', String(shopId));
|
|
259
|
+
return `https://haohuo.jinritemai.com/ecommerce/trade/detail/index.html?${q}`;
|
|
260
|
+
}
|
|
261
|
+
/** 商品详情(pack/detail 的响应)→ Item。 */
|
|
262
|
+
export function productDetail(body, promotionId) {
|
|
263
|
+
const info = body?.detail_info ?? body?.data?.detail_info ?? {};
|
|
264
|
+
const promo = body?.promotions?.[0] ?? body?.promotion ?? {};
|
|
265
|
+
const imgs = [...(info.title_image ?? []), ...(info.detail_imgs ?? [])].map((x) => (typeof x === 'string' ? x : x?.url_list?.[0])).filter(Boolean);
|
|
266
|
+
return n.item({
|
|
267
|
+
id: promotionId,
|
|
268
|
+
kind: 'goods',
|
|
269
|
+
url: productUrl(promotionId, promo.product_id, promo.shop_id),
|
|
270
|
+
title: n.str(promo.title ?? info.title ?? body?.title),
|
|
271
|
+
cover: n.url(imgs[0]),
|
|
272
|
+
media: imgs.map((u, i) => n.media({ id: String(i + 1), type: 'image', url: n.url(u) })),
|
|
273
|
+
price: promo.min_price != null ? n.price(Number(promo.min_price) / 100) : null,
|
|
274
|
+
}, body);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* 通知类型按通知体带的字段判断:数字 type 随版本变(实测 2026-09:31 评论、41 点赞、9009 互动),
|
|
278
|
+
* 而 401 / 601 / 2 / 3 是请求时 notice_group 的分组号,不是单条通知的 type。
|
|
279
|
+
*/
|
|
280
|
+
function noticeKind(v) {
|
|
281
|
+
if (v.follow)
|
|
282
|
+
return 'follow';
|
|
283
|
+
if (v.digg)
|
|
284
|
+
return 'like';
|
|
285
|
+
if (v.at ?? v.mention)
|
|
286
|
+
return 'mention';
|
|
287
|
+
if (v.comment)
|
|
288
|
+
return 'comment';
|
|
289
|
+
return 'system';
|
|
290
|
+
}
|
|
291
|
+
/** 通知(notice_list_v2 项)。 */
|
|
292
|
+
export function notice(v) {
|
|
293
|
+
const u = v.from_user?.[0] ?? v.user ?? v.comment?.comment?.user ?? v.digg?.from_user?.[0] ?? v.follow?.from_user ?? v.interactive_notice?.from_user?.[0] ?? null;
|
|
294
|
+
const aweme = v.comment?.aweme ?? v.digg?.aweme ?? v.aweme ?? null;
|
|
295
|
+
const awemeId = aweme?.aweme_id ?? (v.aweme_id && v.aweme_id !== '0' ? v.aweme_id : null);
|
|
296
|
+
return n.notice({
|
|
297
|
+
id: n.id(v.nid_str ?? v.nid),
|
|
298
|
+
type: noticeKind(v),
|
|
299
|
+
user: u ? authorRef(u) : null,
|
|
300
|
+
target: awemeId ? { id: n.id(awemeId), url: itemUrl(awemeId) } : null,
|
|
301
|
+
text: n.str(v.comment?.comment?.text ?? v.digg?.content ?? v.interactive_notice?.content ?? v.general_notice?.content ?? v.content ?? v.text),
|
|
302
|
+
created_at: n.time(v.create_time),
|
|
303
|
+
}, v);
|
|
304
|
+
}
|
|
305
|
+
/** 直播弹幕长连的消息 → Event;不关心的消息返回 null(上游 dy_live/server.py 的 on_message)。 */
|
|
306
|
+
export function liveEvent(method, msg) {
|
|
307
|
+
const u = msg?.user;
|
|
308
|
+
const secUid = u?.sec_uid;
|
|
309
|
+
const who = u ? n.userRef({ id: secUid || u.id_str || n.idOrNull(u.id), name: u.nickname, url: secUid ? userUrl(secUid) : null }) : null;
|
|
310
|
+
switch (method) {
|
|
311
|
+
case 'WebcastChatMessage':
|
|
312
|
+
return n.event({ type: 'chat', user: who, text: String(msg.content ?? '') }, msg);
|
|
313
|
+
case 'WebcastGiftMessage':
|
|
314
|
+
return n.event({ type: 'gift', user: who, gift: { name: String(msg.gift?.name ?? ''), count: Number(msg.comboCount ?? 1) } }, msg);
|
|
315
|
+
case 'WebcastMemberMessage':
|
|
316
|
+
return n.event({ type: 'enter', user: who }, msg);
|
|
317
|
+
case 'WebcastLikeMessage':
|
|
318
|
+
return n.event({ type: 'like', user: who, text: msg.count != null ? String(msg.count) : null }, msg);
|
|
319
|
+
case 'WebcastSocialMessage':
|
|
320
|
+
return Number(msg.action) === 1 ? n.event({ type: 'follow', user: who }, msg) : null;
|
|
321
|
+
case 'WebcastRoomStatsMessage':
|
|
322
|
+
return n.event({ type: 'other', text: n.str(msg.displayLong) }, msg);
|
|
323
|
+
default:
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
}
|