getvodcasts.pl

Just a simple perl script to cycle through a list of rss feeds and pump out any media urls contained in the “enclosure element” of each item.


Here’s the basic code. I’ve also written a cgi version that prints the urls as hyperlinks (I’ll post that as soon as its been polished a bit more).

The heart of this script is the XML::FeedPP module.

#!/usr/bin/perl

use XML::FeedPP;

my @sources = (
 'http://www.cbsnews.com/common/includes/podcast/podcast_eveningnews_video_1.rss',
 'http://podcastfeeds.nbcnews.com/audio/podcast/MSNBC-NN-NETCAST-M4V.xml',
 'http://www.nasa.gov/rss/TWAN_vodcast.rss',

);

foreach my $source(@sources) {

  my $feed = XML::FeedPP->new($source);
  my $title = $feed->title();
  print $title, "n";
  foreach my $item ( $feed->get_item() ) {
     my $medialink = $item->get('enclosure@url');
     my $pubdate = $item->pubDate();
     print $pubdate, "n";
     print $medialink, "n";
  }
  print "n";
}
__END__;

Output looks like this:

NBC Nightly News (video)
2012-06-11T17:03:11-08:00

One thing I’d like to do with this is find a way to automate creating external link objects in mediatomb, the upnp media server software I run at home. All I need now is an example of how to create such an object via mediatomb’s javascript api.