I was reading this article on m3u files and decided to scratch one of my long-term itches, building a decent windows playlist on the file server. It’s a.. large collection, so I don’t want to build things on the client end, you see, it takes bloody ages.
Up till now, I’ve just created a list of paths, and used that as the playlist. This had 3 disadvantages:
- it’s very hard to have it sorted by anything useful, using the filename is hopeless as there are several different naming conventions involved. blech’s fault.
- I’d quite like to have the track lengths already by the tracks when winamp starts, as opposed to have it add them whenever you see them.
- for some reason, winamp starts much faster when there are EXTINF tags in the playlist file. Don’t know why. Don’t care.
So now I search the server for files, read the id3 tags, sort by artist/album/tracknum/title and print out, along with the track length and name in an EXTINF tag. The whole process takes almost exactly 2 mins, but it’s not very memory-efficient. For various complicated reasons the server has almost a gig of memory in it (ok, they’re not complicated reasons - we just don’t own any other boxes that can use the stuff) so I don’t care about this.
code is here, if you care. It’s hard-coded for my server, but the only thing you’d really need to change is at the beginning, where $root and $remote are defined - $root needs to be where the music lives on the server, $remote is where it lives on the network. For my server, I samba share /music on the server cowboy as cowboymusic. Also, $playlist should be where you want the playlist to go.