Changeset 282
- Timestamp:
- 03/05/06 02:46:03
- Files:
-
- trunk/plagger/AUTHORS (modified) (1 diff)
- trunk/plagger/lib/Plagger/Plugin/CustomFeed/iTunesRecentPlay.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/AUTHORS
r270 r282 13 13 fuba 14 14 Yuichi Tateno (secondlife) 15 Gosuke Miyashita trunk/plagger/lib/Plagger/Plugin/CustomFeed/iTunesRecentPlay.pm
r280 r282 3 3 use warnings; 4 4 use base qw( Plagger::Plugin ); 5 use File::Spec; 5 6 use Encode; 6 use Date ::Parse;7 use DateTime::Format::W3CDTF; 7 8 use HTML::Entities; 8 9 … … 26 27 sub aggregate { 27 28 my($self, $context, $args) = @_; 28 my $conf = $self->conf;29 29 30 30 my $file = $self->conf->{library_path}; 31 31 unless ($file) { 32 32 if ($^O eq 'MSWin32') { 33 require File::HomeDir::Windows; 33 34 my $mymusic = File::HomeDir::Windows->my_win32_folder('My Music'); 34 35 $file = File::Spec->catfile($mymusic, 'iTunes', 'iTunes Music Library.xml'); … … 36 37 $file = File::Spec->catfile($ENV{HOME}, 'Music', 'iTunes', 'iTunes Music Library.xml'); 37 38 } else { 38 $context->log(error => "I can't guess library.xml path using your OS name $^O. Specify using --library option.");39 $context->log(error => "I can't guess library.xml path using your OS name $^O."); 39 40 return; 40 41 } 41 42 } 42 43 43 open my $fh, "<:encoding(utf-8)", $file or die "$file: $!"; 44 open my $fh, "<:encoding(utf-8)", $file 45 or return $class->log(error => "$file: $!"); 44 46 45 47 my $feed = Plagger::Feed->new; … … 62 64 and do { 63 65 my $entry = Plagger::Entry->new; 64 if( $data->{date} and $data->{artist} and str2time($data->{date}) > time - $conf->{reload_period} ){ 65 for(keys %$data){ 66 $entry->meta->{$_} = $data->{$_}; 66 67 my $dt = DateTime::Format::W3CDTF->parse_datetime($data->{date}); 68 unless ($dt) { 69 $context->log( warn => "Can't parse $data->{date}"); 70 next; 71 } 72 if( $data->{date} and $data->{artist} and $dt->epoch > time - $self->conf->{reload_period} ){ 73 for my $key (keys %$data){ 74 $entry->meta->{$key} = $data->{$key}; 67 75 } 68 76 $context->log( info => $data->{artist} . ' ' . $data->{track}); … … 115 123 Gosuke Miyashita, E<lt>gosukenator@gmail.comE<gt> 116 124 125 Tatsuhiko Miyagawa 126 117 127 =head1 SEE ALSO 118 128
