<commit_before>var goog = require('googleapis');
var OAuth2 = goog.auth.OAuth2;
var yt = goog.youtube({version: 'v3'})
var moment = require('moment');


var apiKey = "";
module.exports.init = function(b) {
	b.getConfig("google.json", function(err, conf) {
		apiKey = conf.apiKey
	});
};

var ytRegex =  /(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i;

function formatPt50(pt50) {
	var duration = moment.duration(pt50);
	var hours   = duration.hours()
	var minutes = duration.minutes()
	var seconds = duration.seconds()
	if (hours   < 10) {hours   = "0"+hours;}
	if (minutes < 10) {minutes = "0"+minutes;}
	if (seconds < 10) {seconds = "0"+seconds;}
	var time    = hours+':'+minutes+':'+seconds;
	return time;
}

function likePerecent(vid) {
	try {
		var like = parseInt(vid.statistics.likeCount, 10);
		var hate = parseInt(vid.statistics.dislikeCount, 10);
		return (like / (like + hate) * 100).toString().substr(0, 4) + "%";
	} catch(ex) {
		console.log("Ty google for giving me this video which is screwed", vid)
		return "?%";
	}
}

function sayInfo(vid, cb, sayUrl) {
  var url = 'http://youtu.be/' + vid.id;
  cb((sayUrl ? (url + " ") : '') + vid.snippet.title, '-', formatPt50(vid.contentDetails.duration), (vid.statistics.viewCount ? '- ' + vid.statistics.viewCount + ' views' : '') + "(" + likePerecent(vid) + ") - " + vid.snippet.channelTitle);
}


function sayIdInfo(id, cb, sayUrl) {
	yt.videos.list({auth: apiKey, id: id, part: "snippet,statistics,contentDetails"}, function(err, results) {
		console.log(results)
		if(results.items.length > 0) {
			sayInfo(results.items[0], cb, sayUrl)
		}
	});
}

module.exports.url = function(url, reply) {
	if(apiKey == "") return;
	var m;
	if((m = ytRegex.exec(url))) {<commit_msg>Remove debug console.log<commit_after>var goog = require('googleapis');
var OAuth2 = goog.auth.OAuth2;
var yt = goog.youtube({version: 'v3'})
var moment = require('moment');


var apiKey = "";
module.exports.init = function(b) {
	b.getConfig("google.json", function(err, conf) {
		apiKey = conf.apiKey
	});
};

var ytRegex =  /(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i;

function formatPt50(pt50) {
	var duration = moment.duration(pt50);
	var hours   = duration.hours()
	var minutes = duration.minutes()
	var seconds = duration.seconds()
	if (hours   < 10) {hours   = "0"+hours;}
	if (minutes < 10) {minutes = "0"+minutes;}
	if (seconds < 10) {seconds = "0"+seconds;}
	var time    = hours+':'+minutes+':'+seconds;
	return time;
}

function likePerecent(vid) {
	try {
		var like = parseInt(vid.statistics.likeCount, 10);
		var hate = parseInt(vid.statistics.dislikeCount, 10);
		return (like / (like + hate) * 100).toString().substr(0, 4) + "%";
	} catch(ex) {
		console.log("Ty google for giving me this video which is screwed", vid)
		return "?%";
	}
}

function sayInfo(vid, cb, sayUrl) {
  var url = 'http://youtu.be/' + vid.id;
  cb((sayUrl ? (url + " ") : '') + vid.snippet.title, '-', formatPt50(vid.contentDetails.duration), (vid.statistics.viewCount ? '- ' + vid.statistics.viewCount + ' views' : '') + "(" + likePerecent(vid) + ") - " + vid.snippet.channelTitle);
}


function sayIdInfo(id, cb, sayUrl) {
	yt.videos.list({auth: apiKey, id: id, part: "snippet,statistics,contentDetails"}, function(err, results) {
		if(results.items.length > 0) {
			sayInfo(results.items[0], cb, sayUrl)
		}
	});
}

module.exports.url = function(url, reply) {
	if(apiKey == "") return;
	var m;
	if((m = ytRegex.exec(url))) {
{'fraction_non_alphanumeric': 0.21613995485327314, 'fraction_numerical': 0.018623024830699775, 'mean_word_length': 4.122832369942197, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '3361287', 'n_tokens_mistral': 1420, 'n_tokens_neox': 1328, 'n_words': 269}