Stream youtube videos

syt() { pipe=`mktemp -u`; mkfifo -m 600 "$pipe" && for i in "$@"; do youtube-dl -qo "$pipe" "$i" & mplayer "$pipe" || break; done; rm -f "$pipe"; }
Streams youtube-dl video to mplayer. Usage: syt '' '' Uses mplayer controls

2015-03-14 01:48:20

1 Alternatives + Submit Alt

  • The above line is the meat of the script. What I do is have a key in uzbl that puts the current URL into the clipboard (use if I am on the YouTube page) or right click a link to a YouTube page, or however you want to get the URL into the clipboard. With xbindkeys I run this from the keyboard. The script: #!/bin/bash # Get URL from command line arg if given, else use clipboard. if [[ "$1" == "" ]] ; then url=$(xclip -o) else url="$1" fi # Strip it down to remove cruft url="${url%%&feature*}" url="${url%%&list*}" url="${url%%&index*}" # optional zenity --warning --timeout=1 --title="Running mplayer" --text="$url" mplayer $(youtube-dl -f best -g "$url" 2>/dev/null) Show Sample Output

    mplayer $(youtube-dl -f best -g "$url" 2>/dev/null)
    jtgd · 2015-03-16 20:54:27 0

What Others Think

Grande part! C'est une commande très simple mais elle fonctionne efficacement sur ma machine. Mais cela pourrait être fait d'une manière alternative dans une commande presque similaire pour diffuser des vidéos youtube. Je suis étudiante en informatique et en génie logiciel. Actuellement, je travaille pour cet outil d'audit SEO et logiciel en ligne. J'aime apprendre de nouvelles choses dans ce secteur de programmation et partager mes connaissances avec les gens. Merci quand même.
CherFresne · 86 weeks and 1 day ago
YouTube videos are of different categories including fun, entertainment, educational informational and so on. Have found all the amazing videos through this blog and also they can check resume planet reviews to get quality work. They have the collection of the best videos with the best quality so far.
SidneyWoods · 18 weeks and 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: