Changeset 1399

Show
Ignore:
Timestamp:
08/19/06 17:04:09
Author:
miyagawa
Message:

Notify::Audio: work with enclosures

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Notify/Audio.pm

    r1397 r1399  
    2020    $context->register_hook( 
    2121        $self, 
    22         'publish.feed' => \&update, 
     22        'publish.entry.fixup' => \&update, 
    2323        'publish.finalize' => \&finalize, 
    2424    ); 
     25    $self->{enclosures} = [ ]; 
    2526    $self->{count} = 0; 
    2627} 
     
    2829sub update { 
    2930    my($self, $context, $args) = @_; 
    30     $self->{count}++ if $args->{feed}->count; 
     31 
     32    if ($self->conf->{play_enclosures}) { 
     33        push @{$self->{enclosures}}, grep $_->local_path, $args->{entry}->enclosures; 
     34    } else { 
     35        $self->{count}++; 
     36    } 
    3137} 
    3238 
    3339sub finalize { 
    3440    my($self, $context, $args) = @_; 
    35     $self->play($self->conf->{filename}) if $self->{count}; 
     41 
     42    if ($self->{count}) { 
     43        $self->log(info => "Play $self->conf->{filename}"); 
     44        return $self->play($self->conf->{filename}); 
     45    } 
     46 
     47    for my $enclosures (@{$self->{enclosures}}) { 
     48        $self->log(info => "Play " . $enclosure->local_path); 
     49        $self->play($enclosure->local_path); 
     50    } 
    3651} 
    37  
    3852 
    3953sub play { 
     
    5165=head1 SYNOPSIS 
    5266 
     67  # play single file when feeds are updated 
    5368  - module: Notify::Audio 
    5469    config: 
    5570      filename: /path/to/foo.wav 
     71 
     72  # play enclosures downloaded with Filter::FetchEnclosure 
     73  - module: Notify::Audio 
     74    config: 
     75      play_enclosures: 1 
    5676 
    5777=head1 DESCRIPTION 
     
    6585=item filename 
    6686 
    67 Audio filename to play. Required
     87Audio filename to play. Required, if you don't set I<play_enclosures>
    6888 
    69 =back 
     89=item play_enclosures 
    7090 
    71 =head1 TODO 
    72  
    73 =over 4 
    74  
    75 =item * 
    76  
    77 Configurable audio name per feed. 
    78  
    79 =item * 
    80  
    81 Play enclosures? 
     91If set, it'll play local enclosure file which are downloaded via 
     92Filter::FetchEnclosure, if any. 
    8293 
    8394=back 
  • trunk/plagger/lib/Plagger/Plugin/Notify/Audio/iTunesWin32.pm

    r1397 r1399  
    88    my($self, $filename) = @_; 
    99    $filename or return $self->log(error => "filename is not set"); 
    10      
     10 
    1111    my $itunes = Win32::OLE->new("iTunes.Application"); 
    1212    $itunes->PlayFile($filename);