Skip to content
Newer
Older
100755 43 lines (30 sloc) 813 Bytes
2e5fd2e @abh Small tweaks to the RSS downloader
abh authored Mar 14, 2011
1 #!/usr/bin/env perl
834f1bc @ranguard Start on rss fetcher script - going to convert output to JSON as a st…
ranguard authored Mar 14, 2011
2
035f661 @ranguard Comment
ranguard authored Apr 9, 2011
3 # Fetch the most recent module releases and save out as JSON
4
834f1bc @ranguard Start on rss fetcher script - going to convert output to JSON as a st…
ranguard authored Mar 14, 2011
5 use strict;
6 use warnings;
2e5fd2e @abh Small tweaks to the RSS downloader
abh authored Mar 14, 2011
7 use local::lib;
834f1bc @ranguard Start on rss fetcher script - going to convert output to JSON as a st…
ranguard authored Mar 14, 2011
8 use File::Temp;
9 use XML::RSS;
2e5fd2e @abh Small tweaks to the RSS downloader
abh authored Mar 14, 2011
10 use JSON;
d0980b5 @abh Simplify RSS fetcher
abh authored Mar 20, 2011
11 use LWP::Simple qw(mirror RC_OK);
20b699b @abh Tweaks to 'fetch data' process
abh authored Mar 16, 2011
12 use File::Path qw(mkpath);
834f1bc @ranguard Start on rss fetcher script - going to convert output to JSON as a st…
ranguard authored Mar 14, 2011
13
20b699b @abh Tweaks to 'fetch data' process
abh authored Mar 16, 2011
14 mkpath 'data', 0755 unless -e 'data';
834f1bc @ranguard Start on rss fetcher script - going to convert output to JSON as a st…
ranguard authored Mar 14, 2011
15
16 process_rss(
d0980b5 @abh Simplify RSS fetcher
abh authored Mar 20, 2011
17 { out => 'data/recent.json',
18 url => "http://search.cpan.org/uploads.rdf",
834f1bc @ranguard Start on rss fetcher script - going to convert output to JSON as a st…
ranguard authored Mar 14, 2011
19 }
20 );
21
22 sub process_rss {
23 my $conf = shift;
24
d0980b5 @abh Simplify RSS fetcher
abh authored Mar 20, 2011
25 my $local = $conf->{out} . ".rss";
834f1bc @ranguard Start on rss fetcher script - going to convert output to JSON as a st…
ranguard authored Mar 14, 2011
26
d0980b5 @abh Simplify RSS fetcher
abh authored Mar 20, 2011
27 return unless mirror($conf->{url}, $local) == RC_OK;
834f1bc @ranguard Start on rss fetcher script - going to convert output to JSON as a st…
ranguard authored Mar 14, 2011
28
29 my $rss = XML::RSS->new;
d0980b5 @abh Simplify RSS fetcher
abh authored Mar 20, 2011
30 $rss->parsefile( $local );
834f1bc @ranguard Start on rss fetcher script - going to convert output to JSON as a st…
ranguard authored Mar 14, 2011
31 my $items = $rss->{'items'};
32
2e5fd2e @abh Small tweaks to the RSS downloader
abh authored Mar 14, 2011
33 my $j = JSON->new();
834f1bc @ranguard Start on rss fetcher script - going to convert output to JSON as a st…
ranguard authored Mar 14, 2011
34
d0980b5 @abh Simplify RSS fetcher
abh authored Mar 20, 2011
35 my $json_file = $conf->{out};
20b699b @abh Tweaks to 'fetch data' process
abh authored Mar 16, 2011
36
37 open my $fh, ">:utf8", $json_file
38 or die "Could not open $json_file: $!";
39 print $fh $j->encode($items);
40 close $fh;
834f1bc @ranguard Start on rss fetcher script - going to convert output to JSON as a st…
ranguard authored Mar 14, 2011
41 }
42
Something went wrong with that request. Please try again.