<commit_before>var mongoose = require('mongoose');
var request = require('request');
var cheerio = require('cheerio');
var favicon = require('favicon');

var Site = mongoose.model('site');

module.exports.get = function(site, discord, cb) {
    Site.find({name:site}, function(err, sites) {
        if (err) return console.log(err);
        
        var siteData = sites[0];
        
        if (siteData) {
            if (siteData.profileType) {
                console.log('Profile option found!');
                
                if (siteData.profileType=='website') getWebsiteProfile(site,cb);
                if (siteData.profileType=='favicon') getFavicon(site,cb);
                if (siteData.profileType=='discord') discord.getProfile(site,cb);
            } else {
                console.log('No profile option found. Setting option to default...');
                Site.update({name:site}, {
                    profileType: 'website'
                }, function(err) {
                    if (err) return console.log(err);
                    
                    getWebsiteProfile(site, cb);
                });
            }
        }
        else {
            console.log("Website doesn't exis. Terminating!");
        }
    });
}

function getWebsiteProfile(site, cb) {
    request('https://neocities.org/site/'+site, function(err, response, body) {
        if (err) return console.log(err);
        
        var $ = cheerio.load(body);
        cb('https://neocities.org'+$('.screenshot').attr('style').replace('background-image:url(','').replace(');',''));
    });
}
function getFavicon(site, cb) {
    favicon('https://'+site+'.neocities.org', function(err, url) {
        if (err) return console.log(err);
        if (url.indexOf('http')>-1) {
            cb(url);
        }
        else {
            if (url[0]=='/') {
                cb('https://'+site+'.neocities.org'+url);
            }
            else {
                cb('https://'+site+'.neocities.org/'+url);
            }
        }<commit_msg>Silly spelling mistake!<commit_after>var mongoose = require('mongoose');
var request = require('request');
var cheerio = require('cheerio');
var favicon = require('favicon');

var Site = mongoose.model('site');

module.exports.get = function(site, discord, cb) {
    Site.find({name:site}, function(err, sites) {
        if (err) return console.log(err);
        
        var siteData = sites[0];
        
        if (siteData) {
            if (siteData.profileType) {
                console.log('Profile option found!');
                
                if (siteData.profileType=='website') getWebsiteProfile(site,cb);
                if (siteData.profileType=='favicon') getFavicon(site,cb);
                if (siteData.profileType=='discord') discord.getProfile(site,cb);
            } else {
                console.log('No profile option found. Setting option to default...');
                Site.update({name:site}, {
                    profileType: 'website'
                }, function(err) {
                    if (err) return console.log(err);
                    
                    getWebsiteProfile(site, cb);
                });
            }
        }
        else {
            console.log("Website doesn't exist. Terminating!");
        }
    });
}

function getWebsiteProfile(site, cb) {
    request('https://neocities.org/site/'+site, function(err, response, body) {
        if (err) return console.log(err);
        
        var $ = cheerio.load(body);
        cb('https://neocities.org'+$('.screenshot').attr('style').replace('background-image:url(','').replace(');',''));
    });
}
function getFavicon(site, cb) {
    favicon('https://'+site+'.neocities.org', function(err, url) {
        if (err) return console.log(err);
        if (url.indexOf('http')>-1) {
            cb(url);
        }
        else {
            if (url[0]=='/') {
                cb('https://'+site+'.neocities.org'+url);
            }
            else {
                cb('https://'+site+'.neocities.org/'+url);
            }
        }
{'fraction_non_alphanumeric': 0.16343081838289505, 'fraction_numerical': 0.0014745637748832638, 'mean_word_length': 1.8205128205128205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2312467', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1150, 'n_words': 206}