Subject: | podcast() method fails to run, RSS output has bad date formats |
MP3::Podcast->podcast() method call fails because of an improper call to MP3::Info-
Show quoted text
>get_mp3tag.
Date formats of pubDate elements do not match RFC 2822.
Enclosure elements contain a size element that shouldn't be there. length is proper per the
RSS spec.
The patch attached fixes all three of these issues.
Perl 5.8.8
MP3::Info 1.23
XML::RSS 1.32
OSX 10.5.2 (Darwin 9.2.0)
Subject: | Podcast.pm-0.5.patch |
diff --git a/lib/MP3/Podcast.pm b/lib/MP3/Podcast.pm
index e5dc8cb..8471ceb 100644
--- a/lib/MP3/Podcast.pm
+++ b/lib/MP3/Podcast.pm
@@ -47,6 +47,7 @@ use warnings;
use XML::RSS;
use URI;
use MP3::Info;
+use POSIX qw(strftime);
our $VERSION = '0.05';
@@ -87,14 +88,14 @@ sub podcast {
my $description = shift || $title;
my $sort = shift;
my $rss = XML::RSS->new( version => '2.0',
- encoding=> 'iso-8859-1' );
+ encoding=> 'UTF-8' );
my $urlbase = $self->{'urlbase'};
my $dirbase = $self->{'dirbase'};
$rss->channel(title => $title,
link => "$urlbase/$dir",
publisher => $creator,
- description => $description );
+ description => $description );
my $poddir="$dirbase/$dir";
my $podurl="$urlbase/$dir";
@@ -110,19 +111,17 @@ sub podcast {
next if $file !~ /\.[Mm][Pp]3$/i;
my $filePath="$poddir/$file";
my @stat = stat($filePath);
- my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($stat[9]);
+ my $pubdate = strftime("%a, %e %b %Y %T %z", localtime($stat[9]));
my $tag = get_mp3tag($filePath) or die "No TAG info for $filePath";
my ($mp3title) = ( $file =~ /^(.+?)\.mp3/i );
my $uri = URI->new("$podurl/$file");
$rss->add_item( title => $tag->{'TITLE'} || $mp3title,
- link => $uri,
- enclosure => { url => $uri,
- size => $tag->{'SIZE'},
+ link => $uri,
+ enclosure => { url => $uri,
length => $stat[7],
- type => 'audio/mpeg' },
- pubDate => ($year+1900)."-".($mon+1)."-$mday"."T"."$hour:$min:$sec",
- description => "Podcast $tag->{COMMENT}"
- );
+ type => 'audio/mpeg' },
+ pubDate => $pubdate,
+ description => "Podcast $tag->{COMMENT}" );
}
return $rss;
}