MP3-PodcastFetch
view release on metacpan or search on metacpan
bin/fetch_pods.PLS view on Meta::CPAN
my $album = $cfg->val($podcast=>'force_album');
my $use_pub_date = $cfg->val($podcast=>'use_pub_date');
unless (defined $url) {
warn "No podcast RSS URL defined for $podcast\n";
next;
}
true_or_false(\$keep_old,\$rewrite,\$generate_playlist);
$limit = 1000 if $limit eq 'none';
my $feed = MP3::PodcastFetch->new(
-base => $base,
-subdir => $subdirs ? $subdir : '',
-override_channel_dir => $override_channel,
-rss => $url,
-max => $limit,
-mirror_mode => $mode,
-rewrite_filename => $rewrite,
-upgrade_tag => $upgrade,
-verbose => $verbose,
-force_genre => $genre,
-force_artist => $artist,
-force_album => $album,
-keep_old => $keep_old,
-playlist_handle => $m3ufile,
-playlist_base => $playlist_base,
-use_pub_date => $use_pub_date,
);
$feed->fetch_pods;
$fetched += $feed->fetched;
$skipped += $feed->skipped;
$deleted += $feed->deleted;
$errors += $feed->errors;
}
$date = localtime;
unlink $playlist_path if $playlist_path && !$fetched;
print "$date END fetch_pods: $fetched fetched, $skipped skipped, $deleted deleted, $errors errors.\n\n";
exit 0;
# either create pidfile or exit gracefully
sub write_pidfile {
my $file = shift;
if (-e $file) { # uh oh, maybe we're running :-(
open (F,$file) or return;
my $oldpid = <F>;
chomp $oldpid;
kill 0=>$oldpid and return;
close F;
}
open F,">",$file or die "Can't write PID file $file: $!";
print F $$;
close F;
1;
}
sub find_config_file {
my $self = shift;
my $home = (getpwuid($<))[7] || $ENV{HOME};
my @paths = ("$home/.fetchpods",
"/usr/local/etc/fetchpods.conf",
"/usr/etc/fetchpods.conf",
"/etc/fetchpods.conf",
"$Bin/../etc/fetchpods.conf",
"$Bin/../conf/fetchpods.conf");
foreach (@paths) {
return $_ if -f $_ && -r _;
}
}
sub true_or_false {
for my $ref (@_) {
next unless $$ref;
if ($$ref =~ /^no$/i) {
undef $$ref;
} elsif ($$ref =~ /^yes$/i) {
$$ref = 1;
}
}
}
sub interpolate {
my $ref = shift;
return unless defined $ref;
$ref =~ s/^~([^\/]*)/($1 ? getpwnam($1):getpwuid($<))[7] || "~$1"/eg;
$ref =~ s/\$(\w+)/$ENV{$1}/g;
$ref;
}
__END__
=head1 NAME
fetch_pods.pl -- Fetch and manage podcasts from the command line
=head1 SYNOPSIS
% fetch_pods.pl /etc/fetchpods.conf
Wed Dec 27 16:01:54 2006 START fetch_pods
Updating podcasts for PRI's The World - Geo Quiz. 5 items available...
PRI's The World - Geo Quiz Podcast 135: skipped
PRI's The World - Geo Quiz Podcast 136: skipped
PRI's The World - Geo Quiz Podcast 138: skipped
PRI's The World - Geo Quiz Podcast 139: skipped
Updating podcasts for APM: Future Tense. 5 items available...
A backpack to lighten your load: deleted
How best to begin using your new tech products: skipped
Is malware leading Windows users to the Mac side?: skipped
Last-minute gifts at NetworkforGood.com: skipped
Where will next Bill Gates come from? Survey says: not the United States: 1993249 bytes fetched
Wed Dec 27 16:01:56 2006 END fetch_pods: 1 fetched, 8 skipped, 1 deleted, 1 errors.
=head1 DESCRIPTION
Use this Perl script to fetch and maintain a directory of podcast
subscriptions. Information about which podcasts to fetch are stored in
a configuration file. You can control how many podcast files to keep,
where to keep them, whether to rationalize their ID3 tags, and whether
to delete older podcast files. This script will also create playlists
listing recently-fetched podcasts.
To use this script, create a configuration file (see "Configuration
File Format") listing global options and the podcasts you wish to
subscribe to; a sample configuration file is located in the
distribution directory undef ./conf/fetchpods.conf. Then run
fetch_pods from the command line. You can explicitly give the path to
the configuration file on the command line as shown here:
fetch_pods.pl ~/pods/news_pods.conf
If called with no arguments, fetch_pods.pl will look for a default
configuration file in the following locations:
~/.fetchpods
/usr/local/etc/fetchpods.conf
/usr/etc/fetchpods.conf
/etc/fetchpods.conf
/path/to/this/binary/../etc/fetchpods.conf
/path/to/this/binary/../conf/fetchpods.conf
The script will stop and process the first configuration file it
finds. Note that when you installed this script, it created a default
fetchpods.conf in /etc/fetchpods.conf. You may want to delete this
file.
( run in 2.453 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )