The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MP3::PodcastFetch:Feed -- Fetch and parse an RSS file

SYNOPSIS

 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";
 }

DESCRIPTION

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.

METHODS

This module implements the following methods:

$feed = MP3::PodcastFetch::Feed->new($url)

Create a new MP3::PodcastFetch::Feed object pointing to the indicated URL. The default fetch timeout is set to 10s.

$url = $feed->url([$new_url])

Get or set the RSS URL.

$error = $feed->errstr([$new_error])

Get or set an error message. Call errstr() after an unsuccessful fetch to find out what went wrong.

$timeout = $feed->timeout([$new_timeout])

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.

$env_proxy = $feed->env_proxy([$env_proxy])

Get or set the proxy usage for the RSS XML file fetch operation. The default is without proxy,

@channels = $feed->read_feed()

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.

Internal methods

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.

t_channel
t_item
t_title
t_description
t_guid
t_pubDate
t_author
t_itunes_author
t_enclosure

SEE ALSO

podcast_fetch.pl, MP3::PodcastFetch, MP3::PodcastFetch::Feed::Channel, MP3::PodcastFetch::Feed::Item, MP3::PodcastFetch::TagManager, MP3::PodcastFetch::XML::SimpleParser

AUTHOR

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.