summaryrefslogtreecommitdiff
path: root/lib/gcstar/GCPlugins/GCgames
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gcstar/GCPlugins/GCgames')
-rw-r--r--lib/gcstar/GCPlugins/GCgames/GCGameSpot.pm365
-rw-r--r--lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm512
-rw-r--r--lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm78
-rw-r--r--lib/gcstar/GCPlugins/GCgames/GCMobyGames.pm287
4 files changed, 749 insertions, 493 deletions
diff --git a/lib/gcstar/GCPlugins/GCgames/GCGameSpot.pm b/lib/gcstar/GCPlugins/GCgames/GCGameSpot.pm
index c5870b4..3c6e390 100644
--- a/lib/gcstar/GCPlugins/GCgames/GCGameSpot.pm
+++ b/lib/gcstar/GCPlugins/GCgames/GCGameSpot.pm
@@ -2,7 +2,7 @@ package GCPlugins::GCgames::GCGameSpot;
###################################################
#
-# Copyright 2005-2011 Christian Jodar
+# Copyright 2005-2014 Christian Jodar
#
# This file is part of GCstar.
#
@@ -40,45 +40,76 @@ use GCPlugins::GCgames::GCgamesCommon;
$self->{inside}->{$tagname}++;
if ($self->{parsingList})
{
- if ($tagname eq 'div')
+ if ($tagname eq 'head')
{
- $self->{isGame} = 1
- if $attr->{class} =~ /result_title/;
+ $self->{isGame} = 0;
}
- elsif ($tagname eq 'tpfdatetpf')
+ elsif (($tagname eq 'ul') && ($attr->{class} eq 'editorial river search-results'))
{
- $self->{isDate} = 1;
+ $self->{isGame} = 1;
}
elsif (($tagname eq 'a') && ($self->{isGame}))
{
$self->{itemIdx}++;
- $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href};
+ $self->{itemsList}[$self->{itemIdx}]->{url} = 'http://www.gamespot.com'.$attr->{href};
+ }
+ elsif (($tagname eq 'time') && ($attr->{class} eq 'media-date') && ($self->{isGame}))
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{released} = $attr->{datetime};
+ $self->{isPlatform} = 0;
+
+ my @array = split(/,/,$self->{itemsList}[$self->{itemIdx}]->{platform});
+ my $element;
+
+ my $SaveName = $self->{itemsList}[$self->{itemIdx}]->{name};
+ my $SaveDate = $self->{itemsList}[$self->{itemIdx}]->{released};
+ my $SaveUrl = $self->{itemsList}[$self->{itemIdx}]->{url};
+ $self->{itemIdx}--;
+
+ foreach $element (@array)
+ {
+ if ($element ne '')
+ {
+ $self->{itemIdx}++;
+ $self->{itemsList}[$self->{itemIdx}]->{name} = $SaveName;
+ $self->{itemsList}[$self->{itemIdx}]->{released} = $SaveDate;
+ $self->{itemsList}[$self->{itemIdx}]->{platform} = $element;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $SaveUrl . 'tpfplatformtpf' . $self->{itemsList}[$self->{itemIdx}]->{platform}. 'tpfreleasetpf' . $self->{itemsList}[$self->{itemIdx}]->{released};
+ }
+ }
+ }
+ elsif (($tagname eq 'h3') && ($attr->{class} eq 'media-title') && ($self->{isGame}))
+ {
$self->{isName} = 1;
}
+ elsif (($tagname eq 'div') && ($attr->{class} eq 'media-byline') && ($self->{isGame}))
+ {
+ $self->{isPlatform} = 1;
+ }
+ elsif (($tagname eq 'span') && ($self->{isPlatform} eq 1))
+ {
+ $self->{isPlatform} = 2;
+ }
+ elsif (($tagname eq 'ul') && ($attr->{class} eq 'paginate'))
+ {
+ $self->{isGame} = 0;
+ }
}
elsif ($self->{parsingTips})
{
- if (($tagname eq 'h2') && ($attr->{class} eq 'module_title'))
+ if (($tagname eq 'h2') && ($attr->{class} eq 'cheats__title'))
{
$self->{isSection} = 1;
}
- elsif (($tagname eq 'th') && ($attr->{scope} eq 'row') && ($attr->{class} eq 'code') && ($self->{section} ne ''))
+ elsif (($tagname eq 'th') && ($attr->{scope} eq 'row') && ($attr->{class} eq 'cheats__code') && (($self->{section} eq 'Codes') || ($self->{section} eq 'Unlockables')))
{
$self->{isCheat} = 1;
}
- elsif (($tagname eq 'td') && ($attr->{class} eq 'effect') && ($self->{section} ne ''))
+ elsif (($tagname eq 'td') && ($attr->{class} eq 'cheats__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'))
+ elsif (($tagname eq 'li') && ($attr->{class} eq 'cheats-list__item'))
{
$self->{section} = '';
}
@@ -89,112 +120,74 @@ use GCPlugins::GCgames::GCgamesCommon;
}
else
{
- if ($tagname eq 'img')
+ if (($tagname eq 'a') && ($self->{isScreen}))
{
- $self->{curInfo}->{boxpic} = ' '
- if $attr->{src} =~ /no_preview/;
- if ((! $self->{curInfo}->{boxpic}) && ($attr->{src} =~ /[^xo]boxs[^c]/))
+ if (! $self->{curInfo}->{screenshot1})
{
- $self->{curInfo}->{boxpic} = $attr->{src};
+ $self->{curInfo}->{screenshot1} = $attr->{href};
}
- if ($attr->{src} =~ /thumb/)
+ elsif (! $self->{curInfo}->{screenshot2})
{
- 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};
- }
+ $self->{curInfo}->{screenshot2} = $attr->{href};
}
+ $self->{isScreen} = 0;
}
- 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/))
+ elsif (($tagname eq 'a') && ($attr->{href} =~ /\/cheats\//))
{
- $self->{curInfo}->{exclusive} = 0;
- }
- elsif (($tagname eq 'span') && ($attr->{class} eq 'reviewer'))
- {
- $self->{isRating} = 1;
+ $self->{urlTips} = $attr->{href};
}
- elsif (($tagname eq 'a') && ($self->{isRating} eq 1))
+ elsif (($tagname eq 'li') && ($attr->{class} eq 'pod-images__item'))
{
- $self->{isRating} = 2;
+ $self->{isScreen} = 1;
}
- elsif (($tagname eq 'li') && ($attr->{class} eq 'moreStat play_info number_of_players'))
+ elsif (($tagname eq 'img') && ($self->{isBox}))
{
- $self->{isPlayers} = 1;
+ $self->{curInfo}->{boxpic} = $attr->{src};
+ $self->{curInfo}->{boxpic} =~ s/_medium/_avatar/ if !$self->{bigPics} ;
+ $self->{isBox} = 0;
}
- elsif (($tagname eq 'p') && ($self->{isPlayers} eq 1))
+ elsif (($tagname eq 'dt') && ($attr->{class} eq 'pod-objectStats__title'))
{
- $self->{isPlayers} = 2;
+ $self->{isGame} = 1 if ! $self->{curInfo}->{name};
}
- elsif (($tagname eq 'li') && ($attr->{class} eq 'publisher'))
+ elsif (($tagname eq 'footer') && ($self->{isGame}))
{
- $self->{isEditor} = 1;
+ $self->{isGame} = 0;
+ if ($self->{curInfo}->{exclusive} ne 1)
+ {
+ $self->{curInfo}->{exclusive} = 0;
+ }
}
- elsif (($tagname eq 'a') && ($self->{isEditor} eq 1))
+ elsif (($tagname eq 'h3') && ($self->{isGame}))
{
- $self->{isEditor} = 2;
+ $self->{isName} = 1 if ! $self->{curInfo}->{name};
}
- elsif (($tagname eq 'li') && ($attr->{class} eq 'developer'))
+ elsif (($tagname eq 'ul') && ($attr->{class} eq 'system-list') && ($self->{isGame}))
{
- $self->{isDeveloper} = 1;
+ $self->{curInfo}->{exclusive} = 0;
}
- elsif (($tagname eq 'a') && ($self->{isDeveloper} eq 1))
+ elsif (($tagname eq 'li') && ($attr->{class} =~ m/system /i) && ($self->{isGame}))
{
- $self->{isDeveloper} = 2;
+ $self->{curInfo}->{exclusive} = $self->{curInfo}->{exclusive} + 1;
+ $self->{isPlatform} = 1 if ($attr->{class} =~ m/$self->{curInfo}->{platform}/i);
}
- elsif (($tagname eq 'li') && ($attr->{class} eq 'genre'))
+ elsif (($tagname eq 'div') && ($attr->{class} eq 'media-img imgflare--boxart') && ($self->{isGame}))
{
- $self->{isGenre} = 1;
+ $self->{isBox} = 1;
}
- elsif (($tagname eq 'a') && ($self->{isGenre}))
+ elsif (($tagname eq 'li') && ($attr->{class} eq 'pod-objectStats__item') && ($self->{isGame}))
{
- $self->{curInfo}->{genre} = $attr->{title};
+ $self->{isEditor} = 0;
+ $self->{isDeveloper} = 0;
$self->{isGenre} = 0;
}
- elsif (($tagname eq 'li') && ($attr->{class} eq 'date'))
+ elsif (($tagname eq 'dd') && ($attr->{class} eq 'pod-objectStats__deck'))
{
- $self->{isReleased} = 1;
- }
- elsif (($tagname eq 'a') && ($self->{isReleased} eq 1))
- {
- $self->{isReleased} = 2;
+ $self->{isDesc} = 1;
}
- elsif (($tagname eq 'a') && ($attr->{href} =~ /\/cheats\//) && ($attr->{class} eq 'navItemAction'))
+ elsif (($tagname eq 'div') && ($attr->{class} eq 'gs-score__cell'))
{
- $self->{urlTips} = $attr->{href};
+ $self->{isRating} = 1 if ! $self->{curInfo}->{ratingpress};
}
}
}
@@ -204,14 +197,6 @@ use GCPlugins::GCgames::GCgamesCommon;
my ($self, $tagname) = @_;
$self->{inside}->{$tagname}--;
- if ($self->{parsingList})
- {
- $self->{isGame} = 0
- if ($tagname eq 'div');
- }
- elsif ($self->{parsingTips})
- {
- }
}
sub text
@@ -220,30 +205,53 @@ use GCPlugins::GCgames::GCgamesCommon;
if ($self->{parsingList})
{
- if ($self->{isName})
+ if ($self->{isName} eq 1)
{
- $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};
+ # Enleve les blancs en debut de chaine
+ $origtext =~ s/^\s+//;
+ # Enleve les blancs en fin de chaine
+ $origtext =~ s/\s+$//;
+
+ $self->{itemsList}[$self->{itemIdx}]->{name} = $origtext;
$self->{isName} = 0;
}
- elsif ($self->{isDate})
+ elsif ($self->{isPlatform} eq 2)
{
- $origtext =~ /^\s*Release Date:\s*(.*?)\s*$/ms;
- $self->{itemsList}[$self->{itemIdx}]->{released} = $1;
- $self->{isDate} = 0;
+ # 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 '')
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{platform} = $origtext;
+ }
+ else
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{platform} .= ','.$origtext;
+ }
+
+ $self->{isPlatform} = 1;
}
}
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$/;
+ if (($self->{isSection}) && $self->{inside}->{h2})
+ {
+ $self->{section} = 'Codes' if $origtext =~ /^Cheat Codes/i;
+ $self->{section} = 'Codes' if $origtext =~ /cheats/i;
+ $self->{section} = 'Unlockables' if $origtext =~ /^Unlockables/i;
+ $self->{section} = 'Unlockables' if $origtext =~ /^Achievements/i;
+ $self->{section} = 'Unlockables' if $origtext =~ /^Trophies/i;
+ $self->{section} = 'Unlockables' if $origtext =~ /^Steam Achievements/i;
+ $self->{section} = 'Secrets' if $origtext =~ /^Secrets/i;
+ $self->{section} = 'Secrets' if $origtext =~ /^Easter Eggs/i;
+
+ $self->{section} = 'Secrets' if $self->{section} eq '';
+ $self->{section} = '' if $origtext =~ /Walkthrough/i;
+ $self->{section} = '' if $origtext =~ /FAQ/i;
$self->{isSection} = 0;
+
}
elsif (($self->{section} eq 'Codes') || ($self->{section} eq 'Unlockables'))
{
@@ -283,12 +291,18 @@ use GCPlugins::GCgames::GCgamesCommon;
$self->{isDesc} = 0;
}
}
- elsif ($self->{section} eq 'Secrets')
+
+ if ($self->{section} eq 'Secrets')
{
$origtext =~ s/^\s*//;
$origtext =~ s/\s*$//;
return if !$origtext;
- $self->{curInfo}->{secrets} .= "\n" if $self->{curInfo}->{secrets};
+ # Un peu de mise en page
+ $self->{curInfo}->{secrets} .= "\n\n" if (($self->{curInfo}->{secrets}) && ($self->{inside}->{h2}));
+ $self->{curInfo}->{secrets} .= "\n" if (($self->{curInfo}->{secrets}) && (! $self->{inside}->{td}) && (! $self->{inside}->{h2}) && ($origtext ne 'Effect'));
+ $self->{curInfo}->{secrets} .= "\t\t\t" if (($self->{curInfo}->{secrets}) && ($self->{inside}->{td}));
+ $self->{curInfo}->{secrets} .= "\t\t\t" if (($self->{curInfo}->{secrets}) && ($origtext eq 'Effect'));
+
$self->{curInfo}->{secrets} .= $origtext;
}
}
@@ -299,34 +313,82 @@ use GCPlugins::GCgames::GCgamesCommon;
$origtext =~ s/\n//g;
$self->{curInfo}->{name} = $origtext;
$self->{curInfo}->{platform} = $self->{url_plateforme};
- $self->{curInfo}->{exclusive} = 1;
+ $self->{curInfo}->{released} = $self->{url_release};
$self->{isName} = 0;
}
- elsif ($self->{isRating} eq 2)
+ elsif ($self->{isPlatform})
+ {
+ $self->{curInfo}->{platform} = $origtext;
+ $self->{isPlatform} = 0;
+ }
+ elsif (($origtext eq 'Published By:') && ($self->{isGame}))
+ {
+ $self->{isEditor} = 1;
+ }
+ elsif (($origtext eq 'Developed By:')&& ($self->{isGame}))
+ {
+ $self->{isDeveloper} = 1;
+ }
+ elsif (($origtext eq 'Genre:')&& ($self->{isGame}))
+ {
+ $self->{isGenre} = 1;
+ }
+ elsif ($self->{isRating})
{
+ # Enleve les blancs en debut de chaine
+ $origtext =~ s/^\s+//;
+ # Enleve les blancs en fin de chaine
+ $origtext =~ s/\s+$//;
+
$self->{curInfo}->{ratingpress} = $origtext;
$self->{isRating} = 0;
}
+ elsif ($self->{isDesc})
+ {
+ # Enleve les blancs en debut de chaine
+ $origtext =~ s/^\s+//;
+ # Enleve les blancs en fin de chaine
+ $origtext =~ s/\s+$//;
+ $self->{curInfo}->{description} = $origtext;
+ $self->{isDesc} = 0;
+ }
else
{
$origtext =~ s/^\s*//;
$origtext =~ s/\s*$//;
return if !$origtext;
- if ($self->{isReleased} eq 2)
+ if (($self->{isEditor}) && ($origtext ne ','))
{
- $origtext =~ s/ .$//;
- $self->{curInfo}->{released} = $origtext;
- $self->{isReleased} = 0;
+ if ($self->{curInfo}->{editor} ne '')
+ {
+ $self->{curInfo}->{editor} = $self->{curInfo}->{editor} . ','.$origtext;
+ }
+ else
+ {
+ $self->{curInfo}->{editor} = $origtext;
+ }
}
- elsif ($self->{isEditor} eq 2)
+ elsif (($self->{isDeveloper}) && ($origtext ne ','))
{
- $self->{curInfo}->{editor} = $origtext;
- $self->{isEditor} = 0;
+ if ($self->{curInfo}->{developer} ne '')
+ {
+ $self->{curInfo}->{developer} = $self->{curInfo}->{developer} . ','.$origtext;
+ }
+ else
+ {
+ $self->{curInfo}->{developer} = $origtext;
+ }
}
- elsif ($self->{isDeveloper} eq 2)
+ elsif (($self->{isGenre}) && ($origtext ne ','))
{
- $self->{curInfo}->{developer} = $origtext;
- $self->{isDeveloper} = 0;
+ if ($self->{curInfo}->{genre} ne '')
+ {
+ $self->{curInfo}->{genre} = $self->{curInfo}->{genre} . ','.$origtext;
+ }
+ else
+ {
+ $self->{curInfo}->{genre} = $origtext;
+ }
}
elsif ($self->{isPlayers} eq 2)
{
@@ -359,7 +421,7 @@ use GCPlugins::GCgames::GCgamesCommon;
$self->{isName} = 0;
$self->{isGame} = 0;
- $self->{isDate} = 0;
+ $self->{isPlatform} = 0;
$self->{isCheat} = 0;
$self->{isDesc} = 0;
$self->{isTip} = 0;
@@ -372,10 +434,10 @@ use GCPlugins::GCgames::GCgamesCommon;
$self->{isReleased} = 0;
$self->{isPlayers} = 0;
$self->{isBox} = 0;
- $self->{isExclu} = 0;
- $self->{url_plateforme} = '';
+ $self->{isScreen} = 0;
$self->{urlTips} = "";
- $self->{SaveUrl} = "";
+ $self->{url_plateforme} = '';
+ $self->{url_release} = '';
return $self;
}
@@ -386,22 +448,26 @@ use GCPlugins::GCgames::GCgamesCommon;
if ($self->{parsingTips})
{
- $html =~ s|<b>(.*?)</b>|$1|g;
- $html =~ s|<i>(.*?)</i>|$1|g;
+ my $found = index($html,"Cheats For " . $self->{curInfo}->{platform});
+ if ( $found >= 0 )
+ {
+ $html = substr($html, $found + length('Cheats For ' . $self->{curInfo}->{platform}),length($html)- $found -length('Cheats For ' . $self->{curInfo}->{platform}) );
+ $found = index($html,"\"tab-pane \"");
+ if ( $found >= 0 )
+ {
+ $html = substr($html, 0, $found);
+ }
+ }
+ $html =~ s|</h2>||;
+
## 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;
@@ -440,18 +506,27 @@ use GCPlugins::GCgames::GCgamesCommon;
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/pages/search/solr_search_ajax.php?q='.$word.'&type=game&offset=0&tags_only=false&sort=false';
+ #return 'http://www.gamespot.com/search/?qs='.$word.'&filter=summary';
#return 'http://www.gamespot.com/search.html?qs=' .$word. '&tag=masthead%3Bsearch';
+ return 'http://www.gamespot.com/search/?indices[0]=game&page=1&q='.$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);
+ $found = index($self->{url_plateforme},"tpfreleasetpf");
+ if ( $found >= 0 )
+ {
+ $self->{url_release} = substr($self->{url_plateforme}, $found +length('tpfreleasetpf'),length($self->{url_plateforme})- $found -length('tpfreleasetpf'));
+ $self->{url_plateforme} = substr($self->{url_plateforme}, 0, $found);
+ }
}
return 'http://www.gamespot.com' . $url
diff --git a/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm b/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm
index 560a582..52d0e59 100644
--- a/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm
+++ b/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm
@@ -2,7 +2,7 @@ package GCPlugins::GCgames::GCJeuxVideoCom;
###################################################
#
-# Copyright 2005-2010 Tian
+# Copyright 2005-2016 Tian
#
# This file is part of GCstar.
#
@@ -32,57 +32,159 @@ use GCPlugins::GCgames::GCgamesCommon;
use base 'GCPlugins::GCgames::GCgamesPluginsBase';
+ sub decryptUrl
+ {
+ my ($self, $src) = @_;
+ my $n = '0A12B34C56D78E9F';
+ my $res = 'http://www.jeuxvideo.com';
+ my $s = reverse $src;
+ my ($c, $l);
+ while (length $s)
+ {
+ $l = index $n, chop $s;
+ $c = index $n, chop $s;
+ my $car = $l * 16 + $c;
+ $res .= chr $car;
+ }
+ return $res;
+ }
+
+ sub getPlatformName
+ {
+ my ($self, $platform) = @_;
+ $platform =~ s/^360$/Xbox 360/;
+ $platform =~ s/^32X$/Mega Drive 32X/;
+ $platform =~ s/^3DS$/Nintendo 3DS/;
+ $platform =~ s/^C64$/Commodore 64/;
+ $platform =~ s/^CPC$/Amstrad CPC/;
+ $platform =~ s/^DCAST$/Dreamcast/;
+ $platform =~ s/^DS$/Nintendo DS/;
+ $platform =~ s/^G.GEAR$/Game Gear/;
+ $platform =~ s/^GB$/Game Boy/;
+ $platform =~ s/^GBA$/Game Boy Advance/;
+ $platform =~ s/^Giz$/Gizmondo/;
+ $platform =~ s/^MD$/Mega Drive/;
+ $platform =~ s/^MS$/Master System/;
+ $platform =~ s/^N64$/Nintendo 64/;
+ $platform =~ s/^NEO$/Neo Geo/;
+ $platform =~ s/^New 3DS$/New Nintendo 3DS/;
+ $platform =~ s/^NGAGE$/N-Gage/;
+ $platform =~ s/^NGC$/Gamecube/;
+ $platform =~ s/^ONE$/Xbox One/;
+ $platform =~ s/^PC ENG$/PC Engine/;
+ $platform =~ s/^PS1$/PlayStation/;
+ $platform =~ s/^PS2$/PlayStation 2/;
+ $platform =~ s/^PS3$/PlayStation 3/;
+ $platform =~ s/^PS4$/PlayStation 4/;
+ $platform =~ s/^SNES$/Super Nintendo/;
+ $platform =~ s/^ST$/Atari ST/;
+ $platform =~ s/^V.BOY$/Virtual Boy/;
+ $platform =~ s/^Vita$/PS Vita/;
+ $platform =~ s/^WiiU$/Wii U/;
+ return $platform;
+ }
+
+ sub loadMultipleResults
+ {
+ my ($self, $url) = @_;
+ my $page = $self->loadPage($url); $page =~ /<div\s+class="game-top-version-dispo">(.*?)<\/div>/s;
+ my $tabs = $1;
+ $page =~ /<strong>Sortie\s+France\s+:\s+<\/strong>(.*)/i;
+ my $released = $1;
+ $page =~ /<h1\s+class="highlight">(.*?)<\/h1>/i;
+ my $name = $1;
+ $name =~ s/&#039;/'/g;
+ $name =~ s/&amp;/&/g;
+ my @lines = split /\n/, $tabs;
+ foreach my $line (@lines)
+ {
+ if ($line =~ /href="([^"]*)".*?>([0-9a-zA-Z_. -]*)<\/a>/)
+ {
+ my $url = $1;
+ my $platform = $self->getPlatformName($2);
+ $self->{itemIdx}++;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = 'http://www.jeuxvideo.com'.$url;
+ $self->{itemsList}[$self->{itemIdx}]->{name} = $name;
+ $self->{itemsList}[$self->{itemIdx}]->{platform} = $platform;
+ $self->{itemsList}[$self->{itemIdx}]->{released} = $released;
+ }
+ elsif ($line =~ /<span class="label-support active-mach-version label-.*" itemprop="device" content=".*">([0-9a-zA-Z_. -]*)<\/span>/)
+ {
+ # for some reason, it ends with a / but it's not a multi-platform game
+ $self->{itemIdx}++;
+ $name =~ s/ sur $1$//e;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $url;
+ $self->{itemsList}[$self->{itemIdx}]->{name} = $name;
+ $self->{itemsList}[$self->{itemIdx}]->{platform} = $self->getPlatformName($1);
+ $self->{itemsList}[$self->{itemIdx}]->{released} = $released;
+ }
+ }
+ }
+
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')))
+ if ($tagname eq 'span')
{
- $self->{inResults} = 1;
- }
- elsif ($self->{inResults})
- {
- if ($tagname eq 'img')
+ if (($attr->{class} =~ /JvCare\s+([0-9A-F]*)\s+lien-jv/) && ($attr->{title} ne ""))
{
- $self->{currentPlatform} = $attr->{alt};
+ my $url = $self->decryptUrl($1);
+ if (! exists $self->{urls}->{$url})
+ {
+ if ($url =~ /\/$/)
+ {
+ #If it ends with a /, it means it's a multi-platform game, and the link points to a common page
+ $self->loadMultipleResults($url);
+ $self->{urls}->{$url} = 1;
+ }
+ else
+ {
+ $self->{itemIdx}++;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $url;
+ $self->{isGame} = 1;
+ # Note : some game's name contains '-' => not use $attr->{title}
+ $self->{isName} = 1;
+
+ my @array = split(/-/,$attr->{title});
+ if (scalar(@array) ge 3 )
+ {
+ if (!($array[$#array] =~ /date/i))
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{released} = $array[$#array];
+ }
+ }
+
+ $self->{urls}->{$url} = 1;
+ }
+ }
}
- elsif (($tagname eq 'a') && ($attr->{href} =~ /^http/))
+ return if !$self->{isGame};
+ if ($attr->{class} =~ /recherche-aphabetique-item-machine/)
{
- $self->{itemIdx}++;
- $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href};
- $self->{itemsList}[$self->{itemIdx}]->{platform} = $self->{currentPlatform};
- $self->{isGame} = 1;
+ $self->{isPlatform} = 1;
}
}
}
elsif ($self->{parsingTips})
{
- if ($tagname eq 'tpfdebuttpf')
+ if ($attr->{class} eq 'rubrique-asl')
{
$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))
+ elsif (($tagname eq 'tpfdebuttpf') && ($self->{isTip} eq 2))
{
- $self->{isTip} = 1;
+ $self->{isTip} = 3;
}
- elsif ($tagname eq 'tpfstopsolution')
+ elsif ( (($tagname eq 'p') || ($tagname eq 'h2') || ($tagname eq 'h3')) && (($self->{isTip} eq 3) || ($self->{isTip} eq 4)) )
{
- $self->{isTip} = 4;
+ $self->{curInfo}->{secrets} .= "\n" if $self->{curInfo}->{secrets};
}
- elsif ($tagname eq 'tpffintpf')
+ elsif (($tagname eq 'tpffintpf') && ($self->{isTip} ne 0))
{
- $self->{isTip} = 3;
+ $self->{isTip} = 2;
}
elsif ($tagname eq 'head')
{
@@ -93,71 +195,78 @@ use GCPlugins::GCgames::GCgamesCommon;
}
else
{
- if (($tagname eq 'meta') && ($attr->{property} eq 'og:image'))
+ if ($tagname eq 'span')
{
- my $cover = $attr->{content};
- $cover =~ s|(http://[^/]*)/([^i])|$1/images/$2|;
- if ($self->{bigPics})
+ if ($attr->{class} =~ 'label-support active')
{
- $cover =~ s/-p(-|\.)/-g$1/;
- $cover =~ s/t(\.jpg)/$1/;
+ $self->{is} = 'platform';
}
- my $back = $cover;
- if (!($back =~ s/-avant(-|\.)/-arriere$1/))
+ elsif ($attr->{itemprop} eq 'description')
{
- $back =~ s/f(t?\.jpg)/r$1/;
+ $self->{is} = 'description';
}
- $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})
+ elsif ($attr->{itemprop} eq 'genre')
+ {
+ $self->{is} = 'genre';
+ }
+ elsif ($attr->{class} eq 'recto-jaquette actif')
{
- $self->{curInfo}->{screenshot1} = $attr->{src};
- $self->{curInfo}->{screenshot1} =~ s/.gif/.jpg/;
- $self->{curInfo}->{screenshot1} =~ s/_m\.jpg/\.jpg/;
+ $self->{is} = 'boxpic';
}
- elsif (! $self->{curInfo}->{screenshot2})
+ elsif ($attr->{class} eq 'verso-jaquette actif')
{
- $self->{curInfo}->{screenshot2} = $attr->{src};
- $self->{curInfo}->{screenshot2} =~ s/.gif/.jpg/;
- $self->{curInfo}->{screenshot2} =~ s/_m\.jpg/\.jpg/;
- $self->{isScreen} = 0;
+ $self->{is} = 'backpic';
+ }
+ elsif (($attr->{'data-modal'} eq 'image') && $self->{is})
+ {
+ $self->{curInfo}->{$self->{is}} = 'http:'.$attr->{'data-selector'};
+ $self->{is} = '';
}
}
- elsif (($attr->{href} =~ m^/(etajvhtm|cheats)/^) && ! ($self->{urlTips}))
+ elsif ($tagname eq 'div')
{
- $self->{urlTips} = $attr->{href};
+ if ($attr->{class} eq 'game-top-title')
+ {
+ $self->{is} = 'name';
+ }
+ elsif ($attr->{class} eq 'bloc-note-redac')
+ {
+ $self->{is} = 'ratingpress';
+ }
+ elsif ($attr->{class} eq 'bloc-img-fiche')
+ {
+ $self->{is} = 'screenshot1';
+ }
+ elsif ($attr->{class} eq 'bloc-all-support')
+ {
+ $self->{curInfo}->{exclusive} = 0;
+ }
}
- elsif (($attr->{href} =~ m/test.htm/) && ! ($self->{curInfo}->{players}))
+ elsif ($tagname eq 'img')
{
- my $html = $self->loadPage($attr->{href});
-
- my $found = index($html,"<li><strong>Multijoueurs :</strong>");
- if ( $found >= 0 )
+ if ($self->{is} =~ /screenshot/)
{
- $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;
+ (my $src = 'http:'.$attr->{'data-srcset'}) =~ s/medias-sm/medias/;
+ $self->{curInfo}->{$self->{is}} = $src;
+ if ($self->{is} eq 'screenshot1')
+ {
+ $self->{is} = 'screenshot2';
+ }
+ else
+ {
+ $self->{is} = '';
+ }
}
}
+ elsif (($tagname eq 'h2') && ($attr->{class} =~ /titre-bloc/))
+ {
+ $self->{isTip} = 1;
+ }
+ elsif (($self->{isTip} eq 2) && ($attr->{href} =~ /wiki/i))
+ {
+ $self->{urlTips} = "http://www.jeuxvideo.com/" . $attr->{href};
+ $self->{isTip} = 0;
+ }
}
}
@@ -166,27 +275,33 @@ use GCPlugins::GCgames::GCgamesCommon;
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})
+ return if !$self->{isGame};
+ if ($self->{isPlatform})
{
+ if ($self->{itemsList}[$self->{itemIdx}]->{platform} eq "" )
+ {
+ # Enleve le " - " présent en début de chaîne
+ $origtext =~ s/- //;
+ $self->{itemsList}[$self->{itemIdx}]->{platform} = $self->getPlatformName($origtext);
+ }
+ $self->{isPlatform} = 0;
+ }
+ elsif ($self->{isName})
+ {
+ # Enleve les blancs en debut de chaine
+ $origtext =~ s/^\s+//;
+ # Enleve les blancs en fin de chaine
+ $origtext =~ s/\s+$//;
$self->{itemsList}[$self->{itemIdx}]->{name} = $origtext;
- $self->{isGame} = 0;
+ $self->{isName} = 0;
}
}
elsif ($self->{parsingTips})
@@ -194,71 +309,86 @@ use GCPlugins::GCgames::GCgamesCommon;
# 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)
+# $origtext =~ s/\s+$//;
+# There are problems with some texts if ended blanks are removed
+ if ($self->{isTip} eq 1)
+ {
+ $origtext =~ s|Gameboy|Game Boy|gi;
+ $origtext =~ s|Megadrive|Mega Drive|gi;
+ $origtext =~ s|PlayStation Portable|PSP|gi;
+ $origtext =~ s|PlayStation Vita|PS Vita|gi;
+
+ if (($origtext =~ /$self->{curInfo}->{platform}/i) || ($origtext =~ /astuce/i) || ($origtext =~ /renseignement/i) || ($origtext =~ /campagne/i))
+ {
+ $self->{isTip} = 2;
+ }
+ else
+ {
+ $self->{isTip} = 0;
+ }
+ }
+ elsif ($self->{isTip} eq 4)
{
- $self->{curInfo}->{secrets} .= "\n\n" if $self->{curInfo}->{secrets};
$self->{curInfo}->{secrets} .= $origtext;
- $self->{isTip} = 0;
}
- elsif ($self->{isTip} eq 1)
+ elsif ($self->{isTip} eq 3)
{
chomp($origtext);
if ( ($self->{curInfo}->{secrets}) && ($origtext ne "") )
{
- $self->{curInfo}->{secrets} .= "\n"
+ $self->{curInfo}->{secrets} .= "\n\n"
}
$self->{curInfo}->{secrets} .= $origtext;
- $self->{isTip} = 0;
+ $self->{isTip} = 4;
}
}
else
{
- if ($self->{inside}->{h1})
+ $origtext =~ s/^\s*//;
+ if ($self->{is} && $origtext)
{
- if ($self->{inside}->{a})
+ if ($self->{is} eq 'genre')
{
- $self->{curInfo}->{name} = $origtext;
- $self->{curInfo}->{exclusive} = 1;
+ $self->{curInfo}->{$self->{is}} .= "$origtext,";
}
- elsif ($self->{inside}->{span})
+ else
{
- if ($origtext !~ /^Fiche /)
- {
- $origtext =~ s/^\s*-?\s*//;
- $self->{curInfo}->{platform} = $origtext;
- }
+ $self->{curInfo}->{$self->{is}} = $origtext;
}
+ $self->{curInfo}->{$self->{is}} =~ s/Non/1/i if $self->{is} eq 'players';
+ $self->{curInfo}->{$self->{is}} = int($self->{curInfo}->{$self->{is}} / 2) if $self->{is} eq 'ratingpress';
+ $self->{curInfo}->{$self->{is}} =~ s/\s+$// if $self->{is} eq 'released';
+ $self->{curInfo}->{$self->{is}} = $self->getPlatformName($self->{curInfo}->{$self->{is}}) if $self->{is} eq 'platform';
+ $self->{is} = '';
}
- 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})
+ else
{
- $origtext =~ s/^\s*//;
- $origtext =~ s/\n$//;
- if ($origtext)
+ if ($self->{isTip} eq 1)
{
- 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} = '';
+ if (($origtext =~ /wiki/i) || ($origtext =~ /etajv/i))
+ {
+ $self->{isTip} = 2;
+ }
+ else
+ {
+ $self->{isTip} = 0;
+ }
+ }
+ elsif ($origtext eq 'Editeur(s) / Développeur(s) : ')
+ {
+ $self->{is} = 'editor';
+ }
+ elsif ($origtext =~ /^\s*\|\s*$/)
+ {
+ $self->{is} = 'developer' if ! $self->{curInfo}->{developer};
+ }
+ elsif ($origtext eq 'Sortie France : ')
+ {
+ $self->{is} = 'released';
+ }
+ elsif ($origtext eq 'Nombre maximum de joueurs : ')
+ {
+ $self->{is} = 'players';
}
}
}
@@ -279,7 +409,8 @@ use GCPlugins::GCgames::GCgamesCommon;
$self->{hasField} = {
name => 1,
- platform => 1
+ platform => 1,
+ released => 1
};
$self->{isTip} = 0;
@@ -293,49 +424,24 @@ use GCPlugins::GCgames::GCgamesCommon;
my ($self, $html) = @_;
if ($self->{parsingList})
{
- $self->{parsingEnded} = 0;
- $self->{inResults} = 0;
$self->{isGame} = 0;
+ $self->{isName} = 0;
+ $self->{isReleased} = 0;
+ $self->{isPlatform} = 0;
+ $self->{urls} = {};
+ $html =~ s/<\/?b>//ge;
}
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|&#146;|'|gi;
- $html =~ s|&#149;|*|gi;
- $html =~ s|&#156;|oe|gi;
- $html =~ s|&#133;|...|gi;
- $html =~ s|\x{85}|...|gi;
- $html =~ s|\x{8C}|OE|gi;
- $html =~ s|\x{9C}|oe|gi;
+ $html =~ s|<a data-jvcode="HTMLBLOCK" href="(.+)">|$self->RecupTips("http://www.jeuxvideo.com" . $1)|ge;
+ $html =~ s|Chargement du lecteur vid(.)o...|<p>"Une video est disponible"</p>|gi;
+ $html =~ s|Partager sur :||gi;
+ $html =~ s|<img src="//www.jeuxvideo.com/img/keys/(.+?).gif" alt="(.+?)" />|$2|gi;
}
else
{
$self->{is} = '';
- $self->{inScreenshots} = 0;
+ $self->{curInfo}->{exclusive} = 1;
}
return $html;
}
@@ -345,74 +451,32 @@ use GCPlugins::GCgames::GCgamesCommon;
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=\"");
+ my $found = index($html,"<h2 class=\"titre-bloc\">");
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, "\""));
+ $html = substr($html, $found +length('<h2 class="titre-bloc">'),length($html)- $found -length('<h2 class="titre-bloc">'));
+ $found = index($html,"<div class=\"bloc-lien-revision\">");
+ if ( $found >= 0 )
+ {
+ $html = substr($html, 0, $found);
+ }
}
- $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';
+ return 'http://www.jeuxvideo.com/recherche.php?q='.$word.'&m=9';
}
sub getItemUrl
{
my ($self, $url) = @_;
-
+
return $url if $url;
return 'http://www.jeuxvideo.com/';
}
@@ -432,12 +496,6 @@ use GCPlugins::GCgames::GCgamesCommon;
return 'FR';
}
- sub getCharset
- {
- my $self = shift;
-
- return "ISO-8859-1";
- }
sub isPreferred
{
return 1;
diff --git a/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm b/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm
index bec266f..e81d116 100644
--- a/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm
+++ b/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm
@@ -2,7 +2,7 @@ package GCPlugins::GCgames::GCJeuxVideoFr;
###################################################
#
-# Copyright 2005-2011 Tian
+# Copyright 2005-2014 Tian
#
# This file is part of GCstar.
#
@@ -69,6 +69,18 @@ use GCPlugins::GCgames::GCgamesCommon;
}
elsif ($self->{parsingTips})
{
+ if ($tagname eq 'tpfdebuttpf')
+ {
+ $self->{isTip} = 1;
+ }
+ elsif (($tagname eq 'p') && ($self->{isTip} ne 0 ))
+ {
+ $self->{isTip} = 2;
+ }
+ elsif ($tagname eq 'tpffintpf')
+ {
+ $self->{isTip} = 0;
+ }
}
else
{
@@ -235,6 +247,26 @@ use GCPlugins::GCgames::GCgamesCommon;
}
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)
+ {
+ chomp($origtext);
+ $self->{curInfo}->{secrets} .= "\n" if $self->{curInfo}->{secrets};
+ $self->{curInfo}->{secrets} .= $origtext;
+ $self->{isTip} = 1;
+ }
+ elsif ($self->{isTip} eq 1)
+ {
+ chomp($origtext);
+ if ( ($self->{curInfo}->{secrets}) && ($origtext ne "") )
+ {
+ $self->{curInfo}->{secrets} .= ""
+ }
+ $self->{curInfo}->{secrets} .= $origtext;
+ }
}
else
{
@@ -358,6 +390,8 @@ use GCPlugins::GCgames::GCgamesCommon;
}
elsif ($self->{parsingTips})
{
+ $html =~ s|<option value="(.+)">|$self->RecupSolution($1)|e;
+ $html =~ s|<br />|<p>|gi;
}
else
{
@@ -369,6 +403,41 @@ use GCPlugins::GCgames::GCgamesCommon;
return $html;
}
+ sub RecupSolution
+ {
+ my ($self, $url) = @_;
+
+ my $html = $self->loadPage('http://www.jeuxvideo.fr'.$url);
+ my $savenexturl = '';
+
+ my $found = index($html,"<a class=\"pull-right\" href=\"");
+ if ( $found >= 0 )
+ {
+ $savenexturl = substr($html, $found +length('<a class="pull-right" href="'),length($html)- $found -length('<a class="pull-right" href="'));
+ $savenexturl = substr($savenexturl, 0, index($savenexturl, "\""));
+ }
+
+ $found = index($html,"<ul class=\"walkthrough-breadcrumb\">");
+ if ( $found >= 0 )
+ {
+ $html = substr($html, $found +length('<ul class="walkthrough-breadcrumb">'),length($html)- $found -length('<ul class="walkthrough-breadcrumb">'));
+ $html = substr($html, 0, index($html, "<div class=\"select-toc pull-right\">"));
+ if ( $savenexturl ne "" )
+ {
+ $html .= $self->RecupSolution($savenexturl);
+ }
+ }
+ else
+ {
+ $html = '';
+ if ( $savenexturl ne "" )
+ {
+ $html .= $self->RecupSolution($savenexturl);
+ }
+ }
+ return "<tpfdebuttpf>" . $html . "<tpffintpf>";
+ }
+
sub getSearchUrl
{
my ($self, $word) = @_;
@@ -387,10 +456,11 @@ use GCPlugins::GCgames::GCgamesCommon;
$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/';
+ $self->{url_screenshot} = $url . 'image-photo/';
+ $self->{url_tips} = $url . 'astuce-code/';
+ $self->{url_tips} = $url . 'soluce/';
- return 'http://www.jeuxvideo.fr' . $url;
+ return $url;
}
sub getName
diff --git a/lib/gcstar/GCPlugins/GCgames/GCMobyGames.pm b/lib/gcstar/GCPlugins/GCgames/GCMobyGames.pm
index c6650c3..d6c7ace 100644
--- a/lib/gcstar/GCPlugins/GCgames/GCMobyGames.pm
+++ b/lib/gcstar/GCPlugins/GCgames/GCMobyGames.pm
@@ -2,7 +2,7 @@ package GCPlugins::GCgames::GCMobyGames;
###################################################
#
-# Copyright 2005-2011 Christian Jodar
+# Copyright 2005-2015 Christian Jodar
#
# This file is part of GCstar.
#
@@ -37,37 +37,35 @@ use GCPlugins::GCgames::GCgamesCommon;
{
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|<ul>||gi;
+ $html =~ s|</ul>||gi;
$html =~ s|<b>||gi;
$html =~ s|</b>||gi;
- my $found = index($html,"class=\"sbL sbB sbT\">");
+ $html =~ s|<li>||gi;
+ $html =~ s|</li>||gi;
+ $html =~ s|</h3>||gi;
+ $html =~ s|<hr />||gi;
+ $html =~ s|<br>|\n|gi;
+ $html =~ s|<p>|\n|gi;
+ $html =~ s|</p>||gi;
+ $html =~ s|<pre>||gi;
+ $html =~ s|</pre>||gi;
+ $html =~ s|</td>||gi;
+ $html =~ s|</tr>||gi;
+ my $found = index($html,"sbR sbL sbB\">");
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);
- }
+ $answer = substr($html, $found + length('sbR sbL sbB">'),length($html)- $found -length('sbR sbL sbB">') );
+ $answer = substr($answer, 0, index($answer,"</table>"));
+ $answer = decode_entities($answer);
}
- return @tmpAnswer;
+ return $answer;
}
+
sub extractPlayer
{
my ($self, $html_ini, $word) = @_;
@@ -93,7 +91,7 @@ use GCPlugins::GCgames::GCgamesCommon;
$self->{inside}->{$tagname}++;
if ($self->{parsingList})
{
- if ( !$self->{insideSearchImage}
+ if ( $self->{insideSearchImage}
&& ($tagname eq 'a')
&& ( substr($attr->{href},0,6) eq '/game/' ) )
{
@@ -127,15 +125,16 @@ use GCPlugins::GCgames::GCgamesCommon;
{
$self->{isGame} = 0;
}
- elsif ($tagname eq 'div')
+ elsif ( ($tagname eq 'div') && ($attr->{class} eq 'searchData'))
{
- if ($attr->{class} eq 'searchResult')
+ $self->{insideSearchImage} = 1;
+ }
+ elsif ($tagname eq 'br')
+ {
+ if ($attr->{clear} eq 'all')
{
$self->{currentName} = '';
- }
- elsif ($attr->{class} eq 'searchImage')
- {
- $self->{insideSearchImage} = 1;
+ $self->{insideSearchImage} = 0;
}
}
elsif ($tagname eq 'em')
@@ -145,66 +144,20 @@ use GCPlugins::GCgames::GCgamesCommon;
}
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') )
+ if (($tagname eq 'tr') && ($attr->{class} eq 'mb2'))
{
$self->{isSectionTips} = 1;
}
- elsif ( ($tagname eq 'tr') && (($attr->{class} eq 'mb1') || ($attr->{class} eq 'mb2')) )
+ elsif ( ($tagname eq 'a') && ($self->{isSectionTips}) )
{
- $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;
-
+ $self->{tip_wait} = $self->extractTips('http://www.mobygames.com'.$attr->{href});
}
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;
}
@@ -212,17 +165,13 @@ use GCPlugins::GCgames::GCgamesCommon;
else
{
- if ($tagname eq 'div')
+ if ( ($tagname eq 'h1') && ($attr->{class} eq 'niceHeaderTitle') )
{
- 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->{isName} = 1;
+ }
+ elsif ($tagname eq 'div')
+ {
+ if ($attr->{class} =~ m/scoreBoxBig/i)
{
$self->{isRating} = 1;
}
@@ -232,19 +181,20 @@ use GCPlugins::GCgames::GCgamesCommon;
$self->{isGenre} = 0;
}
- $self->{isDescription} = 0;
+ if ($attr->{class} ne 'listing-detail')
+ {
+ $self->{isDescription} = 0;
+ $self->{isExclusive} = 0;
+ }
}
- elsif ( ($tagname eq 'a') && ($self->{isName}) )
+ elsif ($tagname eq 'tpfdescriptiontpf')
{
- $self->{is} = 'name';
- $self->{curInfo}->{exclusive} = 1;
- $self->{isName} = 0;
+ $self->{isDescription} = 1;
}
- elsif ( ($tagname eq 'a') && ($self->{isPlatform}) )
+ elsif ( ($tagname eq 'a') && ($attr->{class} eq 'edit') )
{
- $self->{is} = 'platform';
- $self->{isPlatform} = 0;
+ $self->{isDescription} = 0;
}
elsif ( ($tagname eq 'a') && ($self->{isEditor}) )
{
@@ -256,6 +206,25 @@ use GCPlugins::GCgames::GCgamesCommon;
$self->{is} = 'developer';
$self->{isDeveloper} = 0;
}
+ elsif ( ($tagname eq 'a') && ($self->{isExclusive}) )
+ {
+ if ($self->{isExclusive} eq 1)
+ {
+ $self->{isExclusive} = $self->{isExclusive} + 1;
+ }
+ else
+ {
+ $self->{curInfo}->{exclusive} = 0;
+ $self->{isExclusive} = 0;
+ }
+ }
+ elsif ( ($tagname eq 'a') && ($self->{isName}) )
+ {
+ $self->{is} = 'name';
+ $self->{curInfo}->{platform} = $self->{url_plateforme};
+ $self->{curInfo}->{exclusive} = 1;
+ $self->{isName} = 0;
+ }
elsif ( ($tagname eq 'a') && ($self->{isDate}) )
{
$self->{is} = 'released';
@@ -275,9 +244,9 @@ use GCPlugins::GCgames::GCgamesCommon;
# 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};
+ $self->{curInfo}->{backpic} = $1;
+ $self->{curInfo}->{backpic} =~ s|/small/|/large/|
+ if $self->{bigPics};
}
}
elsif ($tagname eq 'html')
@@ -332,10 +301,6 @@ use GCPlugins::GCgames::GCgamesCommon;
{
my ($self, $tagname) = @_;
$self->{inside}->{$tagname}--;
- if ($self->{parsingList} && ($tagname eq 'div'))
- {
- $self->{insideSearchImage} = 0;
- }
}
sub text
@@ -359,6 +324,7 @@ use GCPlugins::GCgames::GCgamesCommon;
elsif ($self->{isPlatform})
{
$self->{itemsList}[$self->{itemIdx}]->{platform} = $origtext;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $self->{itemsList}[$self->{itemIdx}]->{url} . 'tpfplatformtpf' . $self->{itemsList}[$self->{itemIdx}]->{platform};
$self->{isPlatform} = 0;
}
elsif ($self->{isGameName})
@@ -377,6 +343,7 @@ use GCPlugins::GCgames::GCgamesCommon;
{
$self->{previous} =~ s/[\s\(]*$//g;
$self->{itemsList}[$self->{itemIdx}]->{platform} = $self->{previous};
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $self->{itemsList}[$self->{itemIdx}]->{url} . 'tpfplatformtpf' . $self->{itemsList}[$self->{itemIdx}]->{platform};
}
}
$self->{isDate} = 0;
@@ -385,20 +352,53 @@ use GCPlugins::GCgames::GCgamesCommon;
}
elsif ($self->{parsingTips})
{
- if ($self->{isSectionTips} eq 1)
+ if ($self->{tip_wait} ne '')
{
- if ($origtext =~ m/General Hints\/Tips/i)
- {
- $self->{isTip} = 2;
- $self->{isCode} = 0;
- }
- elsif ($origtext =~ m/Cheats\/Codes/i)
+ $self->{isUnlock} = 1 if $origtext =~ /Unlockables/i;
+ $self->{isUnlock} = 1 if $origtext =~ /Achievement/i;
+ $self->{isCode} = 1 if $origtext =~ /Cheat/i;
+ }
+ if (($self->{isCode}) || ($self->{isUnlock}))
+ {
+ $Text::Wrap::columns = 80;
+ $self->{tip_wait} = Text::Wrap::wrap('', '', $self->{tip_wait});
+
+ my @array = split(/\n/,$self->{tip_wait});
+ my $element;
+
+ foreach $element (@array)
{
- $self->{isTip} = 0;
- $self->{isCode} = 2;
+ if (($element =~ m/:/i) && !($element =~ m/type one of the following code/i))
+ {
+ $self->{tmpCheatLine} = [];
+ $self->{tmpCheatLine}[0] = substr($element, 0, index($element,":") );
+ $self->{tmpCheatLine}[1] = substr($element, index($element,":") + length(":"),length($element)- index($element,":") -length(":") );
+
+ # Enleve les blancs en debut de chaine
+ $self->{tmpCheatLine}[0] =~ s/^\s+//;
+ $self->{tmpCheatLine}[1] =~ s/^\s+//;
+ # Enleve les blancs en fin de chaine
+ $self->{tmpCheatLine}[0] =~ s/\s+$//;
+ $self->{tmpCheatLine}[1] =~ s/\s+$//;
+
+ push @{$self->{curInfo}->{code}}, $self->{tmpCheatLine} if ($self->{isCode});
+ push @{$self->{curInfo}->{unlockable}}, $self->{tmpCheatLine} if ($self->{isUnlock});
+ $self->{tmpCheatLine} = [];
+ }
}
- $self->{isSectionTips} = 2;
- }
+ $self->{tip_wait} = '';
+ $self->{isCode} = 0;
+ $self->{isUnlock} = 0;
+ }
+ else
+ {
+ if ($self->{curInfo}->{secrets})
+ {
+ $self->{curInfo}->{secrets} .= "\n\n";
+ }
+ $self->{curInfo}->{secrets} .= $self->{tip_wait};
+ $self->{tip_wait} = '';
+ }
}
else
{
@@ -423,6 +423,13 @@ use GCPlugins::GCgames::GCgamesCommon;
$self->{is} = '';
}
+ elsif ($self->{isName} eq 3)
+ {
+ $self->{curInfo}->{name} = $origtext;
+ $self->{curInfo}->{platform} = $self->{url_plateforme};
+ $self->{curInfo}->{exclusive} = 1;
+ $self->{isName} = 0;
+ }
elsif ($self->{isRating})
{
$self->{curInfo}->{ratingpress} = int($origtext/10+0.5);
@@ -432,9 +439,17 @@ use GCPlugins::GCgames::GCgamesCommon;
{
$self->{curInfo}->{description} .= $origtext;
}
+ elsif ($origtext eq 'Published by')
+ {
+ $self->{isEditor} = 1;
+ }
elsif ($origtext eq 'Developed by')
{
- $self->{isDeveloper} = 1
+ $self->{isDeveloper} = 1;
+ }
+ elsif ($origtext eq 'Platforms')
+ {
+ $self->{isExclusive} = 1;
}
elsif ( ($origtext eq 'Also For') || (($origtext eq 'Platforms')))
{
@@ -485,11 +500,13 @@ use GCPlugins::GCgames::GCgamesCommon;
$self->{isDate} = 0;
$self->{isGenre} = 0;
$self->{isDescription} = 0;
- $self->{isBox} = 0;
$self->{isSectionTips} = 0;
- $self->{isTip} = 0;
$self->{isCode} = 0;
+ $self->{isUnlock} = 0;
$self->{is} = '';
+ $self->{url_plateforme} = '';
+ $self->{isExclusive} = 0;
+ $self->{tip_wait} = '';
return $self;
}
@@ -497,7 +514,36 @@ use GCPlugins::GCgames::GCgamesCommon;
sub preProcess
{
my ($self, $html) = @_;
+
$self->{rootUrl} = $self->{loadedUrl};
+
+ if ($self->{parsingTips})
+ {
+ }
+ elsif ($self->{parsingList})
+ {
+ }
+ else
+ {
+ my $found = index($html,"<meta name=\"description\" content=\"");
+ if ( $found >= 0 )
+ {
+ my $rech_description = substr($html, $found,length($html)- $found);
+ $found = index($rech_description,"..");
+ if ( $found >= 0 )
+ {
+ $rech_description = substr($rech_description, index($rech_description,"for ".$self->{url_plateforme})+length("for ".$self->{url_plateforme}), $found-index($rech_description,"for ".$self->{url_plateforme})-length("for ".$self->{url_plateforme}));
+ $rech_description = substr($rech_description, index($rech_description,";")+1, length($rech_description)-index($rech_description,";")-1);
+ # Enleve les blancs en debut de chaine
+ $rech_description =~ s/^\s+//;
+ }
+
+ $html =~ s|<i>||g;
+ $html =~ s|</i>||g;
+ $html =~ s|$rech_description|<tpfdescriptiontpf>$rech_description</tpfdescriptiontpf>|g;
+
+ }
+ }
return $html;
}
@@ -510,6 +556,13 @@ use GCPlugins::GCgames::GCgamesCommon;
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 $url if $url;
return 'http://www.mobygames.com/';