8000 fix: `--filter` works with new formats · fent/node-ytdl@216d8d7 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 216d8d7

Browse files
committed
fix: --filter works with new formats
1 parent 6acea30 commit 216d8d7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

bin/ytdl.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,23 @@ if (opts.infoJson) {
187 8000 187

188188
// Support basic ytdl-core filters manually, so that other
189189
// cli filters are supported when used together.
190+
const hasVideo = format => !!format.qualityLabel;
191+
const hasAudio = format => !!format.audioBitrate;
190192
switch (opts.filter) {
191193
case 'video':
192-
filters.push(format => format.bitrate);
194+
filters.push(hasVideo);
193195
break;
194196

195197
case 'videoonly':
196-
filters.push(format => format.bitrate && !format.audioBitrate);
198+
filters.push(format => hasVideo(format) && !hasAudio(format));
197199
break;
198200

199201
case 'audio':
200-
filters.push(format => format.audioBitrate);
202+
filters.push(hasAudio);
201203
break;
202204

203205
case 'audioonly':
204-
filters.push(format => !format.bitrate && format.audioBitrate);
206+
filters.push(format => !hasVideo(format) && hasAudio(format));
205207
break;
206208
}
207209

0 commit comments

Comments
 (0)
0