<commit_before>"use strict";
const scrapeIt = require("scrape-it");
const unzip = require("unzipper");
const rimraf = require("rimraf");
const url = require("url");

scrapeIt("https://developers.eveonline.com/resource/resources", {
    sde_link: { selector: ".content > h3:nth-child(4) + ul li:last-child a", attr: "href" },
    versioned_filename: { selector: ".content > h3:nth-child(6) + ul li:last-child a", attr: "href" }
}).then(scrape => {
    const link = scrape.sde_link;
    const versionedFilename = scrape.versioned_filename;
    if (typeof link !== "string" || typeof versionedFilename !== "string") throw new Error("Couldn't scrape SDE link!");
    const captures = versionedFilename.match(/YC-(\d+)-(\d+)_(\d+)\.(\d+)/);
    const year = captures[1],
        month = captures[2],
        major = captures[3],
        minor = captures[4];
    const version = `${year}.${month}.${major}-${minor}`;
    const current = require("../package.json").version;
    if (version === current) return console.log(`Already at version ${version}, not redownloading SDE.`);

    const https = require("https");
    const fs = require("fs");

    console.log(`Removing existing sde.zip, if it exists...`);
    try { fs.unlinkSync("sde.zip"); } catch(e) {} // Attempt to remove existing sde zip<commit_msg>dont rely on the patch having YC in the name<commit_after>"use strict";
const scrapeIt = require("scrape-it");
const unzip = require("unzipper");
const rimraf = require("rimraf");
const url = require("url");

function nowInEVETime(namestring) {
    const now = new Date();
    const year = now.getUTCFullYear() - 2017 + 119; // 2017 is YC 119
    const month = now.getUTCMonth();
    const day = now.getUTCDate();
    return `${year}.${month}.${day}-${namestring}`;
}

scrapeIt("https://developers.eveonline.com/resource/resources", {
    sde_link: { selector: ".content > h3:nth-child(4) + ul li:last-child a", attr: "href" },
    versioned_filename: { selector: ".content > h3:nth-child(6) + ul li:last-child a", attr: "href" }
}).then(scrape => {
    const link = scrape.sde_link;
    const versionedFilename = scrape.versioned_filename;
    if (typeof link !== "string" || typeof versionedFilename !== "string") throw new Error("Couldn't scrape SDE link!");
    const current = require("../package.json").version;
    const currNameString = current.match(/(\d+)\.(\d+)\.(\d+)-(.*)/)
    if (currNameString !== null && currNameString[3] === versionedFilename) return console.log(`Already at version ${versionedFilename}, not redownloading SDE.`);
    const version = nowInEVETime(versionedFilename);

    const https = require("https");
    const fs = require("fs");

    console.log(`Removing existing sde.zip, if it exists...`);
    try { fs.unlinkSync("sde.zip"); } catch(e) {} // Attempt to remove existing sde zip
{'fraction_non_alphanumeric': 0.1795325779036827, 'fraction_numerical': 0.009560906515580737, 'mean_word_length': 4.017761989342806, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4294279', 'n_tokens_mistral': 928, 'n_tokens_neox': 895, 'n_words': 230}