I think I have a little problem with this script re timestamps for the played table entries
Assuming that this is run after an iPod sync:
Shouldn't the date run backward from the last played date rather than forwards from the added date or last played date (from played table)?
i.e. The sync increases the playcount and changes the last played date so immediately we are missing a corresponding played table entry for the last played date.
If the play count is > 1 then it would have been played prior to the last played date but after the last played date from the played table.

