Internals/Furniture

Scanning code
const fs = require('fs') const _ = require('lodash') const got = require('got') const async = require('async')

const api = require('../lib/api') // api_data from api_start2 response

const types = { 0: 'floor', 1: 'wall', 2: 'window', 3: 'object', 4: 'chest', 5: 'desk' }

const columns = ['id', 'type', 'no', 'title', 'description', 'rarity', 'price', 'sale', 'season', 'ver', 'time', 'size', 'link']

const onFurniture = (furniture, next) => { const graph = api.api_mst_furnituregraph.find(e => e.api_id === furniture.api_id) const type = types[graph ? graph.api_type : furniture.api_type] const file = graph ? graph.api_filename : _.padStart(furniture.api_id, 3, '0') const ext = graph ? 'swf' : 'png' const url = `http://203.104.209.71/kcs/resources/image/furniture/${type}/${file}.${ext}` const data = {} for (const column of columns) { data[column] = furniture[`api_${column}`] } data.sale = furniture.api_saleflg data.ver = graph ? graph.api_version : '' data.type = type data.url = url data.furniture_api = furniture data.graph_api = graph data.link = `[${url} ${ext}]` got.head(url).then(res => {   const date = new Date(res.headers['last-modified'])    data.time = `${date.getUTCFullYear}/${_.padStart(date.getUTCMonth + 1, 2, '0')}/${_.padStart(date.getUTCDate, 2, '0')} ${_.padStart(date.getUTCHours, 2, '0')}h`    data.size = res.headers['content-length']    data.headers = res.headers    next(null, data)  }).catch(err => {    if (err.statusCode === 404) {      data.url = 404      data.link = 404      next(null, data)    } else {      console.log(err.toString)      process.exit    }  }) }

const onFinish = (err, data) => { data = data.sort((a, b) => a.id - b.id) fs.writeFileSync(`${__dirname}/furniture.mw`, `{|class="wikitable sortable" !${columns.join('!!')} ${data.map(e => `|-\n|${columns.map(key => e[key]).join('||')}`).join('\n')} fs.writeFileSync(`${__dirname}/furniture.json`, JSON.stringify(data, null, 2))  fs.writeFileSync(`${__dirname}/furniture.csv`, data.map(e => `${_.padStart(e.id, 3, '0')}_${e.type},${e.url}`).join('\n')) }
 * }`)

async.mapLimit(api.api_mst_furniture, 50, onFurniture, onFinish)