# -*- cperl -*-
package RssC::Filter::GeocitiesJP;
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/geocities\.jp$/ or
      $uri->host =~ m/geocities\.co\.jp$/;
}

sub filter {
    my ($this, $uri, $line) = @_;
    
    my $begin1 = '<!-- geoguide start -->';
    my $end1 = '<!-- geoguide end -->';

    my $begin2 = '<!-- text below generated by server. PLEASE REMOVE -->';

    if ($this->{skip_until} ne '') {
	if (index($line, $this->{skip_until}) != -1) {
	    $this->{skip_until} = '';
	}
    }
    elsif (index($line, $begin1) != -1) {
	$this->{skip_until} = $end1;
    }
    elsif (index($line, $begin2) != -1) {
	$this->{skip_until} = '\0' x 256; # never occurs
    }
    else {
	return $line;
    }
    return '';
}

1;
