channel-worker 2.5.29 → 2.5.30

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.29",
3
+ "version": "2.5.30",
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": {
@@ -289,6 +289,7 @@ async function run({ page, payload, log }) {
289
289
 
290
290
  const keywordsSearched = [];
291
291
  let videosWatched = 0;
292
+ const watchedGlobal = new Set(); // dedupe reels across ALL keywords this session
292
293
 
293
294
  for (const kw of sessionKeywords) {
294
295
  // 3) Search the keyword via the top bar (from the Reels surface).
@@ -313,15 +314,25 @@ async function run({ page, payload, log }) {
313
314
  continue; // top-bar search persists; next keyword searches from here
314
315
  }
315
316
  log('info', `[warmup-fb] "${kw}" → ${urls.length} results, opening up to ${videosPerKeyword}`);
316
- const watched = new Set();
317
317
  for (let n = 0; n < videosPerKeyword; n++) {
318
318
  // Re-collect each iteration — clicking + goBack mutates the DOM.
319
319
  const current = await collectResultUrls(page);
320
- const next = current.find(u => !watched.has(u.split('?')[0]));
320
+ const next = current.find(u => !watchedGlobal.has(u.split('?')[0]));
321
321
  if (!next) break;
322
- watched.add(next.split('?')[0]);
322
+ watchedGlobal.add(next.split('?')[0]);
323
+ const urlBefore = page.url();
323
324
  const clicked = await clickResultByHref(page, next);
324
325
  if (!clicked) { log('info', `[warmup-fb] couldn't click result ${next.slice(-24)} — skipping`); continue; }
326
+ // Verify the click actually navigated into a reel/video — otherwise we'd
327
+ // re-watch whatever was already open (saw the same reel id reused across
328
+ // keywords). Wait up to 8s for the URL to change to /reel/ or /watch.
329
+ let navigated = false;
330
+ for (let w = 0; w < 8; w++) {
331
+ await page.waitForTimeout(1000);
332
+ const u = page.url();
333
+ if (u !== urlBefore && /\/(reel|watch|videos)\//.test(u)) { navigated = true; break; }
334
+ }
335
+ if (!navigated) { log('info', `[warmup-fb] click didn't navigate (still ${page.url().slice(-30)}) — skipping`); continue; }
325
336
  const ok = await watchCurrent(page, watchMin, watchMax, log);
326
337
  if (ok) videosWatched++;
327
338
  // Back to the results list for the next pick (Escape closes a reel overlay