65.9K
CodeProject is changing. Read more.
Home

MP3 Playlist Generator

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.29/5 (11 votes)

Jul 3, 2003

CPOL

4 min read

viewsIcon

260675

downloadIcon

3352

This is a free tool for enumerating a specifically-structured MP3 collection and creating .m3u playlist files.

Sample Image - playlistgenerator.gif

Generated HTML file without stylesheet applied

Introduction

I wrote this tool because I grew tired of manually creating playlists each and every time I added an album to my collection. The tool recurses the directories of a specifically-structured MP3 collection on your hard disk. During the enumeration, several MP3 playlist files are created, allowing you to access your collection via a Web page.

This tool is for you if:

  • Your collection contains entire CDs and is arranged by artist and album (see "Directory Structure" below).
  • Your collection resides on a machine capable of being a Web server.

If you don't meet the above requirements, then please stop reading here.

Terminology

Host Name Your Web server's host name (e.g., server in the URL http://server/).
Virtual Directory The path in the URL that points to your MP3 collection (e.g., mp3 in the URL http://server/mp3/).
MP3 Root Directory The physical path on disk to your MP3 collection (e.g., E:\mp3).

Directory Structure

The playlist generator will work for you if your collection has the following directory structure:

  • <MP3 Root>
    • <Artist0>
      • <Album0>
        • <Song0>.mp3
        • <Sing1>.mp3
          ...
        • <SongN>.mp3
      • <Album1>
        • <Song0>.mp3
        • <Sing1>.mp3
          ...
        • <SongN>.mp3
    • <Artist1>
      • <Album0>
        • <Song0>.mp3
        • <Sing1>.mp3
          ...
        • <SongN>.mp3
      • <Album1>
        • <Song0>.mp3
        • <Sing1>.mp3
          ...
        • <SongN>.mp3
      ...
    • <ArtistN>
      • <Album0>
        • <Song0>.mp3
        • <Sing1>.mp3
          ...
        • <SongN>.mp3
      • Album1>
        • <Song0>.mp3
        • <Sing1>.mp3
          ...
        • <SongN>.mp3

The artist, album, and song names do not have to be in any particular format; however, I find that prepending the track number to the song name helps if you like to listen to the tracks in the same order that they appear on the CD. A typical directory might look like the following:

  • mp3
    • Weird Al Yankovic
      • Permanent Record - Al In The Box - Disc 1
        • 01 My Bologna.mp3
        • 02 Another One Rides The Bus.mp3
          ...
        • 12 King Of Suede.mp3

The physical path on disk to such a directory would look like this: <drive letter>:\mp3\Weird Al Yankovic\Permanent Record - Al In The Box - Disc 1\.

Files Created During Execution (.htm and .m3u)

The following files are created during the execution of the MP3 Playlist Generator:

index.htm Located in the MP3 Root Directory, this file contains links to all of the generated .m3u files, sorted alphabetically by artist and album. This is the file that you access via the Web server.
(e.g., <MP3 Root Directory>\index.htm)
All.m3u Located in the MP3 Root Directory, this playlist contains entries for all songs by all artists in your collection
(e.g., <MP3 Root Directory>\All.m3u)
<Artist>.m3u Located in the artist's directory, these playlists contain entries for all songs in all albums for the specified artist
(e.g., <MP3 Root Directory>\Weird Al Yankovic\Weird Al Yankovic.m3u)
<Album>.m3u Located in each album's directory, these playlists contain entries for all songs in a particular album.
(e.g., <MP3 Root Directory>\Weird Al Yankovic\Permanent Record - Al In The Box - Disc 1\Permanent Record - Al In The Box - Disc 1.m3u)

If the files already exist, their contents are truncated, so each time the program is run, the playlists and the HTML files are all refreshed.

Setting Up Your MP3 Server

Enable IIS

In order to access the Web page created by the MP3 Playlist Generator, you will need to enable IIS. Please refer to your OS's documentation on how to install and enable IIS.

Create a Virtual Directory for your MP3 Root Directory

In the IIS MMC snap-in, create a virtual directory for your MP3 Root Directory. Please refer to your OS's documentation on how to create a virtual directory.

Enable Default Document Support for index.htm files

If not already enabled for your Web server, enable default document support for index.htm files. Please refer to your OS's documentation on how to enable default document support for specific file types.

Running the MP3 Playlist Generator

  • Copy the program to anywhere on your hard drive and launch it.
  • Insert appropriate values for Host Name, Virtual Directory, and MP3 Root Directory.
  • Click the "Generate .m3u Files" button.

That's it! You should now be able to browse to http://<Host Name>/<Virtual Directory>/ and view a list of your MP3 collection!

To-do List

This tool is by no means polished. Here is a short list of enhancements that I need to make:

  • Add stylesheet for generated HTML file (it's on my home computer, which doesn't have an Internet connection at the moment)
  • Persist user's settings in the registry. Currently, they are hard-coded into the app.
  • Insert a browse dialog to allow users to browse for their MP3 Root Directory.
  • Add a "last generated" timestamp to the HTML file.
  • Add statistics to the HTML file (# artists, # albums, # songs).

If you have any features you would like to see, please post them in the forum below.

History

Version Comments
1.0.0
03 Jul 2003
Initial public release.