ytdl-core
Advanced tools
Comparing version 0.7.2 to 0.7.3
@@ -101,5 +101,18 @@ var qs = require('querystring'); | ||
default: | ||
format = formats.filter(function(format) { | ||
return format.itag === '' + quality; | ||
})[0]; | ||
var getFormat = function(itag) { | ||
for (var i = 0, len = formats.length; i < len; i++) { | ||
if (formats[i].itag === '' + itag) { | ||
return formats[i]; | ||
} | ||
} | ||
return null; | ||
}; | ||
if (Array.isArray(quality)) { | ||
for (var i = 0, len = quality.length; i < len; i++) { | ||
format = getFormat(quality[i]); | ||
if (format) { break; } | ||
} | ||
} else { | ||
format = getFormat(quality); | ||
} | ||
@@ -106,0 +119,0 @@ } |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "0.7.2", | ||
"version": "0.7.3", | ||
"repository": { | ||
@@ -12,0 +12,0 @@ "type": "git", |
@@ -25,3 +25,3 @@ # node-ytdl-core | ||
* `quality` - Video quality to download. Can be an [itag value](http://en.wikipedia.org/wiki/YouTube#Quality_and_formats) value, or `highest`/`lowest`. Defaults to `highest`. | ||
* `quality` - Video quality to download. Can be an [itag value](http://en.wikipedia.org/wiki/YouTube#Quality_and_formats) value, a list of itag values, or `highest`/`lowest`. Defaults to `highest`. | ||
* `filter` - Can be `video` to filter for formats that contain video, `videoonly` for formats that contain video and no additional audio track. Can also be `audio` or `audioonly`. You can give a filtering function that gets called with each format available. Used to decide what format to download. This function is given the `format` object as its first argument, and should return true if the format is preferable. | ||
@@ -28,0 +28,0 @@ * `format` - This can be a specific `format` object returned from `getInfo`. This is primarily used to download specific video or audio streams. **Note:** Supplying this option will ignore the `filter` and `quality` options since the format is explicitly provided. |
@@ -145,2 +145,9 @@ var util = require('../lib/util'); | ||
}); | ||
describe('with list of itags given', function() { | ||
it('Chooses matching format', function() { | ||
var format = util.chooseFormat(sortedFormats, { quality: [99, 160, 18] }); | ||
assert.equal(format.itag, '160'); | ||
}); | ||
}); | ||
}); | ||
@@ -239,3 +246,4 @@ | ||
it('Retrieves formatted video description', function() { | ||
var html = fs.readFileSync(path.resolve(__dirname, 'files/util/multiline-video-description'), 'utf8'); | ||
var html = fs.readFileSync(path.resolve(__dirname, | ||
'files/util/multiline-video-description'), 'utf8'); | ||
var cleanDescription = util.getVideoDescription(html); | ||
@@ -242,0 +250,0 @@ assert.ok(cleanDescription); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7396649
42
31073
7