Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?
http://stackoverflow.com/questions/14952295/set-output-of-a-command-as-a-variable-with-pipes

another option is to write/read from temp file.

share|improve this question
    
What error do you get? The quotes will not affect mplayer, they will affect youtube-dl.exe. What exactly is the output of youtube-dl.exe -g? Is that a stream? –  terdon Sep 22 '13 at 17:52
    
@terdon you are right, the error is coming from youtube-dl seems its sees mplayer as an argument. –  yoshco Sep 22 '13 at 22:01
    
@terdon youtube-dl -g $watch_URI outputs a very, very long URI with lots of parameters. It looks like a “direct” video link. –  Blacklight Shining Sep 23 '13 at 3:53
    
@yoshco Firstly, you want quotes around the YouTube URI, in order to escape the ?. Secondly, does mplayer actually take links to videos on stdin like that? –  Blacklight Shining Sep 23 '13 at 3:54
    
youtube-dl works either with or without quotes for simple urls it doesn't change the situation. –  yoshco Sep 23 '13 at 7:17

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
this worked. just had to add double quotes around the youtube link itself. thanks –  yoshco Sep 23 '13 at 14:33
    
@yoshco - I added the quotes to the answer, thanks :) –  dbenham Sep 23 '13 at 15:12

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.)

share|improve this answer
1  
your answer refers to unix systems. im on windows –  yoshco Sep 23 '13 at 7:18
    
Single quotes, double quotes, and $()-style command substitution are all specified in POSIX and should work the same in any shell. –  Blacklight Shining Sep 23 '13 at 12:04
    
im gettign following erro msg No stream found to handle url $(youtube-dl --get-url 'youtube.com/watch?v=sNPVt3cMkT0') –  yoshco Sep 23 '13 at 14:16
    
Your shell must not be POSIX-compliant. *shrug* You could always install bash or something. –  Blacklight Shining Sep 23 '13 at 14:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.