Created
October 19, 2011 19:28
-
-
Save marcust/1299398 to your computer and use it in GitHub Desktop.
Export use.perl.org content as RSS
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/perl -w | |
use strict; | |
use SOAP::Lite; | |
use XML::RSS; | |
use DateTime::Format::Flexible; | |
use DateTime::Format::Mail; | |
my $user = shift || | |
die "Usage: $0 userID [ usernick ]\n\nStopped"; | |
my $nick = shift || "#$user"; | |
my $host = 'use.perl.org'; | |
my $uri = "http://$host/Slash/Journal/SOAP"; | |
my $proxy = "http://$host/journal.pl"; | |
my $journal = SOAP::Lite->uri($uri)->proxy($proxy); | |
my $results = $journal->get_entries($user, 50)->result; | |
my $rss = XML::RSS->new(version => '2.0'); | |
$rss->channel(title => "use.perl.org journal of $nick", | |
'link' => $proxy, | |
description => "The use.perl.org journal of $nick"); | |
for my $entry (@$results) { | |
my $data = $journal->get_entry( $entry->{id} )->result; | |
my $formattedDate = DateTime::Format::Mail->format_datetime( | |
DateTime::Format::Flexible->parse_datetime( $data->{date})); | |
$rss->add_item(title => $entry->{subject}, 'link' => $entry->{url}, | |
description => $data->{body}, pubDate => $formattedDate ) | |
} | |
print STDOUT $rss->as_string; | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment