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/retry.js CHANGED
@@ -1,45 +1,45 @@
1
- import { delay } from './delay.js';
2
-
3
- const RETRYABLE_PATTERNS = [
4
- 'interrupted',
5
- 'Navigation.*interrupted',
6
- 'net::',
7
- 'ECONN',
8
- 'ETIMEDOUT',
9
- 'ENOTFOUND',
10
- 'EAI_AGAIN',
11
- 'ESOCKETRESET',
12
- 'connection.*refused',
13
- 'connection.*reset',
14
- 'failed.*navigate',
15
- 'target.*closed',
16
- 'crash',
17
- '代理错误',
18
- ];
19
-
20
- export function isRetryableError(error) {
21
- if (!error) return false;
22
- const msg = error.message || error.toString() || '';
23
- return RETRYABLE_PATTERNS.some(p => new RegExp(p, 'i').test(msg));
24
- }
25
-
26
- export async function retryWithBackoff(fn, { maxRetries = 3, baseDelay = 3000, log } = {}) {
27
- let lastError;
28
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
29
- try {
30
- return await fn();
31
- } catch (error) {
32
- lastError = error;
33
- if (attempt >= maxRetries || !isRetryableError(error)) {
34
- throw error;
35
- }
36
- const jitter = Math.random() * 2000;
37
- const waitTime = baseDelay * Math.pow(2, attempt) + jitter;
38
- if (log) {
39
- log(` [重试] ${attempt + 1}/${maxRetries},${Math.round(waitTime / 1000)}s 后重试...`);
40
- }
41
- await delay(Math.round(waitTime), Math.round(waitTime));
42
- }
43
- }
44
- throw lastError;
45
- }
1
+ import { delay } from './delay.js';
2
+
3
+ const RETRYABLE_PATTERNS = [
4
+ 'interrupted',
5
+ 'Navigation.*interrupted',
6
+ 'net::',
7
+ 'ECONN',
8
+ 'ETIMEDOUT',
9
+ 'ENOTFOUND',
10
+ 'EAI_AGAIN',
11
+ 'ESOCKETRESET',
12
+ 'connection.*refused',
13
+ 'connection.*reset',
14
+ 'failed.*navigate',
15
+ 'target.*closed',
16
+ 'crash',
17
+ '代理错误',
18
+ ];
19
+
20
+ export function isRetryableError(error) {
21
+ if (!error) return false;
22
+ const msg = error.message || error.toString() || '';
23
+ return RETRYABLE_PATTERNS.some(p => new RegExp(p, 'i').test(msg));
24
+ }
25
+
26
+ export async function retryWithBackoff(fn, { maxRetries = 3, baseDelay = 3000, log } = {}) {
27
+ let lastError;
28
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
29
+ try {
30
+ return await fn();
31
+ } catch (error) {
32
+ lastError = error;
33
+ if (attempt >= maxRetries || !isRetryableError(error)) {
34
+ throw error;
35
+ }
36
+ const jitter = Math.random() * 2000;
37
+ const waitTime = baseDelay * Math.pow(2, attempt) + jitter;
38
+ if (log) {
39
+ log(` [重试] ${attempt + 1}/${maxRetries},${Math.round(waitTime / 1000)}s 后重试...`);
40
+ }
41
+ await delay(Math.round(waitTime), Math.round(waitTime));
42
+ }
43
+ }
44
+ throw lastError;
45
+ }
package/src/lib/scrape.js CHANGED
@@ -1,89 +1,89 @@
1
- import { TikTokScraper } from './tiktok-scraper.mjs';
2
- import { isProfileUrl, isVideoUrl, extractUniqueId, normalizeUsername } from './url.js';
3
-
4
- // Lazy singleton for TikTokScraper
5
- let scraperInstance = null;
6
- let scraperInitPromise = null;
7
-
8
- async function getScraper() {
9
- if (scraperInstance) return scraperInstance;
10
- if (scraperInitPromise) return scraperInitPromise;
11
- scraperInitPromise = (async () => {
12
- const scraper = new TikTokScraper();
13
- await scraper.init();
14
- scraperInstance = scraper;
15
- scraperInitPromise = null;
16
- return scraper;
17
- })();
18
- return scraperInitPromise;
19
- }
20
-
21
- export async function closeScraper() {
22
- if (scraperInstance) {
23
- await scraperInstance.close();
24
- scraperInstance = null;
25
- }
26
- }
27
-
28
- // Map parseUserInfo output to legacy parser.js format
29
- function mapUserInfo(user) {
30
- if (!user) return null;
31
- return {
32
- uniqueId: user.uniqueId,
33
- uid: user.id,
34
- secUid: user.secUid,
35
- nickname: user.nickname,
36
- signature: user.bio,
37
- ttSeller: user.ttSeller,
38
- verified: user.verified,
39
- followerCount: user.followerCount,
40
- followingCount: user.followingCount,
41
- heartCount: user.heartCount,
42
- videoCount: user.videoCount,
43
- diggCount: user.diggCount,
44
- avatarLarger: user.avatar,
45
- locationCreated: user.locationCreated,
46
- };
47
- }
48
-
49
- // Map parseVideoInfo output to legacy format
50
- function mapVideoLocation(video) {
51
- if (!video) return null;
52
- return video.locationCreated;
53
- }
54
-
55
- export async function extractUserData(url) {
56
- const scraper = await getScraper();
57
- const uniqueId = extractUniqueId(url);
58
- if (!uniqueId) throw new Error(`无法从URL提取用户名: ${url}`);
59
- const user = await scraper.getUserInfo(normalizeUsername(uniqueId));
60
- if (!user) throw new Error('无法解析用户信息');
61
- return mapUserInfo(user);
62
- }
63
-
64
- export async function extractVideoLocation(videoUrl) {
65
- const scraper = await getScraper();
66
- const video = await scraper.getVideoInfo(videoUrl);
67
- return mapVideoLocation(video);
68
- }
69
-
70
- export async function processUrl(url) {
71
- if (isProfileUrl(url)) {
72
- const profileData = await extractUserData(url);
73
- return [profileData];
74
- }
75
-
76
- if (isVideoUrl(url)) {
77
- const profileHandle = extractUniqueId(url);
78
- if (!profileHandle) throw new Error(`无法从视频URL提取用户主页: ${url}`);
79
-
80
- const [profileData, locationCreated] = await Promise.all([
81
- extractUserData(url),
82
- extractVideoLocation(url),
83
- ]);
84
-
85
- return [{ ...profileData, locationCreated }];
86
- }
87
-
88
- return [];
89
- }
1
+ import { TikTokScraper } from './tiktok-scraper.mjs';
2
+ import { isProfileUrl, isVideoUrl, extractUniqueId, normalizeUsername } from './url.js';
3
+
4
+ // Lazy singleton for TikTokScraper
5
+ let scraperInstance = null;
6
+ let scraperInitPromise = null;
7
+
8
+ async function getScraper() {
9
+ if (scraperInstance) return scraperInstance;
10
+ if (scraperInitPromise) return scraperInitPromise;
11
+ scraperInitPromise = (async () => {
12
+ const scraper = new TikTokScraper();
13
+ await scraper.init();
14
+ scraperInstance = scraper;
15
+ scraperInitPromise = null;
16
+ return scraper;
17
+ })();
18
+ return scraperInitPromise;
19
+ }
20
+
21
+ export async function closeScraper() {
22
+ if (scraperInstance) {
23
+ await scraperInstance.close();
24
+ scraperInstance = null;
25
+ }
26
+ }
27
+
28
+ // Map parseUserInfo output to legacy parser.js format
29
+ function mapUserInfo(user) {
30
+ if (!user) return null;
31
+ return {
32
+ uniqueId: user.uniqueId,
33
+ uid: user.id,
34
+ secUid: user.secUid,
35
+ nickname: user.nickname,
36
+ signature: user.bio,
37
+ ttSeller: user.ttSeller,
38
+ verified: user.verified,
39
+ followerCount: user.followerCount,
40
+ followingCount: user.followingCount,
41
+ heartCount: user.heartCount,
42
+ videoCount: user.videoCount,
43
+ diggCount: user.diggCount,
44
+ avatarLarger: user.avatar,
45
+ locationCreated: user.locationCreated,
46
+ };
47
+ }
48
+
49
+ // Map parseVideoInfo output to legacy format
50
+ function mapVideoLocation(video) {
51
+ if (!video) return null;
52
+ return video.locationCreated;
53
+ }
54
+
55
+ export async function extractUserData(url) {
56
+ const scraper = await getScraper();
57
+ const uniqueId = extractUniqueId(url);
58
+ if (!uniqueId) throw new Error(`无法从URL提取用户名: ${url}`);
59
+ const user = await scraper.getUserInfo(normalizeUsername(uniqueId));
60
+ if (!user) throw new Error('无法解析用户信息');
61
+ return mapUserInfo(user);
62
+ }
63
+
64
+ export async function extractVideoLocation(videoUrl) {
65
+ const scraper = await getScraper();
66
+ const video = await scraper.getVideoInfo(videoUrl);
67
+ return mapVideoLocation(video);
68
+ }
69
+
70
+ export async function processUrl(url) {
71
+ if (isProfileUrl(url)) {
72
+ const profileData = await extractUserData(url);
73
+ return [profileData];
74
+ }
75
+
76
+ if (isVideoUrl(url)) {
77
+ const profileHandle = extractUniqueId(url);
78
+ if (!profileHandle) throw new Error(`无法从视频URL提取用户主页: ${url}`);
79
+
80
+ const [profileData, locationCreated] = await Promise.all([
81
+ extractUserData(url),
82
+ extractVideoLocation(url),
83
+ ]);
84
+
85
+ return [{ ...profileData, locationCreated }];
86
+ }
87
+
88
+ return [];
89
+ }
@@ -1,194 +1,194 @@
1
- import { chromium } from 'playwright';
2
- import { detectBrowser } from './browser/launch.js';
3
- import { parseUserInfo, parseVideoInfo } from './parse-ssr.mjs';
4
-
5
- const DEFAULT_POOL_SIZE = 3;
6
- const DEFAULT_WAF_TTL = 120000;
7
- const DEFAULT_WARM_URL = 'https://www.tiktok.com/@nike';
8
-
9
- function delay(ms) {
10
- return new Promise(r => setTimeout(r, ms));
11
- }
12
-
13
- class PageSlot {
14
- constructor(page) {
15
- this.page = page;
16
- this.lock = new PromiseQueue();
17
- }
18
- }
19
-
20
- class PromiseQueue {
21
- constructor() {
22
- this._queue = [];
23
- this._processing = false;
24
- }
25
- async run(task) {
26
- return new Promise((resolve, reject) => {
27
- this._queue.push({ task, resolve, reject });
28
- this._process();
29
- });
30
- }
31
- async _process() {
32
- if (this._processing) return;
33
- this._processing = true;
34
- while (this._queue.length > 0) {
35
- const { task, resolve, reject } = this._queue.shift();
36
- try {
37
- const result = await task();
38
- resolve(result);
39
- } catch (e) {
40
- reject(e);
41
- }
42
- }
43
- this._processing = false;
44
- }
45
- }
46
-
47
- export class TikTokScraper {
48
- constructor({ poolSize = DEFAULT_POOL_SIZE, wafTtl = DEFAULT_WAF_TTL, warmUrl = DEFAULT_WARM_URL } = {}) {
49
- this.poolSize = poolSize;
50
- this.wafTtl = wafTtl;
51
- this.warmUrl = warmUrl;
52
- this.browser = null;
53
- this.context = null;
54
- this.slots = [];
55
- this.slotIdx = 0;
56
- this.lastWarmTime = 0;
57
- this.warmPromise = null;
58
- }
59
-
60
- async init() {
61
- const executablePath = detectBrowser();
62
- if (!executablePath) {
63
- throw new Error('未找到本地浏览器(Chrome/Edge),请先安装浏览器或执行 npx playwright install');
64
- }
65
- this.browser = await chromium.launch({
66
- headless: true,
67
- executablePath,
68
- args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage'],
69
- });
70
- this.context = await this.browser.newContext();
71
- for (let i = 0; i < this.poolSize; i++) {
72
- this.slots.push(new PageSlot(await this.context.newPage()));
73
- }
74
- await this.warmWaf();
75
- }
76
-
77
- async close() {
78
- if (this.browser) {
79
- await this.browser.close();
80
- this.browser = null;
81
- this.context = null;
82
- this.slots = [];
83
- }
84
- }
85
-
86
- async restart() {
87
- await this.close();
88
- await this.init();
89
- }
90
-
91
- isAlive() {
92
- try {
93
- return !!(this.browser && this.browser.isConnected());
94
- } catch {
95
- return false;
96
- }
97
- }
98
-
99
- async warmWaf() {
100
- if (this.warmPromise) return this.warmPromise;
101
- this.warmPromise = (async () => {
102
- const page = await this.context.newPage();
103
- try {
104
- await page.goto(this.warmUrl, { waitUntil: 'domcontentloaded', timeout: 15000 });
105
- await delay(1500);
106
- this.lastWarmTime = Date.now();
107
- } catch (e) {
108
- console.error(`[warmWaf] failed: ${e.message}`);
109
- } finally {
110
- await page.close();
111
- this.warmPromise = null;
112
- }
113
- })();
114
- return this.warmPromise;
115
- }
116
-
117
- _needWarm() {
118
- return Date.now() - this.lastWarmTime > this.wafTtl;
119
- }
120
-
121
- _pickSlot() {
122
- const slot = this.slots[this.slotIdx % this.poolSize];
123
- this.slotIdx++;
124
- return slot;
125
- }
126
-
127
- async _ensurePage(slot) {
128
- try {
129
- if (!slot.page.isClosed()) return slot.page;
130
- } catch {}
131
- slot.page = await this.context.newPage();
132
- return slot.page;
133
- }
134
-
135
- async _fetchViewSource(url, slot) {
136
- const page = await this._ensurePage(slot);
137
-
138
- await page.goto('view-source:' + url, {
139
- waitUntil: 'domcontentloaded',
140
- timeout: 15000,
141
- });
142
-
143
- return await page.evaluate(() => {
144
- const rows = document.querySelectorAll('tr');
145
- let content = '';
146
- rows.forEach(r => {
147
- const lc = r.querySelector('.line-content');
148
- if (lc) content += lc.textContent + '\n';
149
- });
150
- return content;
151
- });
152
- }
153
-
154
- async getUserInfo(uniqueId) {
155
- const slot = this._pickSlot();
156
- return slot.lock.run(async () => {
157
- let rawHtml = await this._fetchViewSource(
158
- `https://www.tiktok.com/@${uniqueId}`,
159
- slot
160
- );
161
- let result = parseUserInfo(rawHtml);
162
- if (!result) {
163
- try { await this.warmWaf(); } catch {}
164
- rawHtml = await this._fetchViewSource(
165
- `https://www.tiktok.com/@${uniqueId}`,
166
- slot
167
- );
168
- result = parseUserInfo(rawHtml);
169
- }
170
- return result || null;
171
- });
172
- }
173
-
174
- async getVideoInfo(videoUrl) {
175
- const slot = this._pickSlot();
176
- return slot.lock.run(async () => {
177
- let rawHtml = await this._fetchViewSource(videoUrl, slot);
178
- let result = parseVideoInfo(rawHtml);
179
- if (!result) {
180
- try { await this.warmWaf(); } catch {}
181
- rawHtml = await this._fetchViewSource(videoUrl, slot);
182
- result = parseVideoInfo(rawHtml);
183
- }
184
- return result || null;
185
- });
186
- }
187
-
188
- async getUserAndVideo(videoUrl) {
189
- const video = await this.getVideoInfo(videoUrl);
190
- if (!video) return null;
191
- const user = await this.getUserInfo(video.author.uniqueId);
192
- return { user, video };
193
- }
194
- }
1
+ import { chromium } from 'playwright';
2
+ import { detectBrowser } from './browser/launch.js';
3
+ import { parseUserInfo, parseVideoInfo } from './parse-ssr.mjs';
4
+
5
+ const DEFAULT_POOL_SIZE = 3;
6
+ const DEFAULT_WAF_TTL = 120000;
7
+ const DEFAULT_WARM_URL = 'https://www.tiktok.com/@nike';
8
+
9
+ function delay(ms) {
10
+ return new Promise(r => setTimeout(r, ms));
11
+ }
12
+
13
+ class PageSlot {
14
+ constructor(page) {
15
+ this.page = page;
16
+ this.lock = new PromiseQueue();
17
+ }
18
+ }
19
+
20
+ class PromiseQueue {
21
+ constructor() {
22
+ this._queue = [];
23
+ this._processing = false;
24
+ }
25
+ async run(task) {
26
+ return new Promise((resolve, reject) => {
27
+ this._queue.push({ task, resolve, reject });
28
+ this._process();
29
+ });
30
+ }
31
+ async _process() {
32
+ if (this._processing) return;
33
+ this._processing = true;
34
+ while (this._queue.length > 0) {
35
+ const { task, resolve, reject } = this._queue.shift();
36
+ try {
37
+ const result = await task();
38
+ resolve(result);
39
+ } catch (e) {
40
+ reject(e);
41
+ }
42
+ }
43
+ this._processing = false;
44
+ }
45
+ }
46
+
47
+ export class TikTokScraper {
48
+ constructor({ poolSize = DEFAULT_POOL_SIZE, wafTtl = DEFAULT_WAF_TTL, warmUrl = DEFAULT_WARM_URL } = {}) {
49
+ this.poolSize = poolSize;
50
+ this.wafTtl = wafTtl;
51
+ this.warmUrl = warmUrl;
52
+ this.browser = null;
53
+ this.context = null;
54
+ this.slots = [];
55
+ this.slotIdx = 0;
56
+ this.lastWarmTime = 0;
57
+ this.warmPromise = null;
58
+ }
59
+
60
+ async init() {
61
+ const executablePath = detectBrowser();
62
+ if (!executablePath) {
63
+ throw new Error('未找到本地浏览器(Chrome/Edge),请先安装浏览器或执行 npx playwright install');
64
+ }
65
+ this.browser = await chromium.launch({
66
+ headless: true,
67
+ executablePath,
68
+ args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage'],
69
+ });
70
+ this.context = await this.browser.newContext();
71
+ for (let i = 0; i < this.poolSize; i++) {
72
+ this.slots.push(new PageSlot(await this.context.newPage()));
73
+ }
74
+ await this.warmWaf();
75
+ }
76
+
77
+ async close() {
78
+ if (this.browser) {
79
+ await this.browser.close();
80
+ this.browser = null;
81
+ this.context = null;
82
+ this.slots = [];
83
+ }
84
+ }
85
+
86
+ async restart() {
87
+ await this.close();
88
+ await this.init();
89
+ }
90
+
91
+ isAlive() {
92
+ try {
93
+ return !!(this.browser && this.browser.isConnected());
94
+ } catch {
95
+ return false;
96
+ }
97
+ }
98
+
99
+ async warmWaf() {
100
+ if (this.warmPromise) return this.warmPromise;
101
+ this.warmPromise = (async () => {
102
+ const page = await this.context.newPage();
103
+ try {
104
+ await page.goto(this.warmUrl, { waitUntil: 'domcontentloaded', timeout: 15000 });
105
+ await delay(1500);
106
+ this.lastWarmTime = Date.now();
107
+ } catch (e) {
108
+ console.error(`[warmWaf] failed: ${e.message}`);
109
+ } finally {
110
+ await page.close();
111
+ this.warmPromise = null;
112
+ }
113
+ })();
114
+ return this.warmPromise;
115
+ }
116
+
117
+ _needWarm() {
118
+ return Date.now() - this.lastWarmTime > this.wafTtl;
119
+ }
120
+
121
+ _pickSlot() {
122
+ const slot = this.slots[this.slotIdx % this.poolSize];
123
+ this.slotIdx++;
124
+ return slot;
125
+ }
126
+
127
+ async _ensurePage(slot) {
128
+ try {
129
+ if (!slot.page.isClosed()) return slot.page;
130
+ } catch {}
131
+ slot.page = await this.context.newPage();
132
+ return slot.page;
133
+ }
134
+
135
+ async _fetchViewSource(url, slot) {
136
+ const page = await this._ensurePage(slot);
137
+
138
+ await page.goto('view-source:' + url, {
139
+ waitUntil: 'domcontentloaded',
140
+ timeout: 15000,
141
+ });
142
+
143
+ return await page.evaluate(() => {
144
+ const rows = document.querySelectorAll('tr');
145
+ let content = '';
146
+ rows.forEach(r => {
147
+ const lc = r.querySelector('.line-content');
148
+ if (lc) content += lc.textContent + '\n';
149
+ });
150
+ return content;
151
+ });
152
+ }
153
+
154
+ async getUserInfo(uniqueId) {
155
+ const slot = this._pickSlot();
156
+ return slot.lock.run(async () => {
157
+ let rawHtml = await this._fetchViewSource(
158
+ `https://www.tiktok.com/@${uniqueId}`,
159
+ slot
160
+ );
161
+ let result = parseUserInfo(rawHtml);
162
+ if (!result) {
163
+ try { await this.warmWaf(); } catch {}
164
+ rawHtml = await this._fetchViewSource(
165
+ `https://www.tiktok.com/@${uniqueId}`,
166
+ slot
167
+ );
168
+ result = parseUserInfo(rawHtml);
169
+ }
170
+ return result || null;
171
+ });
172
+ }
173
+
174
+ async getVideoInfo(videoUrl) {
175
+ const slot = this._pickSlot();
176
+ return slot.lock.run(async () => {
177
+ let rawHtml = await this._fetchViewSource(videoUrl, slot);
178
+ let result = parseVideoInfo(rawHtml);
179
+ if (!result) {
180
+ try { await this.warmWaf(); } catch {}
181
+ rawHtml = await this._fetchViewSource(videoUrl, slot);
182
+ result = parseVideoInfo(rawHtml);
183
+ }
184
+ return result || null;
185
+ });
186
+ }
187
+
188
+ async getUserAndVideo(videoUrl) {
189
+ const video = await this.getVideoInfo(videoUrl);
190
+ if (!video) return null;
191
+ const user = await this.getUserInfo(video.author.uniqueId);
192
+ return { user, video };
193
+ }
194
+ }