tt-help-cli-ycl 1.3.19 → 1.3.21

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 (58) 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 +68 -68
  5. package/scripts/run-explore.bat +68 -68
  6. package/scripts/run-explore.ps1 +81 -81
  7. package/scripts/run-explore.sh +73 -73
  8. package/src/cli/attach.js +180 -180
  9. package/src/cli/auto.js +186 -186
  10. package/src/cli/config.js +152 -152
  11. package/src/cli/explore.js +249 -234
  12. package/src/cli/info.js +88 -88
  13. package/src/cli/progress.js +111 -111
  14. package/src/cli/refresh.js +216 -216
  15. package/src/cli/scrape.js +47 -47
  16. package/src/cli/utils.js +18 -18
  17. package/src/cli/videos.js +41 -41
  18. package/src/cli/watch.js +31 -31
  19. package/src/lib/api-interceptor.js +129 -124
  20. package/src/lib/args.js +517 -517
  21. package/src/lib/browser/anti-detect.js +23 -23
  22. package/src/lib/browser/cdp.js +194 -194
  23. package/src/lib/browser/launch.js +43 -43
  24. package/src/lib/browser/page.js +156 -146
  25. package/src/lib/constants.js +199 -199
  26. package/src/lib/delay.js +54 -54
  27. package/src/lib/explore-fetch.js +118 -118
  28. package/src/lib/fetcher.js +45 -45
  29. package/src/lib/filter.js +66 -66
  30. package/src/lib/io.js +54 -54
  31. package/src/lib/output.js +80 -80
  32. package/src/lib/parse-ssr.mjs +69 -69
  33. package/src/lib/parser.js +47 -47
  34. package/src/lib/retry.js +45 -45
  35. package/src/lib/scrape.js +89 -89
  36. package/src/lib/tiktok-scraper.mjs +194 -194
  37. package/src/lib/url.js +52 -52
  38. package/src/main.js +42 -42
  39. package/src/scraper/auto-core.js +203 -203
  40. package/src/scraper/core.js +211 -211
  41. package/src/scraper/explore-core.js +170 -162
  42. package/src/scraper/modules/captcha-handler.js +114 -114
  43. package/src/scraper/modules/comment-extractor.js +74 -74
  44. package/src/scraper/modules/follow-extractor.js +118 -121
  45. package/src/scraper/modules/guess-extractor.js +51 -51
  46. package/src/scraper/modules/page-helpers.js +48 -48
  47. package/src/scraper/refresh-core.js +179 -179
  48. package/src/utils/index.js +31 -0
  49. package/src/videos/core.js +97 -97
  50. package/src/watch/data-store.js +828 -705
  51. package/src/watch/public/index.html +753 -722
  52. package/src/watch/server.js +705 -562
  53. package/scripts/test-captcha-lib.mjs +0 -68
  54. package/scripts/test-captcha.mjs +0 -81
  55. package/scripts/test-incognito-lib.mjs +0 -36
  56. package/scripts/test-login-state.mjs +0 -128
  57. package/scripts/test-safe-click.mjs +0 -45
  58. 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 };