8 ms·
Here's something i've added to my .bashrc that lets me type in simply 'play <some song name>' using youtube-dl and mplayer (I forget where I found this gem, and
by SG- 11y ago
Here's something i've added to my .bashrc that lets me type in simply 'play <some song name>' using youtube-dl and mplayer (I forget where I found this gem, and sorry for weird formatting, won):
function play {
youtube-dl --default-search=ytsearch: \
--youtube-skip-dash-manifest \
--output="${TMPDIR:-/tmp/}%(title)-s%(id)s.%(ext)s" \
--restrict-filenames \
--format="bestaudio[ext!=webm]" \
--exec=mplayer -vvv "$*"
}
play rick astley never gonna give you up
- tombrossman 11y agoOne very minor annoyance I had was using it with BBC iPlayer. It works, but downloads the video as many dozens of tiny parts to reassemble. Since I use ~/Desktop as my default downloads folder, I created this to keep my desktop uncluttered while it runs: ytdl() { mkdir /tmp/ytdl && cd /tmp/ytdl for item in "$@" ; do youtube-dl "$@" ; done ; mv /tmp/ytdl/* ~/Desktop/ rm -rf /tmp/ytdl exit } Now I can Ctrl + Alt + T a new Terminal window, type ytdl http://www.bbc.co.uk/iplayer/episode/.. http://www.bbc.co.uk/iplayer/episode/... (can use multiple links) then minimise the window and move on to other things.
- porsupah 11y agoWouldn't get_iplayer be simpler? http://www.infradead.org/get_iplayer/html/get_iplayer.html http://www.infradead.org/get_iplayer/html/get_iplayer.html
- ekimekim 11y agoHave you considered opening an issue? Using the current directory as a temp directory seems like something that should be fixed, or at least made configurable.
- Yenrabbit 11y agoThis is brilliant! Thank you :) although I renamed it to yplay, since play is already used on my system.
- Cyph0n 11y agoExcellent use-case! It's not that much faster than just `!yt rick astley never gonna give you up` on DDG, but the advantage is that leaving my dev environment introduces... distractions.
- mafro 11y agoThis is very very awesome. I never bothered to read the man pages in enough detail to even know this was possible! A fine job my good man.
- scrollaway 11y agoFWIW, mpv (a very good fork of mplayer) integrates youtube-dl by default. So you can do `mpv "https://youtube.com/..."` https://youtube.com/..."`. In fact, VLC does too.
- jnpatel 11y agoDo you know if this downloads the file to completion, or streams it?