Tweet-ToDelicious

 view release on metacpan or  search on metacpan

lib/Tweet/ToDelicious.pm  view on Meta::CPAN

    $cv->recv;

}

sub delicious {
    my $self = shift;
    state $delicious = Net::Delicious->new( $self->{config}->{delicious} );
    return $delicious;
}

sub coro_head {
    my $self = shift;
    my $uri  = shift;
    http_head $uri, Coro::rouse_cb;
    my ( $data, $headers ) = Coro::rouse_wait;
    if ( $headers->{Status} ~~ [ 200, 301, 302, 304 ] ) {
        debugf( "expand: %s => %s", $uri, $headers->{URL} );
        return $headers->{URL};
    }
    else {
        debugf( "Status != 200. headers: %s", ddf($headers) );

lib/Tweet/ToDelicious.pm  view on Meta::CPAN


sub _posts {
    my $self      = shift;
    my $delicious = $self->delicious;
    my @posts     = @_;
    debugf( "posts: %s", \@posts );
    if ( @posts > 0 ) {
        for my $post (@posts) {
            async {
                my $done = retry 3, 1, sub {
                    $post->{url} = $self->coro_head( $post->{url} );
                    $delicious->add_post($post);
                };
                infof( "Post %s done", $post->{url} )
                    if $done;
            };
        }
    }
}

1;



( run in 0.401 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )