Subject: | New Feature: Allow XML::RSS objects in sources list |
The attached patch allows you to pass in XML::RSS objects in the sources list. The reason for this is that I want to collect the RSS feeds myself, using mirror() to be more bandwith friendly, instead of the default get().
I've not tested this patch (just about to...), but you may find it useful.
Thanks,
-Dom
--- Aggregate.pm.orig 2003-03-18 13:34:31.000000000 +0000
+++ Aggregate.pm 2003-03-18 13:39:50.000000000 +0000
@@ -60,7 +60,8 @@
=item aggregate (sources=>\@url, sort_by=>\&func, uniq_by=>\&func)
This method fetches all RSS feeds listed in C<@url> and pass their
-items to the object's C<add_item>.
+items to the object's C<add_item>. Alternatively, you can pass in
+pre-parsed XML::RSS objects.
The optional C<sort_by> argument specifies the function to use for
ordering RSS items; it defaults to sort them by their C<{dc}{date}>
@@ -119,8 +120,9 @@
map { encode_entities($_, '&<>') for grep {!ref($_)} values %{$_->{dc}}; $_ }
map { encode_entities($_, '&<>') for grep {!ref($_)} values %{$_->{syn}}; $_ }
map { encode_entities($_, '&<>') for grep {!ref($_)} @{$_->{taxo}}; $_ }
- map { eval { (my $rss = XML::RSS->new)->parse(get($_)); @{$rss->{items}} } }
- grep { /^\w+:/ } @{$sources};
+ map { @{ $_->items } }
+ map { ref($_) ? $_ : eval { (my $rss = XML::RSS->new)->parse(get($_)) } }
+ grep { ref($_) || /^\w+:/ } @{$sources};
return $self;
}