# Hide album contents according to a regular expression.
#
# Example:  Hide any files that contain "old" or "blurry"
# % album -plugin format/hide_regex -hide_regex:regex old -hide_regex:regex blurry
#
sub start_plugin {
	my ($opt) = @_;

	album::hook($opt,'gather_contents_item',\&hide_album_regex);
	album::add_option(1,"regex",album::OPTION_ARR, usage=>"List of album regexes to hide.");

	return {
		author => 'David Hansen',
		href => 'http://www.sr71.net/',
		version => '1.1',
		description => "Hide any albums that match a regex.",
	};
}

sub hide_album_regex {
	my ($opt,$data,$hookname, $dir, $item) = @_;
	my $path_regexes = album::option($opt, "regex");

	foreach $regex (@$path_regexes) {
		return 1 if ($item =~ /$regex/);
	}
	return 0;
}

1;;

