Fixed boat direction
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -89,7 +89,6 @@ export async function getAIS() {
|
||||
}
|
||||
|
||||
export async function getAISImage(mmsi) {
|
||||
console.log(`https://www.vesselfinder.com/vessels/details/${mmsi}`)
|
||||
const res = await fetch(`https://www.vesselfinder.com/vessels/details/${mmsi}`, {
|
||||
headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36' }
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user