#!/usr/bin/perl

name: FlyfileUs
short: FU
uri: qr{flyfile\.us/}
status: OK 2009-08-24

start:
	GET( $-{_uri} );

	ERROR( "file not found" ) if /(No such file|No such user)/;
	m{<h2>Download File (.*?)</h2>}; #\s*<font .*?>You have requested .*? \((\d+\.\d+) Mb\)</font>}s;
	$-{name} = $1;

	! s/^.*?<Form method="POST" action=''>//s;
	! s/(.*?)<\/Form>.*$/$1/s;
	my %opts;
	$opts{$1} = $2 while s/<input type="hidden" name="(.*?)" value="(.*?)">//;
	$opts{method_free} = "Free Download";

	GET( "", post => \%opts );

	m{<small>\((\d+) bytes\)</small>};
	INFO( name => $-{name}, size => $1 );

	RESTART( 600, "download-limit reached" )
		if /You have reached the download-limit/;

	! s/^.*?<Form name="F1" method="POST" action=""//s;
	! s/(.*?)<\/Form>.*$/$1/s;
	my %opts;
	$opts{$1} = $2 while s/<input type="hidden" name="(.*?)" value="(.*?)">//;
	$opts{btn_download} = "Create Download Link";

	DOWNLOAD( $-{_referer}, post => \%opts );

	# html
	RESTART( 120, "temporarily unavailable" )
		if /temporarily unavailable/;

# vim:ts=4:sw=4
