Parsing Podcasts with MagpieRSS
MagpieRSS, my favorite RSS and Atom parser for PHP, doesn’t natively support the <enclosure> tag used in podcasts. This is because Magpie looks for values between an open and close tag and the enclosure is modeled with attributes:
<enclosure url="http://www.leipzig48.com/compositions/ghost/tistime.mp3" length="30720" type="audio/mpeg" />
The developer of Magpie is currently working on standardizing the handling of attributes, but, in the interim, there is a patch available to handle enclosures (thanks to Jude Venn and Mike Krus). This is good, because a podcast without an enclosure isn’t much of a podcast.
- Download the patched version of rss_parse.inc.
- Replace the current rss_parse.inc with the downloaded patch.
- Access the <enclosure> attributes in your script:
echo $arrItem[’enclosure’][0][’url’];
echo $arrItem[’enclosure’][0][’length’];
echo $arrItem[’enclosure’][0][’type’];
