Question for iTunes savy people

For some reason, my computer lost my computer's music library - the music is still there, but the playlists, playcounts and ratings, all gone. I've got around 4000 songs on this computer, and it syncs my iPhone, so I'm rather annoyed about this. Annoyed is a bit of an understatement at this point, because it's a long process to recreate everything the way that I had it. I learned, a little too late, of a way to use the .xml file in the iTunes folder to recreate the library - by the time I'd learned this, I'd already begun to rebuild everything from scratch.
While looking in the iTunes folder, however, I see that there's a ton of .tmp files, and I know that they're there to recreate part of the library. Does anyone know of a way to recreate the library from these files?
Or alternatively, does anyone know of a way to recreate the library from what is still on my iPhone?