feat: implement Open-Meteo weather integration with backfill scripts and updated lake data models.
continuous-integration/drone/push Build encountered an error

This commit is contained in:
David Fencl
2026-06-05 23:34:13 +02:00
parent 8193ce818a
commit 57e9bf12ca
24 changed files with 1122 additions and 758 deletions
+31
View File
@@ -0,0 +1,31 @@
import axios from 'axios';
import * as cheerio from 'cheerio';
import https from 'https';
import { lakesConfig } from './scripts/lakesConfig';
async function run() {
const agent = new https.Agent({ rejectUnauthorized: false });
for (const lake of lakesConfig) {
const [internalId, oid] = lake.id.split('|');
const URL = `https://www.pvl.cz/portal/nadrze/cz/pc/Mereni.aspx?oid=${oid}&id=${internalId}`;
try {
const res = await axios.get(URL, { httpsAgent: agent, headers: { 'User-Agent': 'Mozilla/5.0' } });
const $ = cheerio.load(res.data);
let temp = null;
let precip = null;
$('table').each((i, tbl) => {
const text = $(tbl).text();
if (text.includes('Aktuální hodnoty')) {
const tempMatch = text.match(/Teplota vzduchu \[°C\]\s*([\d,]+)/);
if (tempMatch) temp = tempMatch[1];
const precipMatch = text.match(/Srážky \(24h\) \[mm\]\s*([\d,]+)/);
if (precipMatch) precip = precipMatch[1];
}
});
console.log(`[${internalId}] Temp: ${temp}, Precip: ${precip}`);
} catch (e) {
console.error(e.message);
}
}
}
run();