Skip to content

Instantly share code, notes, and snippets.

@dcaslin
Created July 6, 2019 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcaslin/59726b68b175c68f1d3a09e472ce277a to your computer and use it in GitHub Desktop.
Save dcaslin/59726b68b175c68f1d3a09e472ce277a to your computer and use it in GitHub Desktop.
Concatenates #dimwishlist lists after filtering by description
var conf = require('./config.js')();
var fs = require("fs");
var zip = new require('node-zip')();
var async = require("async");
const https = require('https');
const got = require('got');
// https://api.github.com/users/48klocs/gists
async function processGists(label, gists) {
var s = '// -----' + label + '-----\n\n';
console.log("\n\n" + label);
for (const p of gists) {
console.log(p.description);
for (const key of Object.keys(p.files)) {
const f = p.files[key];
s += '//***** ' + p.description + ':' + f.filename + ':' + f.raw_url + '\n';
console.log(" " + f.filename + ": " + f.raw_url);
const response = await got(f.raw_url);
const gistText = response.body;
s += gistText;
s += '\n';
}
s += '\n\n';
console.log(s);
fs.writeFile(conf.dataDir + '/'+label+'.wishlist.txt', s, function (err) {
if (err) {
return console.log(err);
}
console.log("The version saved.");
});
}
}
(async () => {
const pveList = [];
const pvpList = [];
try {
const response = await got('https://api.github.com/users/48klocs/gists', {json: true});
for (const r of response.body) {
const desc = r.description.toLowerCase();
if (desc.indexOf('#dimwishlist') >= 0) {
if (desc.indexOf('panda') >= 0) {
if (desc.indexOf('pvp') >= 0) {
pvpList.push(r);
}
else if (desc.indexOf('pve') >= 0) {
pveList.push(r);
}
}
}
}
processGists("panda_pve", pveList);
processGists("panda_pvp", pvpList);
} catch (error) {
console.dir(error);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment