4 ms·
YT videos lag a lot when I stream them directly in VLC 2.2.0, (`vlc <youtube link>`) and some protected videos don't play at all, so I often use this: ytpl
by renekooi 12y ago
YT videos lag a lot when I stream them directly in VLC 2.2.0, (`vlc <youtube link>`) and some protected videos don't play at all, so I often use this:
ytplay() { youtube-dl "$1" -o - | vlc - }
As a side benefit it of course also allows you to instantly watch stuff from all the other sites YT-DL supports :)
- jboynyc 12y agoThat's a great idea. I use Livestreamer for that purpose. https://pypi.python.org/pypi/livestreamer/1.10.2 https://pypi.python.org/pypi/livestreamer/1.10.2
- girvo 12y agoHoly heck that's a great idea. Thanks!
- relate 12y agoHad to add a colon: ytplay() { youtube-dl "$1" -o - | vlc -; } but works great!
- wrboyce 12y agoThat is a semicolon, and it shouldn't be necessary (at least not in bash/zsh).
- heinrich5991 12y agoI believe it's necessary, otherwise the closing bracket counts as parameter to the last command.
- e12e 12y agoCorrect. On the command line: ytplay() { youtube-dl "$1" -o - | vlc - ; } or: ytplay() { youtube-dl "$1" -o - | vlc - #<enter here> > } #Where "> " is bash prompting for more/end of definitoin In a file (eg: .bashrc), I'd personally prefer: ytplay() { youtube-dl "${1}" -o - | vlc - } Note that there's very little difference between "$1" and "${1}" in practice, I tend to prefer it for consistency with recommended[1] practice of using ${NAME} rather than $NAME. (And to differentiate something like "${1}${2}" vs "${12}", as you might if $1 was a name, and $2 an extension, or $1 and url-scheme and $2 a host-name (http://hostname http://hostname -> "${1}${2}" 1="http://" http://" 2="hostname"). [1] http://stackoverflow.com/questions/8748831/bash-why-do-we-need-curly-braces-in-variables http://stackoverflow.com/questions/8748831/bash-why-do-we-ne...
- jbk 12y agoI think I fixed the "some protected videos" last week. If not, please share me a YT link.
- unicornporn 12y agoMay I ask what the program "ytplay" is? Google doesn't guide me.
- skeletonjelly 12y agoIt's a function name that renekooi would have made up to run the command following it without having to type it all out every time.
- pritambaral 12y agoThat's how you define a function in Bash.
- quoiquoi 12y agoI use xargs youtube-dl --get-url "$1" | xargs mplayer