File: gmail_unread_feed

package info (click to toggle)
libanyevent-feed-perl 0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 152 kB
  • sloc: perl: 165; makefile: 2
file content (32 lines) | stat: -rwxr-xr-x 695 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl
use strict;
use Encode;
use AnyEvent::Feed;
use AnyEvent;

$XML::Atom::ForceUnicode = 1;

my $cv = AnyEvent->condvar;

my $f = AnyEvent::Feed->new (
      url      => 'https://mail.google.com/mail/feed/atom/unread/',
      username => $ARGV[0],
      password => $ARGV[1],
      interval => 60,
      on_fetch => sub {
         my ($fee, $ent, $feed, $er) = @_;

         if (defined $er) {
            warn "ERROR: $er\n";
            $cv->send;
            return;
         }

         for (@$ent) {
            printf "New mail found:\n   %s\n   => %s\n",
                   encode ('utf-8', $_->[1]->title),
                   $_->[1]->link;
         }
      });

$cv->recv;