package GCPlugins::GCgames::GCNextGame; ################################################### # # Copyright 2005-2010 Christian Jodar # # This file is part of GCstar. # # GCstar is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # GCstar is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GCstar; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # ################################################### use strict; use utf8; use GCPlugins::GCgames::GCgamesCommon; { package GCPlugins::GCgames::GCPluginNextGame; use base 'GCPlugins::GCgames::GCgamesPluginsBase'; sub start { my ($self, $tagname, $attr, $attrseq, $origtext) = @_; $self->{inside}->{$tagname}++; if ($self->{parsingList}) { if ($self->{isGenre} eq '1') { $self->{isGenre} = 2 ; } elsif (($tagname eq 'div') && ($attr->{class} eq 'box_searchresult')) { $self->{isGame} = 1 ; $self->{itemIdx}++; } elsif (($tagname eq 'ul') && ($attr->{class} eq 'platforms')) { $self->{isPlatform} = 1 ; } elsif (($tagname eq 'li') && ($self->{isPlatform} eq 1)) { $self->{isPlatform} = 2 ; } elsif (($tagname eq 'hr') && ($attr->{class} eq 'clear')) { $self->{isPlatform} = 0 ; } elsif (($tagname eq 'a') && ($attr->{class} eq 'blu')) { return if $self->{alreadyRetrieved}->{$attr->{href}}; $self->{alreadyRetrieved}->{$attr->{href}} = 1; $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; $self->{isName} = 1 ; } elsif (($tagname eq 'dt') && ($self->{isGame} eq '1')) { $self->{isAnalyse} = 1 ; } } elsif ($self->{parsingTips}) { } else { if ($self->{isDeveloper} eq 1) { $self->{isDeveloper} = 2; } elsif ($self->{isGenre} eq 1) { $self->{isGenre} = 2; } elsif ($self->{isEditor} eq 1) { $self->{isEditor} = 2 ; } elsif ($self->{isDate} eq 1) { $self->{isDate} = 2 ; } elsif ($self->{isPlayer} eq 1) { $self->{isPlayer} = 2; } elsif ($self->{isPlatform} eq 1) { $self->{isPlatform} = 2; } elsif (($tagname eq 'div') && ($attr->{class} eq 'box_liquid')) { $self->{isDescription} = 0 ; } elsif ($tagname eq 'head') { $self->{isDescription} = 0 ; } elsif (($tagname eq 'h1') && ($attr->{class} eq 'blu')) { $self->{isName} = 1 ; } elsif (($tagname eq 'hr') && ($attr->{class} eq 'clear')) { $self->{isAnalyse} = 0 ; } elsif (($tagname eq 'dl') && ($attr->{class} eq 'datasheet_column')) { $self->{isAnalyse} = 1 ; } elsif (($tagname eq 'dt') && ($self->{isAnalyse} eq '1')) { $self->{isAnalyse} = 2 ; } elsif (($tagname eq 'td') && ($attr->{class} eq 'active current')) { $self->{isPlatform} = 1 ; } elsif (($tagname eq 'img') && ($attr->{id} eq 'datasheet_packshot')) { $self->{curInfo}->{boxpic} = $attr->{src}; if ($self->{bigPics}) { $self->{curInfo}->{boxpic} =~ s|.T160.|.|gi; } } elsif ( ($tagname eq 'img') && ($attr->{class} eq 'thumb') ) { if ($self->{curInfo}->{screenshot1} eq '') { $self->{curInfo}->{screenshot1} = $attr->{src}; if ($self->{bigPics}) { $self->{curInfo}->{screenshot1} =~ s|.T200.|.|gi; } } elsif ($self->{curInfo}->{screenshot2} eq '') { $self->{curInfo}->{screenshot2} = $attr->{src}; if ($self->{bigPics}) { $self->{curInfo}->{screenshot2} =~ s|.T200.|.|gi; } } } elsif (($tagname eq 'a') && ($attr->{name} eq 'REVIEW')) { $self->{isDescription} = 1 ; } elsif (($tagname eq 'ul') && ($attr->{class} eq 'platforms') && ($self->{isDescription} eq 1)) { $self->{isDescription} = 2 ; } elsif (($tagname eq 'a') && ($attr->{class} eq 'blu') && ($self->{isDescription} eq 3)) { my $html = $self->loadPage( $attr->{href}, 0, 1 ); $html =~ s|&|&|gi; my $found = index($html,"