Cover art in del.icio.us RSS feeds

Cool thing #2: Using rvw!, del.icio.us, RSS, Magpie and RSSWriter to add cover images from Amazon to your del.icio.us RSS feed (see this feed for an example).

Magpie code:


require_once(MAGPIE_DIR.'rss_fetch.inc');
include("rss10.inc");
$rss = fetch_rss( "http://del.icio.us/rss/USERNAME" );
$channel = $rss->channel;
$out = new RSSWriter($channel['link'], $channel['title'], $channel['description']);
$out->useModule("content", "http://purl.org/rss/1.0/modules/content/");
foreach ($rss->items as $item) {
    $subject_array = split(" ", $item['dc']['subject']);
    $img_url = "";
    $content = "";
        foreach ($subject_array as $tag){
        if (preg_match("/urn\:(asin|isbn)\:(.*)/", "$tag", $matches)){
	       $img_url = "http://images.amazon.com/images/P/$matches[2].02.MZZZZZZZ.jpg";
	       $content = "<img src=$img_url>".$item['description'];
        }
    }
    
    $out->addItem($item['link'], $item['title'], 
        array("description" => $item['description'],
            "content:encoded" => $content,
            "dc:creator" => $item['dc']['creator'],
            "dc:date" => $item['dc']['date'],
            "dc:subject" => $item['dc']['subject']));
}
$out->serialize();