# $Id: SendSpace 11673 2010-07-14 16:55:15Z sparky $
# Get::SendSpace - File getter plugin for rsget.pl
#
# 2009-2010 (c) Przemysław Iskra <sparky@pld-linux.org>
#		This program is free software,
# you may distribute it under GPL v2 or newer.

name: SendSpace
short: SS
web: "http://sendspace.com/"
tos: "http://sendspace.com/terms.html"
uri: qr{sendspace\.com/file/}
cookie: ss
status: OK 2010-07-14

start:
	GET( $-{_uri} );

	ERROR( "file not found" )
		if /Sorry, the file you requested is not available/;

	! m#<b>Name:</b>\s*(.*?)\s*<br><b>Size:</b>\s*([\d\.]+MB)\s*<br>#;
	INFO( name => $1, asize => $2 );

	! my $form = $self->form( match => { body => qr/"download"/ } );
	! $form->select( download => 0 );

	CLICK( $form->post() );

	! m#<a id="downlink" class="mango" href="(.*?)"#;
	my $file_uri = $1;

	CLICK_DOWNLOAD( $file_uri );

	RESTART( - irand( 60, 300 ), "servers overloaded" )
		if /Sorry, the free service is at full capacity/;
	RESTART( 0, "empty page" ) unless /\S/;
	MULTI() if /You cannot download more than one file at a time/;

# vim: filetype=perl:ts=4:sw=4
