Changeset 749

Show
Ignore:
Timestamp:
05/15/06 21:22:09
Author:
miyagawa
Message:
  • New plugin Filter::FindEnclosures? to auto-discover enclosures
  • New plugin Filter:::HEADEnclosureMetadata to get metadata from enclosures with HEAD requests
  • Added is_inline attribute to Plagger::Enclosure. Fixes #230
  • Publish::Feed: Only publish enclosures with URL set and no is_line flag. Fixes #234
  • Added Plagger::Util::mime_type_of
  • Added flv/m4a to known MIME types list of MIME::Types
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Enclosure.pm

    r748 r749  
    33 
    44use base qw( Class::Accessor::Fast ); 
    5 __PACKAGE__->mk_accessors(qw( length type local_path )); 
     5__PACKAGE__->mk_accessors(qw( length type local_path is_inline )); 
    66 
     7use Plagger::Util; 
    78use URI; 
    89 
     
    2223    } 
    2324 
    24     require MIME::Types; 
    25  
    26     # no type is set in XML ... set via URL extension 
    27     my $ext  = ( $self->url->path =~ /\.(\w+)/ )[0]; 
    28     my $mime = MIME::Types->new->mimeTypeOf($ext) or return; 
    29  
    30     $self->type($mime->type); 
     25    # set MIME type via URL extension 
     26    my $mime = Plagger::Util::mime_type_of($self->url); 
     27    $self->type($mime->type) if $mime; 
    3128} 
    3229 
  • trunk/plagger/lib/Plagger/Plugin/Filter/RewriteEnclosureURL.pm

    r731 r749  
    2525        my $local_path = $enclosure->local_path; 
    2626        unless ($local_path) { 
    27             $context->log(error => "\$enclosure->local_path is not set. You need to load Filter::FetchEnclosure to use this plugin."); 
     27            $context->log(warn => "\$enclosure->local_path is not set. You need to load Filter::FetchEnclosure to use this plugin."); 
    2828            return; 
    2929        } 
  • trunk/plagger/lib/Plagger/Plugin/Publish/Feed.pm

    r747 r749  
    6262            # RSS 2.0 by spec doesn't allow multiple enclosures 
    6363            my @enclosures = $feed_format eq 'RSS' ? ($e->enclosures->[0]) : $e->enclosures; 
    64             for my $enclosure (grep defined $_->url, @enclosures) { 
     64            for my $enclosure (grep { defined $_->url && !$_->is_inline } @enclosures) { 
    6565                $entry->add_enclosure({ 
    6666                    url    => $enclosure->url, 
  • trunk/plagger/lib/Plagger/Util.pm

    r683 r749  
    22use strict; 
    33our @ISA = qw(Exporter); 
    4 our @EXPORT_OK = qw( strip_html dumbnail decode_content extract_title load_uri ); 
     4our @EXPORT_OK = qw( strip_html dumbnail decode_content extract_title load_uri mime_type_of ); 
    55 
    66use Encode (); 
    77use List::Util qw(min); 
    88use HTML::Entities; 
     9use MIME::Types; 
     10use MIME::Type; 
    911 
    1012our $Detector; 
     
    129131} 
    130132 
     133sub mime_type_of { 
     134    my $ext = shift; 
     135 
     136    if (UNIVERSAL::isa($ext, 'URI')) { 
     137        $ext = ( $ext->path =~ /\.(\w+)/ )[0]; 
     138    } 
     139 
     140    my $mimetypes = MIME::Types->new; 
     141    $mimetypes->addType( MIME::Type->new(type => 'video/flv', extensions => [ 'flv' ]) ); 
     142    $mimetypes->addType( MIME::Type->new(type => 'audio/aac', extensions => [ 'm4a', '.aac' ]) ); 
     143 
     144    return $mimetypes->mimeTypeOf($ext); 
     145} 
     146 
    1311471;