-
Notifications
You must be signed in to change notification settings - Fork 74
/
script-download-data.js
39 lines (35 loc) · 1.42 KB
/
script-download-data.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// download data from pubgmap.io
const axios = require('axios')
const fs = require('fs')
const dataMap = {
'erangel-info.json': 'https://api.pubgmap.io/maps/erangel',
'erangel-garages.json': 'https://api.pubgmap.io/maps/erangel/layers/garages',
'erangel-vehicle.json': 'https://api.pubgmap.io/maps/erangel/layers/vehicle_spawns',
'erangel-boat.json': 'https://api.pubgmap.io/maps/erangel/layers/boat_spawns',
'erangel-loot.json': 'https://api.pubgmap.io/maps/erangel/layers/loot_heatmap',
'miramar-info.json': 'https://api.pubgmap.io/maps/miramar',
'miramar-vehicle.json': 'https://api.pubgmap.io/maps/miramar/layers/vehicle_spawns',
'miramar-offroad.json': 'https://api.pubgmap.io/maps/miramar/layers/offroad',
'miramar-boat.json': 'https://api.pubgmap.io/maps/miramar/layers/boat_spawns',
'miramar-loot.json': 'https://api.pubgmap.io/maps/miramar/layers/loot_heatmap',
}
const fileBase = './static/data'
async function main () {
for (const key in dataMap) {
process.stdout.write(`Downloading ${dataMap[key]} to ${fileBase}/${key} `)
let response = null
try {
response = await axios.get(dataMap[key], { responseType: 'arraybuffer' })
fs.writeFileSync(`${fileBase}/${key}`, response.data)
console.log(' - OK!')
} catch (err) {
console.log(' - failed!', err.message)
}
}
}
main().catch(err => {
console.log('unexpected error', err)
cleanup.then(() => {
process.exit(2)
})
})