channel-worker 2.5.99 → 2.5.100

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "channel-worker",
3
- "version": "2.5.99",
3
+ "version": "2.5.100",
4
4
  "description": "Channel Manager worker daemon — runs on remote machines to execute video pipeline jobs",
5
5
  "main": "lib/daemon.js",
6
6
  "bin": {
@@ -28,22 +28,17 @@ function parseViews(txt) {
28
28
  return Math.round(num * mul);
29
29
  }
30
30
 
31
- async function findReelsTabHref(page) {
32
- return page.evaluate(() => {
33
- const direct = document.querySelectorAll("a[href*='sk=reels_tab']");
34
- for (const a of direct) { const h = a.getAttribute('href') || ''; if (h) return h.startsWith('http') ? h : `https://www.facebook.com${h}`; }
35
- for (const a of document.querySelectorAll("a[href*='/profile.php?id=']")) {
36
- const m = (a.getAttribute('href') || '').match(/\/profile\.php\?id=(\d+)/);
37
- if (m) return `https://www.facebook.com/profile.php?id=${m[1]}&sk=reels_tab`;
38
- }
39
- for (const a of document.querySelectorAll("a[aria-label*='Dòng thời gian'], a[aria-label*='Timeline']")) {
40
- const h = a.getAttribute('href') || '';
41
- const m = h.match(/^\/([A-Za-z0-9._-]{3,})\/?(?:\?|$)/);
42
- if (m && !['profile.php', 'reel', 'video', 'videos'].includes(m[1])) return `https://www.facebook.com/${m[1]}/?sk=reels_tab`;
43
- }
44
- return null;
45
- }).catch(() => null);
46
- }
31
+ // Tìm link tab Reels: DÙNG CHUNG với script đăng (upload_facebook), không giữ
32
+ // bản riêng nữa. Bản riêng cũ chỉ có 3 chiến lược (sk=reels_tab / profile.php
33
+ // / "Dòng thời gian") — trên TRANG CHỦ của Page hiện nay không có anchor nào
34
+ // như thế, chỉ shortcut /<id số>/ hoặc /<handle>/reels/ (chiến lược 4-5,
35
+ // thêm script đăng 09/09). Đo 30h tới 10/09 15:15: 15/21 lượt bám bài hỏng
36
+ // "không tìm được link tab Reels" — Góc Người Trồng Nấm 6 lượt, Chuyện Nhà
37
+ // Nông 3, Nông Trại Phục Linh 2… — trong khi CÙNG profile đó script đăng đêm
38
+ // 09/09 tìm được tab để so trước/sau. Bản riêng còn thiếu cả bộ lọc "anchor
39
+ // của bài trong bảng tin" (gốc 2 link page lạ sáng 10/09) nên có thể quét
40
+ // nhầm tab Reels của page KHÁC mà không hay.
41
+ const { discoverReelsTabUrl } = require('./upload_facebook').__testables;
47
42
 
48
43
  // Số người theo dõi của page, đọc ngay trên chính trang đang đứng (header hiện
49
44
  // ở mọi tab của page/profile) — không tốn thêm lượt mở profile nào. Ô
@@ -517,7 +512,7 @@ async function run({ page, payload, log }) {
517
512
  if (!tabUrl) {
518
513
  await page.goto(page_url || 'https://www.facebook.com/', { waitUntil: 'domcontentloaded', timeout: 45_000 });
519
514
  await page.waitForTimeout(4000);
520
- tabUrl = await findReelsTabHref(page);
515
+ tabUrl = await discoverReelsTabUrl(page, log); // có log → in mẫu href khi không khớp
521
516
  }
522
517
  if (!tabUrl) throw new Error('không tìm được link tab Reels của page');
523
518
  log('info', `[fb-stats] ${mode} · reels_tab: ${tabUrl.slice(0, 100)}`);
@@ -565,4 +560,4 @@ async function run({ page, payload, log }) {
565
560
  return { ok: true, mode, tiles: tiles.length, written: d?.written || 0, matched: d?.matched || 0, rising: d?.rising || 0, alerts: d?.alerts || 0, followers };
566
561
  }
567
562
 
568
- module.exports = { run, __testables: { parseViews, scrapeFollowers, parseExact, parseVnPostTime, runInsights, dumpInsightsFailure } };
563
+ module.exports = { run, __testables: { parseViews, scrapeFollowers, parseExact, parseVnPostTime, runInsights, dumpInsightsFailure, discoverReelsTabUrl } };