Changeset 1905

Show
Ignore:
Timestamp:
12/05/06 07:54:06
Author:
miyagawa
Message:

test Media RSS URL with and without the trailing slash. Ugh

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Namespace/MediaRSS.pm

    r1769 r1905  
    1414    my($self, $context, $args) = @_; 
    1515 
    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'; 
    2021 
    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       
    2728 
    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        } 
    3436    } 
    3537 
  • trunk/plagger/t/plugins/Namespace-MediaRSS/base.t

    r1769 r1905  
    44use t::TestPlagger; 
    55 
    6 plan tests => 6
     6plan tests => 8
    77run_eval_expected; 
    88 
     
    2020        - file://$t::TestPlagger::BaseDirURI/t/samples/monkey.rss 
    2121        - file://$t::TestPlagger::BaseDirURI/t/samples/googlevideo.xml 
     22        - file://$t::TestPlagger::BaseDirURI/t/samples/flickr_new.xml 
    2223--- expected 
    2324my @feeds = $context->update->feeds; 
    2425 
    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' ); 
     26is $feeds[0]->entries->[0]->enclosures->[0]->url, 'http://youtube.com/v/MgldehkjK5k.swf'; 
     27is $feeds[0]->entries->[0]->enclosures->[0]->type, 'application/x-shockwave-flash'; 
     28is $feeds[0]->entries->[0]->icon->{url}, 'http://sjl-static4.sjl.youtube.com/vi/MgldehkjK5k/2.jpg'; 
     29 
     30is $feeds[1]->entries->[0]->enclosures->[0]->type, 'video/mp4'; 
     31is $feeds[1]->entries->[0]->enclosures->[1]->type, 'video/x-flv'; 
     32is $feeds[1]->entries->[0]->icon->{url}, 'http://video.google.com/ThumbnailServer?app=vss&contentid=ac22092b58659308&second=5&itag=w320&urlcreated=1148908032&sigh=oxDLuV7bChBhYFMFSFamVpkIHHE'; 
     33 
     34is $feeds[2]->entries->[0]->enclosures->[0]->type, 'image/jpeg'; 
     35is $feeds[2]->entries->[0]->enclosures->[0]->url, 'http://static.flickr.com/109/313831333_60eb5e65b5_m.jpg'; 
    3136 
    3237 
     38