<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Recent Posts in 'SHOUTcast server: mp3_manager module' | Pragmatic Forums</title>
    <link>http://fora.pragprog.com/forums/27/topics/195</link>
    <language>en-us</language>
    <ttl>60</ttl>
    <description></description>
    <item>
      <title>SHOUTcast server: mp3_manager module posted by Joe Armstrong @ Fri, 11 Jan 2008 11:00:53 -0000</title>
      <description>&lt;p&gt;Excellent. The reason for dumping to a .tmp file was that I sometimes manually removed&lt;br /&gt;some files before renaming to mp3data.&lt;/p&gt;


	&lt;p&gt;Unfortunately it proved to be rather difficult to write code that correct unpacks &lt;strong&gt;all&lt;/strong&gt; ID3 tags&lt;br /&gt;these can be at the start or end of the file &amp;#8211; and some of them seem to have been written by buggy programs so the tags are not according to the standards. Correctly parsing all possible&lt;br /&gt;tags might make a nice project. The code in the book should give you some ideas as how to start this.&lt;/p&gt;


	&lt;p&gt;Incidentally, I was able to make the shoutcast code in the book run with my soundbridge so I could &lt;br /&gt;remotely control the soundbrideg &amp;#8211; If I had more time I&amp;#8217;d persue this more&amp;#8230;.&lt;/p&gt;


	&lt;p&gt;Cheers&lt;/p&gt;


	&lt;p&gt;/Joe Armstrng&lt;/p&gt;</description>
      <pubDate>Fri, 11 Jan 2008 11:00:53 -0000</pubDate>
      <guid isPermaLink="false">fora.pragprog.com:27:195:2152</guid>
      <author>Joe Armstrong</author>
      <link>http://fora.pragprog.com/forums/27/topics/195</link>
    </item>
    <item>
      <title>SHOUTcast server: mp3_manager module posted by Alain O'Dea @ Tue, 01 Jan 2008 18:16:04 -0000</title>
      <description>&lt;p&gt;Certain &lt;span class="caps"&gt;MP3&lt;/span&gt; files will cause the &lt;code&gt;shout&lt;/code&gt; module to log an error. In the &lt;code&gt;mp3data&lt;/code&gt; file they show up with format &lt;code&gt;{File,no}&lt;/code&gt; instead of the expected &lt;code&gt;{File, {_Tag, Info}}&lt;/code&gt;. This seems to be because &lt;code&gt;mp3_manager:parse_start_tag/1&lt;/code&gt; only reads &lt;span class="caps"&gt;ID3&lt;/span&gt; tags.&lt;/p&gt;


	&lt;p&gt;Here is a simple solution. Refactor and extend &lt;code&gt;shout:unpack_song_descriptor/1&lt;/code&gt; as follows:&lt;br /&gt;&lt;pre&gt;unpack_song_descriptor({File, Metadata}) -&amp;gt;
    PrintStr = get_print_str(Metadata),
    L1 = ["StreamTitle='", PrintStr,
          "';StreamUrl='http://localhost:3000';"],
    %% io:format("L1=~p~n", [L1]),
    Bin = list_to_binary(L1),
    Nblocks = ((size(Bin) - 1) div 16) + 1,
    NPad = Nblocks*16 - size(Bin),
    Extra = lists:duplicate(NPad, 0),
    Header = list_to_binary([Nblocks, Bin, Extra]),
    %% Header is the SHOUTcast header
    {File, PrintStr, Header}.

get_print_str({_Tag, Info}) -&amp;gt;
    list_to_binary(make_header1(Info));
get_print_str(no) -&amp;gt;
    &amp;lt;&amp;lt;"UNKNOWN"&amp;gt;&amp;gt;.&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;This makes &lt;code&gt;shout:unpack_song_descriptor/1&lt;/code&gt; tolerant of incomplete metadata extraction from &lt;code&gt;mp3_manager&lt;/code&gt; and allows the SHOUTcast server to play songs with broken &lt;span class="caps"&gt;ID3&lt;/span&gt; tags or non-ID3 tags. I love how straight-forward refactoring is in Erlang.&lt;/p&gt;</description>
      <pubDate>Tue, 01 Jan 2008 18:16:04 -0000</pubDate>
      <guid isPermaLink="false">fora.pragprog.com:27:195:2091</guid>
      <author>Alain O'Dea</author>
      <link>http://fora.pragprog.com/forums/27/topics/195</link>
    </item>
    <item>
      <title>SHOUTcast server: mp3_manager module posted by Alain O'Dea @ Tue, 01 Jan 2008 17:38:46 -0000</title>
      <description>&lt;p&gt;I added a function &lt;code&gt;start/0&lt;/code&gt; to mp3_manager.erl to support a configuration file called &lt;code&gt;mp3_manager&lt;/code&gt;. The format of the config file is &lt;code&gt;{Root, Pattern}.&lt;/code&gt;:&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;mp3_manager.erl:&lt;/strong&gt;&lt;br /&gt;&lt;pre&gt;start() -&amp;gt;
    {ok,[{Root, Pattern}|_]} = file:consult(mp3_manager),
    Files = lib_files_find:files(Root, Pattern, true),
    V = map(fun handle/1, Files),
    lib_misc:dump("mp3data", V).&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;mp3_manager:&lt;/strong&gt;&lt;br /&gt;&lt;pre&gt;{"/Users/alain/Music/iTunes/iTunes Music", "*.mp3"}.&lt;/pre&gt;&lt;/p&gt;


	&lt;p&gt;I noticed after I ran the modified mp3_manager module that it creates a file called &lt;code&gt;mp3data.tmp&lt;/code&gt; instead of just &lt;code&gt;mp3data&lt;/code&gt; as the &lt;code&gt;shout&lt;/code&gt; module expects. For some reason &lt;code&gt;lib_misc:dump/2&lt;/code&gt; appends &lt;strong&gt;.tmp&lt;/strong&gt; to the filename passed into it before writing.&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;lib_misc&lt;/code&gt; will need to be modified not to append &lt;strong&gt;.tmp&lt;/strong&gt; or the dumped file will have to be renamed to allow the SHOUTcast server to start.&lt;/p&gt;</description>
      <pubDate>Tue, 01 Jan 2008 17:38:46 -0000</pubDate>
      <guid isPermaLink="false">fora.pragprog.com:27:195:2090</guid>
      <author>Alain O'Dea</author>
      <link>http://fora.pragprog.com/forums/27/topics/195</link>
    </item>
    <item>
      <title>SHOUTcast server: mp3_manager module posted by Alain O'Dea @ Tue, 01 Jan 2008 04:17:21 -0000</title>
      <description>&lt;p&gt;The SHOUTcast server example uses the mp3_manager module. This module is not described in the book and its code is not provided in the book. The code from the site includes mp3_manager.erl, but it includes hard-coded paths for Joe&amp;#8217;s own computer.&lt;/p&gt;


	&lt;p&gt;How does the mp3_manager module work and what needs to be changed to make it work on Mac &lt;span class="caps"&gt;OS X&lt;/span&gt;?&lt;/p&gt;</description>
      <pubDate>Tue, 01 Jan 2008 04:17:21 -0000</pubDate>
      <guid isPermaLink="false">fora.pragprog.com:27:195:2089</guid>
      <author>Alain O'Dea</author>
      <link>http://fora.pragprog.com/forums/27/topics/195</link>
    </item>
  </channel>
</rss>
