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

--get-X option order is ignored #4506

Closed
ghost opened this issue Dec 17, 2014 · 4 comments
Closed

--get-X option order is ignored #4506

ghost opened this issue Dec 17, 2014 · 4 comments

Comments

@ghost
Copy link

@ghost ghost commented Dec 17, 2014

i'm using a command like this:

youtube-dl --playlist-end=N --get-id --get-title --get-url https://youtube.com/user/USERNAME

there are three --get-X options and so youtube-dl outputs three lines per video. but the order of these lines seems predefined and doesn't depend on the order of the options. and this predefined order isn't mentioned in the docs so i can't count on it staying the same.

@phihag
Copy link
Contributor

@phihag phihag commented Dec 17, 2014

Indeed, the only reason why we allow multiple --get-* options in the first place is that we have no explicit code that forbids them. If you want to extract multiple fields and handle them in another application, use the -j option to output a multitude of keys as a single JSON line instead.

@phihag phihag closed this Dec 17, 2014
@ghost
Copy link
Author

@ghost ghost commented Dec 18, 2014

actually one-value-per-line output is much easier to handle in bash and other languages that don't have built-in json support. that's why i didn't use -j.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Dec 18, 2014

You can use jq for that:

$ youtube-dl 'http://www.youtube.com/watch?v=BaW_jenozKc' -j | jq -r '[.id, .title] | join("\n")'
BaW_jenozKc
youtube-dl test video "'/\ä
@ghost
Copy link
Author

@ghost ghost commented Dec 19, 2014

jq is an additional dependency which is completely avoidable. KISS, right? you even mention this in your readme:

youtube-dl makes the best effort to be a good command-line program, and thus should be callable from any programming language. If you encounter any problems parsing its output, feel free to create a report.

from the point of view of bash a good command-line program would output one value per line or a list of whitespace (tab?) separated values as a single line. also JSON-serialization/deserialization is less efficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.