# $Id: MegaUpload 11945 2010-12-03 23:37:19Z sparky $
# Get::MegaUpload - 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: MegaUpload
short: MU
web: "http://megaupload.com/"
tos: "http://megaupload.com/?c=terms"
uri: qr{megaupload\.com/(../)?\?d=}
uri: qr{megaporn\.com/(../)?\?d=}
uri: qr{megarotic\.com/(../)?\?d=}
uri: qr{sexuploader\.com/(../)?\?d=}
uri: qr{megavideo\.com/\?d=}
status: OK 2010-12-03

unify:
	my ($id) = /d=([A-Z0-9]*)/i;
	$id = uc $id;
	my $host = "megaupload";
	$host = "megaporn" if m{^http://(?:www\.)?(?:megarotic|sexuploader|megaporn)};
	return "http://$host.com/?d=$id";

start:
	GET( unify( $-{_uri} ) );

	ERROR( "file not found" )
		if /Unfortunately, the link you have clicked is not available/;

	ERROR( "not allowed: file larger than 1GB" )
		if /<span class="down_txt1">The file you are trying to download is larger than/;

	DELAY( 600, "temporarily unavailable" )
		if /The file you are trying to access is temporarily unavailable/;

	! m{<strong>File size:</strong> ($STDSIZE)<br />}o;
	my $size = $1;

	! m{<div class="down_butt_pad1" style="display:none;" id="downloadlink"><a href="(.*/files/.*/(.*))" class="down_butt1"};
	$-{file_uri} = $1;
	my $name = $2;

	INFO( name => $name, asize => $size );

	! /count=([0-9]+);/;
	WAIT( $1, "starting download" );

	CLICK_DOWNLOAD( $-{file_uri} );

	RESTART( - irand( 60, 360 ), "free limit reached" )
		if /Download limit exceeded/;

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