AnyEvent-Superfeedr

 view release on metacpan or  search on metacpan

eg/print_feed_titles.pl  view on Meta::CPAN

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
33
34
35
36
37
38
use strict;
use Find::Lib '../lib';
use Encode;
 
die "$0 <jid> <pass>" unless @ARGV >= 2;
 
binmode STDOUT, ":utf8";
 
my $end = AnyEvent->condvar;
my $sf = AnyEvent::Superfeedr->new(
    debug => $ENV{DEBUG},
    jid => shift,
    password => shift,
    # bogus for my tests
    #subscription => {
    #    interval => 5,
    #    sub_cb => sub { [ "firehoser.superfeedr.com" ] },
    #    unsub_cb => sub { [ "", undef, '""', "*" ] },
    #},
    on_notification => sub {
        my $notification = shift;
        warn $notification->as_xml;
        printf "%s: %s\n", $notification->title, $notification->feed_uri;
 
        for my $entry ($notification->entries) {
            my $title = Encode::decode_utf8($entry->title);
            $title =~ s/\s+/ /gs;
 
            my $l = length $title;
            my $max = 50;
            if ($l > $max) {
                substr $title, $max - 3, $l - $max + 3, '...';
            }
            printf "~ %-50s\n", $title;
        }
    },

eg/status_feed.pl  view on Meta::CPAN

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use strict;
use Find::Lib '../lib';
use Encode;
 
die "$0 <jid> <pass>" unless @ARGV >= 2;
 
binmode STDOUT, ":utf8";
 
my $end = AnyEvent->condvar;
my $sf = AnyEvent::Superfeedr->new(
    jid => shift,
    password => shift,
    on_notification => sub {
        my $notification = shift;
        printf "Fetched '%s' %s [status=%s], next at %s\n",
            $notification->title,
            $notification->feed_uri,

lib/AnyEvent/Superfeedr.pm  view on Meta::CPAN

167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
            else {
                undef $chunk_cb;
                undef $res_cb;
            }
        }
    };
    $chunk_cb->(\@chunk, $res_cb);
}
 
sub xmpp_node_uri {
    my $enc_feed = URI::Escape::uri_escape_utf8(shift, "\x00-\x1f\x7f-\xff");
    # work around what I think is a but in AnyEvent::XMPP
    #return "xmpp:$SERVICE?;node=$enc_feed";
    return "xmpp:$SERVICE?sub;node=$enc_feed";
}
 
sub xmpp_pubsub {
    my $superfeedr = shift;
    return $superfeedr->{xmpp_pubsub};
}



( run in 1.172 second using v1.01-cache-2.11-cpan-49f99fa48dc )