0

Currently running a MPD source to Icecast2 on my Raspberry Pi 3, using HTTPS.
Everything is working smoothly, however upon retrieving metadata from Icecast using the status-json.xsl file (and opening it directly), all I can find as relevant metadata is the artist and title of the song.
I would also like to be able to retrieve the album for the current song; upon browsing the MPD documentation, I uncommented metadata_to_use in /etc/mpd.conf and tailored it to my needs :
metadata_to_use "artist,album,title,name"

This being done, I restarted Icecast2 and MPD, but on the status-json.xsl file, no additional tags are available.
I thought tags, when required, would appear as additional information on the status-json.xsl file, but I was apparently wrong.
I did not find any relevant property in the part of Icecast2 as far as metadata go.

Could someone please clarify where I am supposed to find the additional tags I need?
Or, if I misconfigured anything, what I am supposed to look for?
Thanks a lot!

Shinkel
  • 11
  • 1
  • I think this is a limitation on the mpd side. Haven't checked in a long while, but they used to use the legacy mechanics even for modern formats. – TBR Dec 29 '21 at 19:29
  • Dang. Thanks for you answer. I will post below the solution I've come up with, just in case someone needs it; but it's really a major workaround :( – Shinkel Dec 29 '21 at 19:43

1 Answers1

1

OK so, long story short, no could do.
Upon reading on the Interweb, I discovered that mpd comes with its own httpd server, and indeed, after making it work, there was simply no need for Icecast2 anymore.

For those interested into how to manage that, here goes :
mpd.conf :

  • Enable the "gapless "yes" to the decoder{} block :
  • Comment out the WHOLE audio_output{} used to mount to Icecast2 (the Shout one)
  • Enable the audio_output{} type "httpd",
  • Set a different port, e.g 8100, should you wish to keep Icecast compatibility for later,
  • Ensure you have encoder "vorbis" as Lame did not work for me as far as metadata go,
  • Ensure you have EITHER bitrate OR quality enabled, not both (will not start anyway)
  • and add after max_clients :
    always_on "yes"
    tags "yes"

    Now, for the metadata parsing : it's a function graciously given here used to break down the data.
    Please note it does not autorefresh yet, but it works.

<!DOCTYPE html>
<html>
    <body>
      <?php
        function get_string_between($string, $start, $end)
        {
            $string = ' ' . $string;
            $ini = strpos($string, $start);
            if ($ini == 0) return false;
            $ini += strlen($start);
            $len = strpos($string, $end, $ini) - $ini;
            return substr($string, $ini, $len);
        }
    
        $fp = fsockopen("192.168.1.10",8100,$errno,$errstr,1);
        if (!$fp)
        {
            echo "$errstr ($errno)<br />\n";
        }
        else
        {
            $out = "GET / HTTP/1.1\r\n";
            $out .= "Host: www.example.com\r\n";
            $out .= "Connection: Close\r\n\r\n";
            fwrite($fp, $out);
            
            $stop=false;
            $album='';
            $artist='';
            $title='';
            
            while(!$stop)
            {
                if(feof($fp)) $stop=true;
                
                $buff=fgets($fp, 512);

                $album=get_string_between($buff,'ALBUM=','vorbis+');
                if($album!=false) $stop=true;
                
                $title=get_string_between($buff,'TITLE=','ALBUM=');
                if($title!=false) $stop=true;
                
                $artist=get_string_between($buff,'ARTIST=','TITLE=');
                if($artist!=false) $stop=true;
            }
            
            if($album==false) $album='n/a';
            if($title==false) $title='n/a';
            if($artist==false) $artist='n/a';
            
            fclose($fp);
            
            echo("<table><tr><td align=center><b>$artist</b> - $title</td></tr>");
            echo("<tr><td align=center><i>$album</i></td></tr></table>");
        }
        ?>
    </body>
</html>

Admittedly, it is a first draft and despite it not working like perfectly, it does work for me, so I hope it helps others!

Shinkel
  • 11
  • 1