Knut-Olav Hoven


WWW::Opentracker::Stats::Mode - Base module for the different modes


    use WWW::Opentracker::Stats::Mode::TPBS;
    my $tpbs = WWW::Opentracker::Stats::Mode::TPBS->new(
            'statsurl'  => 'http://localhost:6969/stats',

    my $stats   = $tpbs->stats();
    printf "%d torrents served", scalar @{$stats->{'files'}};


Provides accessability for fetching and parsing the statistics from Opentracker.



 Args: $class, $args

Constructor. Creates a new instance of the class. This constructor is also used by all sub statistics packages.

It takes a HASH/HASHREF of arguments. - statsurl (mandatory) - useragent (mandatory)


 Args: $self

Fetches statistics from the opentracker server over a HTTP channel, decodes the content in the HTTP response and returns the statistics data structure.

It caches the statistics for the entire lifetime of the object. If something is found in the cache, it is returned instead of contacting the server.


 Args: $self, $payload

Returns the payload unchanged.

WARNING This method should really, really be implemented by a subclass. It should return a HASHREF with a sane structure of the statistics data.


 Args: $self

Makes a HTTP request to the opentracker statistics service using the implementation (sub) class' mode and format settings.

Returns the content of the response unless there was an error. Dies on errors.


 Args: $self

Assembles the URL to the opentracker statistics based on the statsurl, format and mode.

Returns the URL as a string.


 Args: $self, $number

Parses a string that represents a number with a thousands delimiter.


 Private method

 Args: $self

Croaks from the perspect of the caller two steps up the call stack if the method is not called from a subclass implementation.


Knut-Olav Hoven, <>


Copyright (C) 2009 by Knut-Olav Hoven

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.