WWW::RapidShare - Download files from Rapidshare


WWW-RapidShare documentation Contained in the WWW-RapidShare distribution.

Index


Code Index:

NAME

Top

WWW::RapidShare - Download files from Rapidshare

VERSION

Top

This documentation refers to WWW::RapidShare version 0.3.1

NOTE

Top

    Currently only works with rapidshare.com PREMIUM accounts.
    More features coming soon!

SYNOPSIS

Top

    use WWW::RapidShare;

    my $rapid = WWW::RapidShare->new();

    $rapid->url('http://rapidshare.com/files/file.zip');
    $rapid->account_id('xxxxxx');
    $rapid->password('xxxxxx');

    # Download the file associated with the above URL.
    # File will be saved in current directory.
    $rapid->download_file();

  


SUBROUTINES/METHODS

Top

new()

Purpose

    Create a new WWW::RapidShare object

Usage

    my $rapid = WWW::RapidShare->new();

Parameters

    None

Returns

    A WWW::RapidShare object

accessors/mutators

    * url - The URL to download the file
    * account_id - Your account ID
    * password - your password

download_file()

Purpose

    Download the file associated with the URL

Usage

    $rapid->download_file();

Parameters

    None

Returns

    None

Comments

    This method will create a file in the current directory

DEPENDENCIES

Top

* Class::Accessor
* WWW::Mechanize

AUTHOR

Top

Rohan Almeida <rohan@almeida.in>

LICENCE AND COPYRIGHT

Top


WWW-RapidShare documentation Contained in the WWW-RapidShare distribution.
package WWW::RapidShare;
use strict; use warnings;
use base 'Class::Accessor';

use version; our $VERSION = qv('0.3.1');

use WWW::Mechanize;
use File::Basename;
use Data::Dumper;


__PACKAGE__->mk_accessors(qw/
    url
    account_id
    password
    _mech
/);

sub new
{
    my ($proto) = @_;

    my $class = ref $proto || $proto;
    my $self = {};

    bless $self, $class;

    # Create our agent
    my $mech = WWW::Mechanize->new();
    $self->_mech($mech);

    return $self;
}

sub download_file
{
    my $self = shift;

    $self->_mech->get($self->url);
    $self->_mech->form_number(2);
    $self->_mech->submit;

    # login
    $self->_mech->form_with_fields(qw/accountid password/);
    $self->_mech->field(accountid => $self->account_id);
    $self->_mech->field(password => $self->password);
    $self->_mech->submit();
    $self->_mech->click_button(name => 'dl.start');

    my $ah_form = pop @{ $self->_mech->forms };

    my $file_name = basename($ah_form->action);

    print "Fetching " . $ah_form->action . " ...\n";
    print "Saving file as $file_name\n";
    $self->_mech->get( $ah_form->action, ":content_file" => $file_name );
}

1;