tt-help-cli-ycl 1.3.33 → 1.3.34

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 (59) hide show
  1. package/README.md +17 -17
  2. package/cli.js +9 -9
  3. package/package.json +47 -47
  4. package/scripts/run-explore copy.bat +101 -101
  5. package/scripts/run-explore.bat +132 -127
  6. package/scripts/run-explore.ps1 +157 -153
  7. package/scripts/run-explore.sh +119 -113
  8. package/src/cli/attach.js +180 -180
  9. package/src/cli/auto.js +240 -240
  10. package/src/cli/config.js +152 -152
  11. package/src/cli/explore.js +488 -481
  12. package/src/cli/info.js +88 -88
  13. package/src/cli/open.js +111 -111
  14. package/src/cli/progress.js +111 -111
  15. package/src/cli/refresh.js +216 -216
  16. package/src/cli/scrape.js +47 -47
  17. package/src/cli/utils.js +18 -18
  18. package/src/cli/videos.js +41 -41
  19. package/src/cli/watch.js +31 -31
  20. package/src/lib/api-interceptor.js +43 -202
  21. package/src/lib/args.js +722 -722
  22. package/src/lib/browser/anti-detect.js +23 -23
  23. package/src/lib/browser/cdp.js +261 -261
  24. package/src/lib/browser/health-checker.js +114 -114
  25. package/src/lib/browser/launch.js +43 -43
  26. package/src/lib/browser/page.js +183 -183
  27. package/src/lib/constants.js +216 -213
  28. package/src/lib/delay.js +54 -54
  29. package/src/lib/explore-fetch.js +118 -118
  30. package/src/lib/fetcher.js +45 -45
  31. package/src/lib/filter.js +66 -66
  32. package/src/lib/io.js +54 -54
  33. package/src/lib/output.js +80 -80
  34. package/src/lib/page-error-detector.js +105 -105
  35. package/src/lib/parse-ssr.mjs +69 -69
  36. package/src/lib/parser.js +47 -47
  37. package/src/lib/retry.js +45 -45
  38. package/src/lib/scrape.js +89 -89
  39. package/src/lib/tiktok-scraper.mjs +194 -194
  40. package/src/lib/url.js +52 -52
  41. package/src/main.js +48 -48
  42. package/src/scraper/auto-core.js +203 -203
  43. package/src/scraper/core.js +211 -211
  44. package/src/scraper/explore-core.js +167 -167
  45. package/src/scraper/modules/captcha-handler.js +114 -114
  46. package/src/scraper/modules/follow-extractor.js +194 -194
  47. package/src/scraper/modules/guess-extractor.js +51 -51
  48. package/src/scraper/modules/page-helpers.js +48 -48
  49. package/src/scraper/refresh-core.js +179 -179
  50. package/src/videos/core.js +125 -125
  51. package/src/watch/data-store.js +1030 -1030
  52. package/src/watch/public/index.html +753 -753
  53. package/src/watch/server.js +933 -933
  54. package/scripts/test-captcha-lib.mjs +0 -68
  55. package/scripts/test-captcha.mjs +0 -81
  56. package/scripts/test-incognito-lib.mjs +0 -36
  57. package/scripts/test-login-state.mjs +0 -128
  58. package/scripts/test-safe-click.mjs +0 -45
  59. package/src/results/user-videos-bar.lar.lar.moeta.json +0 -37
