Skip to content

Instantly share code, notes, and snippets.

@brussell98
Created July 26, 2018 00:49
Show Gist options
  • Save brussell98/e8c49c6eb9bd4231a771c421d98c14ef to your computer and use it in GitHub Desktop.
Save brussell98/e8c49c6eb9bd4231a771c421d98c14ef to your computer and use it in GitHub Desktop.
Check if a certain Sou You Start hardware setup is available
const axios = require('axios');
const chalk = require('chalk');
const identifiers = ['1804sys07'];
async function check() {
const availabilities = (await axios.get('https://ca.ovh.com/engine/api/dedicated/server/availabilities?country=we', {
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.183 Safari/537.36 Vivaldi/1.96.1147.52'
}
})).data;
const found = [];
for (const av of availabilities) {
if (identifiers.includes(av.hardware) && av.region === 'northAmerica' && av.datacenters.find(dc => dc.datacenter === 'bhs'))
found.push({
hardware: av.hardware,
region: av.region,
datacenter: av.datacenters.find(dc => dc.datacenter === 'bhs')
});
}
console.log(chalk.cyan('\n=================================='));
console.log(chalk.cyan(`[${new Date().toLocaleString()}]: ${found.length} out of ${identifiers.length} tracked hardware is available`));
console.log(chalk.cyan('=================================='));
for (const fnd of found)
console.log(chalk.green(`[${fnd.hardware}]: ${fnd.region}-${fnd.datacenter.datacenter} has availability ${fnd.datacenter.availability}`));
setTimeout(() => check(), (20 + (Math.random() * 4 - 2)) * 60e3);
}
check();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment