#!/usr/bin/perl -w # cast.pl - by dual # # Perl podcast aggregator # # - Reads feed URLs from podcasts.txt. # - Include "all" after the URL to get # every MP3 in the feed. # - Otherwise, cast only grabs the # latest podcast. ###################################### # Include LWP::UA and URI ######################### use strict; use LWP::UserAgent; use URI; # Get the podcast addresses from a file ####################################### open CAST, ") { download ($_); } # Begin download function ######################### sub download { my $all; my $bit; my $test; # Check for and set the all "flag" ################################## 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); die $cast->status_line . "\n" unless $cast->is_success; # Read cast content into array ############################## my $content = $cast->content; # Grab the latest or every enclosure, # if it doesn't/they don't exist ##################################### while ($content =~ /\path_segments(); foreach $bit (@seg) { ($test = $bit) if ($bit =~ /.+\.mp3/); } system ("wget $1") unless -e $test; last unless $all == 1; } # End download ############## }