Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tokenizer example in README to @tokenizer/http v0.5.0 #287

Closed
Borewit opened this issue Jan 3, 2020 · 0 comments · Fixed by #288
Closed

Update tokenizer example in README to @tokenizer/http v0.5.0 #287

Borewit opened this issue Jan 3, 2020 · 0 comments · Fixed by #288

Comments

@Borewit
Copy link
Collaborator

Borewit commented Jan 3, 2020

Update example to @tokenizer/http v0.5.0

const {HttpTokenizer} = require('@tokenizer/http');
const FileType = require('file-type');

const config = {
	avoidHeadRequests: true
};

const audioTrackUrl = 'https://test-audio.netlify.com/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/01%20-%20Diablo%20Swing%20Orchestra%20-%20Heroines.mp3';

(async () => {
	const httpTokenizer = HttpTokenizer.fromUrl(audioTrackUrl, config);
	await httpTokenizer.init();

	const fileType = await FileType.fromTokenizer(httpTokenizer);
	console.log(fileType);
	// { ext: 'mp3', mime: 'audio/mpeg' }
})();

to something like:

const {makeTokenizer} = require('@tokenizer/http');
const FileType = require('file-type');

const config = {
	avoidHeadRequests: true
};

const audioTrackUrl = 'https://test-audio.netlify.com/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/01%20-%20Diablo%20Swing%20Orchestra%20-%20Heroines.mp3';

(async () => {
	const httpTokenizer = await makeTokenizer(audioTrackUrl, config);
	
	const fileType = await FileType.fromTokenizer(httpTokenizer);
	console.log(fileType);
	// { ext: 'mp3', mime: 'audio/mpeg' }
})();

Pending merge: #285, #286

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant