channel-worker 2.5.104 → 2.5.105
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/scripts/upload_facebook.js +30 -2
package/package.json
CHANGED
|
@@ -855,6 +855,18 @@ function diffNewReelIds(beforeIds, afterIds) {
|
|
|
855
855
|
return (afterIds || []).filter((id) => !before.has(id));
|
|
856
856
|
}
|
|
857
857
|
|
|
858
|
+
// URL tab Reels dùng SAU khi đăng: ưu tiên link dò được trên trang hiện tại,
|
|
859
|
+
// không có thì dùng URL đã tìm được lúc chụp ảnh nền. Sau khi bấm Đăng,
|
|
860
|
+
// Facebook hay đưa về /saved/?cref=28 (đo 04/08→13/09: 48/1829 lượt, 74 lần
|
|
861
|
+
// "no reels_tab link found") — trang đó không có link tab Reels, dò lại là
|
|
862
|
+
// trượt và cả so trước/sau lẫn lượt chờ 75s đều bị bỏ → bài lên thật mà thành
|
|
863
|
+
// "mập mờ" (Makeup tại nhà 2 13/09 18:07, thich-lo-mo 12/09). Thuần, test được.
|
|
864
|
+
function pickPostPublishReelsTabUrl({ discovered, remembered }) {
|
|
865
|
+
if (discovered) return { url: discovered, via: 'page' };
|
|
866
|
+
if (remembered) return { url: remembered, via: 'snapshot' };
|
|
867
|
+
return { url: null, via: null };
|
|
868
|
+
}
|
|
869
|
+
|
|
858
870
|
// ID từ gói mạng: tab Reels xác nhận chỉ chứng minh reel THUỘC PAGE MÌNH, không
|
|
859
871
|
// chứng minh nó MỚI. Ca 10/09 16:26 "ẩm thực đồng quê 01": snapshotLen=0 nên cả
|
|
860
872
|
// 40 ID bắt được đều "mới", ID đầu tiên 1600960624772777 có trên tab (là bài
|
|
@@ -948,7 +960,7 @@ async function runOnce({ page, payload, log }) {
|
|
|
948
960
|
} = payload || {};
|
|
949
961
|
if (!video_url) throw new Error('No video_url provided');
|
|
950
962
|
|
|
951
|
-
log('info', '[fb-pw] selectors version=2026.09.
|
|
963
|
+
log('info', '[fb-pw] selectors version=2026.09.13-reels-tab-fallback');
|
|
952
964
|
|
|
953
965
|
page.on('dialog', (d) => { d.accept().catch(() => {}); });
|
|
954
966
|
|
|
@@ -1056,9 +1068,12 @@ async function runOnce({ page, payload, log }) {
|
|
|
1056
1068
|
// trước/sau mà tìm reel mới (xem diffNewReelIds). Một lần goto + quay
|
|
1057
1069
|
// về, ~6-8s. Hỏng thì bỏ qua, không chặn lượt đăng.
|
|
1058
1070
|
let reelIdsBefore = null;
|
|
1071
|
+
// GIỮ LẠI URL tab Reels cho sau khi đăng — xem pickPostPublishReelsTabUrl.
|
|
1072
|
+
let reelsTabUrlBefore = null;
|
|
1059
1073
|
try {
|
|
1060
1074
|
const tabUrl = await discoverReelsTabUrl(page, log);
|
|
1061
1075
|
if (tabUrl) {
|
|
1076
|
+
reelsTabUrlBefore = tabUrl;
|
|
1062
1077
|
await page.goto(tabUrl, { waitUntil: 'domcontentloaded', timeout: 30_000 });
|
|
1063
1078
|
await pause(page, 3500);
|
|
1064
1079
|
reelIdsBefore = await scrapeReelTileIds(page);
|
|
@@ -3032,7 +3047,14 @@ async function runOnce({ page, payload, log }) {
|
|
|
3032
3047
|
// 2. Extract Page ID from "Dòng thời gian của X" timeline anchor or
|
|
3033
3048
|
// any /profile.php?id=<id> anchor, then build the reels_tab URL
|
|
3034
3049
|
// 3. Extract Page slug from any /<handle>/ anchor
|
|
3035
|
-
const
|
|
3050
|
+
const picked = pickPostPublishReelsTabUrl({
|
|
3051
|
+
discovered: await discoverReelsTabUrl(page),
|
|
3052
|
+
remembered: reelsTabUrlBefore,
|
|
3053
|
+
});
|
|
3054
|
+
const reelsTabHref = picked.url;
|
|
3055
|
+
if (picked.via === 'snapshot') {
|
|
3056
|
+
log('info', `[fb-pw] trang hiện tại không có link tab Reels (${String(page.url() || '').slice(0, 70)}) — dùng URL đã biết từ lúc chụp ảnh nền`);
|
|
3057
|
+
}
|
|
3036
3058
|
if (reelsTabHref) {
|
|
3037
3059
|
reelsTabUrl = reelsTabHref;
|
|
3038
3060
|
log('info', `[fb-pw] navigating to page reels tab: ${reelsTabHref.slice(0, 100)}`);
|
|
@@ -3313,6 +3335,11 @@ async function runOnce({ page, payload, log }) {
|
|
|
3313
3335
|
// post_url để quyết, hai cờ này để người đọc log biết hỏng ở khâu nào.
|
|
3314
3336
|
confirm_click_failed: confirmClickFailed,
|
|
3315
3337
|
post_url_captured: !!postUrl,
|
|
3338
|
+
// Ảnh nền tab Reels chụp trước khi mở composer + URL tab. API lưu vào
|
|
3339
|
+
// publish_results[].reels_before để đối chiếu xuôi (PublishReconcile)
|
|
3340
|
+
// biết reel nào là CŨ khi lượt này không lấy được link.
|
|
3341
|
+
reels_before: reelIdsBefore ? reelIdsBefore.slice(0, 300) : undefined,
|
|
3342
|
+
reels_tab_url: reelsTabUrlBefore || reelsTabUrl || undefined,
|
|
3316
3343
|
video_path_local: videoPath,
|
|
3317
3344
|
};
|
|
3318
3345
|
} finally {
|
|
@@ -3352,6 +3379,7 @@ module.exports.__testables = {
|
|
|
3352
3379
|
resilientClick,
|
|
3353
3380
|
confirmPublishDialog,
|
|
3354
3381
|
diffNewReelIds,
|
|
3382
|
+
pickPostPublishReelsTabUrl,
|
|
3355
3383
|
pickReelsTabUrl,
|
|
3356
3384
|
networkIdVerdict,
|
|
3357
3385
|
classifyComposerText,
|