Skip to content

Instantly share code, notes, and snippets.

@mlbright
Created May 10, 2013 05:09
Show Gist options
  • Save mlbright/5552513 to your computer and use it in GitHub Desktop.
Save mlbright/5552513 to your computer and use it in GitHub Desktop.
find all feeds from an OPML file. Add them to rss2email.
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use XML::OPML::LibXML;
use HTTP::Tiny;
use Path::Class;
my $url = "https://raw.github.com/mlbright/myopml/master/subs.xml";
my $rss2email = dir( $ENV{'HOME'}, 'rss2email-2.71' );
my $feeds = "feeds.xml";
chdir $rss2email;
my $response = HTTP::Tiny->new->mirror( $url, $feeds );
unless ( $response->{success} ) {
say "WTF: $response->{status} $response->{reason}\n";
exit(1);
}
my $parser = XML::OPML::LibXML->new;
my $doc = $parser->parse_file($feeds);
my @outline = $doc->outline;
for my $outline (@outline) {
my $attrs = $outline->attrs; # hashref
if ( $outline->is_container ) {
say "nested outline";
# do some recursive stuff, see also walkdown()
}
else {
say $outline->html_url;
system( "./r2e add " . $outline->xml_url );
}
}
system("./r2e run --no-send");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment