Author: tpf
Date: Fri Jan  9 16:42:45 2015
New Revision: 2255

URL: http://svn.gna.org/viewcvs/gcstar?rev=2255&view=rev
Log:
° Add Tips section

Modified:
    trunk/gcstar/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm

Modified: trunk/gcstar/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm
URL: 
http://svn.gna.org/viewcvs/gcstar/trunk/gcstar/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm?rev=2255&r1=2254&r2=2255&view=diff
==============================================================================
--- trunk/gcstar/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm (original)
+++ trunk/gcstar/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm Fri Jan  9 
16:42:45 2015
@@ -2,7 +2,7 @@
 
 ###################################################
 #
-#  Copyright 2005-2014 Tian
+#  Copyright 2005-2015 Tian
 #
 #  This file is part of GCstar.
 #
@@ -115,35 +115,27 @@
         }
         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} = '';
-#            }
+            if ($attr->{class} eq 'rubrique-asl collapsed')
+            {
+                $self->{isTip} = 1;
+            }
+            elsif (($tagname eq 'tpfdebuttpf') && ($self->{isTip} eq 2))
+            {
+                $self->{isTip} = 3;
+            }
+            elsif (   (($tagname eq 'p') || ($tagname eq 'h2') || ($tagname eq 
'h3')) && (($self->{isTip} eq 3) || ($self->{isTip} eq 4)) )
+            {
+                $self->{curInfo}->{secrets} .= "\n" if 
$self->{curInfo}->{secrets};
+            }
+            elsif (($tagname eq 'tpffintpf') && ($self->{isTip} ne 0))
+            {
+                $self->{isTip} = 2;
+            }
+            elsif ($tagname eq 'head')
+            {
+                $self->{isTip} = 0;
+                $self->{urlTips} = '';
+            }
 
         }
         else
@@ -211,10 +203,15 @@
                     }
                 }
             }
-#            elsif (($attr->{href} =~ m^/(etajvhtm|cheats)/^) && ! 
($self->{urlTips}))
-#            {
-#                $self->{urlTips} = $attr->{href};
-#            }
+            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;
+            }
         }
     }
 
@@ -255,26 +252,38 @@
         }
         elsif ($self->{parsingTips})
         {
-#            # Enleve les blancs en debut de chaine
-#            $origtext =~ s/^\s+//;
-#            # Enleve les blancs en fin de chaine
+            # 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;
-#            }
+# There are problems with some texts if ended blanks are removed
+            if ($self->{isTip} eq 1)
+            {
+                   $origtext =~ s|playstation 3|ps3|gi;
+                   $origtext =~ s|wii u|wiiu|gi;
+               if ($origtext =~ /$self->{curInfo}->{platform}/i)
+                   {
+                       $self->{isTip} = 2;
+               }
+                   else
+                   {
+                       $self->{isTip} = 0;
+               }
+            }
+            elsif ($self->{isTip} eq 4)
+            {
+                $self->{curInfo}->{secrets} .= $origtext;
+            }
+            elsif ($self->{isTip} eq 3)
+            {
+                chomp($origtext);
+                if ( ($self->{curInfo}->{secrets}) && ($origtext ne "") )
+                {
+                   $self->{curInfo}->{secrets} .= "\n\n"
+                }
+                $self->{curInfo}->{secrets} .= $origtext;
+                $self->{isTip} = 4;
+            }
         }
         else
         {
@@ -295,7 +304,18 @@
             }
             else
             {
-                if ($origtext eq 'Editeur(s) / Développeur(s) : ')
+                if ($self->{isTip} eq 1)
+                {
+                       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';
                 }
@@ -317,7 +337,6 @@
 
     sub getTipsUrl
     {
-        return undef;
         my $self = shift;
         return $self->{urlTips};
     }
@@ -355,43 +374,8 @@
         }
         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|<h4 class="lien_base"><a href="(.+)">Toutes les 
astuces|$self->RecupTips($1)|ge;
-#            $html =~ s|<h4 class="lien_base"><a href="(.+)">(.+)la solution 
compl|$self->RecupSolution($1)|ge;
-#            $html =~ s|<p>Si rien ne s'affiche apr(.)s plusieurs secondes 
d'attente :</p>|<p>"Une video est disponible"</p>|gi;
-#
-#            $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;
         }
         else
         {
@@ -406,63 +390,21 @@
         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, "\""));
-        }
-
-        $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 = '';
-        }
+            $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);
+               }
+        }
+
         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) = @_;


_______________________________________________
GCstar-commits mailing list
[email protected]
https://mail.gna.org/listinfo/gcstar-commits

Reply via email to