tt-help-cli-ycl 1.3.34 → 1.3.35

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 +101 -101
  5. package/scripts/run-explore.bat +132 -132
  6. package/scripts/run-explore.ps1 +157 -157
  7. package/scripts/run-explore.sh +119 -119
  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/src/cli/attach.js +180 -180
  14. package/src/cli/auto.js +240 -240
  15. package/src/cli/config.js +152 -152
  16. package/src/cli/explore.js +488 -488
  17. package/src/cli/info.js +88 -88
  18. package/src/cli/open.js +111 -111
  19. package/src/cli/progress.js +111 -111
  20. package/src/cli/refresh.js +216 -216
  21. package/src/cli/scrape.js +47 -47
  22. package/src/cli/utils.js +18 -18
  23. package/src/cli/videos.js +41 -41
  24. package/src/cli/watch.js +31 -31
  25. package/src/lib/args.js +722 -722
  26. package/src/lib/browser/anti-detect.js +23 -23
  27. package/src/lib/browser/cdp.js +261 -261
  28. package/src/lib/browser/health-checker.js +114 -114
  29. package/src/lib/browser/launch.js +43 -43
  30. package/src/lib/browser/page.js +183 -183
  31. package/src/lib/constants.js +216 -216
  32. package/src/lib/delay.js +54 -54
  33. package/src/lib/explore-fetch.js +118 -118
  34. package/src/lib/fetcher.js +45 -45
  35. package/src/lib/filter.js +66 -66
  36. package/src/lib/io.js +54 -54
  37. package/src/lib/output.js +80 -80
  38. package/src/lib/page-error-detector.js +105 -105
  39. package/src/lib/parse-ssr.mjs +69 -69
  40. package/src/lib/parser.js +47 -47
  41. package/src/lib/retry.js +45 -45
  42. package/src/lib/scrape.js +89 -89
  43. package/src/lib/tiktok-scraper.mjs +194 -194
  44. package/src/lib/url.js +52 -52
  45. package/src/main.js +48 -48
  46. package/src/results/user-videos-bar.lar.lar.moeta.json +37 -0
  47. package/src/scraper/auto-core.js +203 -203
  48. package/src/scraper/core.js +211 -211
  49. package/src/scraper/explore-core.js +177 -167
  50. package/src/scraper/modules/captcha-handler.js +114 -114
  51. package/src/scraper/modules/follow-extractor.js +194 -194
  52. package/src/scraper/modules/guess-extractor.js +51 -51
  53. package/src/scraper/modules/page-helpers.js +48 -48
  54. package/src/scraper/refresh-core.js +179 -179
  55. package/src/videos/core.js +125 -125
  56. package/src/watch/data-store.js +1040 -1030
  57. package/src/watch/public/index.html +1458 -753
  58. package/src/watch/server.js +939 -933
