Author: tpf
Date: Wed Apr 2 19:38:33 2014
New Revision: 2250
URL: http://svn.gna.org/viewcvs/gcstar?rev=2250&view=rev
Log:
° Take into account modification of the layout of the website
° Solution is retrieved again
Modified:
trunk/gcstar/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm
Modified: trunk/gcstar/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm
URL:
http://svn.gna.org/viewcvs/gcstar/trunk/gcstar/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm?rev=2250&r1=2249&r2=2250&view=diff
==============================================================================
--- trunk/gcstar/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm (original)
+++ trunk/gcstar/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm Wed Apr 2
19:38:33 2014
@@ -2,7 +2,7 @@
###################################################
#
-# Copyright 2005-2011 Tian
+# Copyright 2005-2014 Tian
#
# This file is part of GCstar.
#
@@ -69,6 +69,18 @@
}
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 @@
}
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 @@
}
elsif ($self->{parsingTips})
{
+ $html =~ s|<option value="(.+)">|$self->RecupSolution($1)|e;
+ $html =~ s|<br />|<p>|gi;
}
else
{
@@ -367,6 +401,41 @@
}
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
@@ -387,10 +456,11 @@
$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;
+ $self->{url_screenshot} = $url . 'image-photo/';
+ $self->{url_tips} = $url . 'astuce-code/';
+ $self->{url_tips} = $url . 'soluce/';
+
+ return $url;
}
sub getName
_______________________________________________
GCstar-commits mailing list
[email protected]
https://mail.gna.org/listinfo/gcstar-commits