channel-worker 2.5.109 → 2.5.111

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/lib/api-client.js CHANGED
@@ -68,7 +68,14 @@ class ApiClient {
68
68
  async getNextCommand(workerId) {
69
69
  // Daemon-handled types. `_pw` variants route to the Playwright pipeline
70
70
  // (lib/playwright-runner → scripts/<base>.js) instead of the extension.
71
- const workerTypes = 'launch_profile,close_profile,launch_veo3_profile,set_profile_proxy,save_file,set_thumbnail,set_tags,set_file_input,click_and_upload,type_text,verify_logins,update_extension,sync_youtube_stats,restart_worker,upload_youtube_pw,upload_tiktok_pw,upload_facebook_pw,upload_facebook_photo_pw,warmup_youtube_pw,warmup_facebook_pw,warmup_tiktok_pw,nurture_facebook_pw,fetch_facebook_reel_stats_pw,comment_facebook_pw,scrape_affiliate_products,ingest_shopee_product,get_affiliate_link';
71
+ //
72
+ // ⚠️ ĐÂY LÀ CỔNG THỨ HAI, DỄ QUÊN: API lọc lệnh trả về theo đúng danh sách
73
+ // này (WorkerController.getCommands → filter.type.$in). Thêm loại lệnh mới
74
+ // mà quên khai ở đây thì lệnh nằm PENDING vĩnh viễn, không một dòng lỗi
75
+ // nào — xảy ra 14/09 với verify_facebook_reels_pw (cổng thứ nhất là enum
76
+ // của app/models/WorkerCommand.js, cũng đã quên một lần cùng ngày).
77
+ // api/tests/publish-verify-wiring.test.js canh cả hai cổng.
78
+ const workerTypes = 'launch_profile,close_profile,launch_veo3_profile,set_profile_proxy,save_file,set_thumbnail,set_tags,set_file_input,click_and_upload,type_text,verify_logins,update_extension,sync_youtube_stats,restart_worker,upload_youtube_pw,upload_tiktok_pw,upload_facebook_pw,upload_facebook_photo_pw,warmup_youtube_pw,warmup_facebook_pw,warmup_tiktok_pw,nurture_facebook_pw,fetch_facebook_reel_stats_pw,verify_facebook_reels_pw,comment_facebook_pw,scrape_affiliate_products,ingest_shopee_product,get_affiliate_link';
72
79
  return this.request('GET', `/workers/commands?worker_id=${workerId}&types=${encodeURIComponent(workerTypes)}`);
73
80
  }
74
81
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "channel-worker",
3
- "version": "2.5.109",
3
+ "version": "2.5.111",
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": {
@@ -196,15 +196,39 @@ const RANGE_LABEL = {
196
196
  // qua", kiểu B là "Số liệu chia nhỏ về lượt xem" rồi "26.313 -91% Lượt xem"
197
197
  // (không có chữ "Tổng số"). Bám vào dòng đó là ~10/44 kênh kiểu B bị coi như
198
198
  // trang trống — đúng ca "Má hồng phai" 2026-09-06.
199
+ //
200
+ // CHỈ XÉT PHẦN TỬ ĐANG HIỆN (vá 14/09). Bộ chọn khoảng thời gian để sẵn trong
201
+ // DOM mọi lựa chọn của nó, trong đó có "Hôm nay", và mấy phần tử ấy đứng TRƯỚC
202
+ // chip thật. Bản cũ lấy phần tử khớp ĐẦU TIÊN nên đọc trúng lựa chọn ẩn: trang
203
+ // đã ở "7 ngày qua" mà worker vẫn kết luận chip kẹt "Hôm nay" rồi vứt cả danh
204
+ // sách bài. Dump lượt 13:47 ngày 14/09 (kênh Tóc xinh) nói thẳng:
205
+ // label[7..11] span/div y=0 w=0 "Hôm nay" ← ẩn
206
+ // label[12..18] div y=182 w=297 "7 ngày qua: 7 Tháng 9 - 13 Tháng 9"
207
+ // label[19..24] div y=256 w=366 "8.672 -92% Tổng số lượt xem…"
208
+ // Số 7 ngày đã nằm sẵn trên trang. Hôm 14/09 lỗi này ăn 9/74 kênh cả ngày, và
209
+ // thử lại KHÔNG cứu được (9/10 lượt chạy tay lặp y nguyên) vì chẳng có gì kẹt
210
+ // để mà nguôi — phần tử ẩn thì lần nào cũng ẩn.
211
+ //
212
+ // Đo hiển thị bằng getBoundingClientRect (display:none → 0×0) chứ không phải
213
+ // offsetParent: chip nằm trong khối position:fixed thì offsetParent là null
214
+ // dù đang hiện rành rành. Phần tử cuộn khỏi màn hình vẫn có kích thước thật.
215
+ function pickRangeLabelInPage() {
216
+ const clean = (v) => String(v || '').replace(/\s+/g, ' ').trim();
217
+ const RE = /^(Hôm nay$|Today$|Tùy chỉnh:|Custom:|Năm nay:|This year:|\d+ ngày qua:|Last \d+ days:)/i;
218
+ for (const e of document.querySelectorAll('div[role="button"],div,span')) {
219
+ const t = clean(e.innerText);
220
+ if (t.length >= 70 || !RE.test(t)) continue;
221
+ const r = e.getBoundingClientRect();
222
+ if (!r || r.width <= 0 || r.height <= 0) continue;
223
+ return t;
224
+ }
225
+ return '';
226
+ }
227
+
199
228
  async function currentRangeLabel(page) {
200
- return page.evaluate(() => {
201
- const clean = (v) => String(v || '').replace(/\s+/g, ' ').trim();
202
- for (const e of document.querySelectorAll('div[role="button"],div,span')) {
203
- const t = clean(e.innerText);
204
- if (t.length < 70 && /^(Hôm nay$|Today$|Tùy chỉnh:|Custom:|Năm nay:|This year:|\d+ ngày qua:|Last \d+ days:)/i.test(t)) return t;
205
- }
206
- return '';
207
- }).catch(() => '');
229
+ // Hàm phải TỰ CHỨA: Playwright serialize nó rồi chạy trong trang, closure
230
+ // của module không đi theo.
231
+ return page.evaluate(pickRangeLabelInPage).catch(() => '');
208
232
  }
209
233
 
210
234
  // Tổng lượt xem của khoảng đang hiện, đọc được CẢ HAI kiểu giao diện.
@@ -436,7 +460,10 @@ async function dumpInsightsFailure(page, tag, log) {
436
460
  if (!t || t.length >= 70) continue;
437
461
  if (!/(Hôm nay|Today|Tùy chỉnh|Custom|ngày qua|Last \d+ days|Năm nay|This year)/i.test(t)) continue;
438
462
  const r = e.getBoundingClientRect();
439
- out.push(`${e.tagName.toLowerCase()}[${e.getAttribute('role') || ''}] y=${Math.round(r.y)} w=${Math.round(r.width)} "${t}"`);
463
+ // Ghi thẳng chữ ẨN: dump 14/09 in "y=0 w=0" cho lựa chọn ẩn của bộ
464
+ // chọn, phải soi ba lượt mới nhận ra đó không phải chip thật.
465
+ const hidden = (r.width <= 0 || r.height <= 0) ? ' ẨN' : '';
466
+ out.push(`${e.tagName.toLowerCase()}[${e.getAttribute('role') || ''}] y=${Math.round(r.y)} w=${Math.round(r.width)}${hidden} "${t}"`);
440
467
  if (out.length >= 25) break;
441
468
  }
442
469
  return out;
@@ -564,4 +591,4 @@ async function run({ page, payload, log }) {
564
591
  return { ok: true, mode, tiles: tiles.length, written: d?.written || 0, matched: d?.matched || 0, rising: d?.rising || 0, alerts: d?.alerts || 0, followers };
565
592
  }
566
593
 
567
- module.exports = { run, __testables: { parseViews, scrapeFollowers, parseExact, parseVnPostTime, runInsights, dumpInsightsFailure, discoverReelsTabUrl, discoverReelsTabUrls, openReelsTabWithTiles } };
594
+ module.exports = { run, __testables: { parseViews, scrapeFollowers, parseExact, parseVnPostTime, runInsights, dumpInsightsFailure, pickRangeLabelInPage, discoverReelsTabUrl, discoverReelsTabUrls, openReelsTabWithTiles } };