Problem :
i want to pipe a URL to mplayer.
but can’t see how to encapsulate 1st output with double quotes (otherwise mplayer errors out)
this is wrong
youtube-dl.exe -g http://www.youtube.com/watch?v=sNPVt3cMkT0 | mplayer
relevant?
https://stackoverflow.com/questions/14952295/set-output-of-a-command-as-a-variable-with-pipes
another option is to write/read from temp file.
Solution :
You do not want to pipe the result into mplayer, instead you want to supply the result as an argument, like so:
for /f "delims=" %A in ('youtube-dl.exe -g "http://www.youtube.com/watch?v=sNPVt3cMkT0"') do @mplayer "%%A"
If used within a batch file, then double up all percents, so %A
becomes %%A
.
I googled for an mplayer
manual page; from what I can tell, it takes URIs as arguments. As I mentioned in the comments, you need to quote the YouTube URI. You’ll also need to quote the command substitution, so the shell doesn’t try to expand that into filenames, too. You want something like this:
mplayer "$(youtube-dl --get-url 'https://www.youtube.com/watch?v=sNPVt3cMkT0')"
(--get-url
is equivalent to -g
; I changed it for clarity for those not familiar with youtube-dl
.)