| 173 | | |
|---|
| 174 | | # Media RSS |
|---|
| 175 | | my $media_ns = "http://search.yahoo.com/mrss"; |
|---|
| 176 | | my $media = $e->{entry}->{$media_ns}->{group} || $e->{entry}; |
|---|
| 177 | | my $content = $media->{$media_ns}->{content} || []; |
|---|
| 178 | | $content = [ $content ] unless ref $content && ref $content eq 'ARRAY'; |
|---|
| 179 | | |
|---|
| 180 | | for my $media_content (@{$content}) { |
|---|
| 181 | | my $enclosure = Plagger::Enclosure->new; |
|---|
| 182 | | $enclosure->url( URI->new($media_content->{url}) ); |
|---|
| 183 | | $enclosure->auto_set_type($media_content->{type}); |
|---|
| 184 | | $entry->add_enclosure($enclosure); |
|---|
| 185 | | } |
|---|
| 186 | | |
|---|
| 187 | | if (my $thumbnail = $media->{$media_ns}->{thumbnail}) { |
|---|
| 188 | | $entry->icon({ |
|---|
| 189 | | url => $thumbnail->{url}, |
|---|
| 190 | | width => $thumbnail->{width}, |
|---|
| 191 | | height => $thumbnail->{height}, |
|---|
| 192 | | }); |
|---|
| 193 | | } |
|---|
| 194 | | |
|---|
| 195 | | # Hatena Image extensions |
|---|
| 196 | | my $hatena = $e->{entry}->{"http://www.hatena.ne.jp/info/xmlns#"} || {}; |
|---|
| 197 | | if ($hatena->{imageurl}) { |
|---|
| 198 | | my $enclosure = Plagger::Enclosure->new; |
|---|
| 199 | | $enclosure->url($hatena->{imageurl}); |
|---|
| 200 | | $enclosure->auto_set_type; |
|---|
| 201 | | $entry->add_enclosure($enclosure); |
|---|
| 202 | | } |
|---|
| 203 | | |
|---|
| 204 | | if ($hatena->{imageurlsmall}) { |
|---|
| 205 | | $entry->icon({ url => $hatena->{imageurlsmall} }); |
|---|
| 206 | | } |
|---|
| 207 | | |
|---|
| 208 | | # Apple photocast feed |
|---|
| 209 | | my $apple = $e->{entry}->{"http://www.apple.com/ilife/wallpapers"} || {}; |
|---|
| 210 | | if ($apple->{image}) { |
|---|
| 211 | | my $enclosure = Plagger::Enclosure->new; |
|---|
| 212 | | $enclosure->url( URI->new($apple->{image}) ); |
|---|
| 213 | | $enclosure->auto_set_type; |
|---|
| 214 | | $entry->add_enclosure($enclosure); |
|---|
| 215 | | } |
|---|
| 216 | | if ($apple->{thumbnail}) { |
|---|
| 217 | | $entry->icon({ url => $apple->{thumbnail} }); |
|---|
| 218 | | } |
|---|
| | 173 | $self->handle_media_rss($entry, $e); |
|---|
| | 174 | $self->handle_hatena_image($entry, $e); |
|---|
| | 175 | $self->handle_apple_photocast($entry, $e); |
|---|
| | 190 | } |
|---|
| | 191 | |
|---|
| | 192 | sub handle_media_rss { |
|---|
| | 193 | my($self, $entry, $e) = @_; |
|---|
| | 194 | |
|---|
| | 195 | my $media_ns = "http://search.yahoo.com/mrss"; |
|---|
| | 196 | my $media = $e->{entry}->{$media_ns}->{group} || $e->{entry}; |
|---|
| | 197 | my $content = $media->{$media_ns}->{content} || []; |
|---|
| | 198 | $content = [ $content ] unless ref $content && ref $content eq 'ARRAY'; |
|---|
| | 199 | |
|---|
| | 200 | for my $media_content (@{$content}) { |
|---|
| | 201 | my $enclosure = Plagger::Enclosure->new; |
|---|
| | 202 | $enclosure->url( URI->new($media_content->{url}) ); |
|---|
| | 203 | $enclosure->auto_set_type($media_content->{type}); |
|---|
| | 204 | $entry->add_enclosure($enclosure); |
|---|
| | 205 | } |
|---|
| | 206 | |
|---|
| | 207 | if (my $thumbnail = $media->{$media_ns}->{thumbnail}) { |
|---|
| | 208 | $entry->icon({ |
|---|
| | 209 | url => $thumbnail->{url}, |
|---|
| | 210 | width => $thumbnail->{width}, |
|---|
| | 211 | height => $thumbnail->{height}, |
|---|
| | 212 | }); |
|---|
| | 213 | } |
|---|
| | 214 | } |
|---|
| | 215 | |
|---|
| | 216 | sub handle_hatena_image { |
|---|
| | 217 | my($self, $entry, $e) = @_; |
|---|
| | 218 | |
|---|
| | 219 | # Hatena Image extensions |
|---|
| | 220 | my $hatena = $e->{entry}->{"http://www.hatena.ne.jp/info/xmlns#"} || {}; |
|---|
| | 221 | if ($hatena->{imageurl}) { |
|---|
| | 222 | my $enclosure = Plagger::Enclosure->new; |
|---|
| | 223 | $enclosure->url($hatena->{imageurl}); |
|---|
| | 224 | $enclosure->auto_set_type; |
|---|
| | 225 | $entry->add_enclosure($enclosure); |
|---|
| | 226 | } |
|---|
| | 227 | |
|---|
| | 228 | if ($hatena->{imageurlsmall}) { |
|---|
| | 229 | $entry->icon({ url => $hatena->{imageurlsmall} }); |
|---|
| | 230 | } |
|---|
| | 231 | } |
|---|
| | 232 | |
|---|
| | 233 | sub handle_apple_photocast { |
|---|
| | 234 | my($self, $entry, $e) = @_; |
|---|
| | 235 | |
|---|
| | 236 | my $apple = $e->{entry}->{"http://www.apple.com/ilife/wallpapers"} || {}; |
|---|
| | 237 | if ($apple->{image}) { |
|---|
| | 238 | my $enclosure = Plagger::Enclosure->new; |
|---|
| | 239 | $enclosure->url( URI->new($apple->{image}) ); |
|---|
| | 240 | $enclosure->auto_set_type; |
|---|
| | 241 | $entry->add_enclosure($enclosure); |
|---|
| | 242 | } |
|---|
| | 243 | if ($apple->{thumbnail}) { |
|---|
| | 244 | $entry->icon({ url => $apple->{thumbnail} }); |
|---|
| | 245 | } |
|---|