channel-worker 2.5.88 → 2.5.89
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
|
@@ -215,18 +215,24 @@ async function currentRangeLabel(page) {
|
|
|
215
215
|
// Tổng lượt xem của khoảng đang hiện, đọc được CẢ HAI kiểu giao diện.
|
|
216
216
|
// Phải neo cuối chuỗi ở "Lượt xem": trang còn có "Lượt xem trong tối thiểu 3
|
|
217
217
|
// giây" và "… 1 phút", khớp lỏng là vớ nhầm mấy số đó.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
218
|
+
// Giữa CON SỐ và NHÃN, Facebook nhét đủ thứ không phải chữ: phần trăm, và có
|
|
219
|
+
// khi cả MŨI TÊN. Ảnh chụp 2026-09-06 kênh "lặn biển 01":
|
|
220
|
+
// "105,474 ↓ -46% Total views from previous 28 days"
|
|
221
|
+
// Regex cũ chỉ cho khoảng trắng ở đó nên trượt sạch — trong khi số nằm ngay
|
|
222
|
+
// đấy. Bản tiếng Việt và khoảng 7 ngày không kèm mũi tên nên vẫn chạy, chỉ
|
|
223
|
+
// khoảng tuỳ chỉnh (có % giảm) mới lộ. `[^\p{L}]*` nuốt mọi thứ không phải chữ.
|
|
224
|
+
const TOTAL_LABELS = [
|
|
225
|
+
/^([\d.,]+)([^\p{L}]*)(?:Tổng số lượt xem|Total views)/iu,
|
|
226
|
+
/^([\d.,]+)([^\p{L}]*)(?:Lượt xem|Views)$/iu,
|
|
223
227
|
];
|
|
224
228
|
|
|
225
229
|
function pickTotal(chunks) {
|
|
226
|
-
for (const re of
|
|
230
|
+
for (const re of TOTAL_LABELS) {
|
|
227
231
|
for (const c of chunks) {
|
|
228
232
|
const m = re.exec(c);
|
|
229
|
-
if (m)
|
|
233
|
+
if (!m) continue;
|
|
234
|
+
const pm = /(-?[\d.,]+)%/.exec(m[2] || '');
|
|
235
|
+
return { views: parseExact(m[1]), pct: pm ? parseFloat(pm[1].replace(/,/g, '')) : null };
|
|
230
236
|
}
|
|
231
237
|
}
|
|
232
238
|
return { views: null, pct: null };
|
|
@@ -301,11 +307,8 @@ async function readViewsPage(page, range, log) {
|
|
|
301
307
|
if (/[Ll]ượt xem|[Vv]iews/.test(t)) { seen.add(t); chunks.push(t); }
|
|
302
308
|
if (chunks.length > 120) break;
|
|
303
309
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
.find((t) => t.length < 60 && /ngày qua:|hôm nay/i.test(t)) || '';
|
|
307
|
-
return { chunks, label };
|
|
308
|
-
}).catch(() => ({ chunks: [], label: '' }));
|
|
310
|
+
return { chunks };
|
|
311
|
+
}).catch(() => ({ chunks: [] }));
|
|
309
312
|
|
|
310
313
|
const t0 = pickTotal(raw.chunks);
|
|
311
314
|
const total = t0.views; const pct = t0.pct;
|
|
@@ -384,7 +387,7 @@ async function readTotalChunks(page) {
|
|
|
384
387
|
for (const e of document.querySelectorAll('div,span')) {
|
|
385
388
|
const t = clean(e.innerText);
|
|
386
389
|
if (!t || t.length > 90 || !/\d/.test(t) || seen.has(t)) continue;
|
|
387
|
-
if (/[Ll]ượt xem/.test(t)) { seen.add(t); out.push(t); }
|
|
390
|
+
if (/[Ll]ượt xem|[Vv]iews/.test(t)) { seen.add(t); out.push(t); }
|
|
388
391
|
if (out.length > 120) break;
|
|
389
392
|
}
|
|
390
393
|
return out;
|