<commit_before>const moviedb = require('moviedb');
const convertTmdbToMovie = require('src/tmdb/convertTmdbToMovie');

class TMDB {
	constructor(apiKey, tmdbLibrary) {
		this.tmdbLibrary = tmdbLibrary || moviedb(apiKey);
	}

	search(text, page = 1) {
		const query = { query: text, page };
		return Promise.resolve()
		 .then(() => this.tmdb('searchMulti', query))
		 .catch(() => { throw new Error('Could not search for movies.'); })
		 .then((reponse) => {
		 	try {
		 		return reponse.results.map(convertTmdbToMovie);
		 	} catch (parseError) {
		 		throw new Error('Could not parse result.');
		 	}
		 });
	}

	tmdb(method, argument) {
		return new Promise((resolve, reject) => {
			const callback = (error, reponse) => {
				if (error) {
					return reject(error);
				}
				resolve(reponse);
			};
<commit_msg>Now can handle type selector aswell<commit_after>const moviedb = require('moviedb');
const convertTmdbToMovie = require('src/tmdb/convertTmdbToMovie');

class TMDB {
	constructor(apiKey, tmdbLibrary) {
		this.tmdbLibrary = tmdbLibrary || moviedb(apiKey);
	}

	search(text, page = 1, type = 'searchMulti') {
		const query = { query: text, page };
		return Promise.resolve()
		 .then(() => this.tmdb(type, query))
		 .catch(() => { throw new Error('Could not search for movies.'); })
		 .then((reponse) => {
		 	try {
		 		return reponse.results.map(convertTmdbToMovie);
		 	} catch (parseError) {
		 		throw new Error('Could not parse result.');
		 	}
		 });
	}

	tmdb(method, argument) {
		return new Promise((resolve, reject) => {
			const callback = (error, reponse) => {
				if (error) {
					return reject(error);
				}
				resolve(reponse);
			};

{'fraction_non_alphanumeric': 0.15698022768124625, 'fraction_numerical': 0.0011983223487118035, 'mean_word_length': 3.550408719346049, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '6839936', 'n_tokens_mistral': 660, 'n_tokens_neox': 555, 'n_words': 129}