A Henry P. Erich III Blog

A Geek In and Around Orlando

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910


Navigation

Links

Subscriptions



Visual Studio is a Great Playlist Editor! or 2500 Songs Without Using a Single Meg of HDD!

My Media Player play list now has 2500 songs without using a single megabyte of hard disk space.

I subscribe to Easynews.com which for a short explanation is newsgroups via a browser.   For those of you who are familiar with newsgroups know you can find (a lot) of music within them.   One such group is ABS.mp3.complete_cd.   I had a yearning to be able to randomly listen to songs/files within this group so I can expand my appreciation of music to new levels.   A nice feature of Easynews is their web-based listing of the contents of newsgroups.

And a feature I find even nicer is the Easynews Advanced Search Page which members can find at http://members.easynews.com/global

After searching the complete_cd group for any media file within the last 30 days I get a listing of 4977 files via 500 file pages.   Now if I view source and copy and paste the HTML into a blank text file in Visual Studio I can do a few find and replaces to reformat the data to a playlist for Windows Media Player.

First, the format for a WMP playlist(.WPL) is like this:

<?wpl version="1.0"?>

<smil>

    <head>

        <meta name="Generator" content="Microsoft Windows Media Player -- 9.0.0.3075"/>

        <author/>

        <title>Temp</title>

    </head>

    <body>

         <seq>

                <media src="Path to mp3 file.mp3" />

                <media src="Path to mp3 file.mp3" />

                <media src="Path to mp3 file.mp3" />

                <media src="Path to mp3 file.mp3" />

       </seq>

   </body>

</smil>

The media nodes are the mp3 files.  Simple enough right?

Well…

The source html looks something like this now:

<tr id=”someid”><a href=”/news/filename.mp3”></tr>

With a few M3U’s thrown in too.  I will have to get rid of these lines.

<tr id=”someid”><a href=”/news/filename.m3u”></tr>

Each line from the html needs to be reformatted to a:

<media src=”http://members.easynews.com/news/filename.mp3” />

Here are some of the find and replaces I used.   These are good examples of how to use the regular expressions to reformat the data.   Also, from inside the find and replace window in Visual Studio you can find a link to more help on regular expressions.

Find What: ^.*href="/news

Replace With: <media src="http://members.easynews.com/news  

This replaces the first half of the line:

<tr id=”someid”><a href=”/news

With:

<media src=”http://members.easynews.com/news/

The ^ character anchors the find to the beginning of a line.

The .* matches any character of any amount.

Find What: .mp3"\>.*$

Replace With: .mp3" />

This replaces everything after and including the:

.mp3”></tr>

With:

.mp3” />

The $ character anchors the find to the end of the line.

The \ character escapes the following character.

Find What: ^.*tr\>$\n

Replace With:

This one gets rid of some extra lines.

The lines with the m3u did not have the previous mp3 replacement.

So now where the search find a line that ends in tr> it replaces the entire line.

The \n means new line, this find looks from the beginning of the line to the end of the line plus a new line character and replaces it with nothing, this effectively deletes the unwanted lines.

The end result about five minutes later is a 2500 song playlist without a single meg of my HDD used!

Now, I need to find a news server that can provide me with unlimited or a daily compromise for $10 a month.   If anyone knows of one please let me know.

posted on Monday, March 29, 2004 1:37 PM by he3





Powered by Dot Net Junkies, by Telligent Systems