So, after fiddling with the previously mentioned wp-itunes Wordpress plugin, I have got it automatically adding the last song played when I publish — no more of this typing crap. Hit more to get the code changes…

Here is the code that I added, complete with ugly debugging code!:

add_action('publish_post', 'add_meta_tunes', 7);
function return_wp_itunes($limit = 10) {
        global $wpdb, $table_itunes, $blank_image, $local_offset;

        $results = $wpdb->get_results("SELECT * FROM $table_itunes ORDER BY added_date DESC LIMIT $limit");
        $retstring = "";
        if ($results) {
                foreach ($results as $itune) {
                        if ($itune->image == "")
                                $itune->image = $blank_image;

                        $retstring .= "
n"; $retstring .= "$itune->artist - $itune->album - $itune->trackn"; $retstring .= "
n"; } } return $retstring; } function add_meta_tunes($post_ID) { global $wpdb, $tablepostmeta; global $debug; if( !isset($post_ID)) $post_ID = $_REQUEST['post_ID']; $metakey = $wpdb->escape("tunes"); $metavalue = $wpdb->escape(return_wp_itunes(1)); $log = fopen("/tmp/wpitunes.log", "w"); fwrite($log, "Just testingn"); // Quick-n-dirty check for dups: $dupcheck = $wpdb->get_results("SELECT post_id FROM $tablepostmeta WHERE post_id='$post_ID'",ARRAY_A); if ($dupcheck[0]['post_id']) { $id = $dupcheck[0]['post_id']; fwrite($log, "Skipping duplicate post ID = $idn"); fclose($log); return $post_ID; } fwrite($log, "name = $metavaluen"); fclose($log); if (!empty($metavalue)) { $result = $wpdb->query(" INSERT INTO $tablepostmeta (post_id,meta_key,meta_value) VALUES ('$post_ID','$metakey','$metavalue') "); } return $post_ID; }