tt-help-cli-ycl 1.3.50 → 1.3.52
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/package.json +1 -1
- package/src/lib/tiktok-scraper.mjs +18 -10
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import os from "os";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import fs from "fs";
|
|
3
4
|
import { chromium } from "playwright";
|
|
4
5
|
import { detectBrowser } from "./browser/launch.js";
|
|
5
6
|
import { parseUserInfo, parseVideoInfo } from "./parse-ssr.mjs";
|
|
@@ -144,15 +145,22 @@ export class TikTokScraper {
|
|
|
144
145
|
this.slots = slots;
|
|
145
146
|
|
|
146
147
|
// 启动登录态 pool(1 个 slot)
|
|
148
|
+
// profile 不存在则跳过,不影响主流程
|
|
147
149
|
const fallbackDir = getFallbackProfileDir();
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
if (fs.existsSync(fallbackDir)) {
|
|
151
|
+
const {
|
|
152
|
+
browser: authBrowser,
|
|
153
|
+
context: authContext,
|
|
154
|
+
slots: authSlots,
|
|
155
|
+
} = await initContext(executablePath, 1, fallbackDir);
|
|
156
|
+
this.authBrowser = authBrowser;
|
|
157
|
+
this.authContext = authContext;
|
|
158
|
+
this.authSlots = authSlots;
|
|
159
|
+
} else {
|
|
160
|
+
console.error(
|
|
161
|
+
`[TikTokScraper] 登录态 profile 不存在 (${fallbackDir}),跳过登录态 pool。请先运行 tt-help open 9999 登录 TikTok`,
|
|
162
|
+
);
|
|
163
|
+
}
|
|
156
164
|
|
|
157
165
|
await this.warmWaf();
|
|
158
166
|
}
|
|
@@ -320,7 +328,7 @@ export class TikTokScraper {
|
|
|
320
328
|
}
|
|
321
329
|
|
|
322
330
|
// 仍然失败:使用登录态 pool
|
|
323
|
-
if (!result) {
|
|
331
|
+
if (!result && this.authContext) {
|
|
324
332
|
rawHtml = await this._fetchViewSource(url, this.authContext);
|
|
325
333
|
result = rawHtml ? parseUserInfo(rawHtml) : null;
|
|
326
334
|
}
|
|
@@ -343,7 +351,7 @@ export class TikTokScraper {
|
|
|
343
351
|
}
|
|
344
352
|
|
|
345
353
|
// 仍然失败:使用登录态 pool
|
|
346
|
-
if (!result) {
|
|
354
|
+
if (!result && this.authContext) {
|
|
347
355
|
rawHtml = await this._fetchViewSource(videoUrl, this.authContext);
|
|
348
356
|
result = rawHtml ? parseVideoInfo(rawHtml) : null;
|
|
349
357
|
}
|