0

In reference to question youtube-dl; How download ONLY the playlist, NOT the files therein

Can i get output like the following :

https://youtu.be/0gvUCLL-UGE | video title
https://youtu.be/CPV7zcUy4J0 | video title
https://youtu.be/4wyZNwIrH9I | video title

Example :

https://youtu.be/aYLBLOQrcAE | 5 More Amazing Kitchen Gadgets

The solution provided by @radiolondra works great,

youtube-dl -j --flat-playlist "https://" | jq -r '.id' | sed 's_^_https://youtu.be/_' > result.log

But, I am not able to figure out "JQ" command / query for my requirement.

Please Assist!

------------------Edited------------------

I tried jq -r ".id \ "+" .title" the output was

https://youtu.be/0gvUCLL-UGEvideo title

was not able to insert " | " in between [id] and [title] Others that ended with error:

jq -r "map([.id, .title] | join("| ")) | join('\n')"
jq -r "map([.id, .title] | join(", ")) | join('\n')"
jq -r "map([.id, .title] | join(', ')) | join('\n')"
jq -r "map([.id, .title] | join('| ')) | join('\n')"
jq -r "map([.id, .title] | join(" ")) | join('\n')"
jq -r "map([.id, .title] | join(' ')) | join('\n')"

-----------------------Edited-----------------------

Following modifications seems to be working in Linux, but not able to make them work on windows :

 
jq -r '.entries | map(.id +" | "+ .title) | join("\n")'
jq -r '.[] | map(.id +" | "+ .title) | join("\n")'

On windows i keep getting the following error:

jq: error: syntax error, unexpected INVALID_CHARACTER, expecting $end (Windows cmd shell quoting issues?) at , line 1:
'.entries
jq: 1 compile error
'map' is not recognized as an internal or external command,
operable program or batch file.
Neel
  • 101

1 Answers1

1

This filter works for me:

jq -r '[("https://www.youtube.com/watch?v=" + .url), .title] | join(" | ")'

For example:

$ youtube-dl -j --flat-playlist "https://www.youtube.com/playlist?list=PL_-YkHMlMW8l2yE_vwl8Wg1U1k5kPHq_7" | jq -r '[("https://www.youtube.com/watch?v=" + .url), .title] | join(" | ")'
https://www.youtube.com/watch?v=jWYlIaYIcuI | Joshua Lee Turner - Introduction (Official)
https://www.youtube.com/watch?v=d8F4Pjv3NXQ | Joshua Lee Turner - Nebraska Dreams (Official)
https://www.youtube.com/watch?v=hgXtIA7o-jY | Joshua Lee Turner - Like Lightning (Official)
https://www.youtube.com/watch?v=bl9Ium3ZLCU | Joshua Lee Turner - Belle (Official)
https://www.youtube.com/watch?v=QZSzqL-asiY | Joshua Lee Turner - 319 (Official)
https://www.youtube.com/watch?v=dGLs5nPKJio | Joshua Lee Turner - Public Life (Official)
https://www.youtube.com/watch?v=JUbqL_Yhekk | Joshua Lee Turner - Smoky Sunrise (Official)
https://www.youtube.com/watch?v=5KLMZ-k3UxU | Joshua Lee Turner - Nostalgia / So Far So Long (Official)
https://www.youtube.com/watch?v=OFtN8FPUWDQ | Joshua Lee Turner - Denouement (Official)
https://www.youtube.com/watch?v=YmiOm0XeV00 | Joshua Lee Turner - At Home (Official)
https://www.youtube.com/watch?v=3Fs18SpOmRM | Joshua Lee Turner - Public Life Full Album (Official)