# $Id: OdSiebie 10867 2009-10-26 22:47:10Z sparky $
# Get::OdSiebie - File, audio, video and picture getter plugin for rsget.pl
#
# 2009 (c) Przemysław Iskra <sparky@pld-linux.org>
#		This program is free software,
# you may distribute it under GPL v2 or newer.

name: OdSiebie
short: OS
uri: qr{odsiebie\.com/pokaz/}
cookie: os
slots: max
status: OK 2009-10-22

start:
	GET( $-{_uri} );

	ERROR( "some problem, file not found ?" )
		if $-{_referer} =~ m{/(upload|error)\.html};

	if ( m{<img id="thepic" .* src="(.*?)"} ) { # picture
		$-{file_uri} = $1;
		! m{<dl class="file-info">.*?<dd> ($STDSIZE)</dd>}s;
		my $size = $1;
		$-{file_uri} =~ m{.*/(.*?)$};
		INFO( name => $1, asize => $size );

		GOTO stage_download;
	} elsif ( m{var VideoID = "video=(http://.*?)::url=.*?";} ) { # video
		$-{file_uri} = $1;

		! m{Oryginalna nazwa pliku: (.*?)<br />.*<br />Rozmiar pliku:\s+($STDSIZE)<!--};
		$-{fname} = $1;
		INFO( name => $1, asize => $2 );

		GOTO stage_download;
	}

	# mp3 or binary file
	! m{<dl\s+class="file-info">.*?<dd.*?>
		(?:\s*<!--.*?-->\s*<!--.*?-->\s*)?
		(.*?)
		</dd>.*?<dd>\s*($STDSIZE)</dd>}sx;
	INFO( name => $1, asize => $2 );

	! m{href="(/pobierz/\d+---.*?(\.html)?)"};
	CLICK( $1 );

	! m{href="(/download/\d+---.*?.html)"};
	$-{file_uri} = $1;

stage_download:
	my @fname;
	@fname = ( fname => $-{fname} ) if $-{fname};
	CLICK_DOWNLOAD( $-{file_uri}, @fname );

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