I have a similar function in my bashrc, which also relies on youtube-dl (which is amazing, btw, it does a LOT more than YouTube – bandcamp, SoundCloud, etc).
I think the best part of youtube-dl is its support for bulk downloads. Point it at a YouTube account or playlist, a podcast on SoundCloud, or even, if you can live with yourself, an album on Bandcamp, and it will snarf up every piece of media it can find.
Some pro trips: by default it searches YouTube for the argument you give it, but if given a URL, youtube-dl will always use that instead. So `play <bandcamp URL>`, `mp3 <SoundCloud URL>` will work.
If the first result for your search isn't the song you want, I usually append "hq", "hd", or "album version".
Nice! Works fine on windows with gitbash except for the --exec part, I tried to use the "start" command but it doesn't like the single quote around the path, someone has an idea to workaround that?
1. "function" is non-standard useless syntax
2. mpv now knows how to automatically spawn youtube-dl, fetch the URL, and stream it given a YouTube argument.
per (1), these are my dotfiles and I use Bash exclusively, ergo, I use the syntax I consider better (because you can easily search for "function" and not the standard syntax with no keyword).
`play` will instantly play any song (great for parties), and `mp3` will download it: https://github.com/exogen/dotfiles/blob/730fb8e2b72b2fc3aa3d...