Changeset 1905
- Timestamp:
- 12/05/06 07:54:06
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/lib/Plagger/Plugin/Namespace/MediaRSS.pm
r1769 r1905 14 14 my($self, $context, $args) = @_; 15 15 16 my $media_ns = "http://search.yahoo.com/mrss"; 17 my $media = $args->{orig_entry}->{entry}->{$media_ns}->{group} || $args->{orig_entry}->{entry}; 18 my $content = $media->{$media_ns}->{content} || []; 19 $content = [ $content ] unless ref $content && ref $content eq 'ARRAY'; 16 # Ick, I need to try the URL with and without the trailing slash 17 for my $media_ns ("http://search.yahoo.com/mrss", "http://search.yahoo.com/mrss/") { 18 my $media = $args->{orig_entry}->{entry}->{$media_ns}->{group} || $args->{orig_entry}->{entry}; 19 my $content = $media->{$media_ns}->{content} || []; 20 $content = [ $content ] unless ref $content && ref $content eq 'ARRAY'; 20 21 21 for my $media_content (@{$content}) {22 my $enclosure = Plagger::Enclosure->new;23 $enclosure->url( URI->new($media_content->{url}) );24 $enclosure->auto_set_type($media_content->{type});25 $args->{entry}->add_enclosure($enclosure);26 }22 for my $media_content (@{$content}) { 23 my $enclosure = Plagger::Enclosure->new; 24 $enclosure->url( URI->new($media_content->{url}) ); 25 $enclosure->auto_set_type($media_content->{type}); 26 $args->{entry}->add_enclosure($enclosure); 27 } 27 28 28 if (my $thumbnail = $media->{$media_ns}->{thumbnail}) { 29 $args->{entry}->icon({ 30 url => $thumbnail->{url}, 31 width => $thumbnail->{width}, 32 height => $thumbnail->{height}, 33 }); 29 if (my $thumbnail = $media->{$media_ns}->{thumbnail}) { 30 $args->{entry}->icon({ 31 url => $thumbnail->{url}, 32 width => $thumbnail->{width}, 33 height => $thumbnail->{height}, 34 }); 35 } 34 36 } 35 37 trunk/plagger/t/plugins/Namespace-MediaRSS/base.t
r1769 r1905 4 4 use t::TestPlagger; 5 5 6 plan tests => 6;6 plan tests => 8; 7 7 run_eval_expected; 8 8 … … 20 20 - file://$t::TestPlagger::BaseDirURI/t/samples/monkey.rss 21 21 - file://$t::TestPlagger::BaseDirURI/t/samples/googlevideo.xml 22 - file://$t::TestPlagger::BaseDirURI/t/samples/flickr_new.xml 22 23 --- expected 23 24 my @feeds = $context->update->feeds; 24 25 25 is( ($feeds[0]->entries)[0]->enclosures->[0]->url, 'http://youtube.com/v/MgldehkjK5k.swf' ); 26 is( ($feeds[0]->entries)[0]->enclosures->[0]->type, 'application/x-shockwave-flash' ); 27 is( ($feeds[0]->entries)[0]->icon->{url}, 'http://sjl-static4.sjl.youtube.com/vi/MgldehkjK5k/2.jpg' ); 28 is( ($feeds[1]->entries)[0]->enclosures->[0]->type, 'video/mp4' ); 29 is( ($feeds[1]->entries)[0]->enclosures->[1]->type, 'video/x-flv' ); 30 is( ($feeds[1]->entries)[0]->icon->{url}, 'http://video.google.com/ThumbnailServer?app=vss&contentid=ac22092b58659308&second=5&itag=w320&urlcreated=1148908032&sigh=oxDLuV7bChBhYFMFSFamVpkIHHE' ); 26 is $feeds[0]->entries->[0]->enclosures->[0]->url, 'http://youtube.com/v/MgldehkjK5k.swf'; 27 is $feeds[0]->entries->[0]->enclosures->[0]->type, 'application/x-shockwave-flash'; 28 is $feeds[0]->entries->[0]->icon->{url}, 'http://sjl-static4.sjl.youtube.com/vi/MgldehkjK5k/2.jpg'; 29 30 is $feeds[1]->entries->[0]->enclosures->[0]->type, 'video/mp4'; 31 is $feeds[1]->entries->[0]->enclosures->[1]->type, 'video/x-flv'; 32 is $feeds[1]->entries->[0]->icon->{url}, 'http://video.google.com/ThumbnailServer?app=vss&contentid=ac22092b58659308&second=5&itag=w320&urlcreated=1148908032&sigh=oxDLuV7bChBhYFMFSFamVpkIHHE'; 33 34 is $feeds[2]->entries->[0]->enclosures->[0]->type, 'image/jpeg'; 35 is $feeds[2]->entries->[0]->enclosures->[0]->url, 'http://static.flickr.com/109/313831333_60eb5e65b5_m.jpg'; 31 36 32 37 38
