diff options
Diffstat (limited to 'lib/gcstar/GCPlugins/GCgames')
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCAlapage.pm | 262 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCAmazon.pm | 115 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCAmazonCA.pm | 115 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCAmazonDE.pm | 114 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCAmazonFR.pm | 118 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCAmazonJP.pm | 120 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCAmazonUK.pm | 115 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCDicoDuNet.pm | 291 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCGameSpot.pm | 490 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm | 447 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm | 425 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCLudus.pm | 367 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCMobyGames.pm | 541 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCNextGame.pm | 480 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCTheLegacy.pm | 316 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCgamesAmazonCommon.pm | 314 | ||||
-rw-r--r-- | lib/gcstar/GCPlugins/GCgames/GCgamesCommon.pm | 87 |
17 files changed, 4717 insertions, 0 deletions
diff --git a/lib/gcstar/GCPlugins/GCgames/GCAlapage.pm b/lib/gcstar/GCPlugins/GCgames/GCAlapage.pm new file mode 100644 index 0000000..0d21a94 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCAlapage.pm @@ -0,0 +1,262 @@ +package GCPlugins::GCgames::GCAlapage;
+
+###################################################
+#
+# Copyright 2005-2011 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::GCPluginAlapage;
+
+ use base 'GCPlugins::GCgames::GCgamesPluginsBase';
+
+ sub start
+ {
+ my ($self, $tagname, $attr, $attrseq, $origtext) = @_;
+
+ $self->{inside}->{$tagname}++;
+
+ if ($self->{parsingList})
+ {
+ if (($tagname eq 'div') && ($attr->{class} eq 'infosProduit'))
+ {
+ $self->{itemIdx}++;
+ $self->{isGame} = 1 ;
+ }
+ elsif (($tagname eq 'a') && ($self->{isGame}))
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href};
+ $self->{itemsList}[$self->{itemIdx}]->{name} = $attr->{title};
+ $self->{isGame} = 0 ;
+ }
+ elsif (($tagname eq 'span') && ($attr->{class} eq 'liensAriane') && ($self->{isGame}) && ($self->{itemsList}[$self->{itemIdx}]->{platform} eq ''))
+ {
+ $self->{isPlatform} = 1 ;
+ }
+ }
+ elsif ($self->{parsingTips})
+ {
+ }
+ else
+ {
+
+ if (($tagname eq 'h1') && ($attr->{id} eq 'zm_name_description'))
+ {
+ $self->{isName} = 1 ;
+ }
+ elsif (($tagname eq 'div') && ($attr->{id} eq 'zm_description_long'))
+ {
+ $self->{isDescription} = 1 ;
+ }
+ elsif (($tagname eq 'span') && ($attr->{rel} eq 'images nocount') && ($self->{bigPics}))
+ {
+ $self->{curInfo}->{boxpic} = $attr->{href_img} ;
+ }
+ elsif (($tagname eq 'img') && ($attr->{id} eq 'zm_main_image') && !($self->{bigPics}))
+ {
+ $self->{curInfo}->{boxpic} = $attr->{src} ;
+ }
+ }
+ }
+
+ sub end
+ {
+ my ($self, $tagname) = @_;
+
+ $self->{inside}->{$tagname}--;
+ }
+
+ sub text
+ {
+ my ($self, $origtext) = @_;
+
+ if ($self->{parsingList})
+ {
+ if ($self->{isPlatform})
+ {
+ # Enleve les blancs en debut de chaine
+ $origtext =~ s/^\s+//;
+ # Enleve les blancs en fin de chaine
+ $origtext =~ s/\s+$//;
+
+ $origtext =~ s/Sony //i;
+ $origtext =~ s/Jeux PC/PC/i;
+
+ $self->{itemsList}[$self->{itemIdx}]->{platform} = $origtext;
+ $self->{Save_plateforme} = $self->{itemsList}[$self->{itemIdx}]->{platform};
+ $self->{isPlatform} = 0;
+
+ }
+ }
+ elsif ($self->{parsingTips})
+ {
+ }
+ else
+ {
+ # Enleve les blancs en debut de chaine
+ $origtext =~ s/^\s+//;
+ if ($self->{isName})
+ {
+ $self->{curInfo}->{name} = $origtext;
+ $self->{curInfo}->{platform} = $self->{Save_plateforme};
+ $self->{isName} = 0 ;
+
+ if ($self->{ean} ne '')
+ {
+ $self->{curInfo}->{ean} = $self->{ean};
+ }
+
+ }
+ elsif ($self->{isDescription} eq 1)
+ {
+ # Enleve les blancs dans le texte
+ $origtext =~ s/ / /g;
+ $self->{curInfo}->{description} = $origtext;
+ $self->{isDescription} = 0 ;
+ }
+
+ }
+ }
+
+ sub getTipsUrl
+ {
+ my $self = shift;
+
+ return ;
+
+ }
+
+ sub new
+ {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = $class->SUPER::new();
+ bless ($self, $class);
+
+ $self->{hasField} = {
+ name => 1,
+ platform => 1,
+ released => 0,
+ genre => 0
+ };
+
+ $self->{isName} = 0;
+ $self->{isGame} = 0;
+ $self->{isPlatform} = 0;
+ $self->{Save_plateforme} = '';
+ $self->{isDescription} = 0;
+ $self->{ean} = '';
+
+ return $self;
+ }
+
+ sub preProcess
+ {
+ my ($self, $html) = @_;
+
+ if ($self->{parsingList})
+ {
+ }
+ else
+ {
+ $html =~ s|<br>||gi;
+ $html =~ s|<br />||gi;
+
+ $html =~ s|<b>||gi;
+ $html =~ s|</b>||gi;
+ $html =~ s|<i>||gi;
+ $html =~ s|</i>||gi;
+ $html =~ s|<p>|\n|gi;
+ $html =~ s|</p>||gi;
+ $html =~ s|\x{92}|'|gi;
+ $html =~ s|’|'|gi;
+ $html =~ s|•|*|gi;
+ $html =~ s|œ|oe|gi;
+ $html =~ s|…|...|gi;
+ $html =~ s|\x{85}|...|gi;
+ $html =~ s|\x{8C}|OE|gi;
+ $html =~ s|\x{9C}|oe|gi;
+ }
+ return $html;
+ }
+
+ sub getSearchUrl
+ {
+ my ($self, $word) = @_;
+
+ if ($self->{searchField} eq 'ean')
+ {
+ $self->{ean} = $word;
+ }
+ else
+ {
+ $self->{ean} = '';
+ }
+
+ return 'http://search.alapage.com/search?a=8584451-0-0&s='.$word;
+ }
+
+ sub getItemUrl
+ {
+ my ($self, $url) = @_;
+
+ return $url;
+ }
+
+ sub getName
+ {
+ return 'Alapage';
+ }
+
+ sub getCharset
+ {
+ my $self = shift;
+ #return "UTF-8";
+ return "ISO-8859-15";
+ }
+
+ sub getAuthor
+ {
+ return 'TPF';
+ }
+
+ sub getLang
+ {
+ return 'FR';
+ }
+
+ sub getSearchFieldsArray
+ {
+ return ['ean', 'name'];
+ }
+
+ sub getDefaultPictureSuffix
+ {
+ return '.jpg';
+ }
+
+}
+
+1;
diff --git a/lib/gcstar/GCPlugins/GCgames/GCAmazon.pm b/lib/gcstar/GCPlugins/GCgames/GCAmazon.pm new file mode 100644 index 0000000..36b7890 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCAmazon.pm @@ -0,0 +1,115 @@ +package GCPlugins::GCgames::GCAmazon;
+
+###################################################
+#
+# 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::GCgamesAmazonCommon;
+
+{
+ package GCPlugins::GCgames::GCPluginAmazon;
+
+ use base 'GCPlugins::GCgames::GCgamesAmazonPluginsBase';
+
+ sub new
+ {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = $class->SUPER::new();
+ bless ($self, $class);
+
+ $self->{suffix} = 'com';
+
+ return $self;
+ }
+
+ sub preProcess
+ {
+ my ($self, $html) = @_;
+
+ if ($self->{parsingList})
+ {
+ }
+ else
+ {
+ $html =~ s/>Product Description</><tpfdescription><\/tpfdescription></;
+ # Le descriptif pouvant contenir des balises html je le repere maintenant
+ my $found = index($html,"<tpfdescription>");
+ if ( $found >= 0 )
+ {
+ my $html2 = substr($html, $found,length($html)- $found);
+
+ $html2 =~ s|</li>||gi;
+ $html2 =~ s|<p>|\n\n|gi;
+ $html2 =~ s|</p>||gi;
+ $html2 =~ s|<ul>|\n|gi;
+ $html2 =~ s|</ul>|\n\n|gi;
+ $html2 =~ s|<strong>||gi;
+ $html2 =~ s|</strong>||gi;
+ $html2 =~ s|<em>||gi;
+ $html2 =~ s|</em>||gi;
+
+ $html = substr($html, 0, $found) . $html2 ;
+ }
+
+ $html =~ s/Release Date :</<tpfdateparution></gi;
+ $html =~ s/Release Date:</<tpfdateparution></gi;
+ $html =~ s/<b>Platform:<\/b> </<tpfplateforme><\/tpfplateforme></gi;
+ $html =~ s/<b>Platform:<\/b>/<tpfplateforme><\/tpfplateforme>/gi;
+ $html =~ s/registerImage\("original_image",/<\/script><tpfcouverture src=/gi;
+ $html =~ s/registerImage\("alt_image_1",/<\/script><tpfscreenshot1 src=/gi;
+ $html =~ s/registerImage\("alt_image_2",/<\/script><tpfscreenshot2 src=/gi;
+ $html =~ s|<b>||gi;
+ $html =~ s|</b>||gi;
+ $html =~ s|<i>||gi;
+ $html =~ s|</i>||gi;
+ $html =~ s|<li>|\n*|gi;
+ $html =~ s|<br>|\n|gi;
+ $html =~ s|<br />|\n|gi;
+ $html =~ s|\x{92}|'|gi;
+ $html =~ s|’|'|gi;
+ $html =~ s|•|*|gi;
+ $html =~ s|œ|oe|gi;
+ $html =~ s|…|...|gi;
+ $html =~ s|\x{85}|...|gi;
+ $html =~ s|\x{8C}|OE|gi;
+ $html =~ s|\x{9C}|oe|gi;
+
+ }
+ return $html;
+ }
+
+ sub getName
+ {
+ return 'Amazon (US)';
+ }
+
+ sub getLang
+ {
+ return 'EN';
+ }
+
+}
+
+1;
diff --git a/lib/gcstar/GCPlugins/GCgames/GCAmazonCA.pm b/lib/gcstar/GCPlugins/GCgames/GCAmazonCA.pm new file mode 100644 index 0000000..a54c4ef --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCAmazonCA.pm @@ -0,0 +1,115 @@ +package GCPlugins::GCgames::GCAmazonCA;
+
+###################################################
+#
+# 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::GCgamesAmazonCommon;
+
+{
+ package GCPlugins::GCgames::GCPluginAmazonCA;
+
+ use base 'GCPlugins::GCgames::GCgamesAmazonPluginsBase';
+
+ sub new
+ {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = $class->SUPER::new();
+ bless ($self, $class);
+
+ $self->{suffix} = 'ca';
+
+ return $self;
+ }
+
+ sub preProcess
+ {
+ my ($self, $html) = @_;
+
+ if ($self->{parsingList})
+ {
+ }
+ else
+ {
+ $html =~ s/>Product Description</><tpfdescription><\/tpfdescription></;
+ # Le descriptif pouvant contenir des balises html je le repere maintenant
+ my $found = index($html,"<tpfdescription>");
+ if ( $found >= 0 )
+ {
+ my $html2 = substr($html, $found,length($html)- $found);
+
+ $html2 =~ s|</li>||gi;
+ $html2 =~ s|<p>|\n\n|gi;
+ $html2 =~ s|</p>||gi;
+ $html2 =~ s|<ul>|\n|gi;
+ $html2 =~ s|</ul>|\n\n|gi;
+ $html2 =~ s|<strong>||gi;
+ $html2 =~ s|</strong>||gi;
+ $html2 =~ s|<em>||gi;
+ $html2 =~ s|</em>||gi;
+
+ $html = substr($html, 0, $found) . $html2 ;
+ }
+
+ $html =~ s/Release Date :</<tpfdateparution></gi;
+ $html =~ s/Release Date:</<tpfdateparution></gi;
+ $html =~ s/<b>Platform:<\/b> </<tpfplateforme><\/tpfplateforme></gi;
+ $html =~ s/<b>Platform:<\/b>/<tpfplateforme><\/tpfplateforme>/gi;
+ $html =~ s/registerImage\("original_image",/<\/script><tpfcouverture src=/gi;
+ $html =~ s/registerImage\("alt_image_1",/<\/script><tpfscreenshot1 src=/gi;
+ $html =~ s/registerImage\("alt_image_2",/<\/script><tpfscreenshot2 src=/gi;
+ $html =~ s|<b>||gi;
+ $html =~ s|</b>||gi;
+ $html =~ s|<i>||gi;
+ $html =~ s|</i>||gi;
+ $html =~ s|<li>|\n*|gi;
+ $html =~ s|<br>|\n|gi;
+ $html =~ s|<br />|\n|gi;
+ $html =~ s|\x{92}|'|gi;
+ $html =~ s|’|'|gi;
+ $html =~ s|•|*|gi;
+ $html =~ s|œ|oe|gi;
+ $html =~ s|…|...|gi;
+ $html =~ s|\x{85}|...|gi;
+ $html =~ s|\x{8C}|OE|gi;
+ $html =~ s|\x{9C}|oe|gi;
+
+ }
+ return $html;
+ }
+
+ sub getName
+ {
+ return 'Amazon (CA)';
+ }
+
+ sub getLang
+ {
+ return 'EN';
+ }
+
+}
+
+1;
diff --git a/lib/gcstar/GCPlugins/GCgames/GCAmazonDE.pm b/lib/gcstar/GCPlugins/GCgames/GCAmazonDE.pm new file mode 100644 index 0000000..1dbc106 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCAmazonDE.pm @@ -0,0 +1,114 @@ +package GCPlugins::GCgames::GCAmazonDE; + +################################################### +# +# 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::GCgamesAmazonCommon; + +{ + package GCPlugins::GCgames::GCPluginAmazonDE; + + use base 'GCPlugins::GCgames::GCgamesAmazonPluginsBase'; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{suffix} = 'de'; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s/>Produktbeschreibungen</><tpfdescription><\/tpfdescription></; + # Le descriptif pouvant contenir des balises html je le repere maintenant + my $found = index($html,"<tpfdescription>"); + if ( $found >= 0 ) + { + my $html2 = substr($html, $found,length($html)- $found); + + $html2 =~ s|</li>||gi; + $html2 =~ s|<p>|\n\n|gi; + $html2 =~ s|</p>||gi; + $html2 =~ s|<ul>|\n|gi; + $html2 =~ s|</ul>|\n\n|gi; + $html2 =~ s|<strong>||gi; + $html2 =~ s|</strong>||gi; + $html2 =~ s|<em>||gi; + $html2 =~ s|</em>||gi; + + $html = substr($html, 0, $found) . $html2 ; + } + + $html =~ s/Erscheinungsdatum :</<tpfdateparution></gi; + $html =~ s/Erscheinungsdatum:</<tpfdateparution></gi; + $html =~ s/<b>Plattform:<\/b> </<tpfplateforme><\/tpfplateforme></gi; + $html =~ s/<b>Plattform:<\/b>/<tpfplateforme><\/tpfplateforme>/gi; + $html =~ s/registerImage\("original_image",/<\/script><tpfcouverture src=/gi; + $html =~ s/registerImage\("alt_image_1",/<\/script><tpfscreenshot1 src=/gi; + $html =~ s/registerImage\("alt_image_2",/<\/script><tpfscreenshot2 src=/gi; + $html =~ s|<b>||gi; + $html =~ s|</b>||gi; + $html =~ s|<i>||gi; + $html =~ s|</i>||gi; + $html =~ s|<li>|*|gi; + $html =~ s|<br>|\n|gi; + $html =~ s|<br />|\n|gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + + } + return $html; + } + + sub getName + { + return 'Amazon (DE)'; + } + + sub getLang + { + return 'DE'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCAmazonFR.pm b/lib/gcstar/GCPlugins/GCgames/GCAmazonFR.pm new file mode 100644 index 0000000..1bceb23 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCAmazonFR.pm @@ -0,0 +1,118 @@ +package GCPlugins::GCgames::GCAmazonFR; + +################################################### +# +# 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::GCgamesAmazonCommon; + +{ + package GCPlugins::GCgames::GCPluginAmazonFR; + + use base 'GCPlugins::GCgames::GCgamesAmazonPluginsBase'; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{suffix} = 'fr'; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s/>Description du produit</><tpfdescription><\/tpfdescription></; + $html =~ s/>Descriptions du produit</><tpfdescription><\/tpfdescription></; + # Le descriptif pouvant contenir des balises html je le repere maintenant + my $found = index($html,"<tpfdescription>"); + if ( $found >= 0 ) + { + my $html2 = substr($html, $found,length($html)- $found); + + $html2 =~ s|</li>||gi; + $html2 =~ s|<p>|\n\n|gi; + $html2 =~ s|</p>||gi; + $html2 =~ s|<ul>|\n|gi; + $html2 =~ s|</ul>|\n\n|gi; + $html2 =~ s|<strong>||gi; + $html2 =~ s|</strong>||gi; + $html2 =~ s|<em>||gi; + $html2 =~ s|</em>||gi; + + $html = substr($html, 0, $found) . $html2 ; + } + + $html =~ s/Date de parution :</<tpfdateparution></gi; + $html =~ s/Date de parution:</<tpfdateparution></gi; + $html =~ s/<b>Plate-forme:<\/b> </<tpfplateforme><\/tpfplateforme></gi; + $html =~ s/<b>Plate-forme:<\/b>/<tpfplateforme><\/tpfplateforme>/gi; + $html =~ s/registerImage\("original_image",/<\/script><tpfcouverture src=/gi; + $html =~ s/registerImage\("alt_image_1",/<\/script><tpfscreenshot1 src=/gi; + $html =~ s/registerImage\("alt_image_2",/<\/script><tpfscreenshot2 src=/gi; + $html =~ s|<b>||gi; + $html =~ s|</b>||gi; + $html =~ s|<i>||gi; + $html =~ s|</i>||gi; + $html =~ s|<li>|*|gi; + $html =~ s|<br>|\n|gi; + $html =~ s|<br />|\n|gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|œ|oe|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + # Bug sur Shadow of Memories pour PS2 + $html =~ s|Actio\)n|Action|gi; + + } + return $html; + } + + sub getName + { + return 'Amazon (FR)'; + } + + sub getLang + { + return 'FR'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCAmazonJP.pm b/lib/gcstar/GCPlugins/GCgames/GCAmazonJP.pm new file mode 100644 index 0000000..80824ec --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCAmazonJP.pm @@ -0,0 +1,120 @@ +package GCPlugins::GCgames::GCAmazonJP; + +################################################### +# +# 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::GCgamesAmazonCommon; + +{ + package GCPlugins::GCgames::GCPluginAmazonJP; + + use base 'GCPlugins::GCgames::GCgamesAmazonPluginsBase'; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{suffix} = 'co.jp'; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s/>商品の説明</><tpfdescription><\/tpfdescription></; + # Le descriptif pouvant contenir des balises html je le repere maintenant + my $found = index($html,"<tpfdescription>"); + if ( $found >= 0 ) + { + my $html2 = substr($html, $found,length($html)- $found); + + $html2 =~ s|</li>||gi; + $html2 =~ s|<p>|\n\n|gi; + $html2 =~ s|</p>||gi; + $html2 =~ s|<ul>|\n|gi; + $html2 =~ s|</ul>|\n\n|gi; + $html2 =~ s|<strong>||gi; + $html2 =~ s|</strong>||gi; + $html2 =~ s|<em>||gi; + $html2 =~ s|</em>||gi; + + $html = substr($html, 0, $found) . $html2 ; + } + + $html =~ s/発売日 :</<tpfdateparution></gi; + $html =~ s/発売日:</<tpfdateparution></gi; + $html =~ s/<b>プラットフォーム:<\/b> </<tpfplateforme><\/tpfplateforme></gi; + $html =~ s/<b>プラットフォーム:<\/b>/<tpfplateforme><\/tpfplateforme>/gi; + $html =~ s/registerImage\("original_image",/<\/script><tpfcouverture src=/gi; + $html =~ s/registerImage\("alt_image_1",/<\/script><tpfscreenshot1 src=/gi; + $html =~ s/registerImage\("alt_image_2",/<\/script><tpfscreenshot2 src=/gi; + $html =~ s|<b>||gi; + $html =~ s|</b>||gi; + $html =~ s|<i>||gi; + $html =~ s|</i>||gi; + $html =~ s|<li>|*|gi; + $html =~ s|<br>|\n|gi; + $html =~ s|<br />|\n|gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + + } + return $html; + } + + sub getName + { + return 'Amazon (JP)'; + } + + sub getCharset + { + my $self = shift; + return "SHIFT_JIS"; + } + + sub getLang + { + return 'JP'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCAmazonUK.pm b/lib/gcstar/GCPlugins/GCgames/GCAmazonUK.pm new file mode 100644 index 0000000..5108e8c --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCAmazonUK.pm @@ -0,0 +1,115 @@ +package GCPlugins::GCgames::GCAmazonUK; + +################################################### +# +# 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::GCgamesAmazonCommon; + +{ + package GCPlugins::GCgames::GCPluginAmazonUK; + + use base 'GCPlugins::GCgames::GCgamesAmazonPluginsBase'; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{suffix} = 'co.uk'; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s/>Product Description</><tpfdescription><\/tpfdescription></; + $html =~ s/>Reviews</><tpfdescription><\/tpfdescription></; + # Le descriptif pouvant contenir des balises html je le repere maintenant + my $found = index($html,"<tpfdescription>"); + if ( $found >= 0 ) + { + my $html2 = substr($html, $found,length($html)- $found); + + $html2 =~ s|</li>||gi; + $html2 =~ s|<p>|\n\n|gi; + $html2 =~ s|</p>||gi; + $html2 =~ s|<ul>|\n|gi; + $html2 =~ s|</ul>|\n\n|gi; + $html2 =~ s|<strong>||gi; + $html2 =~ s|</strong>||gi; + $html2 =~ s|<em>||gi; + $html2 =~ s|</em>||gi; + + $html = substr($html, 0, $found) . $html2 ; + } + + $html =~ s/Release Date :</<tpfdateparution></gi; + $html =~ s/Release Date:</<tpfdateparution></gi; + $html =~ s/<b>Platform:<\/b> </<tpfplateforme><\/tpfplateforme></gi; + $html =~ s/<b>Platform:<\/b>/<tpfplateforme><\/tpfplateforme>/gi; + $html =~ s/registerImage\("original_image",/<\/script><tpfcouverture src=/gi; + $html =~ s/registerImage\("alt_image_1",/<\/script><tpfscreenshot1 src=/gi; + $html =~ s/registerImage\("alt_image_2",/<\/script><tpfscreenshot2 src=/gi; + $html =~ s|<b>||gi; + $html =~ s|</b>||gi; + $html =~ s|<i>||gi; + $html =~ s|</i>||gi; + $html =~ s|<li>|*|gi; + $html =~ s|<br>|\n|gi; + $html =~ s|<br />|\n|gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + + } + return $html; + } + + sub getName + { + return 'Amazon (UK)'; + } + + sub getLang + { + return 'EN'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCDicoDuNet.pm b/lib/gcstar/GCPlugins/GCgames/GCDicoDuNet.pm new file mode 100644 index 0000000..fd130cf --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCDicoDuNet.pm @@ -0,0 +1,291 @@ +package GCPlugins::GCgames::GCDicoDuNet; + +################################################### +# +# 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::GCPluginDicoDuNet; + + use base 'GCPlugins::GCgames::GCgamesPluginsBase'; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + if (($tagname eq 'div') && ($attr->{class} eq 'cat_produit')) + { + $self->{isGame} = 1 ; + $self->{isUrl} = 1 ; + } + elsif (($tagname eq 'a') && ($self->{isUrl}) && ($self->{isGame})) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + $self->{isUrl} = 0 ; + } + elsif (($tagname eq 'strong') && ($self->{isGame})) + { + $self->{isName} = 1 ; + $self->{isGame} = 0 ; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + + if (($tagname eq 'h3') && ($attr->{class} eq 'produits')) + { + $self->{isGame} = 1 ; + } + elsif (($tagname eq 'span') && ($self->{isGame} eq 1) ) + { + $self->{isName} = 1 ; + $self->{isGame} = 2 ; + } + elsif (($tagname eq 'a') && ($self->{isGame} eq 2)) + { + $self->{isEditor} = 1 ; + $self->{isGame} = 0 ; + } + elsif ($tagname eq 'table') + { + $self->{isGame} = 0 ; + } + elsif (($tagname eq 'div') && ($attr->{id} eq 'vous_etes_ici')) + { + $self->{isPlatform} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{href} ne 'http://www.dicodunet.com/jeux-video/') && ($self->{isPlatform})) + { + $self->{isPlatform} = 2 ; + } + elsif (($tagname eq 'a') && (index($attr->{href},"www.dicodunet.com/jeux-video/img/") >= 0) && ($self->{curInfo}->{boxpic} eq '')) + { + my $html = $self->loadPage($attr->{href}, 0, 1); + my $found = index($html,"<h3 class=\"produits\">"); + if ( $found >= 0 ) + { + $html = substr($html, $found +length('<h3 class="produits">'),length($html)- $found -length('<h3 class="produits">')); + + my $found = index($html,"<img src=\""); + if ( $found >= 0 ) + { + $html = substr($html, $found +length('<img src="'),length($html)- $found -length('<img src="')); + $html = substr($html, 0,index($html,"\"")); + + $self->{curInfo}->{boxpic} = $html; + } + } + + } + elsif ($tagname eq 'tpfdateparution') + { + $self->{isDate} = 1 ; + } + elsif ($tagname eq 'tpfean') + { + $self->{isEan} = 1 ; + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isName}) + { + $self->{itemsList}[$self->{itemIdx}]->{name} = $origtext; + $self->{isName} = 0; + + } + } + elsif ($self->{parsingTips}) + { + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + if ($self->{isName}) + { + $self->{curInfo}->{name} = $origtext; + $self->{isName} = 0 ; + } + elsif ($self->{isEditor}) + { + $self->{curInfo}->{editor} = $origtext; + $self->{isEditor} = 0 ; + } + elsif ($self->{isPlatform} eq 2) + { + $origtext =~ s/PlayStation 2/Playstation 2/i; + $origtext =~ s/Jeux PC/PC/i; + $origtext =~ s/Jeux Mac/MAC/i; + + if (($self->{curInfo}->{platform} eq '') && ($origtext ne '')) + { + $self->{curInfo}->{platform} = $origtext; + } + elsif ($origtext ne '') + { + $self->{curInfo}->{platform} .= ', '; + $self->{curInfo}->{platform} .= $origtext; + } + $self->{isPlatform} = 0; + } + elsif ($self->{isDate}) + { + $self->{curInfo}->{released} = $origtext; + $self->{curInfo}->{released} =~ s|([0-9]*)-([0-9]*)-([0-9]*)|$3.'/'.$2.'/'.$1|e; + $self->{isDate} = 0 ; + } + elsif ($self->{isEan}) + { + $self->{curInfo}->{ean} = $origtext; + $self->{isEan} = 0 ; + } + + } + } + + sub getTipsUrl + { + my $self = shift; + + return ; + + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + name => 1, + platform => 0, + genre => 0, + released => 0 + }; + + $self->{isName} = 0; + $self->{isGame} = 0; + $self->{isUrl} = 0; + $self->{isPlatform} = 0; + $self->{isEditor} = 0; + $self->{isDate} = 0; + $self->{isEan} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + my $found = index($html,"class=\"produits_box\""); + if ( $found >= 0 ) + { + $html = substr($html, 0, $found); + } + + $html =~ s/Version sortie le /<tpfdateparution>/gi; + $html =~ s/Code EAN : /<tpfean>/gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + } + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + return ('http://www.dicodunet.com/jeux-video/recherche.php', ["q" => "$word"] ); + } + + sub getItemUrl + { + my ($self, $url) = @_; + return $url if $url; + return 'http://www.dicodunet.com/'; + } + + sub getName + { + return 'DicoDuNet'; + } + + sub getCharset + { + my $self = shift; + #return "UTF-8"; + return "ISO-8859-15"; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'FR'; + } + + sub getSearchFieldsArray + { + return ['name']; + } +} + +1; + diff --git a/lib/gcstar/GCPlugins/GCgames/GCGameSpot.pm b/lib/gcstar/GCPlugins/GCgames/GCGameSpot.pm new file mode 100644 index 0000000..c5870b4 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCGameSpot.pm @@ -0,0 +1,490 @@ +package GCPlugins::GCgames::GCGameSpot;
+
+###################################################
+#
+# Copyright 2005-2011 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::GCPluginGameSpot;
+
+ use base 'GCPlugins::GCgames::GCgamesPluginsBase';
+ use Text::Wrap;
+
+ sub start
+ {
+ my ($self, $tagname, $attr, $attrseq, $origtext) = @_;
+
+ $self->{inside}->{$tagname}++;
+ if ($self->{parsingList})
+ {
+ if ($tagname eq 'div')
+ {
+ $self->{isGame} = 1
+ if $attr->{class} =~ /result_title/;
+ }
+ elsif ($tagname eq 'tpfdatetpf')
+ {
+ $self->{isDate} = 1;
+ }
+ elsif (($tagname eq 'a') && ($self->{isGame}))
+ {
+ $self->{itemIdx}++;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href};
+ $self->{isName} = 1;
+ }
+ }
+ elsif ($self->{parsingTips})
+ {
+ if (($tagname eq 'h2') && ($attr->{class} eq 'module_title'))
+ {
+ $self->{isSection} = 1;
+ }
+ elsif (($tagname eq 'th') && ($attr->{scope} eq 'row') && ($attr->{class} eq 'code') && ($self->{section} ne ''))
+ {
+ $self->{isCheat} = 1;
+ }
+ elsif (($tagname eq 'td') && ($attr->{class} eq 'effect') && ($self->{section} ne ''))
+ {
+ $self->{isDesc} = 1;
+ }
+ elsif (($tagname eq 'h3') && ($attr->{class} eq 'cheatCodeTitle') && ($self->{section} eq 'Secrets'))
+ {
+ $self->{curInfo}->{secrets} .= "\n" if $self->{curInfo}->{secrets};
+ }
+ elsif ($tagname eq 'tpfdebuttpf')
+ {
+ $self->{section} = 'Secrets';
+ }
+ elsif (($tagname eq 'div') && ($attr->{class} eq 'head'))
+ {
+ $self->{section} = '';
+ }
+ elsif ($tagname eq 'head')
+ {
+ $self->{urlTips} = '';
+ }
+ }
+ else
+ {
+ if ($tagname eq 'img')
+ {
+ $self->{curInfo}->{boxpic} = ' '
+ if $attr->{src} =~ /no_preview/;
+ if ((! $self->{curInfo}->{boxpic}) && ($attr->{src} =~ /[^xo]boxs[^c]/))
+ {
+ $self->{curInfo}->{boxpic} = $attr->{src};
+ }
+ if ($attr->{src} =~ /thumb/)
+ {
+ my $pic = $attr->{src};
+ $pic =~ s/thumb00([0-9])/screen00$1/;
+ if ($1 && ($1 <= 2))
+ {
+ $self->{curInfo}->{'screenshot'.$1} = $pic
+ if ! $self->{curInfo}->{'screenshot'.$1};
+ }
+ }
+ }
+ elsif (($tagname eq 'div') && ($attr->{class} eq 'boxshot'))
+ {
+ $self->{isBox} = 1;
+ }
+ elsif (($tagname eq 'a') && ($self->{isBox} eq 1))
+ {
+ my $html = $self->loadPage($self->getItemUrl($attr->{href}), 0, 1);
+ my $found = index($html,"id=\"main_image\" src=\"");
+ if ( $found >= 0 )
+ {
+ $html = substr($html, $found +length('id="main_image" src="'),length($html)- $found -length('id="main_image" src="'));
+
+ my @array = split(/"/,$html);
+ #"
+ if ($self->{bigPics})
+ {
+ $self->{curInfo}->{boxpic} = $array[0];
+ }
+ $self->{curInfo}->{backpic} = $array[0];
+ $self->{curInfo}->{backpic} =~ s/_front/_back/;
+ }
+ $self->{isBox} = 0;
+ }
+ elsif (($tagname eq 'h1') && ($attr->{class} eq 'productPageTitle'))
+ {
+ $self->{isName} = 1 if ! $self->{curInfo}->{name};
+ }
+ elsif (($tagname eq 'meta') && ($attr->{name} eq 'description'))
+ {
+ $self->{curInfo}->{description} = $attr->{content};
+ }
+ elsif (($tagname eq 'li') && ($attr->{class} =~ /activeFilter/))
+ {
+ $self->{curInfo}->{exclusive} = 0;
+ }
+ elsif (($tagname eq 'span') && ($attr->{class} eq 'reviewer'))
+ {
+ $self->{isRating} = 1;
+ }
+ elsif (($tagname eq 'a') && ($self->{isRating} eq 1))
+ {
+ $self->{isRating} = 2;
+ }
+ elsif (($tagname eq 'li') && ($attr->{class} eq 'moreStat play_info number_of_players'))
+ {
+ $self->{isPlayers} = 1;
+ }
+ elsif (($tagname eq 'p') && ($self->{isPlayers} eq 1))
+ {
+ $self->{isPlayers} = 2;
+ }
+ elsif (($tagname eq 'li') && ($attr->{class} eq 'publisher'))
+ {
+ $self->{isEditor} = 1;
+ }
+ elsif (($tagname eq 'a') && ($self->{isEditor} eq 1))
+ {
+ $self->{isEditor} = 2;
+ }
+ elsif (($tagname eq 'li') && ($attr->{class} eq 'developer'))
+ {
+ $self->{isDeveloper} = 1;
+ }
+ elsif (($tagname eq 'a') && ($self->{isDeveloper} eq 1))
+ {
+ $self->{isDeveloper} = 2;
+ }
+ elsif (($tagname eq 'li') && ($attr->{class} eq 'genre'))
+ {
+ $self->{isGenre} = 1;
+ }
+ elsif (($tagname eq 'a') && ($self->{isGenre}))
+ {
+ $self->{curInfo}->{genre} = $attr->{title};
+ $self->{isGenre} = 0;
+ }
+ elsif (($tagname eq 'li') && ($attr->{class} eq 'date'))
+ {
+ $self->{isReleased} = 1;
+ }
+ elsif (($tagname eq 'a') && ($self->{isReleased} eq 1))
+ {
+ $self->{isReleased} = 2;
+ }
+ elsif (($tagname eq 'a') && ($attr->{href} =~ /\/cheats\//) && ($attr->{class} eq 'navItemAction'))
+ {
+ $self->{urlTips} = $attr->{href};
+ }
+ }
+ }
+
+ sub end
+ {
+ my ($self, $tagname) = @_;
+
+ $self->{inside}->{$tagname}--;
+ if ($self->{parsingList})
+ {
+ $self->{isGame} = 0
+ if ($tagname eq 'div');
+ }
+ elsif ($self->{parsingTips})
+ {
+ }
+ }
+
+ sub text
+ {
+ my ($self, $origtext) = @_;
+
+ if ($self->{parsingList})
+ {
+ if ($self->{isName})
+ {
+ $origtext =~ /^(.*?)\s*\((.*?)\)\s*$/;
+ $self->{itemsList}[$self->{itemIdx}]->{name} = $1;
+ $self->{itemsList}[$self->{itemIdx}]->{platform} = $2;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $self->{itemsList}[$self->{itemIdx}]->{url} . 'tpfplatformtpf' . $self->{itemsList}[$self->{itemIdx}]->{platform};
+ $self->{isName} = 0;
+ }
+ elsif ($self->{isDate})
+ {
+ $origtext =~ /^\s*Release Date:\s*(.*?)\s*$/ms;
+ $self->{itemsList}[$self->{itemIdx}]->{released} = $1;
+ $self->{isDate} = 0;
+ }
+ }
+ elsif ($self->{parsingTips})
+ {
+ if (($self->{isSection} eq 1) && $self->{inside}->{h2})
+ {
+ $self->{section} = 'Codes' if $origtext =~ /Cheat Codes$/;
+ $self->{section} = 'Unlockables' if $origtext =~ /Unlockables$/;
+ $self->{section} = 'Secrets' if $origtext =~ /Secrets$/;
+ $self->{section} = 'Secrets' if $origtext =~ /Easter Eggs$/;
+ $self->{isSection} = 0;
+ }
+ elsif (($self->{section} eq 'Codes') || ($self->{section} eq 'Unlockables'))
+ {
+ $origtext =~ s/^\s*//;
+ $origtext =~ s/\s*$//;
+ $Text::Wrap::columns = 80;
+ $origtext = Text::Wrap::wrap('', '', $origtext);
+
+ if ($self->{isCheat})
+ {
+ if ($self->{section} eq 'Codes')
+ {
+ $self->{tmpCheatLine} = [];
+ push @{$self->{tmpCheatLine}}, $origtext;
+ }
+ else
+ {
+ $self->{tmpCheatLine} = [];
+ ${$self->{tmpCheatLine}}[1] = $origtext;
+ }
+ $self->{isCheat} = 0;
+ }
+ elsif ($self->{isDesc})
+ {
+ if ($self->{section} eq 'Codes')
+ {
+ push @{$self->{tmpCheatLine}}, $origtext;
+ push @{$self->{curInfo}->{code}}, $self->{tmpCheatLine};
+ $self->{tmpCheatLine} = [];
+ }
+ else
+ {
+ ${$self->{tmpCheatLine}}[0] = $origtext;
+ push @{$self->{curInfo}->{unlockable}}, $self->{tmpCheatLine};
+ $self->{tmpCheatLine} = [];
+ }
+ $self->{isDesc} = 0;
+ }
+ }
+ elsif ($self->{section} eq 'Secrets')
+ {
+ $origtext =~ s/^\s*//;
+ $origtext =~ s/\s*$//;
+ return if !$origtext;
+ $self->{curInfo}->{secrets} .= "\n" if $self->{curInfo}->{secrets};
+ $self->{curInfo}->{secrets} .= $origtext;
+ }
+ }
+ else
+ {
+ if ($self->{isName})
+ {
+ $origtext =~ s/\n//g;
+ $self->{curInfo}->{name} = $origtext;
+ $self->{curInfo}->{platform} = $self->{url_plateforme};
+ $self->{curInfo}->{exclusive} = 1;
+ $self->{isName} = 0;
+ }
+ elsif ($self->{isRating} eq 2)
+ {
+ $self->{curInfo}->{ratingpress} = $origtext;
+ $self->{isRating} = 0;
+ }
+ else
+ {
+ $origtext =~ s/^\s*//;
+ $origtext =~ s/\s*$//;
+ return if !$origtext;
+ if ($self->{isReleased} eq 2)
+ {
+ $origtext =~ s/ .$//;
+ $self->{curInfo}->{released} = $origtext;
+ $self->{isReleased} = 0;
+ }
+ elsif ($self->{isEditor} eq 2)
+ {
+ $self->{curInfo}->{editor} = $origtext;
+ $self->{isEditor} = 0;
+ }
+ elsif ($self->{isDeveloper} eq 2)
+ {
+ $self->{curInfo}->{developer} = $origtext;
+ $self->{isDeveloper} = 0;
+ }
+ elsif ($self->{isPlayers} eq 2)
+ {
+ $origtext =~ s/(Players?)?\s*\(.*?$//;
+ $self->{curInfo}->{players} = $origtext;
+ $self->{isPlayers} = 0;
+ }
+ }
+ }
+ }
+
+ sub getTipsUrl
+ {
+ my $self = shift;
+ return 'http://www.gamespot.com' .$self->{urlTips};
+ }
+
+ sub new
+ {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = $class->SUPER::new();
+ bless ($self, $class);
+
+ $self->{hasField} = {
+ name => 1,
+ platform => 1,
+ released => 1,
+ };
+
+ $self->{isName} = 0;
+ $self->{isGame} = 0;
+ $self->{isDate} = 0;
+ $self->{isCheat} = 0;
+ $self->{isDesc} = 0;
+ $self->{isTip} = 0;
+ $self->{isRating} = 0;
+ $self->{section} = '';
+ $self->{isSection} = 0;
+ $self->{isDeveloper} = 0;
+ $self->{isGenre} = 0;
+ $self->{isEditor} = 0;
+ $self->{isReleased} = 0;
+ $self->{isPlayers} = 0;
+ $self->{isBox} = 0;
+ $self->{isExclu} = 0;
+ $self->{url_plateforme} = '';
+ $self->{urlTips} = "";
+ $self->{SaveUrl} = "";
+
+ return $self;
+ }
+
+ sub preProcess
+ {
+ my ($self, $html) = @_;
+
+ if ($self->{parsingTips})
+ {
+ $html =~ s|<b>(.*?)</b>|$1|g;
+ $html =~ s|<i>(.*?)</i>|$1|g;
+## It takes too much time
+# $html =~ s|<li class="guideAct"><a href="(.+)">Go to Online Walkthrough|'<tpfdebuttpf>' . $self->RecupSolution($1) . '<tpffintpf>'|ge;
+ }
+ elsif ($self->{parsingList})
+ {
+ $html =~ s|Release Date|<tpfdatetpf>Release Date|g;
+ }
+ else
+ {
+ my $found = index($html,"Similar Games");
+ if ( $found >= 0 )
+ {
+ $html = substr($html, 0, $found);
+ }
+ }
+
+ return $html;
+ }
+
+ sub RecupSolution
+ {
+ my ($self, $url) = @_;
+
+ my $html = $self->loadPage($url);
+
+ my $found = index($html,"<h2>");
+ if ( $found >= 0 )
+ {
+ $html = substr($html, $found,length($html)- $found);
+ }
+ else
+ {
+ $found = index($html,"<span class=\"author\">");
+ if ( $found >= 0 )
+ {
+ $html = substr($html, $found,length($html)- $found);
+ }
+ }
+
+ $html = substr($html, 0, index($html, " rel=\"next\">"));
+
+ $html =~ s|<a class="next" href="/gameguides.html"||ge;
+ $html =~ s|<a class="next" href="(.+)"|$self->RecupSolution('http://www.gamespot.com'.$1)|ge;
+
+ return $html;
+ }
+
+ sub getSearchUrl
+ {
+ my ($self, $word) = @_;
+
+ #return 'http://www.gamespot.com/search.html?qs='.$word.'&sub=g&stype=11&type=11';
+ return 'http://www.gamespot.com/pages/search/solr_search_ajax.php?q='.$word.'&type=game&offset=0&tags_only=false&sort=false';
+ #return 'http://www.gamespot.com/search.html?qs=' .$word. '&tag=masthead%3Bsearch';
+ }
+
+ sub getItemUrl
+ {
+ my ($self, $url) = @_;
+ my $found = index($url,"tpfplatformtpf");
+ if ( $found >= 0 )
+ {
+ $self->{url_plateforme} = substr($url, $found +length('tpfplatformtpf'),length($url)- $found -length('tpfplatformtpf'));
+ $url = substr($url, 0,$found);
+ }
+
+ return 'http://www.gamespot.com' . $url
+ if $url !~ /gamespot\.com/;
+ return $url if $url;
+ return 'http://www.gamespot.com';
+ }
+
+ sub getName
+ {
+ return 'GameSpot';
+ }
+
+ sub getAuthor
+ {
+ return 'Tian';
+ }
+
+ sub getLang
+ {
+ return 'EN';
+ }
+
+ sub getCharset
+ {
+ my $self = shift;
+
+ return "ISO-8859-1";
+ }
+ sub isPreferred
+ {
+ return 1;
+ }
+}
+
+1;
diff --git a/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm b/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm new file mode 100644 index 0000000..560a582 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm @@ -0,0 +1,447 @@ +package GCPlugins::GCgames::GCJeuxVideoCom;
+
+###################################################
+#
+# Copyright 2005-2010 Tian
+#
+# 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::GCPluginJeuxVideoCom;
+
+ use base 'GCPlugins::GCgames::GCgamesPluginsBase';
+
+ sub start
+ {
+ my ($self, $tagname, $attr, $attrseq, $origtext) = @_;
+ $self->{inside}->{$tagname}++;
+ return if $self->{parsingEnded};
+ if ($self->{parsingList})
+ {
+ if (($tagname eq 'div') && (($attr->{id} eq 'new_mc') || ($attr->{id} eq 'old_mc')))
+ {
+ $self->{inResults} = 1;
+ }
+ elsif ($self->{inResults})
+ {
+ if ($tagname eq 'img')
+ {
+ $self->{currentPlatform} = $attr->{alt};
+ }
+ elsif (($tagname eq 'a') && ($attr->{href} =~ /^http/))
+ {
+ $self->{itemIdx}++;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href};
+ $self->{itemsList}[$self->{itemIdx}]->{platform} = $self->{currentPlatform};
+ $self->{isGame} = 1;
+ }
+ }
+ }
+ elsif ($self->{parsingTips})
+ {
+ if ($tagname eq 'tpfdebuttpf')
+ {
+ $self->{isTip} = 1;
+ }
+ elsif ( ($tagname eq 'h3') && ($attr->{class} eq 'titre_bloc') && ($self->{isTip} ne 4))
+ {
+ $self->{isTip} = 2;
+ }
+ elsif ( (($tagname eq 'h3') || ($tagname eq 'h4') || ($tagname eq 'h5') ) && ($self->{isTip} ne 3) && ($self->{isTip} ne 4))
+ {
+ $self->{isTip} = 2;
+ }
+ elsif ( ($tagname eq 'p') && ($self->{isTip} ne 3) && ($self->{isTip} ne 4))
+ {
+ $self->{isTip} = 1;
+ }
+ elsif ($tagname eq 'tpfstopsolution')
+ {
+ $self->{isTip} = 4;
+ }
+ elsif ($tagname eq 'tpffintpf')
+ {
+ $self->{isTip} = 3;
+ }
+ elsif ($tagname eq 'head')
+ {
+ $self->{isTip} = 0;
+ $self->{urlTips} = '';
+ }
+
+ }
+ else
+ {
+ if (($tagname eq 'meta') && ($attr->{property} eq 'og:image'))
+ {
+ my $cover = $attr->{content};
+ $cover =~ s|(http://[^/]*)/([^i])|$1/images/$2|;
+ if ($self->{bigPics})
+ {
+ $cover =~ s/-p(-|\.)/-g$1/;
+ $cover =~ s/t(\.jpg)/$1/;
+ }
+ my $back = $cover;
+ if (!($back =~ s/-avant(-|\.)/-arriere$1/))
+ {
+ $back =~ s/f(t?\.jpg)/r$1/;
+ }
+ $self->{curInfo}->{boxpic} = $cover;
+ $self->{curInfo}->{backpic} = $back;
+ }
+ elsif (($tagname eq 'li') && ($attr->{class} eq 'note_redac'))
+ {
+ $self->{is} = 'ratingpress';
+ }
+ elsif ( ($tagname eq 'div') && ($attr->{class} eq 'series_images') )
+ {
+ $self->{inScreenshots} = 1;
+ }
+ elsif ( ($tagname eq 'img') && ($self->{inScreenshots}) )
+ {
+ if (! $self->{curInfo}->{screenshot1})
+ {
+ $self->{curInfo}->{screenshot1} = $attr->{src};
+ $self->{curInfo}->{screenshot1} =~ s/.gif/.jpg/;
+ $self->{curInfo}->{screenshot1} =~ s/_m\.jpg/\.jpg/;
+ }
+ elsif (! $self->{curInfo}->{screenshot2})
+ {
+ $self->{curInfo}->{screenshot2} = $attr->{src};
+ $self->{curInfo}->{screenshot2} =~ s/.gif/.jpg/;
+ $self->{curInfo}->{screenshot2} =~ s/_m\.jpg/\.jpg/;
+ $self->{isScreen} = 0;
+ }
+ }
+ elsif (($attr->{href} =~ m^/(etajvhtm|cheats)/^) && ! ($self->{urlTips}))
+ {
+ $self->{urlTips} = $attr->{href};
+ }
+ elsif (($attr->{href} =~ m/test.htm/) && ! ($self->{curInfo}->{players}))
+ {
+ my $html = $self->loadPage($attr->{href});
+
+ my $found = index($html,"<li><strong>Multijoueurs :</strong>");
+ if ( $found >= 0 )
+ {
+ $html = substr($html, $found +length('<li><strong>Multijoueurs :</strong>'),length($html)- $found -length('<li><strong>Multijoueurs :</strong>'));
+ $self->{curInfo}->{players} = substr($html, 0, index($html, "<"));
+
+ # Enleve les blancs en debut de chaine
+ $self->{curInfo}->{players} =~ s/^\s+//;
+ # Enleve les blancs en fin de chaine
+ $self->{curInfo}->{players} =~ s/\s+$//;
+
+ $self->{curInfo}->{players} =~ s/-/1/;
+ $self->{curInfo}->{players} =~ s/non/1/i;
+ $self->{curInfo}->{players} =~ s/oui/Multijoueurs/i;
+ }
+ }
+ }
+ }
+
+ sub end
+ {
+ my ($self, $tagname) = @_;
+
+ $self->{inside}->{$tagname}--;
+ return if $self->{parsingEnded};
+ if ($self->{parsingList})
+ {
+ if ($tagname eq 'div')
+ {
+ $self->{inResults} = 0;
+ }
+ }
+ }
+
+ sub text
+ {
+ my ($self, $origtext) = @_;
+
+ return if $self->{parsingEnded};
+ if ($self->{parsingList})
+ {
+ if ($self->{isGame})
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{name} = $origtext;
+ $self->{isGame} = 0;
+ }
+ }
+ elsif ($self->{parsingTips})
+ {
+ # Enleve les blancs en debut de chaine
+ $origtext =~ s/^\s+//;
+ # Enleve les blancs en fin de chaine
+ $origtext =~ s/\s+$//;
+ if ($self->{isTip} eq 2)
+ {
+ $self->{curInfo}->{secrets} .= "\n\n" if $self->{curInfo}->{secrets};
+ $self->{curInfo}->{secrets} .= $origtext;
+ $self->{isTip} = 0;
+ }
+ elsif ($self->{isTip} eq 1)
+ {
+ chomp($origtext);
+ if ( ($self->{curInfo}->{secrets}) && ($origtext ne "") )
+ {
+ $self->{curInfo}->{secrets} .= "\n"
+ }
+ $self->{curInfo}->{secrets} .= $origtext;
+ $self->{isTip} = 0;
+ }
+ }
+ else
+ {
+ if ($self->{inside}->{h1})
+ {
+ if ($self->{inside}->{a})
+ {
+ $self->{curInfo}->{name} = $origtext;
+ $self->{curInfo}->{exclusive} = 1;
+ }
+ elsif ($self->{inside}->{span})
+ {
+ if ($origtext !~ /^Fiche /)
+ {
+ $origtext =~ s/^\s*-?\s*//;
+ $self->{curInfo}->{platform} = $origtext;
+ }
+ }
+ }
+ elsif ($self->{inside}->{strong})
+ {
+ $self->{is} = 'released' if ($origtext =~ /Sortie :/) || ($origtext =~ /Sortie France :/);
+ $self->{is} = 'genre' if $origtext =~ /Type :/;
+ $self->{is} = 'description' if $origtext =~ /Descriptif :/;
+ $self->{is} = 'editor' if $origtext =~ /Editeur :/;
+ $self->{is} = 'developer' if $origtext =~ /D.*?veloppeur :/;
+ $self->{is} = 'players' if $origtext =~ /Multijoueurs :/;
+ $self->{curInfo}->{exclusive} = 0 if $origtext =~ /Existe aussi sur :/;
+ }
+ elsif ($self->{is})
+ {
+ $origtext =~ s/^\s*//;
+ $origtext =~ s/\n$//;
+ if ($origtext)
+ {
+ if ($self->{is} eq 'players')
+ {
+ $origtext =~ s/-/1/;
+ $origtext =~ s/non/1/i;
+ $origtext =~ s/oui/Multijoueurs/i;
+ }
+ if ($self->{is} eq 'ratingpress')
+ {
+ $origtext =~ m|(\d*)/20|;
+ $origtext = int($1 / 2);
+ }
+ $self->{curInfo}->{$self->{is}} = $origtext;
+ $self->{is} = '';
+ }
+ }
+ }
+ }
+
+ sub getTipsUrl
+ {
+ my $self = shift;
+ return $self->{urlTips};
+ }
+
+ sub new
+ {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = $class->SUPER::new();
+ bless ($self, $class);
+
+ $self->{hasField} = {
+ name => 1,
+ platform => 1
+ };
+
+ $self->{isTip} = 0;
+ $self->{urlTips} = "";
+
+ return $self;
+ }
+
+ sub preProcess
+ {
+ my ($self, $html) = @_;
+ if ($self->{parsingList})
+ {
+ $self->{parsingEnded} = 0;
+ $self->{inResults} = 0;
+ $self->{isGame} = 0;
+ }
+ elsif ($self->{parsingTips})
+ {
+ $html =~ s|<h4 class="lien_base"><a href="(.+)">Les astuces d|$self->RecupTips($1)|ge;
+ $html =~ s|<h4 class="lien_base"><a href="(.+)">La solution d|$self->RecupSolution($1)|ge;
+ $html =~ s|<h5><a href="(.+)">||gi;
+ $html =~ s|<h3 class="titre_bloc"><span>Plus d'infos</span></h3>|<tpfstopsolution>|gi;
+ $html =~ s|<div id="boxes_v">|<tpffintpf>|gi;
+ $html =~ s|<p class="lien_base">|<tpffintpf>|gi;
+ $html =~ s|<div class="player_article">|<tpffintpf>|gi;
+ $html =~ s|</object>|<tpfdebuttpf>|gi;
+ $html =~ s|<p class="title_bar">|<tpffintpf>|gi;
+ $html =~ s|<div class="bloc3" id="astuces_ajout"><h3 class="titre_bloc">|<tpffintpf>|gi;
+ $html =~ s|<br />|<p>|gi;
+ $html =~ s|<kbd>|<p>|gi;
+ $html =~ s|</kbd>||gi;
+ $html =~ s|<b>||gi;
+ $html =~ s|</b>||gi;
+ $html =~ s|<span>||gi;
+ $html =~ s|<img src="../pics/psx/cercle.gif"\s*(alt="CERCLE")?\s*/>|Cercle|gi;
+ $html =~ s|<img src="../pics/psx/croix.gif"\s*(alt="CROIX")?\s*/>|Croix|gi;
+ $html =~ s|<img src="../pics/psx/carre.gif"\s*(alt="CARRE")?\s*/>|Carr.|gi;
+ $html =~ s|<img src="../pics/psx/triangle.gif"\s*(alt="TRIANGLE")?\s*/>|Triangle|gi;
+ $html =~ s|<img src="http://image.jeuxvideo.com/pics/btajv/psx/cercle.gif"\s*(alt="CERCLE")?\s*/>|Cercle|gi;
+ $html =~ s|<img src="http://image.jeuxvideo.com/pics/btajv/psx/croix.gif"\s*(alt="CROIX")?\s*/>|Croix|gi;
+ $html =~ s|<img src="http://image.jeuxvideo.com/pics/btajv/psx/carre.gif"\s*(alt="CARRE")?\s*/>|Carr.|gi;
+ $html =~ s|<img src="http://image.jeuxvideo.com/pics/btajv/psx/triangle.gif"\s*(alt="TRIANGLE")?\s*/>|Triangle|gi;
+ $html =~ s|\x{92}|'|gi;
+ $html =~ s|’|'|gi;
+ $html =~ s|•|*|gi;
+ $html =~ s|œ|oe|gi;
+ $html =~ s|…|...|gi;
+ $html =~ s|\x{85}|...|gi;
+ $html =~ s|\x{8C}|OE|gi;
+ $html =~ s|\x{9C}|oe|gi;
+ }
+ else
+ {
+ $self->{is} = '';
+ $self->{inScreenshots} = 0;
+ }
+ return $html;
+ }
+
+ sub RecupTips
+ {
+ my ($self, $url) = @_;
+
+ my $html = $self->loadPage($url);
+ my $savenexturl = '';
+
+ my $found = index($html,"<p class=\"astuces_suiv\"> <a href=\"");
+ if ( $found >= 0 )
+ {
+ $savenexturl = substr($html, $found +length('<p class="astuces_suiv"> <a href="'),length($html)- $found -length('<p class="astuces_suiv"> <a href="'));
+ $savenexturl = substr($savenexturl, 0, index($savenexturl, "\""));
+ }
+
+ $found = index($html,"<div id=\"astuce_detail\" class=\"astuce\">");
+ if ( $found >= 0 )
+ {
+ $html = substr($html, $found +length('<div id="astuce_detail" class="astuce">'),length($html)- $found -length('<div id="astuce_detail" class="astuce">'));
+ $html = substr($html, 0, index($html, "<div id=\"barre_outils_v2\">"));
+ if ( $savenexturl ne "" )
+ {
+ $html .= $self->RecupTips($savenexturl);
+ }
+ }
+ else
+ {
+ $html = '';
+ }
+ return "<tpfdebuttpf>" . $html . "<tpffintpf>";
+ }
+
+ sub RecupSolution
+ {
+ my ($self, $url) = @_;
+
+ my $html = $self->loadPage($url);
+ my $savenexturl = '';
+
+ my $found = index($html,"<p class=\"astuces_suiv\"><a href=\"");
+ if ( $found >= 0 )
+ {
+ $savenexturl = substr($html, $found +length('<p class="astuces_suiv"><a href="'),length($html)- $found -length('<p class="astuces_suiv"><a href="'));
+ $savenexturl = substr($savenexturl, 0, index($savenexturl, "\""));
+ }
+
+ $found = index($html,"<div id=\"astuce_detail\" class=\"soluce\">");
+ if ( $found >= 0 )
+ {
+ $html = substr($html, $found +length('<div id="astuce_detail" class="soluce">'),length($html)- $found -length('<div id="astuce_detail" class="soluce">'));
+ $html = substr($html, 0, index($html, "<div id=\"barre_outils_v2\">"));
+ if ( $savenexturl ne "" )
+ {
+ $html .= $self->RecupSolution($savenexturl);
+ }
+ }
+ else
+ {
+ $html = '';
+ }
+ return "<tpfdebuttpf>" . $html . "<tpffintpf>";
+ }
+
+ sub getSearchUrl
+ {
+ my ($self, $word) = @_;
+ $word =~ s/\+/ /g;
+ return 'http://www.jeuxvideo.com/recherche/jeux/'.$word.'.htm';
+ }
+
+ sub getItemUrl
+ {
+ my ($self, $url) = @_;
+
+ return $url if $url;
+ return 'http://www.jeuxvideo.com/';
+ }
+
+ sub getName
+ {
+ return 'jeuxvideo.com';
+ }
+
+ sub getAuthor
+ {
+ return 'Tian & TPF';
+ }
+
+ sub getLang
+ {
+ return 'FR';
+ }
+
+ sub getCharset
+ {
+ my $self = shift;
+
+ return "ISO-8859-1";
+ }
+ sub isPreferred
+ {
+ return 1;
+ }
+}
+
+1;
diff --git a/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm b/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm new file mode 100644 index 0000000..bec266f --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm @@ -0,0 +1,425 @@ +package GCPlugins::GCgames::GCJeuxVideoFr;
+
+###################################################
+#
+# Copyright 2005-2011 Tian
+#
+# 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::GCPluginJeuxVideoFr;
+
+ use base 'GCPlugins::GCgames::GCgamesPluginsBase';
+
+ sub start
+ {
+ my ($self, $tagname, $attr, $attrseq, $origtext) = @_;
+
+ $self->{inside}->{$tagname}++;
+ if ($self->{parsingList})
+ {
+ if ($tagname eq 'div')
+ {
+ $self->{isGame} = 1
+ if $attr->{class} eq "jeuDesc";
+ }
+ if ($self->{isGame})
+ {
+ if ($tagname eq 'a')
+ {
+ $self->{itemIdx}++;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href};
+ $self->{itemsList}[$self->{itemIdx}]->{name} = $attr->{title};
+ }
+ elsif ( ($tagname eq 'span') & ($attr->{class} eq "bleu2"))
+ {
+ $self->{isPlatform} = 1;
+ }
+ elsif ( ($tagname eq 'span') & ($attr->{class} eq "bleu6"))
+ {
+ $self->{isGenre} = 1;
+ }
+ elsif ( ($tagname eq 'p') & ($attr->{class} eq "jeuNote"))
+ {
+ $self->{isGame} = 0;
+ $self->{isEnd} = 1;
+ }
+ }
+ }
+ elsif ($self->{parsingTips})
+ {
+ }
+ else
+ {
+ if ( ($tagname eq 'input') && ($attr->{id} eq 'titreJeu'))
+ {
+ $self->{curInfo}->{name} = $attr->{value};
+ $self->{curInfo}->{platform} = $self->{url_plateforme};
+
+ my $html = $self->loadPage( $self->{url_screenshot} );
+
+ my $found = index($html,"div class=\"image_slideshow\">");
+ if ( $found >= 0 )
+ {
+ $self->{curInfo}->{screenshot1} = substr($html, $found +length('div class="image_slideshow">'),length($html)- $found -length('div class="image_slideshow">'));
+ $found = index($self->{curInfo}->{screenshot1},"<a href=\"");
+ if ( $found >= 0 )
+ {
+ $self->{curInfo}->{screenshot1} = substr($self->{curInfo}->{screenshot1}, $found +length('<a href="'),length($self->{curInfo}->{screenshot1})- $found -length('<a href="'));
+ $self->{curInfo}->{screenshot1} = substr($self->{curInfo}->{screenshot1}, 0,index($self->{curInfo}->{screenshot1},"\""));
+ $found = index($html,"\"imageNumberTotal\"");
+ if ( $found >= 0 )
+ {
+ $self->{curInfo}->{screenshot2} = substr($html, $found +length('"imageNumberTotal"'),length($html)- $found -length('"imageNumberTotal"'));
+ $found = index($self->{curInfo}->{screenshot2},"href=\"");
+ if ( $found >= 0 )
+ {
+ $self->{curInfo}->{screenshot2} = substr($self->{curInfo}->{screenshot2}, $found +length('href="'),length($self->{curInfo}->{screenshot2})- $found -length('href="'));
+ $self->{curInfo}->{screenshot2} = 'http://www.jeuxvideo.fr/' . substr($self->{curInfo}->{screenshot2}, 0,index($self->{curInfo}->{screenshot2},"\""));
+
+ $html = $self->loadPage( $self->{curInfo}->{screenshot2} );
+ $found = index($html,"div class=\"image_slideshow\">");
+ if ( $found >= 0 )
+ {
+ $self->{curInfo}->{screenshot2} = substr($html, $found +length('div class="image_slideshow">'),length($html)- $found -length('div class="image_slideshow">'));
+ $found = index($self->{curInfo}->{screenshot2},"<a href=\"");
+ if ( $found >= 0 )
+ {
+ $self->{curInfo}->{screenshot2} = substr($self->{curInfo}->{screenshot2}, $found +length('<a href="'),length($self->{curInfo}->{screenshot2})- $found -length('<a href="'));
+ $self->{curInfo}->{screenshot2} = substr($self->{curInfo}->{screenshot2}, 0,index($self->{curInfo}->{screenshot2},"\""));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ elsif (($tagname eq 'div') && ($attr->{class} eq 'clearer spacer10'))
+ {
+ $self->{isInfo} = 0;
+ $self->{is} = '';
+ }
+ elsif (($tagname eq 'div') && ($attr->{class} eq 'listing_apropos'))
+ {
+ $self->{isInfo} = 1;
+ }
+ elsif (($self->{isInfo} eq '1') && ($tagname eq 'span') && ($attr->{class} eq 'strong'))
+ {
+ $self->{isInfo} = 2;
+ }
+ elsif (($self->{is}) && ($tagname eq 'span') && ($attr->{class} eq 'noir'))
+ {
+ $self->{isInfo} = 3;
+ }
+ elsif (($self->{is}) && ($tagname eq 'div') && ($attr->{class} eq 'clearer'))
+ {
+ $self->{isInfo} = 1;
+ $self->{is} = '';
+ }
+ elsif (($tagname eq 'span') && ($attr->{class} eq 'note-jeux orange1') && ($attr->{property} eq 'v:rating'))
+ {
+ $self->{isNote} = 1;
+ }
+ elsif (($tagname eq 'div') && ($attr->{class} eq 'contentCommentaire'))
+ {
+ $self->{isDesc} = 1;
+ }
+ elsif (($self->{isDesc}) && ($tagname eq 'div') && ($attr->{class} eq 'clearer'))
+ {
+ $self->{isDesc} = 0;
+ }
+ elsif ( ($tagname eq 'img') && ($attr->{class} eq 'imgJeu') && !($attr->{src} =~ /blank/i))
+ {
+ $self->{curInfo}->{boxpic} = $attr->{src};
+ }
+ }
+ }
+
+ sub end
+ {
+ my ($self, $tagname) = @_;
+
+ $self->{inside}->{$tagname}--;
+ if ($self->{parsingList})
+ {
+ }
+ elsif ($self->{parsingTips})
+ {
+ }
+ }
+
+ sub text
+ {
+ my ($self, $origtext) = @_;
+
+ if ($self->{parsingList})
+ {
+ # Enleve les blancs en debut de chaine
+ $origtext =~ s/^\s+//;
+ # Enleve les blancs en fin de chaine
+ $origtext =~ s/\s+$//;
+
+ if ($self->{isGenre})
+ {
+ if ($self->{itemsList}[$self->{itemIdx}]->{genre} eq '')
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{genre} = $origtext;
+ $self->{isGenre} = 0;
+ }
+ else
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{genre} = $self->{itemsList}[$self->{itemIdx}]->{genre} . ' - ' . $origtext;
+ $self->{isGenre} = 0;
+ }
+ }
+ elsif ($self->{isPlatform})
+ {
+ $origtext =~ s/\|//gi;
+ if ($self->{itemsList}[$self->{itemIdx}]->{platform} eq '')
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{platform} = $origtext;
+ }
+ else
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{platform} .= ', ';
+ $self->{itemsList}[$self->{itemIdx}]->{platform} .= $origtext;
+ }
+ $self->{isPlatform} = 0;
+ }
+ elsif ($self->{isEnd})
+ {
+ my @array = split(/,/,$self->{itemsList}[$self->{itemIdx}]->{platform});
+ my $element;
+
+ my $SaveName = $self->{itemsList}[$self->{itemIdx}]->{name};
+ my $SaveUrl = $self->{itemsList}[$self->{itemIdx}]->{url};
+ my $SaveGenre = $self->{itemsList}[$self->{itemIdx}]->{genre};
+ $self->{itemIdx}--;
+
+ foreach $element (@array)
+ {
+ # Enleve les blancs en debut de chaine
+ $element =~ s/^\s+//;
+ # Enleve les blancs en fin de chaine
+ $element =~ s/\s+$//;
+
+ $self->{itemIdx}++;
+ $self->{itemsList}[$self->{itemIdx}]->{name} = $SaveName;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $SaveUrl . 'tpfplatformtpf' . $element;
+ $self->{itemsList}[$self->{itemIdx}]->{platform} = $element;
+ $self->{itemsList}[$self->{itemIdx}]->{genre} = $SaveGenre;
+ }
+ $self->{isEnd} = 0;
+ }
+ }
+ elsif ($self->{parsingTips})
+ {
+ }
+ else
+ {
+ if ($self->{isInfo} eq 2)
+ {
+ $self->{is} = 'genre' if $origtext =~ /Genre :/;
+ $self->{is} = 'editor' if $origtext =~ /Editeur :/;
+ $self->{is} = 'developer' if $origtext =~ /D.veloppeur :/;
+ $self->{is} = 'players' if $origtext =~ /Nb joueurs :/;
+ $self->{is} = 'released' if $origtext =~ /Sortie :/;
+ $self->{is} = 'exclusive' if $origtext =~ /Plateformes :/;
+ }
+ elsif ($self->{isInfo} eq 3)
+ {
+ # Enleve le caractere | qui separe les champs
+ $origtext =~ s/\|//gi;
+ # Enleve les blancs en debut de chaine
+ $origtext =~ s/^\s+//;
+ # Enleve les blancs en fin de chaine
+ $origtext =~ s/\s+$//;
+ if ($origtext)
+ {
+ if ($self->{is} eq 'players')
+ {
+ $origtext =~ s/Exclusivement Solo/1/i;
+ $origtext =~ s/\s*joueurs?//i;
+ }
+
+ if ($self->{curInfo}->{$self->{is}} eq '')
+ {
+ if ($self->{is} eq 'exclusive')
+ {
+ $self->{curInfo}->{$self->{is}} = 'true';
+ if ($origtext =~ /$self->{curInfo}->{platform}/i)
+ {
+ $self->{curInfo}->{platform} = $origtext;
+ }
+ }
+ else
+ {
+ $self->{curInfo}->{$self->{is}} = $origtext;
+ }
+ }
+ else
+ {
+ if ($self->{is} eq 'exclusive')
+ {
+ $self->{curInfo}->{$self->{is}} = 'false';
+ if ($origtext =~ /$self->{curInfo}->{platform}/i)
+ {
+ $self->{curInfo}->{platform} = $origtext;
+ }
+ }
+ else
+ {
+ $self->{curInfo}->{$self->{is}} = $self->{curInfo}->{$self->{is}} . ', ' . $origtext;
+ }
+ }
+
+ }
+ }
+ elsif ($self->{isNote} eq 1)
+ {
+ $self->{curInfo}->{ratingpress} = $origtext;
+ $self->{isNote} = 0;
+ }
+ elsif ($self->{isDesc} eq 1)
+ {
+ # Enleve les blancs en debut de chaine
+ $origtext =~ s/^\s+//;
+ # Enleve les blancs en fin de chaine
+ $origtext =~ s/\s+$//;
+ $self->{curInfo}->{description} .= $origtext;
+ }
+ }
+ }
+
+ sub getTipsUrl
+ {
+ my $self = shift;
+
+ return $self->{url_tips};
+ }
+
+ sub new
+ {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = $class->SUPER::new();
+ bless ($self, $class);
+
+ $self->{hasField} = {
+ name => 1,
+ platform => 1,
+ released => 0,
+ genre => 1
+ };
+
+ $self->{isGame} = 0;
+ $self->{isPlatform} = 0;
+ $self->{isGenre} = 0;
+ $self->{isEnd} = 0;
+ $self->{isInfo} = 0;
+ $self->{isNote} = 0;
+ $self->{isDesc} = 0;
+ $self->{isTip} = 0;
+ $self->{url_plateforme} = '';
+ $self->{url_screenshot} = '';
+ $self->{url_tips} = '';
+ $self->{is} = '';
+
+ return $self;
+ }
+
+ sub preProcess
+ {
+ my ($self, $html) = @_;
+
+ if ($self->{parsingList})
+ {
+ }
+ elsif ($self->{parsingTips})
+ {
+ }
+ else
+ {
+ $html =~ s|<br />|\n|gi;
+ $html =~ s|<b>||gi;
+ $html =~ s|</b>||gi;
+ }
+
+ return $html;
+ }
+
+ sub getSearchUrl
+ {
+ my ($self, $word) = @_;
+
+ return 'http://www.jeuxvideo.fr/r/'.$word.'/';
+ }
+
+ sub getItemUrl
+ {
+ my ($self, $url) = @_;
+
+ my $found = index($url,"tpfplatformtpf");
+ if ( $found >= 0 )
+ {
+ $self->{url_plateforme} = substr($url, $found +length('tpfplatformtpf'),length($url)- $found -length('tpfplatformtpf'));
+ $url = substr($url, 0,$found);
+ }
+
+ $self->{url_screenshot} = 'http://www.jeuxvideo.fr' . $url . 'image-photo/';
+ $self->{url_tips} = 'http://www.jeuxvideo.fr' . $url . 'astuce-code/';
+
+ return 'http://www.jeuxvideo.fr' . $url;
+ }
+
+ sub getName
+ {
+ return 'jeuxvideo.fr';
+ }
+
+ sub getAuthor
+ {
+ return 'Tian';
+ }
+
+ sub getLang
+ {
+ return 'FR';
+ }
+
+ sub getCharset
+ {
+ my $self = shift;
+
+ return "ISO-8859-1";
+ }
+
+ sub isPreferred
+ {
+ return 1;
+ }
+
+}
+
+1;
diff --git a/lib/gcstar/GCPlugins/GCgames/GCLudus.pm b/lib/gcstar/GCPlugins/GCgames/GCLudus.pm new file mode 100644 index 0000000..42b42a7 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCLudus.pm @@ -0,0 +1,367 @@ +package GCPlugins::GCgames::GCLudus; + +################################################### +# +# 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::GCPluginLudus; + + use base 'GCPlugins::GCgames::GCgamesPluginsBase'; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + if ($self->{parsingList}) + { + if (($tagname eq 'span') && ( $attr->{class} eq 'titolini' )) + { + $self->{isGame} = 1 ; + } + elsif (($tagname eq 'img') && ($self->{isGame})) + { + $self->{isGame} = 0 ; + $self->{isInfo} = 0 ; + } + elsif (($tagname eq 'a') && ($self->{isGame})) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://www.ludus.it/" . $attr->{href}; + $self->{isName} = 1 ; + $self->{isInfo} = 1 ; + } + elsif (($tagname eq 'td') && ( $attr->{class} eq 'trat2' ) && ($self->{isInfo} eq '1')) + { + # le deuxieme champs est le type de donnees + $self->{isInfo} = 2 ; + } + elsif (($tagname eq 'td') && ( $attr->{class} eq 'trat2' ) && ($self->{isInfo} eq '2')) + { + # le troisieme champs est la plateforme + $self->{isPlatform} = 1 ; + $self->{isInfo} = 3 ; + } + elsif (($tagname eq 'td') && ( $attr->{class} eq 'trat2' ) && ($self->{isInfo} eq '3')) + { + # le quatrieme champs est la date de sortie + $self->{isDate} = 1 ; + $self->{isInfo} = 0 ; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + if (($tagname eq 'td') && ($attr->{colspan} eq '2') && ($attr->{class} eq 'titoli2')) + { + $self->{isName} = 1 ; + } + elsif (($tagname eq 'span') && ($attr->{class} eq 'testo4')) + { + $self->{isAnalyse} = 1 ; + } + elsif ($self->{isPlatform} eq 1) + { + $self->{isPlatform} = 2 ; + } + elsif ($self->{isEditor} eq 1) + { + $self->{isEditor} = 2 ; + } + elsif ($self->{isDeveloper} eq 1) + { + $self->{isDeveloper} = 2 ; + } + elsif ($self->{isGenre} eq 1) + { + $self->{isGenre} = 2 ; + } + elsif (($tagname eq 'span') && ($attr->{class} eq 'testo') && ($attr->{align} eq '')) + { + $self->{isDescription} = 1 ; + } + elsif (($tagname eq 'tpfsautdeligne') && ($self->{isDescription})) + { + $self->{curInfo}->{description} .= "\n"; + } + elsif (($tagname eq 'table') && ($self->{isDescription})) + { + $self->{isDescription} = 0 ; + } + elsif ( ($tagname eq 'a') && (index($attr->{onclick},"adafl=win") >= 0) && ($self->{curInfo}->{screenshot1} eq '') && ($self->{curInfo}->{screenshot2} eq '')) + { + $self->{isScreen} = 1; + } + elsif ( ($tagname eq 'img') && ($self->{isScreen}) ) + { + if ($self->{curInfo}->{screenshot1} eq '') + { + $self->{curInfo}->{screenshot1} = $attr->{src}; + $self->{curInfo}->{screenshot1} =~ s|//|http://www.ludus.it/|; + my $found = index(reverse($self->{curInfo}->{screenshot1}),"/"); + if ( $found >= 0 ) + { + my $tempscreen = substr(reverse($self->{curInfo}->{screenshot1}), $found +length('/'),length($self->{curInfo}->{screenshot1})- $found -length('/')); + my $tempscreen2 = substr(reverse($self->{curInfo}->{screenshot1}), 0, $found); + $tempscreen2 = "/immagini_grandi/" . reverse($tempscreen2); + $self->{curInfo}->{screenshot1} = reverse($tempscreen) . $tempscreen2; + } + } + elsif ($self->{curInfo}->{screenshot2} eq '') + { + $self->{curInfo}->{screenshot2} = $attr->{src}; + $self->{curInfo}->{screenshot2} =~ s|//|http://www.ludus.it/|; + my $found = index(reverse($self->{curInfo}->{screenshot2}),"/"); + if ( $found >= 0 ) + { + my $tempscreen = substr(reverse($self->{curInfo}->{screenshot2}), $found +length('/'),length($self->{curInfo}->{screenshot2})- $found -length('/')); + my $tempscreen2 = substr(reverse($self->{curInfo}->{screenshot2}), 0, $found); + $tempscreen2 = "/immagini_grandi/" . reverse($tempscreen2); + $self->{curInfo}->{screenshot2} = reverse($tempscreen) . $tempscreen2; + } + $self->{isScreen} = 0; + } + } + elsif (($tagname eq 'a') && (index($attr->{href},"post_form") >= 0)) + { + $self->{curInfo}->{boxpic} = $attr->{href}; + $self->{curInfo}->{boxpic} =~ s|/LINGUA/IT||; + my $found = index(reverse($self->{curInfo}->{boxpic}),"/"); + if ( $found >= 0 ) + { + $self->{curInfo}->{boxpic} = substr(reverse($self->{curInfo}->{boxpic}), 0, $found); + $self->{curInfo}->{boxpic} = "http://www.ludus.it/copertine/giochi/" . reverse($self->{curInfo}->{boxpic}) . ".jpg"; + } + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//; + if ($self->{isName}) + { + $self->{itemsList}[$self->{itemIdx}]->{name} = $origtext; + $self->{isName} = 0; + } + elsif ($self->{isDate}) + { + $self->{itemsList}[$self->{itemIdx}]->{released} = $origtext; + $self->{isDate} = 0; + } + elsif ($self->{isPlatform}) + { + $origtext =~ s/Pc/PC/; + $self->{itemsList}[$self->{itemIdx}]->{platform} = $origtext; + $self->{isPlatform} = 0; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + if ($self->{isName}) + { + my $found = index(reverse($origtext),"-"); + if ( $found >= 0 ) + { + $origtext = substr(reverse($origtext), $found +length('-'),length($origtext)- $found -length('-')); + $origtext = reverse($origtext); + } + $self->{curInfo}->{name} = $origtext; + $self->{curInfo}->{released} = $self->{itemsList}[$self->{wantedIdx}]->{released}; + $self->{isName} = 0 ; + } + elsif ($self->{isAnalyse}) + { + $self->{isPlatform} = 1 if ($origtext =~ m/Piattaforma:/i); + $self->{isEditor} = 1 if ($origtext =~ m/Software House:/i); + $self->{isDeveloper} = 1 if ($origtext =~ m/Sviluppatore:/i); + $self->{isGenre} = 1 if ($origtext =~ m/Genere:/i); + + $self->{isAnalyse} = 0 ; + } + elsif ($self->{isGenre} eq 2) + { + my @array = split(/\//,$origtext); + my $element; + foreach $element (@array) + { + # Enleve les blancs en debut de chaine + $element =~ s/^\s+//; + $self->{curInfo}->{genre} .= $element; + $self->{curInfo}->{genre} .= ","; + } + $self->{isGenre} = 0; + } + elsif ($self->{isDeveloper} eq 2) + { + $self->{curInfo}->{developer} = $origtext; + $self->{isDeveloper} = 0 ; + } + elsif ($self->{isEditor} eq 2) + { + $self->{curInfo}->{editor} = $origtext; + $self->{isEditor} = 0 ; + } + elsif ($self->{isPlatform} eq 2) + { + $origtext =~ s/Pc/PC/; + $self->{curInfo}->{platform} = $origtext; + $self->{isPlatform} = 0; + } + elsif ($self->{isDescription}) + { + $self->{curInfo}->{description} .= $origtext; + } + } + } + + sub getTipsUrl + { + my $self = shift; + + return ; + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + name => 1, + platform => 1, + genre => 0, + released => 1 + }; + + $self->{isInfo} = 0; + $self->{isName} = 0; + $self->{isGame} = 0; + $self->{isPlatform} = 0 ; + $self->{isAnalyse} = 0; + $self->{isEditor} = 0; + $self->{isDeveloper} = 0; + $self->{isDate} = 0; + $self->{isGenre} = 0; + $self->{isScreen} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s|<u>||gi; + $html =~ s|<li>|\n* |gi; + $html =~ s|<br>|<tpfsautdeligne>|gi; + $html =~ s|<br />|<tpfsautdeligne>|gi; + $html =~ s|<b>||gi; + $html =~ s|</b>||gi; + $html =~ s|<i>||gi; + $html =~ s|</i>||gi; + $html =~ s|<p>|\n|gi; + $html =~ s|</p>||gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + } + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + $word =~ s/\+/ /g; + return ('http://www.ludus.it/code/lista_alfabetica_giochi/LINGUA/IT', ["categoria" => "2", "SEARCH_STRING" => "$word"] ); + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url; + } + + sub getName + { + return 'Ludus'; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'IT'; + } + + sub getCharset + { + my $self = shift; + + return "ISO-8859-1"; + } + + sub getSearchFieldsArray + { + return ['name']; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCMobyGames.pm b/lib/gcstar/GCPlugins/GCgames/GCMobyGames.pm new file mode 100644 index 0000000..c6650c3 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCMobyGames.pm @@ -0,0 +1,541 @@ +package GCPlugins::GCgames::GCMobyGames;
+
+###################################################
+#
+# Copyright 2005-2011 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::GCPluginMobyGames;
+
+ use base 'GCPlugins::GCgames::GCgamesPluginsBase';
+ use HTML::Entities;
+
+ sub extractTips
+ {
+ my ($self, $html_ini) = @_;
+ my $answer = "";
+ my @tmpAnswer = ();
+ my $html = $self->loadPage($html_ini, 0, 1);
+ $html =~ s|<pre>||gi;
+ $html =~ s|</pre>||gi;
+ $html =~ s|<b>||gi;
+ $html =~ s|</b>||gi;
+ my $found = index($html,"class=\"sbL sbB sbT\">");
+ if ( $found >= 0 )
+ {
+ $answer = substr($html, $found + length("class=\"sbL sbB sbT\">"),length($html)- $found -length("class=\"sbL sbB sbT\">") );
+ $answer = substr($answer, 0, index($answer,"</td><td align="));
+
+ $tmpAnswer[0] = decode_entities($answer);
+
+ $found = index($html,"class=\"sbR sbL sbB\"><p>");
+ if ( $found >= 0 )
+ {
+ my $html2 = substr($html, $found + length("class=\"sbR sbL sbB\"><p>"),length($html)- $found -length("class=\"sbR sbL sbB\"><p>") );
+ $html2 = substr($html2, 0, index($html2,"</p>"));
+ $html2 =~ s/<br>/\n/gi;
+ $html2 =~ s|<p>|\n|gi;
+ $html2 =~ s|</p>||gi;
+
+ $tmpAnswer[1] = decode_entities($html2);
+ }
+
+ }
+
+ return @tmpAnswer;
+ }
+
+ sub extractPlayer
+ {
+ my ($self, $html_ini, $word) = @_;
+ my $html = 0;
+ my $found = index($html_ini,$word);
+ if ( $found >= 0 )
+ {
+ $html = substr($html_ini, $found + length($word),length($html_ini)- $found -length($word) );
+ $html = substr($html,0, index($html,"</a>") );
+ $html = reverse($html);
+ $html = substr($html,0, index($html,">") );
+ $html = reverse($html);
+ $html =~ s/ / /g;
+ $html =~ s/1 Player/1/;
+ }
+ return $html;
+ }
+
+ sub start
+ {
+ my ($self, $tagname, $attr, $attrseq, $origtext) = @_;
+
+ $self->{inside}->{$tagname}++;
+ if ($self->{parsingList})
+ {
+ if ( !$self->{insideSearchImage}
+ && ($tagname eq 'a')
+ && ( substr($attr->{href},0,6) eq '/game/' ) )
+ {
+ # Test if there is a platform name in it
+ # (i.e. if we can find a second slash after game/ )
+ if ($attr->{href} =~ m|/game/[^/]*/|)
+ {
+ if ($self->{currentName})
+ {
+ $self->{itemIdx}++;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = 'http://www.mobygames.com'.$attr->{href}.'';
+ $self->{itemsList}[$self->{itemIdx}]->{name} = $self->{currentName};
+ $self->{isPlatform} = 1;
+ }
+ else
+ {
+ # This is a game we want to add
+ $self->{isGame} = 1;
+ $self->{itemIdx}++;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = 'http://www.mobygames.com'.$attr->{href}.'';
+ $self->{isName} = 1 ;
+ }
+ }
+ else
+ {
+ # We will need the name later
+ $self->{isGameName} = 1;
+ }
+ }
+ elsif ( ($tagname eq 'a') && ( substr($attr->{href},0,7) eq '/search' ) )
+ {
+ $self->{isGame} = 0;
+ }
+ elsif ($tagname eq 'div')
+ {
+ if ($attr->{class} eq 'searchResult')
+ {
+ $self->{currentName} = '';
+ }
+ elsif ($attr->{class} eq 'searchImage')
+ {
+ $self->{insideSearchImage} = 1;
+ }
+ }
+ elsif ($tagname eq 'em')
+ {
+ $self->{isDate} = 1;
+ }
+ }
+ elsif ($self->{parsingTips})
+ {
+ if (($tagname eq 'table') && ($attr->{summary} eq 'List of Tips and Tricks'))
+ {
+ $self->{isSectionTips} = 2;
+ }
+ elsif ( ($tagname eq 'b') && ($self->{isSectionTips} eq '2') )
+ {
+ $self->{isSectionTips} = 1;
+ }
+ elsif ( ($tagname eq 'tr') && (($attr->{class} eq 'mb1') || ($attr->{class} eq 'mb2')) )
+ {
+ $self->{isTip} = 1 if ($self->{isTip} eq 2);
+ $self->{isCode} = 1 if ($self->{isCode} eq 2);
+ }
+ elsif ( ($tagname eq 'a') && ($self->{isTip} eq 1))
+ {
+ my @tips = $self->extractTips('http://www.mobygames.com'.$attr->{href}.'');
+ if ($tips[0] =~ m/unlock/i)
+ {
+ $Text::Wrap::columns = 80;
+ $tips[1] = Text::Wrap::wrap('', '', $tips[1]);
+ #$self->{tmpCheatLine} = [];
+ #push @{$self->{tmpCheatLine}}, @tips;
+ push @{$self->{curInfo}->{unlockable}}, \@tips;
+ }
+ else
+ {
+ my $answer = $tips[0];
+ $answer .= "\n";
+ $answer .= $tips[1];
+ if ( ($self->{curInfo}->{secrets}) && ($answer ne "") )
+ {
+ $self->{curInfo}->{secrets} .= "\n\n\n"
+ }
+ $self->{curInfo}->{secrets} .= $answer;
+ }
+ $self->{isTip} = 2;
+ }
+ elsif ( ($tagname eq 'a') && ($self->{isCode} eq 1))
+ {
+ my @tips = $self->extractTips('http://www.mobygames.com'.$attr->{href}.'');
+ @tips = reverse(@tips);
+ $Text::Wrap::columns = 80;
+ $tips[1] = Text::Wrap::wrap('', '', $tips[1]);
+ #$self->{tmpCheatLine} = [];
+ #push @{$self->{tmpCheatLine}}, @tips;
+ push @{$self->{curInfo}->{code}}, \@tips;
+
+ $self->{isCode} = 2;
+
+ }
+ elsif ($tagname eq 'br')
+ {
+ $self->{isTip} = 3;
+ $self->{isCode} = 3;
+ $self->{isSectionTips} = 0;
+ }
+ elsif ($tagname eq 'head')
+ {
+ $self->{isTip} = 0;
+ $self->{isCode} = 0;
+ $self->{isSectionTips} = 0;
+ }
+
+ }
+ else
+ {
+
+ if ($tagname eq 'div')
+ {
+ for ($attr->{id})
+ {
+ /^gameTitle$/ && ($self->{isName} = 1, last);
+ /^gamePlatform/ && ($self->{isPlatform} = 1, last);
+ #/^coreGameCover/ && ($self->{isBox} = 1, last);
+ /^coreGameRelease/ && ($self->{isEditor} = 1, last);
+ }
+
+ if ($attr->{class} =~ m/scoreBoxBig/)
+ {
+ $self->{isRating} = 1;
+ }
+
+ if ($self->{curInfo}->{genre})
+ {
+ $self->{isGenre} = 0;
+ }
+
+ $self->{isDescription} = 0;
+
+ }
+ elsif ( ($tagname eq 'a') && ($self->{isName}) )
+ {
+ $self->{is} = 'name';
+ $self->{curInfo}->{exclusive} = 1;
+ $self->{isName} = 0;
+ }
+ elsif ( ($tagname eq 'a') && ($self->{isPlatform}) )
+ {
+ $self->{is} = 'platform';
+ $self->{isPlatform} = 0;
+ }
+ elsif ( ($tagname eq 'a') && ($self->{isEditor}) )
+ {
+ $self->{is} = 'editor';
+ $self->{isEditor} = 0;
+ }
+ elsif ( ($tagname eq 'a') && ($self->{isDeveloper}) )
+ {
+ $self->{is} = 'developer';
+ $self->{isDeveloper} = 0;
+ }
+ elsif ( ($tagname eq 'a') && ($self->{isDate}) )
+ {
+ $self->{is} = 'released';
+ $self->{isDate} = 0;
+ }
+ elsif ( ($tagname eq 'a') && ($self->{isGenre}) )
+ {
+ $self->{is} = 'genre';
+ }
+ elsif ($tagname eq 'img')
+ {
+ if ($attr->{src} =~ m|covers/small|)
+ {
+ $attr->{src} =~ s|/small/|/large/|
+ if $self->{bigPics};
+ $self->{curInfo}->{boxpic} = $attr->{src};
+ # From here we try to get back cover
+ my $covers = $self->loadPage($self->{rootUrl}.'/cover-art', 0, 1);
+ $covers =~ m|<img alt=".*?Back Cover".*?src="([^"]*)"|;
+ $self->{curInfo}->{backpic} = $1;
+ $self->{curInfo}->{backpic} =~ s|/small/|/large/|
+ if $self->{bigPics};
+ }
+ }
+ elsif ($tagname eq 'html')
+ {
+ my $html = $self->loadPage($self->{curInfo}->{$self->{urlField}}.'/techinfo', 0, 1);
+ my $player_offline = $self->extractPlayer($html, "Number of Players: Offline" );
+ my $player_online = $self->extractPlayer($html, "Number of Players: Online" );
+ my $player_total = $self->extractPlayer($html, "Number of Players Supported" );
+
+ if ($player_total)
+ {
+ $self->{curInfo}->{players} = $player_total;
+ }
+ else
+ {
+ if ($player_offline)
+ {
+ $self->{curInfo}->{players} = 'Offline: '.$player_offline;
+ }
+ if ($player_online)
+ {
+ if ( $self->{curInfo}->{players} )
+ {
+ $self->{curInfo}->{players} .= '; Online: '.$player_online;
+ }
+ else
+ {
+ $self->{curInfo}->{players} = 'Online: '.$player_online;
+ }
+ }
+ }
+
+ $html = $self->loadPage($self->{curInfo}->{$self->{urlField}}.'/screenshots', 0, 1);
+ my $screen = 1;
+ while ($html =~ m|src="(/images/shots/[^"]*?)"|g)
+ {
+ $self->{curInfo}->{'screenshot'.$screen} = 'http://www.mobygames.com' . $1;
+ $self->{curInfo}->{'screenshot'.$screen} =~ s|/images/shots/s/|/images/shots/l/|
+ if $self->{bigPics};
+ $screen++;
+ last if $screen > 2;
+ }
+ }
+ elsif ( ($tagname eq 'br') && ($self->{isDescription}) )
+ {
+ $self->{curInfo}->{description} .= "\n";
+ }
+ }
+ }
+
+ sub end
+ {
+ my ($self, $tagname) = @_;
+ $self->{inside}->{$tagname}--;
+ if ($self->{parsingList} && ($tagname eq 'div'))
+ {
+ $self->{insideSearchImage} = 0;
+ }
+ }
+
+ sub text
+ {
+ my ($self, $origtext) = @_;
+
+ if ($self->{parsingList})
+ {
+ if ($self->{isName})
+ {
+ #$self->{itemsList}[$self->{itemIdx}]->{name} = $origtext;
+ if ($origtext !~ /^Game:/)
+ {
+ if (!$self->{currentName})
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{name} = $origtext;
+ }
+ $self->{isName} = 0;
+ }
+ }
+ elsif ($self->{isPlatform})
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{platform} = $origtext;
+ $self->{isPlatform} = 0;
+ }
+ elsif ($self->{isGameName})
+ {
+ $self->{currentName} = $origtext;
+ $self->{isGameName} = 0;
+ }
+ elsif ($self->{isDate})
+ {
+ # <em> tags enclose both dates and the 'a.k.a.' text, so make sure we
+ # ignore the aka ones
+ if ($origtext !~ /^a\.k\.a\./)
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{released} = $origtext;
+ if (! $self->{itemsList}[$self->{itemIdx}]->{platform})
+ {
+ $self->{previous} =~ s/[\s\(]*$//g;
+ $self->{itemsList}[$self->{itemIdx}]->{platform} = $self->{previous};
+ }
+ }
+ $self->{isDate} = 0;
+ }
+ $self->{previous} = $origtext;
+ }
+ elsif ($self->{parsingTips})
+ {
+ if ($self->{isSectionTips} eq 1)
+ {
+ if ($origtext =~ m/General Hints\/Tips/i)
+ {
+ $self->{isTip} = 2;
+ $self->{isCode} = 0;
+ }
+ elsif ($origtext =~ m/Cheats\/Codes/i)
+ {
+ $self->{isTip} = 0;
+ $self->{isCode} = 2;
+ }
+ $self->{isSectionTips} = 2;
+ }
+ }
+ else
+ {
+ if ($self->{is})
+ {
+ $origtext =~ s/^\s*//;
+
+ if ($self->{is} eq 'platform')
+ {
+ $self->{curInfo}->{$self->{is}} = $origtext;
+ $self->{curInfo}->{platform} =~ s/DOS/PC/;
+ $self->{curInfo}->{platform} =~ s/Windows/PC/;
+ }
+ elsif ($self->{is} eq 'genre')
+ {
+ push @{$self->{curInfo}->{genre}}, [ $origtext ];
+ }
+ else
+ {
+ $self->{curInfo}->{$self->{is}} = $origtext;
+ }
+
+ $self->{is} = '';
+ }
+ elsif ($self->{isRating})
+ {
+ $self->{curInfo}->{ratingpress} = int($origtext/10+0.5);
+ $self->{isRating} = 0;
+ }
+ elsif ($self->{isDescription})
+ {
+ $self->{curInfo}->{description} .= $origtext;
+ }
+ elsif ($origtext eq 'Developed by')
+ {
+ $self->{isDeveloper} = 1
+ }
+ elsif ( ($origtext eq 'Also For') || (($origtext eq 'Platforms')))
+ {
+ $self->{curInfo}->{exclusive} = 0;
+ }
+ elsif ($origtext eq 'Released')
+ {
+ $self->{isDate} = 1
+ }
+ elsif ($origtext eq 'Genre')
+ {
+ $self->{isGenre} = 1
+ }
+ elsif ($origtext eq 'Description')
+ {
+ $self->{isDescription} = 1
+ }
+ }
+ }
+
+ sub getTipsUrl
+ {
+ my $self = shift;
+ my $url = $self->{curInfo}->{$self->{urlField}}.'/hints';
+ $url =~ s/##MobyGames//;
+ return $url;
+ }
+
+ sub new
+ {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = $class->SUPER::new();
+ bless ($self, $class);
+
+ $self->{hasField} = {
+ name => 1,
+ platform => 1,
+ released => 1
+ };
+
+ $self->{isName} = 0;
+ $self->{isGame} = 0;
+ $self->{isGameName} = 0;
+ $self->{isPlatform} = 0;
+ $self->{isEditor} = 0;
+ $self->{isDeveloper} = 0;
+ $self->{isDate} = 0;
+ $self->{isGenre} = 0;
+ $self->{isDescription} = 0;
+ $self->{isBox} = 0;
+ $self->{isSectionTips} = 0;
+ $self->{isTip} = 0;
+ $self->{isCode} = 0;
+ $self->{is} = '';
+
+ return $self;
+ }
+
+ sub preProcess
+ {
+ my ($self, $html) = @_;
+ $self->{rootUrl} = $self->{loadedUrl};
+ return $html;
+ }
+
+ sub getSearchUrl
+ {
+ my ($self, $word) = @_;
+ return 'http://www.mobygames.com/search/quick?q='.$word.'&p=-1&search=Go&sFilter=1&sG=on';
+ }
+
+ sub getItemUrl
+ {
+ my ($self, $url) = @_;
+
+ return $url if $url;
+ return 'http://www.mobygames.com/';
+ }
+
+ sub getName
+ {
+ return 'MobyGames';
+ }
+
+ sub getAuthor
+ {
+ return 'TPF';
+ }
+
+ sub getLang
+ {
+ return 'EN';
+ }
+
+ sub getCharset
+ {
+ my $self = shift;
+
+ return "ISO-8859-1";
+ }
+}
+
+1;
diff --git a/lib/gcstar/GCPlugins/GCgames/GCNextGame.pm b/lib/gcstar/GCPlugins/GCgames/GCNextGame.pm new file mode 100644 index 0000000..b884b54 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCNextGame.pm @@ -0,0 +1,480 @@ +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,"<div class=\"testo edit_inline_box\" id=\"id_text\">");
+ if ( $found >= 0 )
+ {
+ $html = "<>" . substr($html, $found +length('<div class="testo edit_inline_box" id="id_text">'),length($html)- $found -length('<div class="testo edit_inline_box" id="id_text">'));
+
+ $found = index($html,"<div class=\"byline\">");
+ if ( $found >= 0 )
+ {
+ $html = substr($html, 0, $found);
+ }
+
+ my @array = split(/</,$html);
+ my $element;
+
+ foreach $element (@array)
+ {
+ $found = index($element,">");
+ if ( $found >= 0 )
+ {
+ $self->{curInfo}->{description} .= substr($element, $found +length('>'),length($element)- $found -length('>'));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ sub end
+ {
+ my ($self, $tagname) = @_;
+
+ $self->{inside}->{$tagname}--;
+ }
+
+ sub text
+ {
+ my ($self, $origtext) = @_;
+
+ if ($self->{parsingList})
+ {
+ if ($self->{isName})
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{name} = $origtext;
+ $self->{isName} = 0;
+ }
+ elsif ($self->{isPlatform} eq 2)
+ {
+ # Enleve les blancs en debut de chaine
+ $origtext =~ s/^\s+//;
+ # Enleve les blancs en fin de chaine
+ $origtext =~ s/\s+$//;
+
+ if (($self->{itemsList}[$self->{itemIdx}]->{platform} eq '') && ($origtext ne ''))
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{platform} = $origtext;
+ }
+ elsif ($origtext ne '')
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{platform} .= ', ';
+ $self->{itemsList}[$self->{itemIdx}]->{platform} .= $origtext;
+ }
+
+ $self->{isPlatform} = 1 ;
+ }
+ elsif ($self->{isAnalyse})
+ {
+ $self->{isGenre} = 1 if ($origtext =~ m/Genere/i);
+
+ $self->{isAnalyse} = 0 ;
+ }
+ elsif ($self->{isGenre} eq 2)
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{genre} = $origtext;
+
+ my @array = split(/,/,$self->{itemsList}[$self->{itemIdx}]->{platform});
+ my $element;
+
+ my $SaveName = $self->{itemsList}[$self->{itemIdx}]->{name};
+ my $SaveUrl = $self->{itemsList}[$self->{itemIdx}]->{url};
+ my $SaveGenre = $self->{itemsList}[$self->{itemIdx}]->{genre};
+ $self->{itemIdx}--;
+
+ if ($SaveName ne "")
+ {
+ foreach $element (@array)
+ {
+ # Enleve les blancs en debut de chaine
+ $element =~ s/^\s+//;
+ # Enleve les blancs en fin de chaine
+ $element =~ s/\s+$//;
+
+ $self->{itemIdx}++;
+ $self->{itemsList}[$self->{itemIdx}]->{name} = $SaveName;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $SaveUrl . $element .'/';
+ $self->{itemsList}[$self->{itemIdx}]->{platform} = $element;
+ $self->{itemsList}[$self->{itemIdx}]->{genre} = $SaveGenre;
+ }
+ }
+ else
+ {
+ $self->{itemIdx}++;
+ delete $self->{itemsList}[$self->{itemIdx}];
+ $self->{itemIdx}--;
+ }
+
+ $self->{isGenre} = 0;
+ }
+ }
+ elsif ($self->{parsingTips})
+ {
+ }
+ else
+ {
+ # Enleve les blancs en debut de chaine
+ $origtext =~ s/^\s+//;
+ if ($self->{isName})
+ {
+ $self->{curInfo}->{name} = $origtext;
+ $self->{isName} = 0 ;
+
+ if ($self->{ean} ne '')
+ {
+ $self->{curInfo}->{ean} = $self->{ean};
+ }
+
+ }
+ elsif ($self->{isPlatform} eq 2)
+ {
+ $self->{curInfo}->{platform} = $origtext;
+ $self->{isPlatform} = 0;
+ }
+ elsif ($self->{isAnalyse} eq 2)
+ {
+ $self->{isEditor} = 1 if ($origtext =~ m/Produttore/i);
+ $self->{isDeveloper} = 1 if ($origtext =~ m/Sviluppatore/i);
+ $self->{isGenre} = 1 if ($origtext =~ m/Genere/i);
+ $self->{isDate} = 1 if ($origtext =~ m/Disponibile/i);
+ $self->{isPlayer} = 1 if ($origtext =~ m/Giocatori/i);
+
+ $self->{isAnalyse} = 1 ;
+ }
+ elsif ($self->{isDeveloper} eq 2)
+ {
+ $self->{curInfo}->{developer} = $origtext;
+ $self->{isDeveloper} = 0;
+ }
+ elsif ($self->{isGenre} eq 2)
+ {
+ $self->{curInfo}->{genre} = $origtext;
+ $self->{isGenre} = 0;
+ }
+ elsif ($self->{isEditor} eq 2)
+ {
+ $self->{curInfo}->{editor} = $origtext;
+ $self->{isEditor} = 0 ;
+ }
+ elsif ($self->{isDate} eq 2)
+ {
+ $self->{curInfo}->{released} = $origtext;
+ $self->{isDate} = 0 ;
+ }
+ elsif ($self->{isPlayer} eq 2)
+ {
+ $self->{curInfo}->{players} = $origtext;
+ $self->{isPlayer} = 0 ;
+ }
+ elsif ($self->{isDescription} eq 2)
+ {
+ if ($origtext =~ m/$self->{curInfo}->{platform}/i)
+ {
+ $self->{isDescription} = 3;
+ }
+ else
+ {
+ $self->{isDescription} = 1;
+ }
+ }
+
+ }
+ }
+
+ sub getTipsUrl
+ {
+ my $self = shift;
+
+ return ;
+
+ }
+
+ sub new
+ {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = $class->SUPER::new();
+ bless ($self, $class);
+
+ $self->{hasField} = {
+ name => 1,
+ platform => 1,
+ genre => 1,
+ released => 0
+ };
+
+ $self->{isName} = 0;
+ $self->{isGame} = 0;
+ $self->{isPlatform} = 0;
+ $self->{isAnalyse} = 0 ;
+ $self->{isGenre} = 0;
+ $self->{isEditor} = 0;
+ $self->{isDeveloper} = 0;
+ $self->{isDate} = 0;
+ $self->{isPlayer} = 0;
+ $self->{isDescription} = 0;
+ $self->{ean} = '';
+
+ return $self;
+ }
+
+ sub preProcess
+ {
+ my ($self, $html) = @_;
+
+ if ($self->{parsingList})
+ {
+ }
+ else
+ {
+ $html =~ s|</li><li>|<ul class="platforms">|gi;
+ $html =~ s|<li>|\n* |gi;
+ $html =~ s|<br>|\n|gi;
+ $html =~ s|<br />|\n|gi;
+ $html =~ s|<b>||gi;
+ $html =~ s|</b>||gi;
+ $html =~ s|<i>||gi;
+ $html =~ s|</i>||gi;
+ $html =~ s|<p>|\n|gi;
+ $html =~ s|</p>||gi;
+ $html =~ s|\x{92}|'|gi;
+ $html =~ s|’|'|gi;
+ $html =~ s|•|*|gi;
+ $html =~ s|œ|oe|gi;
+ $html =~ s|…|...|gi;
+ $html =~ s|\x{85}|...|gi;
+ $html =~ s|\x{8C}|OE|gi;
+ $html =~ s|\x{9C}|oe|gi;
+ }
+ $self->{alreadyRetrieved} = {};
+ return $html;
+ }
+
+ sub getSearchUrl
+ {
+ my ($self, $word) = @_;
+
+ if ($self->{searchField} eq 'ean')
+ {
+ $self->{ean} = $word;
+ }
+ else
+ {
+ $self->{ean} = '';
+ }
+
+ return 'http://next.videogame.it/magazine/review/?name='.$word;
+ }
+
+ sub getItemUrl
+ {
+ my ($self, $url) = @_;
+
+ return $url if $url;
+ return 'http://next.videogame.it/';
+ }
+
+ sub getName
+ {
+ return 'NextGame';
+ }
+
+ sub getCharset
+ {
+ my $self = shift;
+ return "ISO-8859-1";
+ }
+
+ sub getAuthor
+ {
+ return 'TPF';
+ }
+
+ sub getLang
+ {
+ return 'IT';
+ }
+
+ sub getSearchFieldsArray
+ {
+ return ['name'];
+ }
+
+ sub getDefaultPictureSuffix
+ {
+ return '.jpg';
+ }
+}
+
+1;
+
diff --git a/lib/gcstar/GCPlugins/GCgames/GCTheLegacy.pm b/lib/gcstar/GCPlugins/GCgames/GCTheLegacy.pm new file mode 100644 index 0000000..c0759a4 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCTheLegacy.pm @@ -0,0 +1,316 @@ +package GCPlugins::GCgames::GCTheLegacy; + +################################################### +# +# 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::GCPluginTheLegacy; + + use base 'GCPlugins::GCgames::GCgamesPluginsBase'; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + if ($self->{parsingList}) + { + if (($tagname eq 'a') && ( $attr->{class} eq 'aa' )) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://www.thelegacy.de/Museum/" . $attr->{href}; + $self->{isName} = 1 ; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + if (($tagname eq 'div') && ($attr->{style} eq 'font-size:14pt; color:#990000; padding-top:0.5em;')) + { + $self->{isName} = 1 ; + } + elsif (($tagname eq 'div') && ($attr->{class} eq 'description') && ($self->{curInfo}->{platform} eq '')) + { + $self->{isPlatform} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{target} eq 'ListGames') && ($attr->{class} eq 'a') && ($attr->{style} eq '')) + { + $self->{isGenre} = 1 ; + } + elsif (($tagname eq 'img') && ($attr->{src} =~ m|/pics/cover/Thumb|i)) + { + $self->{curInfo}->{boxpic} = "http://www.thelegacy.de" . $attr->{src}; + } + elsif (($tagname eq 'img') && ($attr->{src} =~ m|/pics/backcover/Thumb|i)) + { + $self->{curInfo}->{backpic} = "http://www.thelegacy.de" . $attr->{src}; + } + elsif (($tagname eq 'img') && ($attr->{src} =~ m|/pics/screen|i)) + { + if ($self->{curInfo}->{screenshot1} eq '') + { + $self->{curInfo}->{screenshot1} = "http://www.thelegacy.de" . $attr->{src}; + } + elsif ($self->{curInfo}->{screenshot2} eq '') + { + $self->{curInfo}->{screenshot2} = "http://www.thelegacy.de" . $attr->{src}; + } + } + elsif ( (($tagname eq 'span') ||($tagname eq 'div')) && ($attr->{class} eq 'category')) + { + $self->{isAnalyse} = 1 ; + } + elsif (($self->{isEditor} eq 1) && ($tagname eq 'a') && ($attr->{target} eq 'ListGames') && ($attr->{class} eq 'aa') && ($self->{curInfo}->{editor} eq '')) + { + $self->{isEditor} = 2 ; + } + elsif (($self->{isDeveloper} eq 1) && ($tagname eq 'a') && ($attr->{target} eq 'ListGames') && ($attr->{class} eq 'aa') && ($self->{curInfo}->{developer} eq '')) + { + $self->{isDeveloper} = 2 ; + } + elsif (($self->{isDate} eq 1) && ($tagname eq 'div') && ($attr->{class} eq 'description') && ($self->{curInfo}->{released} eq '')) + { + $self->{isDate} = 2 ; + } + elsif (($tagname eq 'a') && ($attr->{name} =~ m|review_|i)) + { + $self->{isDescription} = 1 ; + } + elsif (($self->{isDescription} eq 1) && ($tagname eq 'a') && ($attr->{class} eq 'aa')) + { + $self->{isDescription} = 2 ; + } + elsif (($tagname eq 'span') && ( $attr->{id} =~ m|review_|i) && ( $attr->{id} =~ m|_less|i)) + { + $self->{isDescription} = 0 ; + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//; + if ($self->{isName}) + { + $self->{itemsList}[$self->{itemIdx}]->{name} = $origtext; + $self->{isName} = 0; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//; + if ($self->{isName}) + { + $self->{curInfo}->{name} = $origtext; + $self->{isName} = 0 ; + } + elsif ($self->{isAnalyse}) + { + $self->{isDate} = 0; + $self->{isDeveloper} = 0; + $self->{isEditor} = 0; + + $self->{isDate} = 1 if ($origtext =~ m/ffentlichung/i); + $self->{isDate} = 1 if ($origtext =~ m/Publishing/i); + $self->{isDeveloper} = 1 if ($origtext =~ m/Entwickler/i); + $self->{isDeveloper} = 1 if ($origtext =~ m/developer/i); + $self->{isEditor} = 1 if ($origtext =~ m/Publisher/i); + + $self->{isAnalyse} = 0 ; + } + elsif ($self->{isDate} eq 2) + { + $origtext =~ s/://; + $self->{curInfo}->{released} = $origtext; + $self->{isDate} = 0 ; + } + elsif ($self->{isGenre}) + { + $self->{curInfo}->{genre} .= $origtext; + $self->{curInfo}->{genre} .= ","; + $self->{isGenre} = 0; + } + elsif ($self->{isDeveloper} eq 2) + { + $self->{curInfo}->{developer} = $origtext; + $self->{isDeveloper} = 0 ; + } + elsif ($self->{isEditor} eq 2) + { + $self->{curInfo}->{editor} = $origtext; + $self->{isEditor} = 0 ; + } + elsif ($self->{isPlatform}) + { + $origtext =~ s/PC \(Windows\)/PC/; + my @array = split(/-/,$origtext); + $self->{curInfo}->{platform} = $array[0]; + # Enleve les blancs en fin de chaine + $self->{curInfo}->{platform} =~ s/\s+$//; + $self->{isPlatform} = 0; + } + elsif ($self->{isDescription} eq 1) + { + $self->{curInfo}->{description} .= $origtext; + } + elsif ($self->{isDescription} eq 2) + { + $self->{isDescription} = 1; + } + } + } + + sub getTipsUrl + { + my $self = shift; + + return ; + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + name => 1, + platform => 0, + genre => 0, + released => 0 + }; + + $self->{isInfo} = 0; + $self->{isName} = 0; + $self->{isPlatform} = 0 ; + $self->{isAnalyse} = 0; + $self->{isEditor} = 0; + $self->{isDeveloper} = 0; + $self->{isDate} = 0; + $self->{isGenre} = 0; + $self->{isDescription} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s|<u>||gi; + $html =~ s|<li>|\n* |gi; + $html =~ s|<br>|\n|gi; + $html =~ s|<br />|\n|gi; + $html =~ s|<b>||gi; + $html =~ s|</b>||gi; + $html =~ s|<i>||gi; + $html =~ s|</i>||gi; + $html =~ s|<p>|\n|gi; + $html =~ s|</p>||gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|œ|oe|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + } + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + return "http://www.thelegacy.de/Museum/SQLlist_games.php3?logicalSearchConnection[]=AND&SearchValue=" . $word. "&searchEntity=TITLE&Review=&Forum=&type=&changed=&TopTen=&titel_id=&game_id=&titel=&first_letter=&misc=yes&quick=yes"; + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url; + } + + sub getName + { + return 'TheLegacy'; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'DE'; + } + + sub getCharset + { + my $self = shift; + + return "ISO-8859-15"; + } + + sub getSearchFieldsArray + { + return ['name']; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCgamesAmazonCommon.pm b/lib/gcstar/GCPlugins/GCgames/GCgamesAmazonCommon.pm new file mode 100644 index 0000000..ce3b52c --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCgamesAmazonCommon.pm @@ -0,0 +1,314 @@ +package GCPlugins::GCgames::GCgamesAmazonCommon;
+
+###################################################
+#
+# Copyright 2005-2010 Tian
+#
+# 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;
+use GCPlugins::GCstar::GCAmazonCommon;
+
+{
+ package GCPlugins::GCgames::GCgamesAmazonPluginsBase;
+
+ use base ('GCPlugins::GCgames::GCgamesPluginsBase', 'GCPlugins::GCstar::GCPluginAmazonCommon');
+
+ sub start
+ {
+ my ($self, $tagname, $attr, $attrseq, $origtext) = @_;
+
+ $self->{inside}->{$tagname}++;
+
+ if ($self->{parsingList})
+ {
+ if ( ($tagname eq 'div') && ($attr->{class} eq 'buying') && ($self->{isGame} ne 2) )
+ {
+ $self->{itemIdx}++;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $self->{loadedUrl};
+ $self->{isGame} = 2 ;
+ }
+ elsif ( ($tagname eq 'h1') && ($attr->{class} eq 'headerblocktitle') && ($self->{isGame} ne 2) )
+ {
+ $self->{isGame} = 1 ;
+ $self->{isUrl} = 1 ;
+ }
+ elsif ( ($tagname eq 'td') && ($attr->{class} eq 'imageColumn') && ($self->{isGame} ne 2) )
+ {
+ $self->{isGame} = 1 ;
+ $self->{isUrl} = 1 ;
+ }
+ elsif ( ($tagname eq 'a') && ($self->{isGame} eq 1) && ($self->{isUrl}) )
+ {
+ $self->{itemIdx}++;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href};
+ $self->{isUrl} = 0 ;
+ }
+ elsif ( ($tagname eq 'span') && ($attr->{class} eq 'srTitle') && ($self->{isGame} eq 1) )
+ {
+ $self->{isName} = 1 ;
+ }
+ elsif ( ($tagname eq 'span') && ($attr->{class} eq 'binding') && ($self->{isGame} eq 1) )
+ {
+ $self->{isPlatform} = 1 ;
+ }
+ elsif ( ($tagname eq 'span') && ($attr->{class} eq 'avail') )
+ {
+ $self->{isGame} = 0 ;
+ }
+ elsif ( ($tagname eq 'div') && ($attr->{class} eq 'usedPrice') )
+ {
+ $self->{isGame} = 0 ;
+ }
+ elsif ( ($tagname eq 'input') && ($attr->{name} eq 'sdp-sai-asin') )
+ {
+ $self->{isCodeEAN} = 1 ;
+ }
+ elsif ( ($tagname eq 'a') && ($self->{isCodeEAN}))
+ {
+ $self->{SaveUrl} = $attr->{href};
+ $self->{isCodeEAN} = 0 ;
+ }
+ elsif ( ($tagname eq 'b') && ($attr->{class} eq 'sans') )
+ {
+ $self->{itemIdx}++;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $self->{SaveUrl};
+ }
+ }
+ elsif ($self->{parsingTips})
+ {
+ }
+ else
+ {
+
+ if ( ($tagname eq 'meta') && ($attr->{name} eq 'keywords') )
+ {
+ my ($name, $editor, @genre) = split(/,/,$attr->{content});
+ $self->{curInfo}->{name} = $name;
+ $self->{curInfo}->{editor} = $editor;
+ my $element;
+ foreach $element (@genre)
+ {
+ $element =~ s/^\s+//;
+ if ( !($element =~ m/console/i) && !($element =~ m/cartouche/i) && !($element =~ m/video games/i) && !($element =~ /([0-9])/))
+ {
+ $self->{curInfo}->{genre} .= $element;
+ $self->{curInfo}->{genre} .= ",";
+ }
+ }
+
+ # Sur Amazon.com et amazon.co.jp je n ai pas reussi a trouver un critere pertinent pour la recherche des genres
+ if (($self->{suffix} eq 'com') || ($self->{suffix} eq 'co.jp') )
+ {
+ $self->{curInfo}->{genre} = '';
+ }
+
+ if ($self->{ean} ne '')
+ {
+ $self->{curInfo}->{ean} = $self->{ean};
+ }
+ }
+ elsif ($tagname eq 'tpfdateparution')
+ {
+ $self->{isDate} = 1 ;
+ }
+ elsif ($tagname eq 'tpfplateforme')
+ {
+ $self->{isPlatform} = 1 ;
+ }
+ elsif ($tagname eq 'tpfcouverture')
+ {
+ $self->{curInfo}->{boxpic} = $self->extractImage($attr);
+ }
+ elsif ($tagname eq 'tpfscreenshot1')
+ {
+ $self->{curInfo}->{screenshot1} = $self->extractImage($attr);
+ }
+ elsif ($tagname eq 'tpfscreenshot2')
+ {
+ $self->{curInfo}->{screenshot2} = $self->extractImage($attr);
+ }
+ elsif (($tagname eq 'tpfdescription') )
+ {
+ $self->{isDesc} = 1;
+ }
+ elsif ( ($tagname eq 'div') && ($attr->{class} eq 'bucket') && ($self->{isDesc} eq 1))
+ {
+ $self->{isDesc} = 0;
+ }
+
+ }
+ }
+
+ sub end
+ {
+ my ($self, $tagname) = @_;
+
+ $self->{inside}->{$tagname}--;
+ }
+
+ sub text
+ {
+ my ($self, $origtext) = @_;
+
+ if ($self->{parsingList})
+ {
+ if ($self->{isPlatform})
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{platform} = $self->transformPlatform($origtext);
+ $self->{isPlatform} = 0;
+ }
+ elsif ($self->{isName})
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{name} = $origtext;
+ $self->{isName} = 0;
+ }
+ }
+ elsif ($self->{parsingTips})
+ {
+ }
+ else
+ {
+ # Enleve les blancs en debut de chaine
+ $origtext =~ s/^\s+//;
+ # Enleve les blancs en fin de chaine
+ $origtext =~ s/\s+$//;
+
+ if ($self->{isDate})
+ {
+ $self->{curInfo}->{released} = $origtext;
+ $self->{isDate} = 0;
+ }
+ elsif ($self->{isPlatform})
+ {
+ if ($origtext ne '' )
+ {
+ $self->{curInfo}->{platform} = $self->transformPlatform($origtext);
+ $self->{isPlatform} = 0;
+ }
+ }
+ elsif (($self->{isDesc}) && ($origtext ne ""))
+ {
+ $self->{curInfo}->{description} .= $origtext ."\n";
+ }
+ }
+ }
+
+ sub transformPlatform
+ {
+ my ($self, $platform) = @_;
+
+ $platform =~ s/^([\w ]*)\W{2}.*$/$1/ms;
+ $platform =~ s/SONY //i;
+ if ($platform =~ m/windows/i)
+ {
+ $platform = 'PC';
+ }
+ return $platform;
+ }
+
+ sub getTipsUrl
+ {
+ my $self = shift;
+
+ return;
+ }
+
+ sub new
+ {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = $class->SUPER::new();
+ bless ($self, $class);
+
+ $self->{hasField} = {
+ name => 1,
+ platform => 1
+ };
+
+ $self->{isCodeEAN} = 0;
+ $self->{SaveUrl} = '';
+ $self->{isName} = 0;
+ $self->{isGame} = 0;
+ $self->{isUrl} = 0;
+ $self->{isPlatform} = 0;
+ $self->{isDate} = 0;
+ $self->{isDesc} = 0;
+ $self->{ean} = '';
+
+ return $self;
+ }
+
+ sub getSearchUrl
+ {
+ my ($self, $word) = @_;
+
+ if ($self->{searchField} eq 'ean')
+ {
+ $self->{ean} = $word;
+ return "http://s1.amazon." . $self->{suffix} . "/exec/varzea/sdp/sai-condition/" . $word;
+ }
+ else
+ {
+ $self->{ean} = '';
+ }
+
+ return 'http://www.amazon.' . $self->{suffix} . '/gp/search/?redirect=true&search-alias=videogames&keywords=' .$word;
+ }
+
+ sub getItemUrl
+ {
+ my ($self, $url) = @_;
+
+ return $url if $url;
+ return 'http://www.amazon.' . $self->{suffix};
+ }
+
+ sub getName
+ {
+ return 'Amazon';
+ }
+
+ sub getAuthor
+ {
+ return 'TPF';
+ }
+
+ sub getLang
+ {
+ return 'FR';
+ }
+
+ sub getCharset
+ {
+ my $self = shift;
+
+ return "ISO-8859-1";
+ }
+
+ sub getSearchFieldsArray
+ {
+ return ['ean', 'name'];
+ }
+}
+
+1;
diff --git a/lib/gcstar/GCPlugins/GCgames/GCgamesCommon.pm b/lib/gcstar/GCPlugins/GCgames/GCgamesCommon.pm new file mode 100644 index 0000000..9403652 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCgamesCommon.pm @@ -0,0 +1,87 @@ +package GCPlugins::GCgames::GCgamesCommon; + +################################################### +# +# 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; + +our $MAX_ACTORS = 6; +our $MAX_DIRECTORS = 4; + +use GCPlugins::GCPluginsBase; + +{ + package GCPlugins::GCgames::GCgamesPluginsBase; + + use base qw(GCPluginParser); + use HTML::Entities; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + return $self; + } + + sub getSearchFieldsArray + { + return ['name']; + } + + sub getTipsUrl + { + my $self = shift; + + return ''; + } + + sub getTips + { + my $self = shift; + my $url = $self->getTipsUrl; + if ($url) + { + $self->{parsingTips} = 1; + my $html = $self->loadPage($url, 0, 1); + $html = $self->preProcess($html); + decode_entities($html); + $self->{inside} = undef; + $self->parse($html); + $self->{parsingTips} = 0; + } + } + + sub getItemInfo + { + my $self = shift; + + $self->SUPER::getItemInfo; + $self->getTips; + + return $self->{curInfo}; + } + +} + +1;
\ No newline at end of file |