[request] add youtube-dl stream capabilities
it would be awesome if mpd could make use of youtube-dl capabilities ...
youtube-dl is able to get the real (audio) stream of any given media-website. something like youtube-dl -x -g <$link> will give you the temp. usable link and only the audio string. actually i am using a script
#!/bin/bash
link="$1"
echo -n $(youtube-dl --get-id $link) $(youtube-dl -e $link)
echo mpc --host 172.16.0.123 add `youtube-dl -x -g $link`
mpc --host 172.16.0.123 add `youtube-dl -x -g $link`
but this has drawbacks, like i must use terminal magic .. i would love to simply add a stream and given by the url it "automaticly" try to fetch the actual streaming ip. (sidenode, with mpc add - there is no way to manipulate add_trackname?!)
(or maybe you can point me a way how i can do it inside mpd code, or smbd. else have done this)
See https://github.com/MusicPlayerDaemon/MPD/pull/223
There is a way to manipulate track name (and other tags). Here's a script (written in fish) that does a similar thing:
#!/bin/fish
function set_tag -a songid tag value
begin
echo "addtagid $songid $tag \"$value\""
sleep 1
end | telnet $mpd_host $mpd_port
end
set mpd_host localhost
set mpd_port 6600
set artist $argv[1]
set title $argv[2]
set json_data (yt-dlp -j "ytsearch:$artist $title")
set url (echo "$json_data" | jq -r '.["requested_formats"][] | select(.["resolution"] == "audio only")["url"]')
set thumb (echo "$json_data" | jq -r '.thumbnails|last|.url')
set songid (
begin
begin
echo "addid $url"
sleep 1
end | telnet $mpd_host $mpd_port 2>/dev/null
end | awk '/^Id:/{print $NF}'
)
set_tag $songid Artist "$artist"
set_tag $songid Title "$title"
Example usage:
add_yt.sh 'Rick Astley' 'Never Gonna Give you up'