Skip to content

Instantly share code, notes, and snippets.

@samizzo
Forked from LeLocTai/asset-sale.js
Created November 17, 2019 11:14
Show Gist options
  • Save samizzo/12849ff0adb815ed8e87f7adffca3ab8 to your computer and use it in GitHub Desktop.
Save samizzo/12849ff0adb815ed8e87f7adffca3ab8 to your computer and use it in GitHub Desktop.
For use in Unity Asset Store sale page dev console
(async function get() {
const publisher_id = 20835;
const period = 48; //months
function nextMon(current) {
let mon = --current[1];
let year = current[0];
if (mon < 1) {
year--;
mon = 12;
}
return [year, mon];
}
const now = new Date();
const from = [now.getFullYear(), now.getMonth() + 1];
let current = from;
let tsv = 'Date Copies Sold Price Gross\n';
for (_ = 0; _ < period; _++) {
let date = `${current[0] * 100 + current[1]}`;
const res = await fetch(
`https://publisher.assetstore.unity3d.com/api/publisher-info/sales/${publisher_id}/${date}.json`
);
const data = await res.json();
data.aaData.forEach(function (entry, index) {
tsv += `01/${current[1]}/${current[0]} ${entry[2]} ${entry[1]} ${entry[5]}\n`;
});
current = nextMon(current);
}
console.log('Done!');
return tsv;
})().then(copy);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment