Fixed boat direction

This commit is contained in:
2026-09-04 08:57:13 -04:00
parent f3ca75decb
commit 9e1ef69b16
5 changed files with 27 additions and 16 deletions

View File

@@ -346,18 +346,27 @@ export async function getADSBImage(icao) {
const data = await fetch(url,
{headers: {'User-Agent': 'Mozilla/5.0', 'Referer': 'https://duckduckgo.com/'}}
).then(resp => resp.json());
return data?.results?.[0]?.image || null;
console.log(query, data.results)
// Sequentially try each image until we find a valid one
if (data?.results?.length) {
for (const result of data.results) {
if (!result.image) continue;
try {
const imgRes = await fetch(result.image);
if (imgRes.ok) return result.image;
} catch (e) {
continue; // Try next image
}
}
}
return null;
}
const c = cfg();
let aircraft = (await adsbCache).find(a => a.icao?.toLowerCase() === icao?.toLowerCase());
if(!aircraft) aircraft = enrichAircraft({hex: icao});
if(!aircraft) return null;
const generic = duckduckgo(aircraft.model ? `${aircraft.manufacturer} ${aircraft.model}` : `${aircraft.aircraft} Aircraft`);
const aircraft = await this.get(icao);
const generic = duckduckgo(`${aircraft.type || aircraft.shape} Aircraft`);
const specific = await fetch(`https://api.planespotters.net/pub/photos/hex/${icao.toLowerCase()}`,
{headers: {'User-Agent': `Personal ADSB Feeder + Dashboard (${c.EMAIL})`}}
{headers: {'User-Agent': `open-sight.net (zaktimson@gmail.com)`}}
).then(resp => resp.ok ? resp.json() : null);
let src;