fix: oprava parsování pro aktuální podobu TechTower
ci/woodpecker/push/workflow Pipeline failed

This commit is contained in:
2026-04-28 12:50:19 +02:00
parent d6729388ab
commit 4e7b83b667
+17 -2
View File
@@ -280,6 +280,7 @@ export const getMenuTechTower = async (firstDayOfWeek: Date, mock: boolean = fal
const $ = load(html);
let secondTry = false;
let thirdTry = false;
// První pokus - varianta "Obědy"
let fonts = $('font.wsw-41');
let font = undefined;
@@ -288,7 +289,7 @@ export const getMenuTechTower = async (firstDayOfWeek: Date, mock: boolean = fal
font = f;
}
})
// Druhý pokus - varianta "Jídelní lístek"
// Druhý pokus - varianta "Jídelní lístek" (starší formát)
if (!font) {
fonts = $('font.wnd-font-size-90');
fonts.each((i, f) => {
@@ -298,12 +299,26 @@ export const getMenuTechTower = async (firstDayOfWeek: Date, mock: boolean = fal
}
})
}
// Třetí pokus - nový formát: font.wsw-41 s textem "Jídelní lístek" (vše v jednom bloku)
if (!font) {
fonts = $('font.wsw-41');
fonts.each((i, f) => {
if ($(f).text().trim().startsWith('Jídelní lístek')) {
font = f;
thirdTry = true;
}
})
}
if (!font) {
throw new Error('Chyba: nenalezen <font> pro obědy v HTML Techtower.');
}
const result: Food[][] = [];
const siblings = secondTry ? $(font).parent().parent().parent().siblings('p') : $(font).parent().parent().siblings();
const siblings = thirdTry
? $(font).parent().siblings('p')
: secondTry
? $(font).parent().parent().parent().siblings('p')
: $(font).parent().parent().siblings();
let parsing = false;
let currentDayIndex = 0;
for (let i = 0; i < siblings.length; i++) {