Subject: | PATCH - override channle title, to possibly collect multiple files in a single directory |
Patch below is against 1.04 version. It adds
&MP3::PodcastFetch::override_channel_dir, with POD updates. I have
updated bin/fetch_pod.PLS but not bin/fetch_pod.pl as former is used to
generate the later during build process.
Main reason is that I wanted to collect multiple feeds with same general
topic in a single directory (all lower case, thank you very much), instead
of having multitude of directories with possibly only 1 or 2 files in
them. Moreover alphabetical sorting may intermingle the topics. So the
change allows to listen or skip same general topic in one full swoop.
Subject: | PodcastFetch-override-channel-title.diff |
diff --git a/MP3-PodcastFetch-1.04/bin/fetch_pods.PLS b/MP3-PodcastFetch-1.04/bin/fetch_pods.PLS
index 00dd54c..d852461 100644
--- a/MP3-PodcastFetch-1.04/bin/fetch_pods.PLS
+++ b/MP3-PodcastFetch-1.04/bin/fetch_pods.PLS
@@ -106,6 +106,7 @@ for my $podcast (@sections) {
my $url = $cfg->val($podcast=>'url');
my $limit = $cfg->val($podcast=>'limit') || 'none';
my $subdir = $cfg->val($podcast=>'subdir') || 0;
+ my $override_channel = $cfg->val($podcast=>'override_channel_dir');
my $keep_old = $cfg->val($podcast=>'keep_old') || 0;
my $rewrite = $cfg->val($podcast=>'rewrite_filename') || 0;
my $upgrade = $cfg->val($podcast=>'upgrade_tag') || 0;
@@ -127,6 +128,7 @@ for my $podcast (@sections) {
my $feed = MP3::PodcastFetch->new(
-base => $base,
-subdir => $subdirs ? $subdir : '',
+ -override_channel_dir => $override_channel,
-rss => $url,
-max => $limit,
-mirror_mode => $mode,
@@ -349,6 +351,11 @@ Set the base directory for the downloaded podcasts. This option must
be present. The shortcuts ~, ~user and $ENVIRONMENT_VARIABLE are all
recognized.
+=item override_channel_dir
+
+Use a directory other than a channel title which is the default. This
+allows to put multiple channel feeds in a single directory.
+
=item verbose
A boolean controlling the verbosity of the output from the script. Set
diff --git a/MP3-PodcastFetch-1.04/lib/MP3/PodcastFetch.pm b/MP3-PodcastFetch-1.04/lib/MP3/PodcastFetch.pm
index 0b6a4e6..f7feb42 100644
--- a/MP3-PodcastFetch-1.04/lib/MP3/PodcastFetch.pm
+++ b/MP3-PodcastFetch-1.04/lib/MP3/PodcastFetch.pm
@@ -60,7 +60,7 @@ This module implements the following methods:
=cut
BEGIN {
- my @accessors = qw(base subdir rss
+ my @accessors = qw(base subdir override_channel_dir rss
max timeout mirror_mode verbose rewrite_filename upgrade_tags use_pub_date
keep_old playlist_handle playlist_base force_genre force_artist
force_album fetch_callback delete_callback env_proxy);
@@ -94,6 +94,11 @@ appropriately-named subdirectories of this location, one subdirectory
per channel. Additional subdirectory levels can be added using the
B<-subdirs> argument. This argument is required.
+=item -override_channel_dir
+
+Default is to use directory named after a channel title. Specify
+another directory instead.
+
=item -rss
The URL of the RSS feed to subscribe to. This is usually indicated in
@@ -275,6 +280,7 @@ on every deleted file immediately after the file is deleted.
# arguments:
# -base => base directory for podcasts, e.g. /var/podcasts
# -subdir => subdirectory for this podcast, e.g. music
+# -override_channel_dir => directory to use instead of channel title
# -rss => url of the RSS feed to read
# -max => maximum number of episodes to keep
# -timeout => timeout for URL requests
@@ -299,6 +305,7 @@ sub new {
my $self = bless {},ref $class || $class;
$self->base($args{-base} || '/tmp/podcasts');
$self->subdir($args{-subdir});
+ $self->override_channel_dir($args{-override_channel_dir});
$self->rss($args{-rss} || croak 'please provide -rss argument');
$self->max($args{-max} );
$self->timeout($args{-timeout} || 30 );
@@ -338,6 +345,8 @@ Where $new_value is optional.
=item $feed->subdir
+=item $feed->override_channel_dir
+
=item $feed->rss
=item $feed->timeout
@@ -852,14 +861,19 @@ sub generate_directory {
=item $dirname = $feed->channel_dir($channel)
-Generate a directory named based on the provided channel object's title.
+Generate a directory named based on the provided channel object's title,
+unless it is overriden by B<-override_channel_dir> value.
=cut
sub channel_dir {
my $self = shift;
my $channel = shift;
- return $self->safestr($channel->title); # potential bug here -- what if two podcasts have same title?
+
+ my $dir = $self->override_channel_dir || $channel->title;
+
+ return
+ $self->safestr( $dir ); # potential bug here -- what if two podcasts have same title?
}
=item $safe_str = $feed->safe_str($unsafe_str)