-
-
Save samizzo/12849ff0adb815ed8e87f7adffca3ab8 to your computer and use it in GitHub Desktop.
For use in Unity Asset Store sale page dev console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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