# -*- cperl -*-
package RssC::Filter::Isweb;
use base RssC::Filter;
use strict;
use warnings;

sub new {
    my $class = shift;
    my $this = $class->SUPER::new(@_);
    $this->{skip_until} = '';
    $this;
}

sub interested_p {
    my ($this, $uri) = @_;
    $uri->host =~ m/infoseek\.co\.jp$/;
}

sub filter {
    my ($this, $uri, $line) = @_;

    my $ad_begin_1 = '<!--Infoseek Analyzer start-->';
    my $ad_begin_2 = '<!-- isweb auto-insert';
    my $ad_end     = '<!-- inserted by isweb server -->';

    if ($this->{skip_until} ne '') {
	if (index($line, $this->{skip_until}) != -1) {
	    $this->{skip_until} = '';
	}
    }
    elsif (index($line, $ad_begin_1) != -1 or
	     index($line, $ad_begin_2) != -1) {
	$this->{skip_until} = $ad_end;
    }
    else {
	return $line;
    }
    return '';
}

1;