package/src/cli/config.js CHANGED
@@ -1,152 +1,152 @@
1
- import { HELP_TEXT, configPath, saveBrowser, saveUserId, saveMaxFollowing, saveMaxFollowers, saveMaxVideos, saveMaxComments, getConfigText } from '../lib/constants.js';
2
- import { readFileSync, writeFileSync, existsSync } from 'fs';
3
- import { fileURLToPath } from 'url';
4
- import { dirname, join } from 'path';
5
-
6
- const __dirname = dirname(fileURLToPath(import.meta.url));
7
- const pkgPath = join(__dirname, '..', '..', 'package.json');
8
- const { version } = JSON.parse(readFileSync(pkgPath, 'utf-8'));
9
-
10
- function showConfig(urls, outputFile) {
11
- const configLines = getConfigText();
12
- if (urls.length > 0) {
13
- configLines.push(`\n URL数量: ${urls.length}`);
14
- }
15
- if (outputFile) {
16
- configLines.push(` 输出文件: ${outputFile}`);
17
- }
18
- console.error(configLines.join('\n'));
19
- }
20
-
21
- function showUsage() {
22
- console.error(HELP_TEXT.join('\n'));
23
- process.exit(0);
24
- }
25
-
26
- function handleConfig(action, key, value) {
27
- switch (action) {
28
- case 'show': {
29
- const configLines = getConfigText();
30
- console.error(configLines.join('\n'));
31
- break;
32
- }
33
-
34
- case 'set': {
35
- if (!key) {
36
- console.error('用法: tt-help config set <key> <value>');
37
- console.error(' 可用 key: proxy, server, browser, userId, maxFollowing, maxFollowers, maxVideos, maxComments');
38
- return;
39
- }
40
-
41
- switch (key) {
42
- case 'proxy':
43
- if (!value) {
44
- console.error('请提供 proxy 的值');
45
- console.error('用法: tt-help config set proxy <代理地址>');
46
- return;
47
- }
48
- saveProxy(value);
49
- console.error(`代理已更新: ${value}`);
50
- break;
51
-
52
- case 'server':
53
- if (!value) {
54
- console.error('请提供 server 的值');
55
- return;
56
- }
57
- saveServer(value);
58
- console.error(`服务器已更新: ${value}`);
59
- break;
60
-
61
- case 'browser':
62
- if (!value) {
63
- console.error('请提供 browser 的值');
64
- console.error('用法: tt-help config set browser <浏览器路径>');
65
- console.error(' 或: tt-help config set-browser <浏览器路径>');
66
- return;
67
- }
68
- saveBrowser(value);
69
- console.error(`浏览器路径已更新: ${value}`);
70
- break;
71
-
72
- case 'userId':
73
- if (!value) {
74
- console.error('请提供 userId 的值');
75
- return;
76
- }
77
- saveUserId(value);
78
- console.error(`用户号已更新: ${value}`);
79
- break;
80
-
81
- case 'maxFollowing':
82
- if (!value) {
83
- console.error('请提供 maxFollowing 的值');
84
- return;
85
- }
86
- saveMaxFollowing(value);
87
- console.error(`商家关注采集数已更新: ${value}`);
88
- break;
89
-
90
- case 'maxFollowers':
91
- if (!value) {
92
- console.error('请提供 maxFollowers 的值');
93
- return;
94
- }
95
- saveMaxFollowers(value);
96
- console.error(`粉丝采集数已更新: ${value}`);
97
- break;
98
-
99
- case 'maxVideos':
100
- if (!value) {
101
- console.error('请提供 maxVideos 的值');
102
- return;
103
- }
104
- saveMaxVideos(value);
105
- console.error(`视频采集数已更新: ${value}`);
106
- break;
107
-
108
- case 'maxComments':
109
- if (!value) {
110
- console.error('请提供 maxComments 的值');
111
- return;
112
- }
113
- saveMaxComments(value);
114
- console.error(`评论采集数已更新: ${value}`);
115
- break;
116
-
117
- default:
118
- console.error(`未知配置项: ${key}`);
119
- console.error(' 可用 key: proxy, server, browser, userId, maxFollowing, maxFollowers, maxVideos, maxComments');
120
- }
121
- break;
122
- }
123
-
124
- case 'reset': {
125
- if (existsSync(configPath)) {
126
- writeFileSync(configPath, '{}', 'utf-8');
127
- console.error('配置已重置为默认');
128
- } else {
129
- console.error('配置文件不存在或已是默认状态');
130
- }
131
- break;
132
- }
133
-
134
- default:
135
- console.error(`未知配置命令: ${action}`);
136
- console.error('用法: tt-help config [show|set|reset]');
137
- }
138
- }
139
-
140
- function saveProxy(newProxy) {
141
- const cfg = existsSync(configPath) ? JSON.parse(readFileSync(configPath, 'utf-8')) : {};
142
- cfg.proxy = newProxy;
143
- writeFileSync(configPath, JSON.stringify(cfg, null, 2), 'utf-8');
144
- }
145
-
146
- function saveServer(newServer) {
147
- const cfg = existsSync(configPath) ? JSON.parse(readFileSync(configPath, 'utf-8')) : {};
148
- cfg.server = newServer;
149
- writeFileSync(configPath, JSON.stringify(cfg, null, 2), 'utf-8');
150
- }
151
-
152
- export { handleConfig, showConfig, showUsage, version };
1
+ import { HELP_TEXT, configPath, saveBrowser, saveUserId, saveMaxFollowing, saveMaxFollowers, saveMaxVideos, saveMaxComments, getConfigText } from '../lib/constants.js';
2
+ import { readFileSync, writeFileSync, existsSync } from 'fs';
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname, join } from 'path';
5
+
6
+ const __dirname = dirname(fileURLToPath(import.meta.url));
7
+ const pkgPath = join(__dirname, '..', '..', 'package.json');
8
+ const { version } = JSON.parse(readFileSync(pkgPath, 'utf-8'));
9
+
10
+ function showConfig(urls, outputFile) {
11
+ const configLines = getConfigText();
12
+ if (urls.length > 0) {
13
+ configLines.push(`\n URL数量: ${urls.length}`);
14
+ }
15
+ if (outputFile) {
16
+ configLines.push(` 输出文件: ${outputFile}`);
17
+ }
18
+ console.error(configLines.join('\n'));
19
+ }
20
+
21
+ function showUsage() {
22
+ console.error(HELP_TEXT.join('\n'));
23
+ process.exit(0);
24
+ }
25
+
26
+ function handleConfig(action, key, value) {
27
+ switch (action) {
28
+ case 'show': {
29
+ const configLines = getConfigText();
30
+ console.error(configLines.join('\n'));
31
+ break;
32
+ }
33
+
34
+ case 'set': {
35
+ if (!key) {
36
+ console.error('用法: tt-help config set <key> <value>');
37
+ console.error(' 可用 key: proxy, server, browser, userId, maxFollowing, maxFollowers, maxVideos, maxComments');
38
+ return;
39
+ }
40
+
41
+ switch (key) {
42
+ case 'proxy':
43
+ if (!value) {
44
+ console.error('请提供 proxy 的值');
45
+ console.error('用法: tt-help config set proxy <代理地址>');
46
+ return;
47
+ }
48
+ saveProxy(value);
49
+ console.error(`代理已更新: ${value}`);
50
+ break;
51
+
52
+ case 'server':
53
+ if (!value) {
54
+ console.error('请提供 server 的值');
55
+ return;
56
+ }
57
+ saveServer(value);
58
+ console.error(`服务器已更新: ${value}`);
59
+ break;
60
+
61
+ case 'browser':
62
+ if (!value) {
63
+ console.error('请提供 browser 的值');
64
+ console.error('用法: tt-help config set browser <浏览器路径>');
65
+ console.error(' 或: tt-help config set-browser <浏览器路径>');
66
+ return;
67
+ }
68
+ saveBrowser(value);
69
+ console.error(`浏览器路径已更新: ${value}`);
70
+ break;
71
+
72
+ case 'userId':
73
+ if (!value) {
74
+ console.error('请提供 userId 的值');
75
+ return;
76
+ }
77
+ saveUserId(value);
78
+ console.error(`用户号已更新: ${value}`);
79
+ break;
80
+
81
+ case 'maxFollowing':
82
+ if (!value) {
83
+ console.error('请提供 maxFollowing 的值');
84
+ return;
85
+ }
86
+ saveMaxFollowing(value);
87
+ console.error(`商家关注采集数已更新: ${value}`);
88
+ break;
89
+
90
+ case 'maxFollowers':
91
+ if (!value) {
92
+ console.error('请提供 maxFollowers 的值');
93
+ return;
94
+ }
95
+ saveMaxFollowers(value);
96
+ console.error(`粉丝采集数已更新: ${value}`);
97
+ break;
98
+
99
+ case 'maxVideos':
100
+ if (!value) {
101
+ console.error('请提供 maxVideos 的值');
102
+ return;
103
+ }
104
+ saveMaxVideos(value);
105
+ console.error(`视频采集数已更新: ${value}`);
106
+ break;
107
+
108
+ case 'maxComments':
109
+ if (!value) {
110
+ console.error('请提供 maxComments 的值');
111
+ return;
112
+ }
113
+ saveMaxComments(value);
114
+ console.error(`评论采集数已更新: ${value}`);
115
+ break;
116
+
117
+ default:
118
+ console.error(`未知配置项: ${key}`);
119
+ console.error(' 可用 key: proxy, server, browser, userId, maxFollowing, maxFollowers, maxVideos, maxComments');
120
+ }
121
+ break;
122
+ }
123
+
124
+ case 'reset': {
125
+ if (existsSync(configPath)) {
126
+ writeFileSync(configPath, '{}', 'utf-8');
127
+ console.error('配置已重置为默认');
128
+ } else {
129
+ console.error('配置文件不存在或已是默认状态');
130
+ }
131
+ break;
132
+ }
133
+
134
+ default:
135
+ console.error(`未知配置命令: ${action}`);
136
+ console.error('用法: tt-help config [show|set|reset]');
137
+ }
138
+ }
139
+
140
+ function saveProxy(newProxy) {
141
+ const cfg = existsSync(configPath) ? JSON.parse(readFileSync(configPath, 'utf-8')) : {};
142
+ cfg.proxy = newProxy;
143
+ writeFileSync(configPath, JSON.stringify(cfg, null, 2), 'utf-8');
144
+ }
145
+
146
+ function saveServer(newServer) {
147
+ const cfg = existsSync(configPath) ? JSON.parse(readFileSync(configPath, 'utf-8')) : {};
148
+ cfg.server = newServer;
149
+ writeFileSync(configPath, JSON.stringify(cfg, null, 2), 'utf-8');
150
+ }
151
+
152
+ export { handleConfig, showConfig, showUsage, version };