AnyEvent-Superfeedr

 view release on metacpan or  search on metacpan

eg/print_feed_titles.pl  view on Meta::CPAN

use strict;
use warnings;
use Find::Lib '../lib';
use AnyEvent::Superfeedr;
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

use strict;
use warnings;
use Find::Lib '../lib';
use AnyEvent::Superfeedr;
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

            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 0.796 second using v1.01-cache-2.11-cpan-49f99fa48dc )