tt-help-cli-ycl 1.3.36 → 1.3.37
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.
- package/cli.js +3 -3
- package/package.json +5 -2
- package/src/cli/config.js +2 -2
- package/src/lib/constants.js +45 -0
- package/src/npm-main.js +69 -0
package/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { fileURLToPath } from
|
|
3
|
-
import { dirname, resolve } from
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
import { dirname, resolve } from "path";
|
|
4
4
|
|
|
5
5
|
const __filename = fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = dirname(__filename);
|
|
7
7
|
|
|
8
|
-
const mainPath = resolve(__dirname,
|
|
8
|
+
const mainPath = resolve(__dirname, "src", "npm-main.js");
|
|
9
9
|
await import(`file://${mainPath}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tt-help-cli-ycl",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.37",
|
|
4
4
|
"description": "TikTok user & video data scraper - extract ttSeller, verified, locationCreated from HTML source",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -41,9 +41,12 @@
|
|
|
41
41
|
"homepage": "https://github.com/jsjhycl/tt-help-cli#readme",
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"axios": "^1.16.1",
|
|
44
|
-
"better-sqlite3": "^12.10.0",
|
|
45
44
|
"https-proxy-agent": "^9.0.0",
|
|
46
45
|
"playwright": "^1.59.1",
|
|
46
|
+
"tt-help-cli-ycl": "^1.3.36",
|
|
47
47
|
"undici": "^8.1.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"better-sqlite3": "^12.10.0"
|
|
48
51
|
}
|
|
49
52
|
}
|
package/src/cli/config.js
CHANGED
|
@@ -28,8 +28,8 @@ function showConfig(urls, outputFile) {
|
|
|
28
28
|
console.error(configLines.join("\n"));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
function showUsage() {
|
|
32
|
-
console.error(
|
|
31
|
+
function showUsage(helpText = HELP_TEXT) {
|
|
32
|
+
console.error(helpText.join("\n"));
|
|
33
33
|
process.exit(0);
|
|
34
34
|
}
|
|
35
35
|
|
package/src/lib/constants.js
CHANGED
|
@@ -190,6 +190,50 @@ const HELP_TEXT = [
|
|
|
190
190
|
" tt-help videostats data/result.db -p 3",
|
|
191
191
|
];
|
|
192
192
|
|
|
193
|
+
const PUBLIC_HELP_HIDDEN_HEADERS = new Set([
|
|
194
|
+
" tt-help watch -o <db路径> [-p 端口]",
|
|
195
|
+
" videostats <db路径> -p <并发数>",
|
|
196
|
+
" db-import --db <db路径> [--users users.json] [--done done.json] [--videos videos.json]",
|
|
197
|
+
]);
|
|
198
|
+
|
|
199
|
+
const PUBLIC_HELP_HIDDEN_LINES = new Set([
|
|
200
|
+
" tt-help watch -o data/result.db",
|
|
201
|
+
" tt-help videostats data/result.db -p 3",
|
|
202
|
+
]);
|
|
203
|
+
|
|
204
|
+
function removeHelpSections(lines, hiddenHeaders, hiddenLines = new Set()) {
|
|
205
|
+
const result = [];
|
|
206
|
+
let skipping = false;
|
|
207
|
+
|
|
208
|
+
for (const line of lines) {
|
|
209
|
+
if (hiddenHeaders.has(line)) {
|
|
210
|
+
skipping = true;
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (skipping) {
|
|
215
|
+
if (line === "") {
|
|
216
|
+
skipping = false;
|
|
217
|
+
}
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (hiddenLines.has(line)) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
result.push(line);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const PUBLIC_HELP_TEXT = removeHelpSections(
|
|
232
|
+
HELP_TEXT,
|
|
233
|
+
PUBLIC_HELP_HIDDEN_HEADERS,
|
|
234
|
+
PUBLIC_HELP_HIDDEN_LINES,
|
|
235
|
+
);
|
|
236
|
+
|
|
193
237
|
function getConfigText() {
|
|
194
238
|
let currentUserId = userId;
|
|
195
239
|
if (!currentUserId && existsSync(configPath)) {
|
|
@@ -222,6 +266,7 @@ export {
|
|
|
222
266
|
configPath,
|
|
223
267
|
DEFAULT_PROXY,
|
|
224
268
|
HELP_TEXT,
|
|
269
|
+
PUBLIC_HELP_TEXT,
|
|
225
270
|
browser,
|
|
226
271
|
userId,
|
|
227
272
|
maxFollowing,
|
package/src/npm-main.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { parseArgs } from "./lib/args.js";
|
|
2
|
+
import { PUBLIC_HELP_TEXT } from "./lib/constants.js";
|
|
3
|
+
import { handleInfo } from "./cli/info.js";
|
|
4
|
+
import { handleExplore } from "./cli/explore.js";
|
|
5
|
+
import { handleAttach } from "./cli/attach.js";
|
|
6
|
+
import { handleConfig, showConfig, showUsage, version } from "./cli/config.js";
|
|
7
|
+
import { handleOpen } from "./cli/open.js";
|
|
8
|
+
import { handleComments } from "./cli/comments.js";
|
|
9
|
+
|
|
10
|
+
function exitUnsupportedCommand(command) {
|
|
11
|
+
console.error(
|
|
12
|
+
`[${command}] 当前 npm 发布包不包含该命令;如需使用,请在仓库源码环境中运行 node src/main.js ${command} ...`,
|
|
13
|
+
);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function main() {
|
|
18
|
+
const parsed = parseArgs();
|
|
19
|
+
|
|
20
|
+
switch (parsed.subcommand) {
|
|
21
|
+
case "explore":
|
|
22
|
+
return handleExplore(parsed);
|
|
23
|
+
case "info":
|
|
24
|
+
return handleInfo(parsed);
|
|
25
|
+
case "attach":
|
|
26
|
+
return handleAttach(parsed);
|
|
27
|
+
case "watch":
|
|
28
|
+
case "videostats":
|
|
29
|
+
case "db-import":
|
|
30
|
+
return exitUnsupportedCommand(parsed.subcommand);
|
|
31
|
+
case "open":
|
|
32
|
+
return handleOpen(parsed);
|
|
33
|
+
case "comments":
|
|
34
|
+
return handleComments(parsed);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
urls,
|
|
39
|
+
outputFile,
|
|
40
|
+
exploreCount,
|
|
41
|
+
showConfig: showCfg,
|
|
42
|
+
showHelp,
|
|
43
|
+
showVersion,
|
|
44
|
+
configAction,
|
|
45
|
+
configKey,
|
|
46
|
+
configValue,
|
|
47
|
+
} = parsed;
|
|
48
|
+
|
|
49
|
+
if (showVersion) {
|
|
50
|
+
console.log(version);
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
if (showHelp) return showUsage(PUBLIC_HELP_TEXT);
|
|
54
|
+
if (configAction) return handleConfig(configAction, configKey, configValue);
|
|
55
|
+
if (showCfg) return showConfig(urls, outputFile);
|
|
56
|
+
if (urls.length === 0 && exploreCount === 0)
|
|
57
|
+
return showUsage(PUBLIC_HELP_TEXT);
|
|
58
|
+
|
|
59
|
+
if (exploreCount > 0) {
|
|
60
|
+
return handleExplore({ ...parsed, subcommand: "explore" });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return handleInfo(parsed);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
main().catch((err) => {
|
|
67
|
+
console.error(`错误: ${err.message}`);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
});
|