#!/usr/bin/perl -w # podgrab.pl - by dual # # Grabs your podcasts # # - Reads feed URLs from feeds.txt. # # - Include "all" after the feed URL # to get every MP3 in the feed. # Otherwise, podgrab grabs the # latest podcast. #################################### use strict; use LWP::UserAgent; #================================ # SET USER DEFINED VARIABLES HERE # Podcasts directory my $dir = '/some/dir/podcasts'; # Feeds XML my $xml = '/some/dir/feeds.txt'; #================================ # Change working directory chdir $dir; # Get the podcast addresses from config file open my $feeds, '<', $xml or die "Can't open feeds.txt: $!"; # Read the podcast URLs and pass # them to the download function while (<$feeds>) { download($_) unless /^#|^\s+$/; } # Begin download function sub download { # Check for and set the all flag my $all; chomp(my $url = $_[0]); if ($url =~ s/\s+all$//) { $all = 1; } else { $all = 0; } # Grab the content and check status my $browser = LWP::UserAgent->new(); my $cast = $browser->get($url); my $stat = $cast->status_line; print "$stat\n\n" unless $cast->is_success; # Read in cast content my $content = $cast->content; # Grab the podcasts(s) if we haven't before while ($content =~ /