fix: Improve title extraction to concatenate contextual lines

This commit is contained in:
Carlos (Almeira) 2026-06-21 12:21:18 -05:00
parent 81826fbf9c
commit a0eaad5315

View File

@ -136,13 +136,16 @@ async function run() {
let title = `Boletín Gobernación - Mes ${month} #${monthCounts[month] + 1}`; let title = `Boletín Gobernación - Mes ${month} #${monthCounts[month] + 1}`;
if (cleanCaption.length > 20) { if (cleanCaption.length > 20) {
const lines = cleanCaption.split('\n').map(l => l.trim()).filter(l => l.length > 5); const lines = cleanCaption.split('\n').map(l => l.replace(/^[\p{Emoji}\s*_*]+/gu, '').trim()).filter(l => l.length > 5);
if (lines.length > 0) { if (lines.length > 0) {
title = lines[0]; title = lines[0];
if ((title.toUpperCase() === title || title.includes("GOBERNACIÓN") || title.includes("Boletín")) && lines.length > 1) { const genericTitles = ['flash informativo', 'boletín', 'gobernación del cauca', 'comunicado', 'atención', 'apreciados periodistas', 'medios de comunicación'];
title = lines[1]; const isGeneric = genericTitles.some(g => title.toLowerCase().includes(g)) || title.toUpperCase() === title || title.length < 25;
if (isGeneric && lines.length > 1) {
title = `${title} | ${lines[1]}`;
} }
title = title.replace(/^[\p{Emoji}\s*_*]+/gu, ''); // Remove emojis, stars, underscores
if (title.length > 100) title = title.substring(0, 100) + '...'; if (title.length > 100) title = title.substring(0, 100) + '...';
} }
} }