Changeset 1827

Show
Ignore:
Timestamp:
11/10/06 16:17:35
Author:
miyagawa
Message:

Update per mixi.jp site upgrade.

  • Reworked image extraction regular expression locally since HTML is slightly changed. Sigh.
  • Now added found images to enclosures so FetchEnclosure? and attach_enclosures work. w00t!
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/CustomFeed/Mixi.pm

    r1784 r1827  
    179179                    my $meth = $MAP->{$type}->{get_detail}; 
    180180                    my($item) = $self->{mixi}->$meth($msg->{link}); 
     181 
     182                    if ($meth eq 'get_view_diary') { 
     183                        $item->{images} = $self->get_images($self->{mixi}->response->content); 
     184                    } 
    181185                    $item; 
    182186                }, 
     
    187191                   $body =~ s!(\r\n?|\n)!<br />!g; 
    188192                for my $image (@{ $item->{images} }) { 
    189                     # xxx this should be $entry->enclosures 
    190193                    $body .= qq(<div><a href="$image->{link}"><img src="$image->{thumb_link}" style="border:0" /></a></div>); 
     194                    my $enclosure = Plagger::Enclosure->new; 
     195                    $enclosure->url( URI->new($image->{thumb_link}) ); 
     196                    $enclosure->auto_set_type; 
     197                    $enclosure->is_inline(1); 
     198                    $entry->add_enclosure($enclosure); 
    191199                } 
    192200                $entry->body($body); 
     
    203211 
    204212    $context->update->add($feed); 
     213} 
     214 
     215sub get_images { 
     216    my($self, $content) = @_; 
     217 
     218    my @images; 
     219    while ($content =~ m!MM_openBrWindow\('(show_diary_picture\.pl\?.*?)',.*?><img src="(http://ic\d+\.mixi\.jp/p/.*?)"!g) { 
     220        push @images, { link => "http://mixi.jp/$1", thumb_link => $2 }; 
     221    } 
     222 
     223    return \@images; 
    205224} 
    206225