tt-help-cli-ycl 1.3.48 → 1.3.50

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.
Files changed (64) hide show
  1. package/README.md +33 -33
  2. package/cli.js +9 -9
  3. package/package.json +52 -52
  4. package/scripts/run-explore copy.bat +101 -101
  5. package/scripts/run-explore.bat +134 -134
  6. package/scripts/run-explore.ps1 +159 -159
  7. package/scripts/run-explore.sh +121 -121
  8. package/scripts/test-captcha-lib.mjs +68 -0
  9. package/scripts/test-captcha.mjs +81 -0
  10. package/scripts/test-incognito-lib.mjs +36 -0
  11. package/scripts/test-login-state.mjs +128 -0
  12. package/scripts/test-safe-click.mjs +45 -0
  13. package/scripts/test-watch-db-smoke.mjs +246 -0
  14. package/src/cli/attach.js +331 -331
  15. package/src/cli/auto.js +265 -265
  16. package/src/cli/comments.js +620 -620
  17. package/src/cli/config.js +170 -170
  18. package/src/cli/db-import.js +51 -51
  19. package/src/cli/explore.js +555 -555
  20. package/src/cli/open.js +109 -111
  21. package/src/cli/progress.js +111 -111
  22. package/src/cli/refresh.js +288 -288
  23. package/src/cli/scrape.js +47 -47
  24. package/src/cli/utils.js +18 -18
  25. package/src/cli/videos.js +41 -41
  26. package/src/cli/videostats.js +196 -196
  27. package/src/cli/watch.js +30 -30
  28. package/src/lib/api-interceptor.js +161 -161
  29. package/src/lib/args.js +809 -809
  30. package/src/lib/browser/anti-detect.js +23 -23
  31. package/src/lib/browser/cdp.js +261 -261
  32. package/src/lib/browser/health-checker.js +114 -114
  33. package/src/lib/browser/launch.js +43 -43
  34. package/src/lib/browser/page.js +184 -184
  35. package/src/lib/constants.js +297 -297
  36. package/src/lib/delay.js +54 -54
  37. package/src/lib/explore-fetch.js +118 -118
  38. package/src/lib/fetcher.js +45 -45
  39. package/src/lib/filter.js +66 -66
  40. package/src/lib/io.js +54 -54
  41. package/src/lib/output.js +80 -80
  42. package/src/lib/page-error-detector.js +109 -109
  43. package/src/lib/parse-ssr.mjs +69 -69
  44. package/src/lib/parser.js +47 -47
  45. package/src/lib/retry.js +45 -45
  46. package/src/lib/scrape.js +90 -90
  47. package/src/lib/target-locations.js +61 -61
  48. package/src/lib/tiktok-scraper.mjs +98 -61
  49. package/src/lib/url.js +52 -52
  50. package/src/main.js +73 -73
  51. package/src/npm-main.js +70 -70
  52. package/src/results/user-videos-bar.lar.lar.moeta.json +37 -0
  53. package/src/scraper/auto-core.js +203 -203
  54. package/src/scraper/core.js +255 -255
  55. package/src/scraper/explore-core.js +208 -208
  56. package/src/scraper/modules/captcha-handler.js +114 -114
  57. package/src/scraper/modules/follow-extractor.js +250 -250
  58. package/src/scraper/modules/guess-extractor.js +51 -51
  59. package/src/scraper/modules/page-helpers.js +48 -48
  60. package/src/scraper/refresh-core.js +213 -213
  61. package/src/videos/core.js +143 -143
  62. package/src/watch/data-store.js +2980 -2980
  63. package/src/watch/public/index.html +2355 -2355
  64. package/src/watch/server.js +727 -727
