# $Id: ImageShack 11654 2010-07-12 01:21:17Z sparky $
# Image::ImageShack - Image 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: ImageShack
short: I:ImageShack
web: "http://imageshack.us/"
tos: "http://reg.imageshack.us/content.php?page=rules"
uri: qr{profile\.imageshack\.us/user/.*?/images/detail/#\d+/.+}
uri: qr{(?:img\d+\.)imageshack\.us/(?:i/.+/|my\.php\?image=.+)}
slots: max
status: OK 2010-07-12

unify:
	return "http://img$1.imageshack.us/i/$2/"
		if m{http://profile\.imageshack\.us/user/.*?/images/detail/#(\d+)/(.+)}
			or m{http://img(\d+)\.imageshack\.us/my\.php\?image=(.+)};

start:
	GET( $-{_uri} );

	ERROR( "file not found" ) if $-{_referer} eq "http://www.imageshack.us/";

	! m{src="(.*?)" alt="click to zoom"};
	my $file_uri = de_ml( $1 );
	( my $fname = $file_uri ) =~ s{.*/}{};

	my $q = "image";
	$q = $1 if $fname =~ /\.(\S{1,5}?)$/;

	INFO( name => $fname, quality => $q );

	DOWNLOAD( $file_uri );

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