Friday, June 03, 2005

Podcast Playlist Generator

I've just been introduced to the world of podcasting, where anyone can make audio files available periodically, and these can be downloaded to my PC, and then to a portable device, so you can have customised listening material available at any time

I've been using iPodder, a simple aggregator which takes care of checking for new podcasts, and downloads them for me. It also allows the option of running a custom command after each download.

Unfortunately there doesn't seem to be a possibility to create a playlist for each podcast, or an option to create a playlist containing a list of all current podcasts.

Perl to the rescue. A nice simple script, which can be run from iPodder after each download, and will generate m3u playlists which EphPod can then convert for my iPod.


use warnings;
use strict;

my @casts = list_dir(".");
foreach my $dir (@casts)
next if (! -d $dir); ##check its a directory
my @files = list_dir($dir); ##list all the files

#create the playlist file
open(OUT, ">$dir.m3u") die "cant write playlist for $dir : $!";
foreach my $file(@files)
print OUT "$dir/$file\n";
close OUT;

#list the contents of a directory - exclude . and ..
sub list_dir
my ($dir) = @_;
opendir(DIR, $dir) die "cant read dir $dir:$!";
my @results;
while(my $file = readdir(DIR))
next if ($file =~ /^\.$/);
next if ($file =~ /^\.\.$/);
push(@results, $file);
close DIR;
return @results;

1 comment:

Andreea Palomares said...

Hey... I'm a big podcast fan myself. I've recently discovered Lexy ( - a service that lets you create a podcast playlist and will only play the unheard stuff for you. It's all web-based, no downloads and I like that I could call in with my phone to hear the podcasts... completely replaced my iPod.