package/src/cli/config.js CHANGED
@@ -1,170 +1,170 @@
1
- import {
2
- HELP_TEXT,
3
- configPath,
4
- saveBrowser,
5
- saveUserId,
6
- saveMaxFollowing,
7
- saveMaxFollowers,
8
- saveMaxVideos,
9
- saveMaxComments,
10
- getConfigText,
11
- } from "../lib/constants.js";
12
- import { readFileSync, writeFileSync, existsSync } from "fs";
13
- import { fileURLToPath } from "url";
14
- import { dirname, join } from "path";
15
-
16
- const __dirname = dirname(fileURLToPath(import.meta.url));
17
- const pkgPath = join(__dirname, "..", "..", "package.json");
18
- const { version } = JSON.parse(readFileSync(pkgPath, "utf-8"));
19
-
20
- function showConfig(urls, outputFile) {
21
- const configLines = getConfigText();
22
- if (urls.length > 0) {
23
- configLines.push(`\n URL数量: ${urls.length}`);
24
- }
25
- if (outputFile) {
26
- configLines.push(` 输出/锚点路径: ${outputFile}`);
27
- }
28
- console.error(configLines.join("\n"));
29
- }
30
-
31
- function showUsage(helpText = HELP_TEXT) {
32
- console.error(helpText.join("\n"));
33
- process.exit(0);
34
- }
35
-
36
- function handleConfig(action, key, value) {
37
- switch (action) {
38
- case "show": {
39
- const configLines = getConfigText();
40
- console.error(configLines.join("\n"));
41
- break;
42
- }
43
-
44
- case "set": {
45
- if (!key) {
46
- console.error("用法: tt-help config set <key> <value>");
47
- console.error(
48
- " 可用 key: proxy, server, browser, userId, maxFollowing, maxFollowers, maxVideos, maxComments",
49
- );
50
- return;
51
- }
52
-
53
- switch (key) {
54
- case "proxy":
55
- if (!value) {
56
- console.error("请提供 proxy 的值");
57
- console.error("用法: tt-help config set proxy <代理地址>");
58
- return;
59
- }
60
- saveProxy(value);
61
- console.error(`代理已更新: ${value}`);
62
- break;
63
-
64
- case "server":
65
- if (!value) {
66
- console.error("请提供 server 的值");
67
- return;
68
- }
69
- saveServer(value);
70
- console.error(`服务器已更新: ${value}`);
71
- break;
72
-
73
- case "browser":
74
- if (!value) {
75
- console.error("请提供 browser 的值");
76
- console.error("用法: tt-help config set browser <浏览器路径>");
77
- console.error(" 或: tt-help config set-browser <浏览器路径>");
78
- return;
79
- }
80
- saveBrowser(value);
81
- console.error(`浏览器路径已更新: ${value}`);
82
- break;
83
-
84
- case "userId":
85
- if (!value) {
86
- console.error("请提供 userId 的值");
87
- return;
88
- }
89
- saveUserId(value);
90
- console.error(`用户号已更新: ${value}`);
91
- break;
92
-
93
- case "maxFollowing":
94
- if (!value) {
95
- console.error("请提供 maxFollowing 的值");
96
- return;
97
- }
98
- saveMaxFollowing(value);
99
- console.error(`商家关注采集数已更新: ${value}`);
100
- break;
101
-
102
- case "maxFollowers":
103
- if (!value) {
104
- console.error("请提供 maxFollowers 的值");
105
- return;
106
- }
107
- saveMaxFollowers(value);
108
- console.error(`粉丝采集数已更新: ${value}`);
109
- break;
110
-
111
- case "maxVideos":
112
- if (!value) {
113
- console.error("请提供 maxVideos 的值");
114
- return;
115
- }
116
- saveMaxVideos(value);
117
- console.error(`视频采集数已更新: ${value}`);
118
- break;
119
-
120
- case "maxComments":
121
- if (!value) {
122
- console.error("请提供 maxComments 的值");
123
- return;
124
- }
125
- saveMaxComments(value);
126
- console.error(`评论采集数已更新: ${value}`);
127
- break;
128
-
129
- default:
130
- console.error(`未知配置项: ${key}`);
131
- console.error(
132
- " 可用 key: proxy, server, browser, userId, maxFollowing, maxFollowers, maxVideos, maxComments",
133
- );
134
- }
135
- break;
136
- }
137
-
138
- case "reset": {
139
- if (existsSync(configPath)) {
140
- writeFileSync(configPath, "{}", "utf-8");
141
- console.error("配置已重置为默认");
142
- } else {
143
- console.error("配置文件不存在或已是默认状态");
144
- }
145
- break;
146
- }
147
-
148
- default:
149
- console.error(`未知配置命令: ${action}`);
150
- console.error("用法: tt-help config [show|set|reset]");
151
- }
152
- }
153
-
154
- function saveProxy(newProxy) {
155
- const cfg = existsSync(configPath)
156
- ? JSON.parse(readFileSync(configPath, "utf-8"))
157
- : {};
158
- cfg.proxy = newProxy;
159
- writeFileSync(configPath, JSON.stringify(cfg, null, 2), "utf-8");
160
- }
161
-
162
- function saveServer(newServer) {
163
- const cfg = existsSync(configPath)
164
- ? JSON.parse(readFileSync(configPath, "utf-8"))
165
- : {};
166
- cfg.server = newServer;
167
- writeFileSync(configPath, JSON.stringify(cfg, null, 2), "utf-8");
168
- }
169
-
170
- export { handleConfig, showConfig, showUsage, version };
1
+ import {
2
+ HELP_TEXT,
3
+ configPath,
4
+ saveBrowser,
5
+ saveUserId,
6
+ saveMaxFollowing,
7
+ saveMaxFollowers,
8
+ saveMaxVideos,
9
+ saveMaxComments,
10
+ getConfigText,
11
+ } from "../lib/constants.js";
12
+ import { readFileSync, writeFileSync, existsSync } from "fs";
13
+ import { fileURLToPath } from "url";
14
+ import { dirname, join } from "path";
15
+
16
+ const __dirname = dirname(fileURLToPath(import.meta.url));
17
+ const pkgPath = join(__dirname, "..", "..", "package.json");
18
+ const { version } = JSON.parse(readFileSync(pkgPath, "utf-8"));
19
+
20
+ function showConfig(urls, outputFile) {
21
+ const configLines = getConfigText();
22
+ if (urls.length > 0) {
23
+ configLines.push(`\n URL数量: ${urls.length}`);
24
+ }
25
+ if (outputFile) {
26
+ configLines.push(` 输出/锚点路径: ${outputFile}`);
27
+ }
28
+ console.error(configLines.join("\n"));
29
+ }
30
+
31
+ function showUsage(helpText = HELP_TEXT) {
32
+ console.error(helpText.join("\n"));
33
+ process.exit(0);
34
+ }
35
+
36
+ function handleConfig(action, key, value) {
37
+ switch (action) {
38
+ case "show": {
39
+ const configLines = getConfigText();
40
+ console.error(configLines.join("\n"));
41
+ break;
42
+ }
43
+
44
+ case "set": {
45
+ if (!key) {
46
+ console.error("用法: tt-help config set <key> <value>");
47
+ console.error(
48
+ " 可用 key: proxy, server, browser, userId, maxFollowing, maxFollowers, maxVideos, maxComments",
49
+ );
50
+ return;
51
+ }
52
+
53
+ switch (key) {
54
+ case "proxy":
55
+ if (!value) {
56
+ console.error("请提供 proxy 的值");
57
+ console.error("用法: tt-help config set proxy <代理地址>");
58
+ return;
59
+ }
60
+ saveProxy(value);
61
+ console.error(`代理已更新: ${value}`);
62
+ break;
63
+
64
+ case "server":
65
+ if (!value) {
66
+ console.error("请提供 server 的值");
67
+ return;
68
+ }
69
+ saveServer(value);
70
+ console.error(`服务器已更新: ${value}`);
71
+ break;
72
+
73
+ case "browser":
74
+ if (!value) {
75
+ console.error("请提供 browser 的值");
76
+ console.error("用法: tt-help config set browser <浏览器路径>");
77
+ console.error(" 或: tt-help config set-browser <浏览器路径>");
78
+ return;
79
+ }
80
+ saveBrowser(value);
81
+ console.error(`浏览器路径已更新: ${value}`);
82
+ break;
83
+
84
+ case "userId":
85
+ if (!value) {
86
+ console.error("请提供 userId 的值");
87
+ return;
88
+ }
89
+ saveUserId(value);
90
+ console.error(`用户号已更新: ${value}`);
91
+ break;
92
+
93
+ case "maxFollowing":
94
+ if (!value) {
95
+ console.error("请提供 maxFollowing 的值");
96
+ return;
97
+ }
98
+ saveMaxFollowing(value);
99
+ console.error(`商家关注采集数已更新: ${value}`);
100
+ break;
101
+
102
+ case "maxFollowers":
103
+ if (!value) {
104
+ console.error("请提供 maxFollowers 的值");
105
+ return;
106
+ }
107
+ saveMaxFollowers(value);
108
+ console.error(`粉丝采集数已更新: ${value}`);
109
+ break;
110
+
111
+ case "maxVideos":
112
+ if (!value) {
113
+ console.error("请提供 maxVideos 的值");
114
+ return;
115
+ }
116
+ saveMaxVideos(value);
117
+ console.error(`视频采集数已更新: ${value}`);
118
+ break;
119
+
120
+ case "maxComments":
121
+ if (!value) {
122
+ console.error("请提供 maxComments 的值");
123
+ return;
124
+ }
125
+ saveMaxComments(value);
126
+ console.error(`评论采集数已更新: ${value}`);
127
+ break;
128
+
129
+ default:
130
+ console.error(`未知配置项: ${key}`);
131
+ console.error(
132
+ " 可用 key: proxy, server, browser, userId, maxFollowing, maxFollowers, maxVideos, maxComments",
133
+ );
134
+ }
135
+ break;
136
+ }
137
+
138
+ case "reset": {
139
+ if (existsSync(configPath)) {
140
+ writeFileSync(configPath, "{}", "utf-8");
141
+ console.error("配置已重置为默认");
142
+ } else {
143
+ console.error("配置文件不存在或已是默认状态");
144
+ }
145
+ break;
146
+ }
147
+
148
+ default:
149
+ console.error(`未知配置命令: ${action}`);
150
+ console.error("用法: tt-help config [show|set|reset]");
151
+ }
152
+ }
153
+
154
+ function saveProxy(newProxy) {
155
+ const cfg = existsSync(configPath)
156
+ ? JSON.parse(readFileSync(configPath, "utf-8"))
157
+ : {};
158
+ cfg.proxy = newProxy;
159
+ writeFileSync(configPath, JSON.stringify(cfg, null, 2), "utf-8");
160
+ }
161
+
162
+ function saveServer(newServer) {
163
+ const cfg = existsSync(configPath)
164
+ ? JSON.parse(readFileSync(configPath, "utf-8"))
165
+ : {};
166
+ cfg.server = newServer;
167
+ writeFileSync(configPath, JSON.stringify(cfg, null, 2), "utf-8");
168
+ }
169
+
170
+ export { handleConfig, showConfig, showUsage, version };
@@ -1,51 +1,51 @@
1
- import { closeStoreDb, importLegacyJsonToDb } from "../watch/data-store.js";
2
-
3
- export async function handleDbImport(options) {
4
- const { dbPath, usersFilePath, doneFilePath, videosFilePath, showHelp } =
5
- options;
6
-
7
- if (showHelp) {
8
- console.error(
9
- "用法: tt-help db-import --db <db路径> [--users users.json] [--done done.json] [--videos videos.json]",
10
- );
11
- console.error("");
12
- console.error("示例:");
13
- console.error(
14
- " tt-help db-import --db data/result.db --users data/result.json --done data/result-done.json --videos data/result-videos.json",
15
- );
16
- return;
17
- }
18
-
19
- if (!dbPath) {
20
- console.error("请提供 --db <db路径>");
21
- process.exit(1);
22
- }
23
-
24
- if (!usersFilePath && !doneFilePath && !videosFilePath) {
25
- console.error("至少提供一个导入源:--users / --done / --videos");
26
- process.exit(1);
27
- }
28
-
29
- try {
30
- const result = importLegacyJsonToDb({
31
- dbFilePath: dbPath,
32
- usersFilePath,
33
- doneFilePath,
34
- videosFilePath,
35
- });
36
-
37
- console.error("[db-import] 导入完成");
38
- console.error(`[db-import] 数据库: ${result.dbPath}`);
39
- console.error(
40
- `[db-import] 新增 users: ${result.usersImported}, 总数: ${result.totalUsers}`,
41
- );
42
- console.error(
43
- `[db-import] 新增 jobs: ${result.jobsImported}, 总数: ${result.totalJobs}`,
44
- );
45
- console.error(
46
- `[db-import] 新增 videos: ${result.videosImported}, 总数: ${result.totalVideos}`,
47
- );
48
- } finally {
49
- closeStoreDb();
50
- }
51
- }
1
+ import { closeStoreDb, importLegacyJsonToDb } from "../watch/data-store.js";
2
+
3
+ export async function handleDbImport(options) {
4
+ const { dbPath, usersFilePath, doneFilePath, videosFilePath, showHelp } =
5
+ options;
6
+
7
+ if (showHelp) {
8
+ console.error(
9
+ "用法: tt-help db-import --db <db路径> [--users users.json] [--done done.json] [--videos videos.json]",
10
+ );
11
+ console.error("");
12
+ console.error("示例:");
13
+ console.error(
14
+ " tt-help db-import --db data/result.db --users data/result.json --done data/result-done.json --videos data/result-videos.json",
15
+ );
16
+ return;
17
+ }
18
+
19
+ if (!dbPath) {
20
+ console.error("请提供 --db <db路径>");
21
+ process.exit(1);
22
+ }
23
+
24
+ if (!usersFilePath && !doneFilePath && !videosFilePath) {
25
+ console.error("至少提供一个导入源:--users / --done / --videos");
26
+ process.exit(1);
27
+ }
28
+
29
+ try {
30
+ const result = importLegacyJsonToDb({
31
+ dbFilePath: dbPath,
32
+ usersFilePath,
33
+ doneFilePath,
34
+ videosFilePath,
35
+ });
36
+
37
+ console.error("[db-import] 导入完成");
38
+ console.error(`[db-import] 数据库: ${result.dbPath}`);
39
+ console.error(
40
+ `[db-import] 新增 users: ${result.usersImported}, 总数: ${result.totalUsers}`,
41
+ );
42
+ console.error(
43
+ `[db-import] 新增 jobs: ${result.jobsImported}, 总数: ${result.totalJobs}`,
44
+ );
45
+ console.error(
46
+ `[db-import] 新增 videos: ${result.videosImported}, 总数: ${result.totalVideos}`,
47
+ );
48
+ } finally {
49
+ closeStoreDb();
50
+ }
51
+ }