Created
May 10, 2013 05:09
-
-
Save mlbright/5552513 to your computer and use it in GitHub Desktop.
find all feeds from an OPML file. Add them to rss2email.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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