#!/bin/sh
FINAL_FILE=funny.xml
TEMP_FILE=funny.$$.xml
TEMP_XSLT=funny.$$.xsl
WGET="/sw/bin/wget -q -O -"
XSLT=/sw/bin/xsltproc
# RSS header
cat > $TEMP_FILE << _HERE_
<?xml version="1.0"?>
<rss xmlns:itunes="http://www.itunes.com/DTDs/Podcast-1.0.dtd" version="2.0">
<channel>
<title>Doctor-Demento Related</title>
<link>http://www.themadmusicarchive.com/</link>
<description>Manic Mondays, Freakin Funny Music, and The Mad Music Hour in one feed</description>
<lastBuildDate>Sat, 03 Dec 2005 16:00:24 -0500</lastBuildDate>
<language>en-us</language>
<copyright>Copyright 2005 TheMadMusicArchive.com</copyright>
<generator>dirCastv0.4</generator>
<webMaster>wayne@themadmusicarchive.com</webMaster>
<ttl>60</ttl>
<!--iTunes specific tags-->
<itunes:category text="Comedy" />
<itunes:category text="Movies & Television">
<itunes:category text="Music" />
</itunes:category>
<itunes:keywords>TheMadMusicArchive, comedy, Dr. Demento, dementia, funny mu
sic, funny songs, funny, weird, music</itunes:keywords>
<itunes:subtitle>Bringing you an hour of funny music every Saturday night at
9:00 P.M. Eastern Time.</itunes:subtitle>
<itunes:summary>Sit back, kick your feet up, call in the kids and enjoy some
good clean fun!</itunes:summary>
<itunes:image href="http://www.themadmusicarchive.com/madmusichour.jpg" />
<itunes:author>Captain Wayne</itunes:author>
<itunes:owner>
<itunes:name>Wayne Ross</itunes:name>
<itunes:email>wayne@themadmusicarchive.com</itunes:email>
</itunes:owner>
_HERE_
# Temporary XSL file
cat > $TEMP_XSLT > $TEMP_XSLT << _HERE2_
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/xhtml1/strict">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:apply-templates select="/rss/channel/item" />
</xsl:template>
<xsl:template match="item">
<xsl:copy-of select="." />
</xsl:template>
</xsl:stylesheet>
_HERE2_
# Get each feed
$WGET http://www.themadmusicarchive.com/pod128k.xml \
| perl -pne 's/([^<])\/itunes:duration/$1<\/itunes:duration/' \
| $XSLT $TEMP_XSLT - \
| perl -pne 's/\<\?xml .*?\?\>//' \
>> $TEMP_FILE
$WGET http://www.suddendeath.org/cast/feed.xml \
| $XSLT $TEMP_XSLT - \
| perl -pne 's/\<\?xml .*?\?\>//' \
>> $TEMP_FILE
$WGET http://www.jakewaters.com/podcast/cast.xml \
| $XSLT $TEMP_XSLT - \
| perl -pne 's/\<\?xml .*?\?\>//' \
>> $TEMP_FILE
# Close file, rename temp to actual
echo "</channel></rss>" >> $TEMP_FILE
mv $TEMP_FILE $FINAL_FILE
rm $TEMP_XSLT