MP3::PodcastFetch:Feed -- Fetch and parse an RSS file
use MP3::PodcastFetch::Feed; my $feed = MP3::PodcastFetch::Feed->new('http://www.npr.org/rss/podcast.php?id=500001'); $feed->timeout(100); my @channels = $feed->read_feed; for my $c (@channels) { print "Title = ",$c->title,"\n"; }
This package provides convenient downloading and parsing of the subscription information in an RSS feed URL. It was written to support the podcast_fetch.pl script.
To use it, create an MP3::PodcastFetch:Feed object with the desired RSS URL. Set additional parameters such as timeout values. Then call the read_feed() method to get a list of MP3::PodcastFetch::Feed::Channel objects that contain various bits of information about the podcast subscription.
Internally, it is a subclass of MP3::PodcastFetch::XML::SimpleParser, a very straightforward sax-based XML parser.
This module implements the following methods:
Create a new MP3::PodcastFetch::Feed object pointing to the indicated URL. The default fetch timeout is set to 10s.
Get or set the RSS URL.
Get or set an error message. Call errstr() after an unsuccessful fetch to find out what went wrong.
Get or set the timeout for the RSS XML file fetch operation. The default timeout is 10s, meaning that the module will wait a maximum of 10 seconds to get a response from the remote server.
Get or set the proxy usage for the RSS XML file fetch operation. The default is without proxy,
This is the main workhorse method of the module. It tries to read and parse the RSS file at the previously-indicated URL. If successful, it returns a list of MP3::PodcastFetch::Feed::Channel objects containing information about each channel and the podcast episodes contained within them. If unsuccessful, it returns an empty list. You can use the errstr() method to find out what went wrong.
The following methods are used during the parse of the downloaded RSS file. See MP3::PodcastFetch::XML::SimpleParser for a description of how they work.
podcast_fetch.pl, MP3::PodcastFetch, MP3::PodcastFetch::Feed::Channel, MP3::PodcastFetch::Feed::Item, MP3::PodcastFetch::TagManager, MP3::PodcastFetch::XML::SimpleParser
Lincoln Stein <lstein@cshl.org>.
Copyright (c) 2006 Lincoln Stein
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty.
To install MP3::PodcastFetch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MP3::PodcastFetch
CPAN shell
perl -MCPAN -e shell install MP3::PodcastFetch
For more information on module installation, please visit the detailed CPAN module installation guide.