ADSB images

This commit is contained in:
2026-07-04 22:09:13 -04:00
parent 54c53a5822
commit be40d845bd
2 changed files with 2 additions and 1 deletions

View File

@@ -356,7 +356,7 @@ export async function getADSBImage(icao) {
const specific = await fetch(`https://api.planespotters.net/pub/photos/hex/${icao.toLowerCase()}`).then(resp => resp.ok ? resp.json() : null); const specific = await fetch(`https://api.planespotters.net/pub/photos/hex/${icao.toLowerCase()}`).then(resp => resp.ok ? resp.json() : null);
let src; let src;
if(specific?.photos?.[0]) src = specific?.photos?.[0]; if(specific?.photos?.[0]) src = specific.photos[0].thumbnail_large?.src || specific.photos[0].thumbnail?.src;
else src = await generic; else src = await generic;
if(!src) return null; if(!src) return null;

View File

@@ -157,6 +157,7 @@ app.get('/api/icon/:icon', asyncHandler(async (req, res, next) => {
app.get('/api/adsb', asyncHandler(async (req, res) => res.json(await getADSB()))); app.get('/api/adsb', asyncHandler(async (req, res) => res.json(await getADSB())));
app.get('/api/adsb-image/:icao', asyncHandler(async (req, res) => { app.get('/api/adsb-image/:icao', asyncHandler(async (req, res) => {
const blob = await getADSBImage(req.params.icao); const blob = await getADSBImage(req.params.icao);
if (!blob) return res.status(404).send('No image found');
const buffer = Buffer.from(await blob.arrayBuffer()); const buffer = Buffer.from(await blob.arrayBuffer());
res.contentType(blob.type).send(buffer); res.contentType(blob.type).send(buffer);
})); }));