Making MP3 Playlists with PHP

Feb
20
2006

When I ripped a bunch of CD's a while back, I missed a setting that created playlists in the directory with the MP3's. As a result, I've got dozens and dozens of directories of MP3's and to play all of the files in a given directory, I have to "select all", etc.

It's been livable (because if you consider anything with MP3's to *not* be livable, your priorities are out of whack), but irritating for a while.

So, last night, I was looking for something to occupy my mind for 20 minutes or so and I figured I'd check this one off of my list. I did a quick lookup of the m3u file format (MP3 playlists if you didn't know) and saw that it's pretty simple.

There's a single line header:

#EXTM3U

followed by a pair of lines for each track in the playlist:


#EXTINF:82,You Are (The Government)
01 - You Are (The Government).mp3

The "82" is the length of the track in seconds, followed by the title of the song. The second line is just the mp3 filename itself (includes a path if you aren't ever going to move the files). I left it relative in my script because it looks in the current directory first. If you were putting your m3u files in a single place, they'd need better paths to where the music is directly.

Anyway, with that bit of information, I went and grabbed a PHP library for reading ID3 tags and set to work. I created a "playlist.php" file in the root directory of the getid3 library.

In that file, I created a single function that takes a directory path and creates a m3u of the mp3's in that directoy and drops it *into* that directory. At the moment, I'm just changing the directory variable and running it manually. However, I may put this function into a recursive script that digs through directories and checks for mp3's. If it finds an mp3 in a directory, it would create an m3u file there as well. That way, I could just point it at the top of the music tree and let it dig through.

But, that's another exercise. Here's the code for playlist.php.

Read the rest of this entry »

Fat Basset and the Vet

Feb
17
2006

Today, Rowdy and Bailey went to the vet for their annual exam, shots, etc. While we'd been musing that Bailey seems even fatter than normal, the vet confirmed it. While I've been losing weight over the last year, Bailey's somehow managed to put on . . . 8 . . . freaking . . . pounds.

Now, I know what you're thinking. "Of course she gained weight, you feed her too much." I know that's what you're thinking because that's what I'd be thinking.

But, here's the thing. For the past several months, she actually doesn't even eat half of what is in her bowl (portions the same as 2 years ago with the same food). Rowdy's been closer to 3/4 of his, but neither one is eating much at all. They only get one bite-sized treat a day and that's it. Yet, somehow they're getting fat.

We're going to start regular weigh-ins and strict monitoring to see if we can figure it out, but I'm wondering if we've got generous neighbors somewhere. It's happened in the past that we discovered neighbors on ALL sides all giving them a daily handful of treats. I didn't think we had this going on here too, but maybe we do. Maybe, they're getting all they need to eat from the neighbors and it isn't that nasty "lite" food that Mom and Dad feed them.

Unfortunately, it's hard to just go up to your neighbors and ask, "Are you feeding our dogs?". It just seems weird to say that.

Weather? Yeah, We've Got It. So?

Feb
17
2006

This comic really made me chuckle, given the contrast between the "we're all going to die, because winter weather is hitting us" that seems to have filled the news and internet channels over the last week and the downright clinical telling of fact that today's weather (radio reported wind chills of -37F [note the negative]) has brought to today's newspaper. No freaking out, just reporting the fact that it's really cold, that the commute wasn't affected and AAA isn't reporting any problems with travel. In other words, if you live in North America, while winter weather is worth reporting, calm the $%^& down about it. You'll survive.

And, if you're going to start going on about it, you'd better be prepared to beat the comparisons that the folks in Canada, Minnesota, North Dakota and other places where winter is just part of life.

JavaScript Libraries and Patterns: Yahoo! Does AJAX

Feb
17
2006

A few days ago, Yahoo released a couple of things as libraries, including a Javascript widget library. I quickly downloaded it and got as far as checking out the examples, before life got in the way of messing with it further. My delay has proven worthwhile, though, because one of my big questions: Which one of the 987 Javascript libraries should I be using? is partially addressed in a Sitepoint article. JavaScript Libraries and Patterns: Yahoo! Does AJAX talks about some of this stuff.

I do, however, have to say that 5 years ago, if more than 100 lines of Javascript was "unheard of" in your circles, you weren't hanging out with many decent web developers. Hell, I remember Aaron writing an entire CMS for publishing articles on a college newspaper, in Javascript, in 1997. Just because the entire world seems to have discovered XMLHttpRequests and Javascript's actual usefullness in the last year doesn't mean they haven't been used for much longer than that.

Aside from that little diatribe of mine, I generally found the article worth reading. I've just been feeling a little, old I guess, lately when reading about web development as it seems so many article authors wrote their first HTML in the last 3 years and have absolutely no history. Further depressing is the fact that the web has history at this point and that I was present for pretty much all of it.

When I read about people waxing nostalgic about being able to read "all the blogs", I remember being able to read every site in Yahoo and pretty much all of the web, not just a small niche of it. Others memories go back much further. I remember *why* we used tables for layout and see why many of the current CSS hacks like stacked "floats" are the exact same kind of thing: using elements that sort of work to get around inherent deficiencies in the setup. And, when CSS3 gets implemented, there will be a backlash against it just like there was against tables (which are still a quick way to get complex grids to work on the web where CSS is still a pain).

Or maybe I just found more grey in my beard this morning and I'm cranky because of that and being sick.

Cheap Prescription Sunglasses and Why You Don't Want Transitions

Feb
17
2006
J Sunglasses

Along with the mixed up laptop, my new prescription sunglasses arrived this week. I ordered them from 39 Dollar Glasses again this time and was pleased again with the results. I get my prescription from the eye doctor and order online.

Sometimes I don't get any glasses from the store (though I did this time), but since I have to pay full-price for the exam, I have no problem with that. In most of these places, the eye doctors are independent entities anyway, so I have absolutely no problem getting my sunglasses for $50 instead of $250.

When you order from the site, you'll need your prescription, but you'll also need your "pupilary distance", which is the distance between your eyes. I've had to specifically ask that this be added to my prescription every time I've gotten one written down. They don't include this unless you ask for it.

I get pretty basic metal rimmed glasses, an there isn't a lot of style in most men's frames anyway (unless you decide to get WAY too pretentious for my taste), so I don't need to try them on to choose. Besides, I can't really see when I've got the demo frames on anyway, so they always look different in reality by the time they arrive.

To me, it's a great option for sunglasses, a second pair for sports or outdoor activities, etc. if not for your primary pair.

One last caveat. Transitions lenses (the ones that darken in sunlight) are UV sensitive in how they work. The catch is that you don't get enough UV while in a car. This means that if you want sunglasses for driving purposes, the Transitions are utterly useless. As I'm not much of an outdoors person (sports, hunting, etc.), my primary reason for shades is driving, which led to serious frustration when I paid the extra to get these the last time around. Never again. Don't buy the hype. If the sun isn't shining directly on them, they don't work like you think.

« Older Entries   Newer Entries »

J Wynia

For better or worse, I'm the guy who runs things here. I'm a web consultant, software developer, writer and geek from Minneapolis, MN. This site is a fairly wide cross-section of the things I'm interested in and enjoy writing about.

Oh, and if you happen to be looking for hosting for your Subversion repositories or just web hosting in general, take a look at Dreamhost. It's what I use for Subversion and your signup helps me out.

Feeds and Links


www.flickr.com
This is a Flickr badge showing public photos from J Wynia. Make your own badge here.

Search


Pages

Archives

Computers Blog Directory
© 2003-2008 J Wynia. All original content is licensed under the terms of the Creative Commons Attribution license unless otherwise noted. Content from other sources is licensed under its original terms.