obs-StreamFX/tools/convert-patreon-csv.js
Michael Fabian 'Xaymar' Dirks e3302fa163 ci, tools: Automatically generate contributor attribution files
Also includes a tool to convert Patreon Membership .csv files into a support patch set.
2023-04-05 18:51:50 +02:00

30 lines
653 B
JavaScript

const PATH = require("path");
const FS = require("fs/promises");
const CSV = require("csv");
(async () => {
const parser = CSV.parse(
await FS.readFile(process.argv[2]),
{
columns: true
}
);
let unsorted_users = {};
for await(const record of parser) {
unsorted_users[record['Name']] = `https://www.patreon.com/user/creators?u=${record['User ID']}`;
}
let users = {};
let keys = Object.keys(unsorted_users);
for (let key of keys.sort()) {
users[key] = unsorted_users[key];
}
FS.writeFile(
PATH.join(__dirname, "patch-supporters-patreon.json"),
JSON.stringify(users, undefined, '\t'),
{
encoding: 'utf8'
}
);
})();