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

filter: 'audioonly' does not work on v1.0.2 #529

Closed
mahhov opened this issue Nov 27, 2019 · 6 comments
Closed

filter: 'audioonly' does not work on v1.0.2 #529

mahhov opened this issue Nov 27, 2019 · 6 comments
Labels

Comments

@mahhov
Copy link

mahhov commented Nov 27, 2019

Was using an older version in the morning (0.27), and ytdl(<id>, {filter: 'audioonly'}) worked fine. I updated to version 1.0.2, and now I get No formats found.

From what I can tell, this is the relevant code:
fn = (format) => !format.bitrate && format.audioBitrate;

fn = (format) => !format.bitrate && format.audioBitrate;

Here are console.logs of the available formats for a particular video:

const ytdl = require('ytdl-core');
ytdl.getInfo('QvtjAoFBmVg', (err, info) =>
    console.log(JSON.stringify(info.formats)));

Version 0.27, note the last 4 formats have bitrate: null:
https://gist.github.com/mahhov/632f869350ebb5a6dab64ce7715ea449

Version 1.0.2, note that now all 23 formats have a bitrate:
https://gist.github.com/mahhov/5cfa8ae7c9853f3d2cdb99fe1dabf954

@RocoGreen
Copy link

bitrate is null if it's a audio format but audioBitrate not.
I dunno but the line you refered is correct so something isn't right
And please, can you send me the video url ?

@mahhov
Copy link
Author

mahhov commented Nov 27, 2019

For this one example at least, checking
format.mimeType.startsWith('audio') && format.audioBitrate or !format.qualityLabel && format.audioBitrate would both work, but I'm not sure if that's valid for all videos.

@RocoGreen
Copy link

I checked with an another video but fent verification is correct but something isn't right

@mahhov
Copy link
Author

mahhov commented Nov 27, 2019

The video ID is in my snippet, QvtjAoFBmVg.

bitrate is null if it's a audio format

It has 23 formats available, the last 4 are audio-only but have non-null bitrate with v1.0.2, as seen in my 2nd JSON gist.

@RocoGreen
Copy link

Problem noticed, some audio formats contains bitrate value, i will try an another verification

@RocoGreen
Copy link

So the fix is:
fn = (format) => !format.qualityLabel && format.audioBitrate

@fent fent added the bug label Nov 28, 2019
@fent fent closed this as completed in 5263504 Nov 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants