fix: Improve title extraction to concatenate contextual lines
This commit is contained in:
parent
81826fbf9c
commit
a0eaad5315
@ -136,13 +136,16 @@ async function run() {
|
||||
let title = `Boletín Gobernación - Mes ${month} #${monthCounts[month] + 1}`;
|
||||
|
||||
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) {
|
||||
title = lines[0];
|
||||
if ((title.toUpperCase() === title || title.includes("GOBERNACIÓN") || title.includes("Boletín")) && lines.length > 1) {
|
||||
title = lines[1];
|
||||
const genericTitles = ['flash informativo', 'boletín', 'gobernación del cauca', 'comunicado', 'atención', 'apreciados periodistas', 'medios de comunicación'];
|
||||
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) + '...';
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user