https://play.google.com/intl/en_us/badges/
npm install
npm run dl-badges
https://play.google.com/intl/en_us/badges/
npm install
npm run dl-badges
const fs = require('fs') | |
const request = require('request-promise-native') | |
const URI = 'https://play.google.com/intl/en_us/badges/images/generic' | |
const DEFAULT_BADGE_DIR = 'google-play-store-badges' | |
const ISO_CODES = [ | |
'en', 'de', 'tr', 'es', 'pt', 'fr', | |
'it', 'ru', 'zh', 'pl', 'gr', 'hr', | |
'sr', 'da', 'hu', 'nl', 'sv', 'id', | |
'el', 'zh-cn' | |
] | |
const download = (baseUri, isoCode, callback) => { | |
const uri = `${baseUri}/${isoCode}_badge_web_generic.png` | |
const badgeFilename = `google-play-badge-${isoCode}.png` | |
request.head(uri) | |
.then(res => { | |
if (res.statusCode !== 404) { | |
request(uri) | |
.pipe(fs.createWriteStream(`${DEFAULT_BADGE_DIR}/google-play-badge-${isoCode}.png`)) | |
} | |
}) | |
.catch(err => console.error(err.options.uri)) | |
} | |
const downloadPlayStoreBadges = () => { | |
if (!fs.existsSync(DEFAULT_BADGE_DIR)) fs.mkdirSync(DEFAULT_BADGE_DIR) | |
ISO_CODES.forEach(iso => { | |
download(URI, iso) | |
}) | |
} | |
downloadPlayStoreBadges() |
{ | |
"name": "download-play-store-badges", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"dl-badges": "node index.js" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"request": "^2.81.0", | |
"request-promise-native": "^1.0.4" | |
} | |
} |