-
Notifications
You must be signed in to change notification settings - Fork 371
Add bitrate information to format output #59
Conversation
@@ -234,7 +234,9 @@ ytdl.getInfo = function(url, args, options, callback) { | |||
|
|||
|
|||
var formatsRegex = | |||
/^(\d+)\s+([a-z0-9]+)\s+(\d+x\d+|\d+p|audio only|\?x\d+|unknown)/; | |||
/^(\d+)\s+([a-z0-9]+)\s+(\d+x\d+|\d+p|audio only|\?x\d+|unknown)(.*)$/; | |||
var extendedRegex = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be put into the first regex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe it would be better to split the rest of the string by commas, and parse all of those fields not just the bitrate
So, yes and yes on both comments, however here are the reasons I did it the way I did it:
...this said, if you are more knowledgeable about the Example raw output:
|
Can't find documentation on the output for this. From the output above, it looks like sometimes it has extra info, sometimes it doesn't, and when it does the number of fields is not constant. But it looks like we would be able to get the bitrate, fps, and size of the format. |
Happy to add the format (e.g. |
Isn't the rightmost part the size? ie 26.55MiB for 135 |
I coded the parsing of the extra fields & I ran into a bug when testing. Happy to fix it in this PR however it would change the existing data structure returned by To avoid any regression, I think the best would be to keep the I will let you weigh-in before I make the fix To reproduce, just try getting the format from |
How about naming the field |
Updated to fix #60 as well. Note that the regex is still split into multiple patterns, primarily because some attributes don't always show up, and the code is much more readable using |
filetype : result[2], | ||
resolution : result[3], | ||
}); | ||
} | ||
if (/^\d+$/.test(compiledResult.code)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would only be set for youtube videos right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The itag
attributes will be set for any video with an integer code
value. So the itag
would be set for youtube and any of the other ~500+ web sites supported by youtube dl in theory that use integer code
values (if any).
tests still fail :( |
There's a new PR #62 It uses the |
I played with Let's close this PR after you accept #62 Not related but I am planning to work on a PR to allow submitting multiple urls at a time. Let me know if you have any thoughts on the topic? |
when I first made this, that option didn't exist. when it was first added, IIRC it didn't include a downloadable url from the formats. |
The PR adds a
bitrate
field to the format output when the data is available. An example output would look like this as a result: