<commit_before>const superagent = require("superagent");
const playlist = require(`${__dirname}/playlist.js`);
const search = require(`${__dirname}/search.js`);

module.exports = async (query, i = 0) => {
	if(playlistRegex.test(query)) return playlist(query.match(playlistRegex)[1]);

	try {
		var { body } = await superagent.get(bot.config.lavalink.url)
			.set("Authorization", bot.config.lavalink.auth)
			.query({ identifier: query });
	} catch(err) {
		if(i) throw err;
		return module.exports(search(query), i + 1);
	}

	if(body && Array.isArray(body)) var data = [body];
	else throw new Error("No track resolved");

	data.info.track = data.track;
	return data.info;
};

const playlistRegex = /^(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{12,})[a-z0-9;:@#?&%=+\/\$_.-]*/; // eslint-disable-line max-len<commit_msg>check for body length<commit_after>const superagent = require("superagent");
const playlist = require(`${__dirname}/playlist.js`);
const search = require(`${__dirname}/search.js`);

module.exports = async (query, i = 0) => {
	if(playlistRegex.test(query)) return playlist(query.match(playlistRegex)[1]);

	try {
		var { body } = await superagent.get(bot.config.lavalink.url)
			.set("Authorization", bot.config.lavalink.auth)
			.query({ identifier: query });
	} catch(err) {
		if(i) throw err;
		return module.exports(search(query), i + 1);
	}

	if(body && Array.isArray(body) && body.length) var data = [body];
	else throw new Error("No track resolved");

	data.info.track = data.track;
	return data.info;
};

const playlistRegex = /^(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{12,})[a-z0-9;:@#?&%=+\/\$_.-]*/; // eslint-disable-line max-len
{'fraction_non_alphanumeric': 0.2594510616261005, 'fraction_numerical': 0.0072501294665976174, 'mean_word_length': 4.1246684350132625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2949413', 'n_tokens_mistral': 767, 'n_tokens_neox': 744, 'n_words': 113}