Plagger/Plugin/Namespace/ApplePhotocast.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 32 CC 3 SCAR 19.5
CC
3
Cov
0%
handle
12.0
register
2.0
BEGIN
2.0
CRAP 7.0
1 package Plagger::Plugin::Namespace::ApplePhotocast;
2 use strict;
3 use base qw( Plagger::Plugin );
4  
5 sub register {
6 my($self, $context) = @_;
7 $context->register_hook(
8 $self,
9 'aggregator.entry.fixup' => \&handle,
10 );
11 }
12  
13 sub handle {
14 my($self, $context, $args) = @_;
15  
16 my $apple = $args->{orig_entry}->{entry}->{"http://www.apple.com/ilife/wallpapers"} || {};
17 if ($apple->{image}) {
18 my $enclosure = Plagger::Enclosure->new;
19 $enclosure->url( URI->new($apple->{image}) );
20 $enclosure->auto_set_type;
21 $args->{entry}->add_enclosure($enclosure);
22 }
23 if ($apple->{thumbnail}) {
24 $args->{entry}->icon({ url => $apple->{thumbnail} });
25 }
26 }
27  
28  
29 1;
30 __END__