tt-help-cli-ycl 1.3.6 → 1.3.8

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 (46) hide show
  1. package/README.md +17 -17
  2. package/cli.js +9 -9
  3. package/package.json +45 -45
  4. package/src/cli/auto.js +131 -121
  5. package/src/cli/explore.js +147 -138
  6. package/src/cli/progress.js +111 -111
  7. package/src/cli/scrape.js +47 -47
  8. package/src/cli/utils.js +18 -18
  9. package/src/cli/videos.js +41 -41
  10. package/src/cli/watch.js +31 -31
  11. package/src/lib/args.js +391 -391
  12. package/src/lib/browser/anti-detect.js +23 -23
  13. package/src/lib/browser/cdp.js +142 -142
  14. package/src/lib/browser/launch.js +43 -43
  15. package/src/lib/browser/page.js +87 -87
  16. package/src/lib/constants.js +109 -95
  17. package/src/lib/delay.js +54 -54
  18. package/src/lib/explore-fetch.js +118 -118
  19. package/src/lib/fetcher.js +45 -45
  20. package/src/lib/filter.js +66 -66
  21. package/src/lib/io.js +54 -54
  22. package/src/lib/mac-or-uuid.js +82 -0
  23. package/src/lib/output.js +80 -80
  24. package/src/lib/parser.js +47 -47
  25. package/src/lib/retry.js +44 -44
  26. package/src/lib/scrape.js +40 -40
  27. package/src/lib/url.js +52 -52
  28. package/src/main.mjs +221 -221
  29. package/src/scraper/auto-core.mjs +185 -185
  30. package/src/scraper/core.mjs +190 -190
  31. package/src/scraper/explore-core.mjs +162 -162
  32. package/src/scraper/modules/captcha-handler.mjs +114 -114
  33. package/src/scraper/modules/comment-extractor.mjs +69 -69
  34. package/src/scraper/modules/follow-extractor.mjs +121 -121
  35. package/src/scraper/modules/guess-extractor.mjs +51 -51
  36. package/src/scraper/modules/page-error-detector.mjs +70 -70
  37. package/src/scraper/modules/page-helpers.mjs +48 -48
  38. package/src/scraper/modules/scroll-collector.mjs +189 -189
  39. package/src/test-auto-follow.cjs +109 -0
  40. package/src/test-extractors.cjs +75 -0
  41. package/src/test-follow.cjs +41 -0
  42. package/src/videos/core.mjs +126 -126
  43. package/src/watch/data-store.mjs +258 -261
  44. package/src/watch/public/index.html +580 -464
  45. package/src/watch/server.mjs +308 -281
  46. package/src/results/user-videos-bar.lar.lar.moeta.json +0 -37
package/src/cli/videos.js CHANGED
@@ -1,41 +1,41 @@
1
- import { writeFileSync } from 'fs';
2
-
3
- export async function handleVideos(options) {
4
- const { videosUsername, videosMax, outputFile } = options;
5
-
6
- if (!videosUsername) {
7
- console.error('用法: tt-help videos <用户名> [最大视频数] [-o 输出路径]');
8
- console.error('示例: tt-help videos bar.lar.lar.moeta 1000');
9
- console.error(' tt-help videos username 50 -o videos.json');
10
- console.error('');
11
- console.error('选项: -o, --output <路径> 输出到文件(默认输出到 stdout)');
12
- process.exit(1);
13
- }
14
-
15
- const { runGetUserVideos } = await import('../videos/core.mjs');
16
-
17
- let browser;
18
- try {
19
- const { output, browser: b } = await runGetUserVideos({
20
- username: videosUsername,
21
- maxVideos: videosMax,
22
- log: console.error,
23
- });
24
- browser = b;
25
-
26
- const json = JSON.stringify(output, null, 2);
27
- if (outputFile) {
28
- writeFileSync(outputFile, json, 'utf-8');
29
- console.error(`结果已写入: ${outputFile}`);
30
- } else {
31
- process.stdout.write(json + '\n');
32
- }
33
-
34
- console.error(`\n共 ${output.videos.length} 个视频, 用户: @${videosUsername}`);
35
- } catch (err) {
36
- console.error(`获取用户视频失败: ${err.message}`);
37
- process.exit(1);
38
- } finally {
39
- if (browser) await browser.close().catch(() => {});
40
- }
41
- }
1
+ import { writeFileSync } from 'fs';
2
+
3
+ export async function handleVideos(options) {
4
+ const { videosUsername, videosMax, outputFile } = options;
5
+
6
+ if (!videosUsername) {
7
+ console.error('用法: tt-help videos <用户名> [最大视频数] [-o 输出路径]');
8
+ console.error('示例: tt-help videos bar.lar.lar.moeta 1000');
9
+ console.error(' tt-help videos username 50 -o videos.json');
10
+ console.error('');
11
+ console.error('选项: -o, --output <路径> 输出到文件(默认输出到 stdout)');
12
+ process.exit(1);
13
+ }
14
+
15
+ const { runGetUserVideos } = await import('../videos/core.mjs');
16
+
17
+ let browser;
18
+ try {
19
+ const { output, browser: b } = await runGetUserVideos({
20
+ username: videosUsername,
21
+ maxVideos: videosMax,
22
+ log: console.error,
23
+ });
24
+ browser = b;
25
+
26
+ const json = JSON.stringify(output, null, 2);
27
+ if (outputFile) {
28
+ writeFileSync(outputFile, json, 'utf-8');
29
+ console.error(`结果已写入: ${outputFile}`);
30
+ } else {
31
+ process.stdout.write(json + '\n');
32
+ }
33
+
34
+ console.error(`\n共 ${output.videos.length} 个视频, 用户: @${videosUsername}`);
35
+ } catch (err) {
36
+ console.error(`获取用户视频失败: ${err.message}`);
37
+ process.exit(1);
38
+ } finally {
39
+ if (browser) await browser.close().catch(() => {});
40
+ }
41
+ }
package/src/cli/watch.js CHANGED
@@ -1,31 +1,31 @@
1
- import { existsSync } from 'fs';
2
- import { createStore } from '../watch/data-store.mjs';
3
- import { startWatchServer, openBrowser } from '../watch/server.mjs';
4
-
5
- export async function handleWatch(options) {
6
- const { outputFile, watchPort } = options;
7
-
8
- if (!outputFile) {
9
- console.error('用法: tt-help watch -o <数据文件> [-p 端口]');
10
- console.error('示例: tt-help watch -o data.json');
11
- console.error(' tt-help watch -o data.json -p 8080');
12
- process.exit(1);
13
- }
14
-
15
- if (!existsSync(outputFile)) {
16
- console.error(`文件不存在: ${outputFile}`);
17
- process.exit(1);
18
- }
19
-
20
- const store = createStore(outputFile);
21
- const { server, port } = await startWatchServer(outputFile, watchPort, store);
22
- openBrowser(port);
23
-
24
- process.once('SIGINT', () => {
25
- store.stopBackup();
26
- server.close();
27
- process.exit(0);
28
- });
29
-
30
- console.error('按 Ctrl+C 停止监控服务');
31
- }
1
+ import { existsSync } from 'fs';
2
+ import { createStore } from '../watch/data-store.mjs';
3
+ import { startWatchServer, openBrowser } from '../watch/server.mjs';
4
+
5
+ export async function handleWatch(options) {
6
+ const { outputFile, watchPort } = options;
7
+
8
+ if (!outputFile) {
9
+ console.error('用法: tt-help watch -o <数据文件> [-p 端口]');
10
+ console.error('示例: tt-help watch -o data.json');
11
+ console.error(' tt-help watch -o data.json -p 8080');
12
+ process.exit(1);
13
+ }
14
+
15
+ if (!existsSync(outputFile)) {
16
+ console.error(`文件不存在: ${outputFile}`);
17
+ process.exit(1);
18
+ }
19
+
20
+ const store = createStore(outputFile);
21
+ const { server, port } = await startWatchServer(outputFile, watchPort, store);
22
+ openBrowser(port);
23
+
24
+ process.once('SIGINT', () => {
25
+ store.stopBackup();
26
+ server.close();
27
+ process.exit(0);
28
+ });
29
+
30
+ console.error('按 Ctrl+C 停止监控服务');
31
+ }