package/src/lib/args.js CHANGED
@@ -1,722 +1,722 @@
1
- import { readFileSync } from "fs";
2
- import { server as defaultServer } from "./constants.js";
3
-
4
- const PRESETS = ["fast", "normal", "slow", "stealth"];
5
-
6
- function parseScrapeArgs(args) {
7
- let scrapeUrl = null;
8
- let scrapePreset = null;
9
- let scrapeMaxVideos = 20;
10
- let scrapeMaxComments = 999;
11
- let scrapeMaxGuess = 10;
12
- let scrapeSwitchDelay = null;
13
- let scrapeCommentDelay = null;
14
- let outputFile = null;
15
-
16
- const positional = [];
17
-
18
- for (let i = 0; i < args.length; i++) {
19
- const arg = args[i];
20
- if (arg === "-o" || arg === "--output") {
21
- outputFile = args[++i];
22
- } else if (arg === "--switch-delay") {
23
- scrapeSwitchDelay = parseInt(args[++i]) || null;
24
- } else if (arg === "--comment-delay") {
25
- scrapeCommentDelay = parseInt(args[++i]) || null;
26
- } else {
27
- positional.push(arg);
28
- }
29
- }
30
-
31
- scrapeUrl = positional[0] || null;
32
-
33
- if (positional[1]) {
34
- if (PRESETS.includes(positional[1].toLowerCase())) {
35
- scrapePreset = positional[1].toLowerCase();
36
- scrapeMaxVideos = parseInt(positional[2]) || 20;
37
- scrapeMaxComments = parseInt(positional[3]) || 999;
38
- scrapeMaxGuess = parseInt(positional[4]) || 10;
39
- } else {
40
- scrapeMaxVideos = parseInt(positional[1]) || 20;
41
- scrapeMaxComments = parseInt(positional[2]) || 999;
42
- scrapeMaxGuess = parseInt(positional[3]) || 10;
43
- }
44
- }
45
-
46
- return {
47
- subcommand: "scrape",
48
- scrapeUrl,
49
- scrapePreset,
50
- scrapeMaxVideos,
51
- scrapeMaxComments,
52
- scrapeMaxGuess,
53
- scrapeSwitchDelay,
54
- scrapeCommentDelay,
55
- outputFile,
56
- urls: [],
57
- outputFormat: "json",
58
- exploreCount: 0,
59
- showConfig: false,
60
- showHelp: false,
61
- customProxy: null,
62
- configAction: null,
63
- configValue: null,
64
- pipeMode: false,
65
- filterStr: null,
66
- };
67
- }
68
-
69
- function parseAutoArgs(args) {
70
- let autoCollectMax = 1;
71
- let autoScrapeDepth = 50;
72
- let autoMaxComments = 200;
73
- let autoMaxGuess = 10;
74
- let autoPreset = "fast";
75
- let autoSwitchDelay = null;
76
- let autoCommentDelay = null;
77
- let serverUrl = defaultServer;
78
- let autoEnableFollow = false;
79
- let autoMaxFollowing = 200;
80
- let autoMaxFollowers = 200;
81
-
82
- const positional = [];
83
- const PRESETS = ["fast", "normal", "slow", "stealth"];
84
-
85
- for (let i = 0; i < args.length; i++) {
86
- const arg = args[i];
87
- if (arg === "--server") {
88
- serverUrl = args[++i];
89
- } else if (arg === "--switch-delay") {
90
- autoSwitchDelay = parseInt(args[++i]) || null;
91
- } else if (arg === "--comment-delay") {
92
- autoCommentDelay = parseInt(args[++i]) || null;
93
- } else if (arg === "--enable-follow") {
94
- autoEnableFollow = true;
95
- } else if (arg === "--max-following") {
96
- autoMaxFollowing = parseInt(args[++i]) || 200;
97
- } else if (arg === "--max-followers") {
98
- autoMaxFollowers = parseInt(args[++i]) || 200;
99
- } else {
100
- positional.push(arg);
101
- }
102
- }
103
-
104
- // 收集用户名(非 preset、非数字的都是用户名)
105
- const usernames = [];
106
- let j = 0;
107
- while (
108
- j < positional.length &&
109
- !PRESETS.includes(positional[j]?.toLowerCase()) &&
110
- isNaN(positional[j])
111
- ) {
112
- usernames.push(positional[j].replace("@", ""));
113
- j++;
114
- }
115
-
116
- // preset
117
- if (j < positional.length && PRESETS.includes(positional[j].toLowerCase())) {
118
- autoPreset = positional[j].toLowerCase();
119
- j++;
120
- autoCollectMax = parseInt(positional[j]) || 1;
121
- j++;
122
- autoScrapeDepth = parseInt(positional[j]) || 50;
123
- j++;
124
- autoMaxComments = parseInt(positional[j]) || 200;
125
- j++;
126
- autoMaxGuess = parseInt(positional[j]) || 10;
127
- j++;
128
- } else if (usernames.length > 0) {
129
- autoCollectMax = parseInt(positional[j]) || 1;
130
- j++;
131
- autoScrapeDepth = parseInt(positional[j]) || 50;
132
- j++;
133
- autoMaxComments = parseInt(positional[j]) || 200;
134
- j++;
135
- autoMaxGuess = parseInt(positional[j]) || 10;
136
- }
137
-
138
- return {
139
- subcommand: "auto",
140
- autoUsernames: usernames,
141
- autoCollectMax,
142
- autoScrapeDepth,
143
- autoMaxComments,
144
- autoMaxGuess,
145
- autoPreset,
146
- autoSwitchDelay,
147
- autoCommentDelay,
148
- serverUrl,
149
- autoEnableFollow,
150
- autoMaxFollowing,
151
- autoMaxFollowers,
152
- urls: [],
153
- outputFormat: "json",
154
- exploreCount: 0,
155
- showConfig: false,
156
- showHelp: false,
157
- customProxy: null,
158
- configAction: null,
159
- configValue: null,
160
- pipeMode: false,
161
- filterStr: null,
162
- };
163
- }
164
-
165
- function parseExploreArgs(args) {
166
- let serverUrl = defaultServer;
167
- let explorePreset = "normal";
168
- let exploreMaxComments = 10;
169
- let exploreMaxGuess = 0;
170
- let exploreEnableFollow = true;
171
- let exploreMaxFollowing = 50;
172
- let exploreMaxFollowers = 50;
173
- let exploreLocation = "PL,NL,BE,DE,FR,IT,ES,IE,AT";
174
- let exploreJobLocations = null;
175
- let exploreMaxUsers = 0;
176
- let explorePort = null;
177
- let exploreBasePort = null;
178
- let explorePortCount = null;
179
- let exploreUserId = null;
180
- let exploreMaxVideos = 16;
181
-
182
- const positional = [];
183
- const PRESETS = ["fast", "normal", "slow", "stealth"];
184
-
185
- for (let i = 0; i < args.length; i++) {
186
- const arg = args[i];
187
- if (arg === "--server") {
188
- serverUrl = args[++i];
189
- } else if (arg === "--max-comments") {
190
- exploreMaxComments = parseInt(args[++i]) || 0;
191
- } else if (arg === "--max-guess") {
192
- exploreMaxGuess = parseInt(args[++i]) || 0;
193
- } else if (arg === "--location") {
194
- exploreLocation = args[++i];
195
- } else if (arg === "--job-locations") {
196
- exploreJobLocations = args[++i];
197
- } else if (arg === "--enable-follow") {
198
- exploreEnableFollow = true;
199
- } else if (arg === "--disable-follow") {
200
- exploreEnableFollow = false;
201
- } else if (arg === "--max-following") {
202
- exploreMaxFollowing = parseInt(args[++i]) || 50;
203
-
204
- exploreMaxFollowers = parseInt(args[++i]) || 50;
205
- } else if (arg === "--max-users") {
206
- exploreMaxUsers = parseInt(args[++i]) || 0;
207
- } else if (arg === "--port") {
208
- explorePort = parseInt(args[++i]) || 9222;
209
- } else if (arg === "--base-port") {
210
- exploreBasePort = parseInt(args[++i]) || 9222;
211
- } else if (arg === "--port-count") {
212
- explorePortCount = parseInt(args[++i]) || 10;
213
- } else if (arg === "--user-id") {
214
- exploreUserId = args[++i];
215
- } else if (arg === "--max-videos") {
216
- exploreMaxVideos = parseInt(args[++i]) || 16;
217
- } else {
218
- positional.push(arg);
219
- }
220
- }
221
-
222
- const usernames = [];
223
- let j = 0;
224
- while (
225
- j < positional.length &&
226
- !PRESETS.includes(positional[j]?.toLowerCase()) &&
227
- isNaN(positional[j])
228
- ) {
229
- usernames.push(positional[j].replace("@", ""));
230
- j++;
231
- }
232
-
233
- if (j < positional.length && PRESETS.includes(positional[j].toLowerCase())) {
234
- explorePreset = positional[j].toLowerCase();
235
- j++;
236
- }
237
-
238
- return {
239
- subcommand: "explore",
240
- exploreUsernames: usernames,
241
- explorePreset,
242
- exploreMaxComments,
243
- exploreMaxGuess,
244
- exploreEnableFollow,
245
- exploreMaxFollowing,
246
- exploreMaxFollowers,
247
- exploreLocation,
248
- exploreJobLocations,
249
- serverUrl,
250
- exploreMaxUsers,
251
- explorePort,
252
- exploreBasePort,
253
- explorePortCount,
254
- exploreUserId,
255
- exploreMaxVideos,
256
- urls: [],
257
- outputFormat: "json",
258
- exploreCount: 0,
259
- showConfig: false,
260
- showHelp: false,
261
- customProxy: null,
262
- configAction: null,
263
- configValue: null,
264
- pipeMode: false,
265
- filterStr: null,
266
- };
267
- }
268
-
269
- function parseVideosArgs(args) {
270
- let videosUsername = null;
271
- let videosMax = 5;
272
- let outputFile = null;
273
-
274
- const positional = [];
275
-
276
- for (let i = 0; i < args.length; i++) {
277
- const arg = args[i];
278
- if (arg === "-o" || arg === "--output") {
279
- outputFile = args[++i];
280
- } else {
281
- positional.push(arg);
282
- }
283
- }
284
-
285
- videosUsername = positional[0] ? positional[0].replace("@", "") : null;
286
- videosMax = parseInt(positional[1]) || 5;
287
-
288
- return {
289
- subcommand: "videos",
290
- videosUsername,
291
- videosMax,
292
- outputFile,
293
- urls: [],
294
- outputFormat: "json",
295
- exploreCount: 0,
296
- showConfig: false,
297
- showHelp: false,
298
- customProxy: null,
299
- configAction: null,
300
- configValue: null,
301
- pipeMode: false,
302
- filterStr: null,
303
- };
304
- }
305
-
306
- function parseInfoArgs(args) {
307
- let onlyVideo = false;
308
- const urls = [];
309
-
310
- for (let i = 0; i < args.length; i++) {
311
- const arg = args[i];
312
- if (arg === "--onlyvideo") {
313
- onlyVideo = true;
314
- } else if (!arg.startsWith("--")) {
315
- urls.push(arg);
316
- }
317
- }
318
-
319
- return {
320
- subcommand: "info",
321
- infoUrls: urls,
322
- infoOnlyVideo: onlyVideo,
323
- outputFile: null,
324
- outputFormat: "json",
325
- exploreCount: 0,
326
- showConfig: false,
327
- showHelp: false,
328
- showVersion: false,
329
- customProxy: null,
330
- configAction: null,
331
- configKey: null,
332
- configValue: null,
333
- pipeMode: false,
334
- filterStr: null,
335
- };
336
- }
337
-
338
- function parseWatchArgs(args) {
339
- let outputFile = "./result.json";
340
- let watchPort = 3001;
341
-
342
- for (let i = 0; i < args.length; i++) {
343
- const arg = args[i];
344
- if (arg === "-o" || arg === "--output") {
345
- outputFile = args[++i];
346
- } else if (arg === "-p") {
347
- watchPort = parseInt(args[++i]) || 3001;
348
- }
349
- }
350
-
351
- return {
352
- subcommand: "watch",
353
- outputFile,
354
- watchPort,
355
- urls: [],
356
- outputFormat: "json",
357
- exploreCount: 0,
358
- showConfig: false,
359
- showHelp: false,
360
- customProxy: null,
361
- configAction: null,
362
- configValue: null,
363
- pipeMode: false,
364
- filterStr: null,
365
- };
366
- }
367
-
368
- function parseRefreshArgs(args) {
369
- let serverUrl = defaultServer;
370
- let explorePreset = "normal";
371
- let exploreMaxComments = 10;
372
- let exploreMaxGuess = 0;
373
- let explorePort = null;
374
- let exploreProfile = null;
375
- let exploreUserId = null;
376
-
377
- for (let i = 0; i < args.length; i++) {
378
- const arg = args[i];
379
- if (arg === "--server") {
380
- serverUrl = args[++i];
381
- } else if (arg === "--comments") {
382
- exploreMaxComments = parseInt(args[++i]) || 10;
383
- } else if (arg === "--guess") {
384
- exploreMaxGuess = parseInt(args[++i]) || 0;
385
- } else if (arg === "--preset") {
386
- explorePreset = args[++i];
387
- } else if (arg === "--port") {
388
- explorePort = parseInt(args[++i]) || 9222;
389
- } else if (arg === "--profile") {
390
- exploreProfile = args[++i];
391
- } else if (arg === "--user-id") {
392
- exploreUserId = args[++i];
393
- }
394
- }
395
-
396
- return {
397
- subcommand: "refresh",
398
- explorePreset,
399
- exploreMaxComments,
400
- exploreMaxGuess,
401
- explorePort,
402
- exploreProfile,
403
- exploreUserId,
404
- serverUrl,
405
- urls: [],
406
- outputFormat: "json",
407
- exploreCount: 0,
408
- showConfig: false,
409
- showHelp: false,
410
- customProxy: null,
411
- configAction: null,
412
- configValue: null,
413
- pipeMode: false,
414
- filterStr: null,
415
- };
416
- }
417
-
418
- function parseAttachArgs(args) {
419
- let parallel = 1;
420
- let interval = 10;
421
- let serverUrl = defaultServer;
422
-
423
- for (let i = 0; i < args.length; i++) {
424
- const arg = args[i];
425
- if (arg === "-p" || arg === "--parallel") {
426
- parallel = parseInt(args[++i], 10) || 1;
427
- } else if (arg === "-i" || arg === "--interval") {
428
- interval = parseInt(args[++i], 10) || 10;
429
- } else if (arg === "-s" || arg === "--server") {
430
- serverUrl = args[++i];
431
- }
432
- }
433
-
434
- return {
435
- subcommand: "attach",
436
- attachParallel: parallel,
437
- attachInterval: interval,
438
- serverUrl,
439
- urls: [],
440
- outputFormat: "json",
441
- exploreCount: 0,
442
- showConfig: false,
443
- showHelp: false,
444
- customProxy: null,
445
- configAction: null,
446
- configValue: null,
447
- pipeMode: false,
448
- filterStr: null,
449
- };
450
- }
451
-
452
- function parseOpenArgs(args) {
453
- let openPort = null;
454
- let openList = false;
455
-
456
- for (let i = 0; i < args.length; i++) {
457
- const arg = args[i];
458
- if (arg === "--list") {
459
- openList = true;
460
- } else if (!arg.startsWith("-")) {
461
- openPort = arg;
462
- }
463
- }
464
-
465
- return {
466
- subcommand: "open",
467
- openPort,
468
- openList,
469
- urls: [],
470
- outputFormat: "json",
471
- exploreCount: 0,
472
- showConfig: false,
473
- showHelp: false,
474
- customProxy: null,
475
- configAction: null,
476
- configValue: null,
477
- pipeMode: false,
478
- filterStr: null,
479
- };
480
- }
481
-
482
- function parseVideoStatsArgs(args) {
483
- let statsFile = null;
484
- let statsParallel = 3;
485
-
486
- for (let i = 0; i < args.length; i++) {
487
- const arg = args[i];
488
- if (arg === "-p" || arg === "--parallel") {
489
- statsParallel = parseInt(args[++i]) || 3;
490
- } else if (!arg.startsWith("-")) {
491
- statsFile = args[i] || null;
492
- }
493
- }
494
-
495
- return {
496
- subcommand: "videostats",
497
- statsFile,
498
- statsParallel,
499
- commentsUrl: null,
500
- commentsMax: 20,
501
- commentsSave: false,
502
- commentsParallel: 1,
503
- commentsInterval: 10,
504
- commentsServer: defaultServer,
505
- urls: [],
506
- outputFormat: "json",
507
- exploreCount: 0,
508
- showConfig: false,
509
- showHelp: false,
510
- customProxy: null,
511
- configAction: null,
512
- configValue: null,
513
- pipeMode: false,
514
- filterStr: null,
515
- };
516
- }
517
-
518
- function parseCommentsArgs(args) {
519
- let commentsUrl = null;
520
- let commentsMax = 20;
521
- let commentsSave = false;
522
- let commentsParallel = 1;
523
- let commentsInterval = 10;
524
- let commentsServer = defaultServer;
525
-
526
- const positional = [];
527
-
528
- for (let i = 0; i < args.length; i++) {
529
- const arg = args[i];
530
- if (arg === "--save") {
531
- commentsSave = true;
532
- } else if (arg === "-p" || arg === "--parallel") {
533
- commentsParallel = parseInt(args[++i]) || 1;
534
- } else if (arg === "-i" || arg === "--interval") {
535
- commentsInterval = parseInt(args[++i]) || 10;
536
- } else if (arg === "-s" || arg === "--server") {
537
- commentsServer = args[++i];
538
- } else if (arg === "-m" || arg === "--max-comments") {
539
- commentsMax = parseInt(args[++i]) || 20;
540
- } else {
541
- positional.push(arg);
542
- }
543
- }
544
-
545
- commentsUrl = positional[0] || null;
546
- if (positional[1]) {
547
- commentsMax = parseInt(positional[1]) || 20;
548
- }
549
-
550
- return {
551
- subcommand: "comments",
552
- commentsUrl,
553
- commentsMax,
554
- commentsSave,
555
- commentsParallel,
556
- commentsInterval,
557
- commentsServer,
558
- urls: [],
559
- outputFormat: "json",
560
- exploreCount: 0,
561
- showConfig: false,
562
- showHelp: false,
563
- customProxy: null,
564
- configAction: null,
565
- configValue: null,
566
- pipeMode: false,
567
- filterStr: null,
568
- };
569
- }
570
-
571
- export function parseArgs() {
572
- const args = process.argv.slice(2);
573
-
574
- if (args.includes("-h") || args.includes("--help")) {
575
- return {
576
- showHelp: true,
577
- showVersion: false,
578
- subcommand: null,
579
- urls: [],
580
- outputFile: null,
581
- outputFormat: "json",
582
- exploreCount: 0,
583
- showConfig: false,
584
- customProxy: null,
585
- configAction: null,
586
- configValue: null,
587
- pipeMode: false,
588
- filterStr: null,
589
- };
590
- }
591
- if (args.includes("--version")) {
592
- return {
593
- showHelp: false,
594
- showVersion: true,
595
- subcommand: null,
596
- urls: [],
597
- outputFile: null,
598
- outputFormat: "json",
599
- exploreCount: 0,
600
- showConfig: false,
601
- customProxy: null,
602
- configAction: null,
603
- configValue: null,
604
- pipeMode: false,
605
- filterStr: null,
606
- };
607
- }
608
-
609
- if (args.length > 0 && args[0] === "explore") {
610
- return parseExploreArgs(args.slice(1));
611
- }
612
-
613
- if (args.length > 0 && args[0] === "info") {
614
- return parseInfoArgs(args.slice(1));
615
- }
616
-
617
- if (args.length > 0 && args[0] === "watch") {
618
- return parseWatchArgs(args.slice(1));
619
- }
620
-
621
- if (args.length > 0 && args[0] === "attach") {
622
- return parseAttachArgs(args.slice(1));
623
- }
624
-
625
- if (args.length > 0 && args[0] === "open") {
626
- return parseOpenArgs(args.slice(1));
627
- }
628
-
629
- if (args.length > 0 && args[0] === "comments") {
630
- return parseCommentsArgs(args.slice(1));
631
- }
632
-
633
- if (args.length > 0 && args[0] === "videostats") {
634
- return parseVideoStatsArgs(args.slice(1));
635
- }
636
-
637
- const urls = [];
638
- let inputFile = null;
639
- let outputFile = null;
640
- let outputFormat = "json";
641
- let exploreCount = 0;
642
- let showConfig = false;
643
- let showHelp = false;
644
- let showVersion = false;
645
- let customProxy = null;
646
- let configAction = null;
647
- let configKey = null;
648
- let configValue = null;
649
- let pipeMode = false;
650
- let filterStr = null;
651
-
652
- for (let i = 0; i < args.length; i++) {
653
- const arg = args[i];
654
-
655
- if (arg === "--explore") {
656
- exploreCount =
657
- args[i + 1] && !args[i + 1].startsWith("http")
658
- ? parseInt(args[++i], 10)
659
- : 100;
660
- } else if (arg === "--proxy") {
661
- customProxy = args[++i];
662
- } else if (arg === "--filter") {
663
- filterStr = args[++i];
664
- } else if (arg === "config") {
665
- configAction = args[i + 1];
666
- if (!configAction) {
667
- configAction = "show";
668
- } else if (
669
- configAction === "set" ||
670
- configAction === "set-proxy" ||
671
- configAction === "set-browser"
672
- ) {
673
- configKey = args[i + 2];
674
- configValue = args[i + 3];
675
- i += 3;
676
- } else {
677
- i++;
678
- }
679
- } else if (arg === "--pipe") {
680
- pipeMode = true;
681
- } else if (arg === "-i" || arg === "--input") {
682
- inputFile = args[++i];
683
- } else if (arg === "-o" || arg === "--output") {
684
- outputFile = args[++i];
685
- } else if (arg === "-f" || arg === "--format") {
686
- outputFormat = args[++i];
687
- } else if (arg === "-c" || arg === "--config") {
688
- showConfig = true;
689
- } else if (arg === "-h" || arg === "--help") {
690
- showHelp = true;
691
- } else if (arg === "--version") {
692
- showVersion = true;
693
- } else if (arg.startsWith("http")) {
694
- urls.push(arg);
695
- }
696
- }
697
-
698
- if (inputFile) {
699
- const content = readFileSync(inputFile, "utf-8");
700
- const lines = content
701
- .split(/\r?\n/)
702
- .map((l) => l.trim())
703
- .filter((l) => l.startsWith("http"));
704
- urls.push(...lines);
705
- }
706
-
707
- return {
708
- urls,
709
- outputFile,
710
- outputFormat,
711
- exploreCount,
712
- showConfig,
713
- showHelp,
714
- showVersion,
715
- customProxy,
716
- configAction,
717
- configKey,
718
- configValue,
719
- pipeMode,
720
- filterStr,
721
- };
722
- }
1
+ import { readFileSync } from "fs";
2
+ import { server as defaultServer } from "./constants.js";
3
+
4
+ const PRESETS = ["fast", "normal", "slow", "stealth"];
5
+
6
+ function parseScrapeArgs(args) {
7
+ let scrapeUrl = null;
8
+ let scrapePreset = null;
9
+ let scrapeMaxVideos = 20;
10
+ let scrapeMaxComments = 999;
11
+ let scrapeMaxGuess = 10;
12
+ let scrapeSwitchDelay = null;
13
+ let scrapeCommentDelay = null;
14
+ let outputFile = null;
15
+
16
+ const positional = [];
17
+
18
+ for (let i = 0; i < args.length; i++) {
19
+ const arg = args[i];
20
+ if (arg === "-o" || arg === "--output") {
21
+ outputFile = args[++i];
22
+ } else if (arg === "--switch-delay") {
23
+ scrapeSwitchDelay = parseInt(args[++i]) || null;
24
+ } else if (arg === "--comment-delay") {
25
+ scrapeCommentDelay = parseInt(args[++i]) || null;
26
+ } else {
27
+ positional.push(arg);
28
+ }
29
+ }
30
+
31
+ scrapeUrl = positional[0] || null;
32
+
33
+ if (positional[1]) {
34
+ if (PRESETS.includes(positional[1].toLowerCase())) {
35
+ scrapePreset = positional[1].toLowerCase();
36
+ scrapeMaxVideos = parseInt(positional[2]) || 20;
37
+ scrapeMaxComments = parseInt(positional[3]) || 999;
38
+ scrapeMaxGuess = parseInt(positional[4]) || 10;
39
+ } else {
40
+ scrapeMaxVideos = parseInt(positional[1]) || 20;
41
+ scrapeMaxComments = parseInt(positional[2]) || 999;
42
+ scrapeMaxGuess = parseInt(positional[3]) || 10;
43
+ }
44
+ }
45
+
46
+ return {
47
+ subcommand: "scrape",
48
+ scrapeUrl,
49
+ scrapePreset,
50
+ scrapeMaxVideos,
51
+ scrapeMaxComments,
52
+ scrapeMaxGuess,
53
+ scrapeSwitchDelay,
54
+ scrapeCommentDelay,
55
+ outputFile,
56
+ urls: [],
57
+ outputFormat: "json",
58
+ exploreCount: 0,
59
+ showConfig: false,
60
+ showHelp: false,
61
+ customProxy: null,
62
+ configAction: null,
63
+ configValue: null,
64
+ pipeMode: false,
65
+ filterStr: null,
66
+ };
67
+ }
68
+
69
+ function parseAutoArgs(args) {
70
+ let autoCollectMax = 1;
71
+ let autoScrapeDepth = 50;
72
+ let autoMaxComments = 200;
73
+ let autoMaxGuess = 10;
74
+ let autoPreset = "fast";
75
+ let autoSwitchDelay = null;
76
+ let autoCommentDelay = null;
77
+ let serverUrl = defaultServer;
78
+ let autoEnableFollow = false;
79
+ let autoMaxFollowing = 200;
80
+ let autoMaxFollowers = 200;
81
+
82
+ const positional = [];
83
+ const PRESETS = ["fast", "normal", "slow", "stealth"];
84
+
85
+ for (let i = 0; i < args.length; i++) {
86
+ const arg = args[i];
87
+ if (arg === "--server") {
88
+ serverUrl = args[++i];
89
+ } else if (arg === "--switch-delay") {
90
+ autoSwitchDelay = parseInt(args[++i]) || null;
91
+ } else if (arg === "--comment-delay") {
92
+ autoCommentDelay = parseInt(args[++i]) || null;
93
+ } else if (arg === "--enable-follow") {
94
+ autoEnableFollow = true;
95
+ } else if (arg === "--max-following") {
96
+ autoMaxFollowing = parseInt(args[++i]) || 200;
97
+ } else if (arg === "--max-followers") {
98
+ autoMaxFollowers = parseInt(args[++i]) || 200;
99
+ } else {
100
+ positional.push(arg);
101
+ }
102
+ }
103
+
104
+ // 收集用户名(非 preset、非数字的都是用户名)
105
+ const usernames = [];
106
+ let j = 0;
107
+ while (
108
+ j < positional.length &&
109
+ !PRESETS.includes(positional[j]?.toLowerCase()) &&
110
+ isNaN(positional[j])
111
+ ) {
112
+ usernames.push(positional[j].replace("@", ""));
113
+ j++;
114
+ }
115
+
116
+ // preset
117
+ if (j < positional.length && PRESETS.includes(positional[j].toLowerCase())) {
118
+ autoPreset = positional[j].toLowerCase();
119
+ j++;
120
+ autoCollectMax = parseInt(positional[j]) || 1;
121
+ j++;
122
+ autoScrapeDepth = parseInt(positional[j]) || 50;
123
+ j++;
124
+ autoMaxComments = parseInt(positional[j]) || 200;
125
+ j++;
126
+ autoMaxGuess = parseInt(positional[j]) || 10;
127
+ j++;
128
+ } else if (usernames.length > 0) {
129
+ autoCollectMax = parseInt(positional[j]) || 1;
130
+ j++;
131
+ autoScrapeDepth = parseInt(positional[j]) || 50;
132
+ j++;
133
+ autoMaxComments = parseInt(positional[j]) || 200;
134
+ j++;
135
+ autoMaxGuess = parseInt(positional[j]) || 10;
136
+ }
137
+
138
+ return {
139
+ subcommand: "auto",
140
+ autoUsernames: usernames,
141
+ autoCollectMax,
142
+ autoScrapeDepth,
143
+ autoMaxComments,
144
+ autoMaxGuess,
145
+ autoPreset,
146
+ autoSwitchDelay,
147
+ autoCommentDelay,
148
+ serverUrl,
149
+ autoEnableFollow,
150
+ autoMaxFollowing,
151
+ autoMaxFollowers,
152
+ urls: [],
153
+ outputFormat: "json",
154
+ exploreCount: 0,
155
+ showConfig: false,
156
+ showHelp: false,
157
+ customProxy: null,
158
+ configAction: null,
159
+ configValue: null,
160
+ pipeMode: false,
161
+ filterStr: null,
162
+ };
163
+ }
164
+
165
+ function parseExploreArgs(args) {
166
+ let serverUrl = defaultServer;
167
+ let explorePreset = "normal";
168
+ let exploreMaxComments = 10;
169
+ let exploreMaxGuess = 0;
170
+ let exploreEnableFollow = true;
171
+ let exploreMaxFollowing = 50;
172
+ let exploreMaxFollowers = 50;
173
+ let exploreLocation = "PL,NL,BE,DE,FR,IT,ES,IE,AT";
174
+ let exploreJobLocations = null;
175
+ let exploreMaxUsers = 0;
176
+ let explorePort = null;
177
+ let exploreBasePort = null;
178
+ let explorePortCount = null;
179
+ let exploreUserId = null;
180
+ let exploreMaxVideos = 16;
181
+
182
+ const positional = [];
183
+ const PRESETS = ["fast", "normal", "slow", "stealth"];
184
+
185
+ for (let i = 0; i < args.length; i++) {
186
+ const arg = args[i];
187
+ if (arg === "--server") {
188
+ serverUrl = args[++i];
189
+ } else if (arg === "--max-comments") {
190
+ exploreMaxComments = parseInt(args[++i]) || 0;
191
+ } else if (arg === "--max-guess") {
192
+ exploreMaxGuess = parseInt(args[++i]) || 0;
193
+ } else if (arg === "--location") {
194
+ exploreLocation = args[++i];
195
+ } else if (arg === "--job-locations") {
196
+ exploreJobLocations = args[++i];
197
+ } else if (arg === "--enable-follow") {
198
+ exploreEnableFollow = true;
199
+ } else if (arg === "--disable-follow") {
200
+ exploreEnableFollow = false;
201
+ } else if (arg === "--max-following") {
202
+ exploreMaxFollowing = parseInt(args[++i]) || 50;
203
+
204
+ exploreMaxFollowers = parseInt(args[++i]) || 50;
205
+ } else if (arg === "--max-users") {
206
+ exploreMaxUsers = parseInt(args[++i]) || 0;
207
+ } else if (arg === "--port") {
208
+ explorePort = parseInt(args[++i]) || 9222;
209
+ } else if (arg === "--base-port") {
210
+ exploreBasePort = parseInt(args[++i]) || 9222;
211
+ } else if (arg === "--port-count") {
212
+ explorePortCount = parseInt(args[++i]) || 10;
213
+ } else if (arg === "--user-id") {
214
+ exploreUserId = args[++i];
215
+ } else if (arg === "--max-videos") {
216
+ exploreMaxVideos = parseInt(args[++i]) || 16;
217
+ } else {
218
+ positional.push(arg);
219
+ }
220
+ }
221
+
222
+ const usernames = [];
223
+ let j = 0;
224
+ while (
225
+ j < positional.length &&
226
+ !PRESETS.includes(positional[j]?.toLowerCase()) &&
227
+ isNaN(positional[j])
228
+ ) {
229
+ usernames.push(positional[j].replace("@", ""));
230
+ j++;
231
+ }
232
+
233
+ if (j < positional.length && PRESETS.includes(positional[j].toLowerCase())) {
234
+ explorePreset = positional[j].toLowerCase();
235
+ j++;
236
+ }
237
+
238
+ return {
239
+ subcommand: "explore",
240
+ exploreUsernames: usernames,
241
+ explorePreset,
242
+ exploreMaxComments,
243
+ exploreMaxGuess,
244
+ exploreEnableFollow,
245
+ exploreMaxFollowing,
246
+ exploreMaxFollowers,
247
+ exploreLocation,
248
+ exploreJobLocations,
249
+ serverUrl,
250
+ exploreMaxUsers,
251
+ explorePort,
252
+ exploreBasePort,
253
+ explorePortCount,
254
+ exploreUserId,
255
+ exploreMaxVideos,
256
+ urls: [],
257
+ outputFormat: "json",
258
+ exploreCount: 0,
259
+ showConfig: false,
260
+ showHelp: false,
261
+ customProxy: null,
262
+ configAction: null,
263
+ configValue: null,
264
+ pipeMode: false,
265
+ filterStr: null,
266
+ };
267
+ }
268
+
269
+ function parseVideosArgs(args) {
270
+ let videosUsername = null;
271
+ let videosMax = 5;
272
+ let outputFile = null;
273
+
274
+ const positional = [];
275
+
276
+ for (let i = 0; i < args.length; i++) {
277
+ const arg = args[i];
278
+ if (arg === "-o" || arg === "--output") {
279
+ outputFile = args[++i];
280
+ } else {
281
+ positional.push(arg);
282
+ }
283
+ }
284
+
285
+ videosUsername = positional[0] ? positional[0].replace("@", "") : null;
286
+ videosMax = parseInt(positional[1]) || 5;
287
+
288
+ return {
289
+ subcommand: "videos",
290
+ videosUsername,
291
+ videosMax,
292
+ outputFile,
293
+ urls: [],
294
+ outputFormat: "json",
295
+ exploreCount: 0,
296
+ showConfig: false,
297
+ showHelp: false,
298
+ customProxy: null,
299
+ configAction: null,
300
+ configValue: null,
301
+ pipeMode: false,
302
+ filterStr: null,
303
+ };
304
+ }
305
+
306
+ function parseInfoArgs(args) {
307
+ let onlyVideo = false;
308
+ const urls = [];
309
+
310
+ for (let i = 0; i < args.length; i++) {
311
+ const arg = args[i];
312
+ if (arg === "--onlyvideo") {
313
+ onlyVideo = true;
314
+ } else if (!arg.startsWith("--")) {
315
+ urls.push(arg);
316
+ }
317
+ }
318
+
319
+ return {
320
+ subcommand: "info",
321
+ infoUrls: urls,
322
+ infoOnlyVideo: onlyVideo,
323
+ outputFile: null,
324
+ outputFormat: "json",
325
+ exploreCount: 0,
326
+ showConfig: false,
327
+ showHelp: false,
328
+ showVersion: false,
329
+ customProxy: null,
330
+ configAction: null,
331
+ configKey: null,
332
+ configValue: null,
333
+ pipeMode: false,
334
+ filterStr: null,
335
+ };
336
+ }
337
+
338
+ function parseWatchArgs(args) {
339
+ let outputFile = "./result.json";
340
+ let watchPort = 3001;
341
+
342
+ for (let i = 0; i < args.length; i++) {
343
+ const arg = args[i];
344
+ if (arg === "-o" || arg === "--output") {
345
+ outputFile = args[++i];
346
+ } else if (arg === "-p") {
347
+ watchPort = parseInt(args[++i]) || 3001;
348
+ }
349
+ }
350
+
351
+ return {
352
+ subcommand: "watch",
353
+ outputFile,
354
+ watchPort,
355
+ urls: [],
356
+ outputFormat: "json",
357
+ exploreCount: 0,
358
+ showConfig: false,
359
+ showHelp: false,
360
+ customProxy: null,
361
+ configAction: null,
362
+ configValue: null,
363
+ pipeMode: false,
364
+ filterStr: null,
365
+ };
366
+ }
367
+
368
+ function parseRefreshArgs(args) {
369
+ let serverUrl = defaultServer;
370
+ let explorePreset = "normal";
371
+ let exploreMaxComments = 10;
372
+ let exploreMaxGuess = 0;
373
+ let explorePort = null;
374
+ let exploreProfile = null;
375
+ let exploreUserId = null;
376
+
377
+ for (let i = 0; i < args.length; i++) {
378
+ const arg = args[i];
379
+ if (arg === "--server") {
380
+ serverUrl = args[++i];
381
+ } else if (arg === "--comments") {
382
+ exploreMaxComments = parseInt(args[++i]) || 10;
383
+ } else if (arg === "--guess") {
384
+ exploreMaxGuess = parseInt(args[++i]) || 0;
385
+ } else if (arg === "--preset") {
386
+ explorePreset = args[++i];
387
+ } else if (arg === "--port") {
388
+ explorePort = parseInt(args[++i]) || 9222;
389
+ } else if (arg === "--profile") {
390
+ exploreProfile = args[++i];
391
+ } else if (arg === "--user-id") {
392
+ exploreUserId = args[++i];
393
+ }
394
+ }
395
+
396
+ return {
397
+ subcommand: "refresh",
398
+ explorePreset,
399
+ exploreMaxComments,
400
+ exploreMaxGuess,
401
+ explorePort,
402
+ exploreProfile,
403
+ exploreUserId,
404
+ serverUrl,
405
+ urls: [],
406
+ outputFormat: "json",
407
+ exploreCount: 0,
408
+ showConfig: false,
409
+ showHelp: false,
410
+ customProxy: null,
411
+ configAction: null,
412
+ configValue: null,
413
+ pipeMode: false,
414
+ filterStr: null,
415
+ };
416
+ }
417
+
418
+ function parseAttachArgs(args) {
419
+ let parallel = 1;
420
+ let interval = 10;
421
+ let serverUrl = defaultServer;
422
+
423
+ for (let i = 0; i < args.length; i++) {
424
+ const arg = args[i];
425
+ if (arg === "-p" || arg === "--parallel") {
426
+ parallel = parseInt(args[++i], 10) || 1;
427
+ } else if (arg === "-i" || arg === "--interval") {
428
+ interval = parseInt(args[++i], 10) || 10;
429
+ } else if (arg === "-s" || arg === "--server") {
430
+ serverUrl = args[++i];
431
+ }
432
+ }
433
+
434
+ return {
435
+ subcommand: "attach",
436
+ attachParallel: parallel,
437
+ attachInterval: interval,
438
+ serverUrl,
439
+ urls: [],
440
+ outputFormat: "json",
441
+ exploreCount: 0,
442
+ showConfig: false,
443
+ showHelp: false,
444
+ customProxy: null,
445
+ configAction: null,
446
+ configValue: null,
447
+ pipeMode: false,
448
+ filterStr: null,
449
+ };
450
+ }
451
+
452
+ function parseOpenArgs(args) {
453
+ let openPort = null;
454
+ let openList = false;
455
+
456
+ for (let i = 0; i < args.length; i++) {
457
+ const arg = args[i];
458
+ if (arg === "--list") {
459
+ openList = true;
460
+ } else if (!arg.startsWith("-")) {
461
+ openPort = arg;
462
+ }
463
+ }
464
+
465
+ return {
466
+ subcommand: "open",
467
+ openPort,
468
+ openList,
469
+ urls: [],
470
+ outputFormat: "json",
471
+ exploreCount: 0,
472
+ showConfig: false,
473
+ showHelp: false,
474
+ customProxy: null,
475
+ configAction: null,
476
+ configValue: null,
477
+ pipeMode: false,
478
+ filterStr: null,
479
+ };
480
+ }
481
+
482
+ function parseVideoStatsArgs(args) {
483
+ let statsFile = null;
484
+ let statsParallel = 3;
485
+
486
+ for (let i = 0; i < args.length; i++) {
487
+ const arg = args[i];
488
+ if (arg === "-p" || arg === "--parallel") {
489
+ statsParallel = parseInt(args[++i]) || 3;
490
+ } else if (!arg.startsWith("-")) {
491
+ statsFile = args[i] || null;
492
+ }
493
+ }
494
+
495
+ return {
496
+ subcommand: "videostats",
497
+ statsFile,
498
+ statsParallel,
499
+ commentsUrl: null,
500
+ commentsMax: 20,
501
+ commentsSave: false,
502
+ commentsParallel: 1,
503
+ commentsInterval: 10,
504
+ commentsServer: defaultServer,
505
+ urls: [],
506
+ outputFormat: "json",
507
+ exploreCount: 0,
508
+ showConfig: false,
509
+ showHelp: false,
510
+ customProxy: null,
511
+ configAction: null,
512
+ configValue: null,
513
+ pipeMode: false,
514
+ filterStr: null,
515
+ };
516
+ }
517
+
518
+ function parseCommentsArgs(args) {
519
+ let commentsUrl = null;
520
+ let commentsMax = 20;
521
+ let commentsSave = false;
522
+ let commentsParallel = 1;
523
+ let commentsInterval = 10;
524
+ let commentsServer = defaultServer;
525
+
526
+ const positional = [];
527
+
528
+ for (let i = 0; i < args.length; i++) {
529
+ const arg = args[i];
530
+ if (arg === "--save") {
531
+ commentsSave = true;
532
+ } else if (arg === "-p" || arg === "--parallel") {
533
+ commentsParallel = parseInt(args[++i]) || 1;
534
+ } else if (arg === "-i" || arg === "--interval") {
535
+ commentsInterval = parseInt(args[++i]) || 10;
536
+ } else if (arg === "-s" || arg === "--server") {
537
+ commentsServer = args[++i];
538
+ } else if (arg === "-m" || arg === "--max-comments") {
539
+ commentsMax = parseInt(args[++i]) || 20;
540
+ } else {
541
+ positional.push(arg);
542
+ }
543
+ }
544
+
545
+ commentsUrl = positional[0] || null;
546
+ if (positional[1]) {
547
+ commentsMax = parseInt(positional[1]) || 20;
548
+ }
549
+
550
+ return {
551
+ subcommand: "comments",
552
+ commentsUrl,
553
+ commentsMax,
554
+ commentsSave,
555
+ commentsParallel,
556
+ commentsInterval,
557
+ commentsServer,
558
+ urls: [],
559
+ outputFormat: "json",
560
+ exploreCount: 0,
561
+ showConfig: false,
562
+ showHelp: false,
563
+ customProxy: null,
564
+ configAction: null,
565
+ configValue: null,
566
+ pipeMode: false,
567
+ filterStr: null,
568
+ };
569
+ }
570
+
571
+ export function parseArgs() {
572
+ const args = process.argv.slice(2);
573
+
574
+ if (args.includes("-h") || args.includes("--help")) {
575
+ return {
576
+ showHelp: true,
577
+ showVersion: false,
578
+ subcommand: null,
579
+ urls: [],
580
+ outputFile: null,
581
+ outputFormat: "json",
582
+ exploreCount: 0,
583
+ showConfig: false,
584
+ customProxy: null,
585
+ configAction: null,
586
+ configValue: null,
587
+ pipeMode: false,
588
+ filterStr: null,
589
+ };
590
+ }
591
+ if (args.includes("--version")) {
592
+ return {
593
+ showHelp: false,
594
+ showVersion: true,
595
+ subcommand: null,
596
+ urls: [],
597
+ outputFile: null,
598
+ outputFormat: "json",
599
+ exploreCount: 0,
600
+ showConfig: false,
601
+ customProxy: null,
602
+ configAction: null,
603
+ configValue: null,
604
+ pipeMode: false,
605
+ filterStr: null,
606
+ };
607
+ }
608
+
609
+ if (args.length > 0 && args[0] === "explore") {
610
+ return parseExploreArgs(args.slice(1));
611
+ }
612
+
613
+ if (args.length > 0 && args[0] === "info") {
614
+ return parseInfoArgs(args.slice(1));
615
+ }
616
+
617
+ if (args.length > 0 && args[0] === "watch") {
618
+ return parseWatchArgs(args.slice(1));
619
+ }
620
+
621
+ if (args.length > 0 && args[0] === "attach") {
622
+ return parseAttachArgs(args.slice(1));
623
+ }
624
+
625
+ if (args.length > 0 && args[0] === "open") {
626
+ return parseOpenArgs(args.slice(1));
627
+ }
628
+
629
+ if (args.length > 0 && args[0] === "comments") {
630
+ return parseCommentsArgs(args.slice(1));
631
+ }
632
+
633
+ if (args.length > 0 && args[0] === "videostats") {
634
+ return parseVideoStatsArgs(args.slice(1));
635
+ }
636
+
637
+ const urls = [];
638
+ let inputFile = null;
639
+ let outputFile = null;
640
+ let outputFormat = "json";
641
+ let exploreCount = 0;
642
+ let showConfig = false;
643
+ let showHelp = false;
644
+ let showVersion = false;
645
+ let customProxy = null;
646
+ let configAction = null;
647
+ let configKey = null;
648
+ let configValue = null;
649
+ let pipeMode = false;
650
+ let filterStr = null;
651
+
652
+ for (let i = 0; i < args.length; i++) {
653
+ const arg = args[i];
654
+
655
+ if (arg === "--explore") {
656
+ exploreCount =
657
+ args[i + 1] && !args[i + 1].startsWith("http")
658
+ ? parseInt(args[++i], 10)
659
+ : 100;
660
+ } else if (arg === "--proxy") {
661
+ customProxy = args[++i];
662
+ } else if (arg === "--filter") {
663
+ filterStr = args[++i];
664
+ } else if (arg === "config") {
665
+ configAction = args[i + 1];
666
+ if (!configAction) {
667
+ configAction = "show";
668
+ } else if (
669
+ configAction === "set" ||
670
+ configAction === "set-proxy" ||
671
+ configAction === "set-browser"
672
+ ) {
673
+ configKey = args[i + 2];
674
+ configValue = args[i + 3];
675
+ i += 3;
676
+ } else {
677
+ i++;
678
+ }
679
+ } else if (arg === "--pipe") {
680
+ pipeMode = true;
681
+ } else if (arg === "-i" || arg === "--input") {
682
+ inputFile = args[++i];
683
+ } else if (arg === "-o" || arg === "--output") {
684
+ outputFile = args[++i];
685
+ } else if (arg === "-f" || arg === "--format") {
686
+ outputFormat = args[++i];
687
+ } else if (arg === "-c" || arg === "--config") {
688
+ showConfig = true;
689
+ } else if (arg === "-h" || arg === "--help") {
690
+ showHelp = true;
691
+ } else if (arg === "--version") {
692
+ showVersion = true;
693
+ } else if (arg.startsWith("http")) {
694
+ urls.push(arg);
695
+ }
696
+ }
697
+
698
+ if (inputFile) {
699
+ const content = readFileSync(inputFile, "utf-8");
700
+ const lines = content
701
+ .split(/\r?\n/)
702
+ .map((l) => l.trim())
703
+ .filter((l) => l.startsWith("http"));
704
+ urls.push(...lines);
705
+ }
706
+
707
+ return {
708
+ urls,
709
+ outputFile,
710
+ outputFormat,
711
+ exploreCount,
712
+ showConfig,
713
+ showHelp,
714
+ showVersion,
715
+ customProxy,
716
+ configAction,
717
+ configKey,
718
+ configValue,
719
+ pipeMode,
720
+ filterStr,
721
+ };
722
+ }