# $Id: Gazeta 11997 2010-12-19 17:28:08Z sparky $
# Audio::Gazeta - Audio getter plugin for rsget.pl
#
# 2010 (c) Paweł Zuzelski <pawelz@pld-linux.org>
#		This program is free software,
# you may distribute it under GPL v2 or newer.

name: Gazeta
short: A:Gazeta
web: "http://gazeta.pl/"
uri: qr{bi.gazeta.pl/im/\d/\d+/m\d+\.mp3}
slots: max
status: OK 2010-09-19

unify:
	# don't remove #/.*
	return $_;

start:
	GET( $-{_uri}, headonly => 1 );

	my ( $len ) = /^Content-Length:\s*(\d+)\r?$/mi;
	$len ||= -1;

	my $fname;
	if ( $-{_uri} =~ m{#/([^/]+?)(?:\.mp3)?$} ) {
		$fname = uri_unescape( $1 ) . ".mp3";
	} else {
		! $-{_uri} =~ m{.*/(.*?)(#.*?)?$};
		$fname = uri_unescape( $1 );
	}

	INFO( name => $fname, size => $len, quality => "mp3" );

	DOWNLOAD( $-{_uri}, fname => $fname );

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