Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Commit

Permalink
add getFormats example
Browse files Browse the repository at this point in the history
  • Loading branch information
przemyslawpluta committed Mar 14, 2016
1 parent 6912150 commit d9b2925
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions example/formats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var ytdl = require('..');

var url = 'http://www.youtube.com/watch?v=0RUvealeXZ0';

function mapInfo(item) {
'use strict';
return {itag: item.format_id, filetype: item.ext, resolution: item.resolution || 'audio only'};
}

ytdl.getInfo(url, function getFormats(err, info) {
'use strict';
if (err) { throw err; }
var formats = {id: info.id, formats: info.formats.map(mapInfo)};
console.log(formats);
});

0 comments on commit d9b2925

Please sign in to comment.