ADSB images
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user