notandy / ympd

Standalone MPD Web GUI written in C, utilizing Websockets and Bootstrap/JS
http://www.ympd.org
GNU General Public License v2.0
523 stars 144 forks source link

youtube-dl integration #151

Open nariox opened 7 years ago

nariox commented 7 years ago

Hi, I'm wondering if it'd be possible to integrate youtube-dl so youtube links (or other supported websites) could be pasted into ympd and played.

I currently have a shairport-sync/mpd server set-up, but since I don't personally own any apple products (wife owns iPad), I find myself not being able to stream playlists/music directly from my own devices. Workarounds are welcome too, but I think an youtube-dl tab/plugin would be neat!

kousu commented 5 years ago

I was thinking about this problem too. I think it might be better solved as a playlist plugin on the server side. For example, soundcloud:// URLs are handled by https://github.com/MusicPlayerDaemon/MPD/blob/ce49d99c2f3265f2975b2cff583684bf191bbd93/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx. It looks like it wouldn't be too hard to fork that and shove a call to youtube-dl -gx in there.

kousu commented 5 years ago

Also, YouTube streams don't have the metadata nicely embedded and they probably aren't the only one, so we should fall back on youtube-dl's metadata extractors would be good. If I youtube-dl -gx http://youtube.com/watch?v=something | mpc add then I just get a big messy URL on the playlist. In comparison, youtube-dl -gx http://bandcamp.com/track/something | mpc add does also leave a long URL in the playlist, but once mpd plays it it gets the metadata out of the stream and relabels the entry with that.

kousu commented 5 years ago

Oh snap, someone forked the entire project to add this feature: https://github.com/bjuriewicz/ympd-youtube

But they did it by adding a folder to cache mp3s to and running

youtube-dl --max-quality=140 --extract-audio --audio-format=mp3 

which wouldn't be my first choice, especially when youtube-dl -gx exists.

Emilot commented 5 years ago

Also look at...

https://github.com/mayflower/maympd

kousu commented 5 years ago

ympd-youtube and maympd both ask youtube-dl to download the file and embed id3 tags in it, so then mpd will load up the metadata correctly. But I'd rather stream, not download. My servers don't necessarily have a lot of space I can fill up and forget about.

HyShai commented 5 years ago

There's an active PR on the main MPD repo to add a youtube-dl plugin - https://github.com/MusicPlayerDaemon/MPD/pull/223