| 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__ |