| •1 |
#!/usr/bin/perl |
| 2 |
use strict; |
| 3 |
use Encode; |
| 4 |
use AnyEvent::Feed; |
| 5 |
use AnyEvent; |
| 6 |
|
| 7 |
$XML::Atom::ForceUnicode = 1; |
| 8 |
|
| 9 |
my $cv = AnyEvent->condvar; |
| 10 |
|
| 11 |
my $f = AnyEvent::Feed->new ( |
| 12 |
url => 'https://mail.google.com/mail/feed/atom/unread/', |
| 13 |
username => $ARGV[0], |
| 14 |
password => $ARGV[1], |
| 15 |
interval => 60, |
| 16 |
on_fetch => sub { |
| 17 |
my ($fee, $ent, $feed, $er) = @_; |
| 18 |
|
| 19 |
if (defined $er) { |
| 20 |
warn "ERROR: $er\n"; |
| 21 |
$cv->send; |
| 22 |
return; |
| 23 |
} |
| 24 |
|
| 25 |
for (@$ent) { |
| 26 |
printf "New mail found:\n %s\n => %s\n", |
| 27 |
encode ('utf-8', $_->[1]->title), |
| 28 |
$_->[1]->link; |
| 29 |
} |
| 30 |
}); |
| 31 |
|
| 32 |
$cv->recv; |