App-FeedDeduplicator

 view release on metacpan or  search on metacpan

lib/App/FeedDeduplicator/Publisher.pm  view on Meta::CPAN

      ($b->{entry}->issued || $b->{entry}->modified || $b->{entry}->updated || $b->{entry}->date || 0)
        <=>
      ($a->{entry}->issued || $a->{entry}->modified || $a->{entry}->updated || $a->{entry}->date || 0)
    } @$entries;

    if (@sorted > $max_entries) {
      $#sorted = $max_entries - 1;
    }

    if ($format eq 'json') {
      say encode_json([ map { {
        title => $_->{entry}->title,
        link  => $_->{entry}->link,
        summary => $_->{entry}->summary->body,
        issued => $_->{entry}->issued && $_->{entry}->issued->iso8601,
        source_name => $_->{feed}{name},
        source_url  => $_->{feed}{web},
      } } @sorted ]);
    } else {
      my $feed = XML::Feed->new($format);
      $feed->title("Deduplicated Feed");
      $feed->add_entry($_) for @sorted;
      say $feed->as_xml;
    }
  }
}

=head1 AUTHOR

Dave Cross <dave@perlhacks.com>

=head1 COPYRIGHT AND LICENSE



( run in 1.764 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )