#!/usr/bin/perl use strict; use warnings; use XML::Feed; use Data::Dumper; use Getopt::Long; use Pod::Usage; use Perlanet::IronMan; use IronMan::Schema; my ($cli_dsn, $cli_feed, $DEBUG); GetOptions( 'dsn=s' => \$cli_dsn, 'feed=s' => \$cli_feed, 'v' => \$DEBUG, ) or die pod2usage; my $dsn = "dbi:SQLite:/var/www/ironboy.enlightenedperl.org/ironman/subscriptions.db"; # Database DSN if(defined($cli_dsn)) { $dsn = $cli_dsn; } # Schema for our database my $schema = IronMan::Schema->connect($dsn); # Perlanet configuration settings #my $cfg = {}; #$cfg->{title} = "all.things.per.ly"; #$cfg->{description} = "all.things.per.ly IronMan agregation"; #$cfg->{url} = "http://ironboy.enlightenedperl.org/"; #$cfg->{self_link} = "http://ironboy.enlightenedperl.org/"; #$cfg->{agent} = "Perlanet"; #$cfg->{author}->{name} = "Perlanet"; #$cfg->{feed}->{format} = "Atom"; #$cfg->{entries} = 10; # #$cfg->{filter}->{keywords} = ["cpan", "ironman", "perl"]; # Get me a Perlanet::IronMan thingy using our schema my $p = Perlanet::IronMan->new({ author => { name => "Perlanet" }, title => "ironman.enlightenedperl.org", description => "ironman.enlightenedperl.org IronMan Blog Aggregation", url => "http://ironman.enlightenedperl.org/", self_link => "http://ironman.enlightenedperl.org/", agent => "Perlanet::IronMan", author => { name => "Perlanet::IronMan" }, feed => { format => "Atom" }, # Ironman specifics filter => { keywords => ["cpan", "ironman", "perl"] }, schema => $schema, }); # Get the list of feeds from the database print("Fetching the Perlanet::Feed objects array\n"); my $feeds_obj = $p->feeds; # Sample data: # bless( { # 'website' => 'http://jjnapiorkowski.vox.com/library/posts/page/1/', # 'entries' => [], # 'url' => 'http://jjnapiorkowski.vox.com/library/posts/atom.xml', # 'title' => 'John Napiorkowski', # 'id' => 'D78C979A-6678-11DE-98DD-DC36AA5A0737', # 'author' => '' # }, 'Perlanet::Feed' ) #if($DEBUG) { print(Dumper($feeds_obj)); } #exit; if($DEBUG) { print("Fetching the feed data\n"); } foreach my $feed_obj ( @{ $feeds_obj } ) { if(defined($cli_feed)) { unless($feed_obj->url eq $cli_feed) { next; } } if($DEBUG) { print("Feed object:\n"); print(Dumper($feed_obj)); } if($DEBUG) { print("Fetching posts from feed '" . $feed_obj->url . "'\n"); } my @feed_posts = $p->fetch_feeds( $feed_obj ); if($DEBUG) { print(Dumper(@feed_posts)); } if($DEBUG) { print("Filtering posts to remove duplicates\n"); } # Filter feed_posts for previously seen posts @feed_posts = $p->select_entries(@feed_posts); if($DEBUG) { print(Dumper(@feed_posts)); } if($DEBUG) { print("Building a post object\n"); } my $post = $p->build_feed(@feed_posts); if($DEBUG) { print(Dumper($post)); } if($DEBUG) { print("Rendering post object\n"); } $p->render($post); }