diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-03-09 22:05:42 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-03-09 22:05:42 +0100 |
commit | ad3a1af7de96e4c76b3f9ac9b1539092e81d123a (patch) | |
tree | 343f50d68935c7bd689924f01b7e83316a3fb9ec /lib/gcstar | |
parent | 965998f7990b75e58fe5219f9c38a3c24198375a (diff) | |
parent | b9a4e9c8a68dcb6b17617f4f7a5ad5ad3298bfa9 (diff) |
Merge tag 'upstream/1.7.1'
Upstream version 1.7.1
Diffstat (limited to 'lib/gcstar')
22 files changed, 1584 insertions, 1515 deletions
diff --git a/lib/gcstar/GCExport/GCExportBase.pm b/lib/gcstar/GCExport/GCExportBase.pm index fb23ec2..0c229d7 100644 --- a/lib/gcstar/GCExport/GCExportBase.pm +++ b/lib/gcstar/GCExport/GCExportBase.pm @@ -133,6 +133,29 @@ use GCExportImport; return $self->{options}->{parent}->getUniqueImageFileName($suffix, $title, $dir); } + sub createMiniature + { + my ($self, $source, $dest, $newHeight) = @_; + + $source =~ /.*?(\.[^.]*)$/; + my $suffix = $1; + my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file($source); + my ($width, $height) = ($pixbuf->get_width, $pixbuf->get_height); + my $picWidth = $width * ($newHeight / $height); + $pixbuf = GCUtils::scaleMaxPixbuf($pixbuf, $picWidth, $newHeight, 1); + my $format; + if ($suffix =~ /png/i) + { + $format = 'png'; + } + else + { + $dest =~ s/\.[^.]*$/\.jpg/; + $format = 'jpeg'; + } + $pixbuf->save($dest, $format); + } + sub duplicatePicture { my ($self, $orig, $field, $dir, $title, $newHeight) = @_; @@ -157,21 +180,7 @@ use GCExportImport; my $picHeight = $self->getNewPictureHeight; if ($picHeight) { - my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file($newPic); - my ($width, $height) = ($pixbuf->get_width, $pixbuf->get_height); - my $picWidth = $width * ($picHeight / $height); - $pixbuf = GCUtils::scaleMaxPixbuf($pixbuf, $picWidth, $picHeight, 1); - my $format; - if ($suffix =~ /png/i) - { - $format = 'png'; - } - else - { - $dest =~ s/\.[^.]*$/\.jpg/; - $format = 'jpeg'; - } - $pixbuf->save($dest, $format); + $self->createMiniature($newPic, $dest, $picHeight); } else { diff --git a/lib/gcstar/GCExport/GCExportExternal.pm b/lib/gcstar/GCExport/GCExportExternal.pm index d5c096c..2263387 100644 --- a/lib/gcstar/GCExport/GCExportExternal.pm +++ b/lib/gcstar/GCExport/GCExportExternal.pm @@ -45,6 +45,7 @@ use GCExport::GCExportBase; bless ($self, $class); $self->{useZip} = $self->checkOptionalModule('Archive::Zip'); + $self->{covers} = {}; return $self; } @@ -57,10 +58,13 @@ use GCExport::GCExportBase; sub transformPicturePath { my ($self, $path, $file, $item, $field) = @_; - return $self->duplicatePicture($path, + my $newPath = $self->duplicatePicture($path, $field, $self->{imageDir}, $item->{$self->{model}->{commonFields}->{title}}); + $self->{isCover}->{$newPath} = 1 + if $self->{model}->{commonFields}->{cover} eq $field; + return $newPath; } sub process @@ -123,8 +127,19 @@ use GCExport::GCExportBase; my $zip = Archive::Zip->new(); $zip->addFile(basename($self->{fileName})); $zip->addDirectory(basename($self->{imageDir})); + my $miniDir = $self->{imageDir}.'-mini'; + mkdir $miniDir; + $zip->addDirectory(basename($miniDir)); my @images = glob $imagesSubDir.'/*'; - $zip->addFile($_) foreach @images; + foreach my $image(@images) + { + $zip->addFile($image); + my $imgFile = basename($image); + my $fullFileName = $self->{imageDir}."/$imgFile"; + next if !$self->{isCover}->{$image}; + $self->createMiniature($fullFileName, "$miniDir/$imgFile", 150); + $zip->addFile(basename($miniDir)."/$imgFile"); + } my $result = $zip->writeToFileNamed($outFile); if ($result) { diff --git a/lib/gcstar/GCExport/GCExportHTML.pm b/lib/gcstar/GCExport/GCExportHTML.pm index b083545..406039c 100644 --- a/lib/gcstar/GCExport/GCExportHTML.pm +++ b/lib/gcstar/GCExport/GCExportHTML.pm @@ -195,6 +195,7 @@ use GCExport::GCExportBase; $parent->{options}->{modelFile}->set_sensitive($model eq 'UseFile'); $parent->{fieldsSelection}->set_sensitive($self->{isGeneric}->{$model}) if $parent->{fieldsSelection}; + $self->{wantsFieldsSelection} = $self->{isGeneric}->{$model}; } sub preview @@ -240,7 +241,6 @@ use GCExport::GCExportBase; { my $self = shift; return 1; - return $self->{genericAdded} || $self->{genericModels}; } sub wantsImagesSelection diff --git a/lib/gcstar/GCGraphicComponents/GCDoubleLists.pm b/lib/gcstar/GCGraphicComponents/GCDoubleLists.pm index c59cae1..63ab50f 100644 --- a/lib/gcstar/GCGraphicComponents/GCDoubleLists.pm +++ b/lib/gcstar/GCGraphicComponents/GCDoubleLists.pm @@ -470,6 +470,32 @@ use GCUtils; $self->removeFromPermanent($self->{ignoreString}); } + sub setModel + { + my ($self, $model) = @_; + $self->{model} = $model; + if ($model) + { + my $groups = $model->getGroups; + $self->{separator} = $model->getDisplayedText('Separator'); + while (my ($key, $value) = each %{$model->{fieldsInfo}}) + { + next if !$value->{displayed}; + my $displayed = $groups->{$value->{group}}->{displayed} + . $self->{separator} + . $value->{displayed}; + $self->{fieldNameToId}->{$displayed} = $key; + $self->{fieldIdToName}->{$key} = $displayed; + } + my $order = 0; + foreach (@{$model->{groups}}) + { + $self->{groupsOrder}->{$groups->{$_->{id}}->{displayed}} = $order++; + } + $self->{model} = $model; + } + } + sub new { my ($proto, $parent, $preList, $isIdList, $ignoreField) = @_; @@ -524,27 +550,32 @@ use GCUtils; $self->{fieldNameToId} = {}; $self->{groupsOrder} = {}; - my $model = $self->{parent}->{model}; - if ($model) - { - my $groups = $model->getGroups; - $self->{separator} = $model->getDisplayedText('Separator'); - while (my ($key, $value) = each %{$model->{fieldsInfo}}) - { - next if !$value->{displayed}; - my $displayed = $groups->{$value->{group}}->{displayed} - . $self->{separator} - . $value->{displayed}; - $self->{fieldNameToId}->{$displayed} = $key; - $self->{fieldIdToName}->{$key} = $displayed; - } - my $order = 0; - foreach (@{$model->{groups}}) - { - $self->{groupsOrder}->{$groups->{$_->{id}}->{displayed}} = $order++; - } - $self->{model} = $model; - } +# my $model = $self->{parent}->{model}; +# use Data::Dumper; +# if ($model) +# { +# my $groups = $model->getGroups; +# print "GROUPS : ",Dumper($groups),"\n"; +# print "FIELDS : ",Dumper($model->{fieldsInfo}),"\n"; +# $self->{separator} = $model->getDisplayedText('Separator'); +# while (my ($key, $value) = each %{$model->{fieldsInfo}}) +# { +# next if !$value->{displayed}; +# my $displayed = $groups->{$value->{group}}->{displayed} +# . $self->{separator} +# . $value->{displayed}; +# print "ADDING ",$displayed,"\n"; +# $self->{fieldNameToId}->{$displayed} = $key; +# $self->{fieldIdToName}->{$key} = $displayed; +# } +# my $order = 0; +# foreach (@{$model->{groups}}) +# { +# $self->{groupsOrder}->{$groups->{$_->{id}}->{displayed}} = $order++; +# } +# $self->{model} = $model; +# } + $self->setModel($self->{parent}->{model}); if ($preList) { diff --git a/lib/gcstar/GCItemsLists/GCImageLists.pm b/lib/gcstar/GCItemsLists/GCImageLists.pm index 2250bcb..6c775e9 100644 --- a/lib/gcstar/GCItemsLists/GCImageLists.pm +++ b/lib/gcstar/GCItemsLists/GCImageLists.pm @@ -1,4 +1,4 @@ -package GCImageLists; +package GCImageLists; ################################################### # @@ -1424,7 +1424,7 @@ my $timeOutBetweenEnhancements = 50; if ($^O =~ /win32/i) { # It looks like Win32 version only supports JPEG pictures for background - $tmpPixbuf->save($self->{style}->{tmpBgPixmap}, 'jpeg', quality => '100'); + $tmpPixbuf->save($self->{style}->{tmpBgPixmapFile}, 'jpeg', quality => '100'); } else { diff --git a/lib/gcstar/GCItemsLists/GCListOptions.pm b/lib/gcstar/GCItemsLists/GCListOptions.pm index c41084b..f473319 100644 --- a/lib/gcstar/GCItemsLists/GCListOptions.pm +++ b/lib/gcstar/GCItemsLists/GCListOptions.pm @@ -145,6 +145,9 @@ use Gtk2; sub initValues { my $self = shift; + $self->{groupByOption}->setModel($self->{parent}->{model}); + $self->{secondarySortOption}->setModel($self->{parent}->{model}); + $self->{resizeImgList}->set_active($self->{optionsManager}->resizeImgList); $self->{animateImgList}->set_active($self->{optionsManager}->animateImgList); $self->{columns}->set_value($self->{optionsManager}->columns); @@ -213,6 +216,7 @@ use Gtk2; #my $self = $class->SUPER::new(0,0); $self->{optionsManager} = $optionsManager; + $self->{parent} = $parent; $self->{lang} = $parent->{lang}; # $self->set_row_spacings($GCUtils::halfMargin); @@ -384,12 +388,16 @@ use Gtk2; { my $self = shift; + $self->{groupByOption}->setModel($self->{parent}->{model}); + $self->{secondarySortOption}->setModel($self->{parent}->{model}); + $self->{imgSizeOption}->setValue($self->{optionsManager}->detailImgSize); $self->{groupByOption}->setValue($self->{optionsManager}->groupBy); $self->{secondarySortOption}->setValue($self->{optionsManager}->secondarySort); $self->{groupedFirst}->setValue($self->{optionsManager}->groupedFirst); $self->{addCount}->setValue($self->{optionsManager}->addCount); + $self->{fieldsSelection}->setModel($self->{parent}->{model}); my @tmpFieldsArray = split m/\|/, $self->{optionsManager}->details; $self->{fieldsSelection}->setListFromIds(\@tmpFieldsArray); @@ -435,6 +443,7 @@ use Gtk2; $self->{lang} = $parent->{lang}; $self->{optionsManager} = $optionsManager; + $self->{parent} = $parent; bless ($self, $class); diff --git a/lib/gcstar/GCItemsLists/GCTextLists.pm b/lib/gcstar/GCItemsLists/GCTextLists.pm index aaa080b..741d03e 100644 --- a/lib/gcstar/GCItemsLists/GCTextLists.pm +++ b/lib/gcstar/GCItemsLists/GCTextLists.pm @@ -742,6 +742,7 @@ use locale; $self->{secondaryField} = $self->{preferences}->secondarySort; $self->{secondaryIndex} = -1; $self->{addSecondary} = 0; + $self->{numericFields} = []; foreach my $field(@tmpArray) { @@ -767,6 +768,7 @@ use locale; push @columnsType, 'Glib::Double'; $renderer = Gtk2::CellRendererText->new; $attribute = 'text'; + push @{$self->{numericFields}}, $field; } else { @@ -1582,6 +1584,22 @@ use locale; $generated); $self->{originalValue}->{$generated} = $original; $self->{model}->set($iter, $self->{visibleCol}, $nbChildren); + + my %totals; + my $field; + my $childIter = $self->{subModel}->iter_children($subIter); + while ($childIter) + { + for $field(@{$self->{numericFields}}) + { + $totals{$field} += ($self->{subModel}->get($childIter))[$self->{fieldToId}->{$field}]; + } + $childIter = $self->{subModel}->iter_next($childIter); + } + for $field(@{$self->{numericFields}}) + { + $self->{model}->set($iter, $self->{fieldToId}->{$field}, $totals{$field}); + } } sub refreshCounts diff --git a/lib/gcstar/GCLang/CA/GCstar.pm b/lib/gcstar/GCLang/CA/GCstar.pm index c741c5f..5b66ffa 100644 --- a/lib/gcstar/GCLang/CA/GCstar.pm +++ b/lib/gcstar/GCLang/CA/GCstar.pm @@ -138,11 +138,11 @@ podeu usar <b>el botó situat devall dels detalls de la pel·lícula</b>.', 'MenuNoFilter' => '_Tot', 'MenuConfiguration' => '_Configura', - 'MenuDisplayMenu' => 'Display', - 'MenuDisplayFullScreen' => 'Full screen', - 'MenuDisplayMenuBar' => 'Menus', - 'MenuDisplayToolBar' => 'Toolbar', - 'MenuDisplayStatusBar' => 'Bottom bar', + 'MenuDisplayMenu' => 'Mostrar', + 'MenuDisplayFullScreen' => 'Pantalla completa', + 'MenuDisplayMenuBar' => 'Menús', + 'MenuDisplayToolBar' => 'Barra d\'eines', + 'MenuDisplayStatusBar' => 'Barra d\'estat', 'MenuDisplayOptions' => '_Informació a mostrar', 'MenuBorrowers' => '_Prestataris', 'MenuToolbarConfiguration' => '_Controls de la barra d\'eines', @@ -409,7 +409,7 @@ Logo i disseny web per le Spektre', 'ImagesOptionsBgTooltip' => 'Canvia el color de fons', 'ImagesOptionsFgTooltip'=> 'Canvia el color de la selecció', 'ImagesOptionsResizeImgList' => 'Canvia automàticament el nombre de columnes', - 'ImagesOptionsAnimateImgList' => 'Use animations', + 'ImagesOptionsAnimateImgList' => 'Utilitza animacions', 'ImagesOptionsSizeLabel' => 'Mida', 'ImagesOptionsSizeList' => {0 => 'Molt Petit', 1 => 'Petit', 2 => 'Mitjà', 3 => 'Gran', 4 => 'Molt Gran'}, 'ImagesOptionsSizeTooltip' => 'Trieu la mida de la imatge', diff --git a/lib/gcstar/GCLang/CS/GCstar.pm b/lib/gcstar/GCLang/CS/GCstar.pm index 359f860..7d31ea2 100644 --- a/lib/gcstar/GCLang/CS/GCstar.pm +++ b/lib/gcstar/GCLang/CS/GCstar.pm @@ -137,11 +137,11 @@ K rozlišení, který server vlastní dané informace, můžete použít 'MenuNoFilter' => '_Vše', 'MenuConfiguration' => '_Nastavení', - 'MenuDisplayMenu' => 'Display', - 'MenuDisplayFullScreen' => 'Full screen', - 'MenuDisplayMenuBar' => 'Menus', - 'MenuDisplayToolBar' => 'Toolbar', - 'MenuDisplayStatusBar' => 'Bottom bar', + 'MenuDisplayMenu' => 'Zobrazení', + 'MenuDisplayFullScreen' => 'Celá obrazovka', + 'MenuDisplayMenuBar' => 'Nabídky', + 'MenuDisplayToolBar' => 'Nástrojová lišta', + 'MenuDisplayStatusBar' => 'Stavová lišta', 'MenuDisplayOptions' => '_Zobrazené informace', 'MenuBorrowers' => '_Dlužníci', 'MenuToolbarConfiguration' => '_Toolbar controls', @@ -408,7 +408,7 @@ Logo a webdesign od le Spektre', 'ImagesOptionsBgTooltip' => 'Změna barvy pozadí', 'ImagesOptionsFgTooltip'=> 'Změna barvy výběru', 'ImagesOptionsResizeImgList' => 'Automatically change number of columns', - 'ImagesOptionsAnimateImgList' => 'Use animations', + 'ImagesOptionsAnimateImgList' => 'Používat animace', 'ImagesOptionsSizeLabel' => 'Velikost obrázků', 'ImagesOptionsSizeList' => {0 => 'Velmi malé', 1 => 'Malé', 2 => 'Středně velké', 3 => 'Velké', 4 => 'Velmi velké'}, 'ImagesOptionsSizeTooltip' => 'Výběr velikosti obrázků', diff --git a/lib/gcstar/GCLang/DE/GCstar.pm b/lib/gcstar/GCLang/DE/GCstar.pm index 2326204..f1ea537 100644 --- a/lib/gcstar/GCLang/DE/GCstar.pm +++ b/lib/gcstar/GCLang/DE/GCstar.pm @@ -137,11 +137,11 @@ Webseite, von der die Informationen stammen.', 'MenuNoFilter' => '_Alle', 'MenuConfiguration' => '_Einstellungen', - 'MenuDisplayMenu' => 'Display', - 'MenuDisplayFullScreen' => 'Full screen', - 'MenuDisplayMenuBar' => 'Menus', - 'MenuDisplayToolBar' => 'Toolbar', - 'MenuDisplayStatusBar' => 'Bottom bar', + 'MenuDisplayMenu' => 'Anzeige', + 'MenuDisplayFullScreen' => 'Vollbild', + 'MenuDisplayMenuBar' => 'Menüs', + 'MenuDisplayToolBar' => 'Symbolleiste', + 'MenuDisplayStatusBar' => 'Fußleiste', 'MenuDisplayOptions' => 'Sichtbare _Felder', 'MenuBorrowers' => 'Ent_leiher', 'MenuToolbarConfiguration' => '_Werkzeugleiste konfigurieren', @@ -422,7 +422,7 @@ Logo und Webdesign von le Spektre', 'ImagesOptionsBgTooltip' => 'Hintergrundfarbe ändern', 'ImagesOptionsFgTooltip'=> 'Farbe für die Auswahl einstellen', 'ImagesOptionsResizeImgList' => 'Anzahl der Spalten automatisch anpassen', - 'ImagesOptionsAnimateImgList' => 'Use animations', + 'ImagesOptionsAnimateImgList' => 'Verwende Animationen', 'ImagesOptionsSizeLabel' => 'Größe', 'ImagesOptionsSizeList' => {0 => 'Sehr klein', 1 => 'Klein', 2 => 'Mittel', 3 => 'Groß', 4 => 'Sehr Groß'}, 'ImagesOptionsSizeTooltip' => 'Bildgröße auswählen', diff --git a/lib/gcstar/GCLang/EL/GCstar.pm b/lib/gcstar/GCLang/EL/GCstar.pm index 5cc5efc..dd4884d 100644 --- a/lib/gcstar/GCLang/EL/GCstar.pm +++ b/lib/gcstar/GCLang/EL/GCstar.pm @@ -138,11 +138,11 @@ search plugins) προορίζονται για <b>προσωπική χρήση 'MenuNoFilter' => '_Όλα', 'MenuConfiguration' => '_Ρυθμίσεις', - 'MenuDisplayMenu' => 'Display', - 'MenuDisplayFullScreen' => 'Full screen', - 'MenuDisplayMenuBar' => 'Menus', - 'MenuDisplayToolBar' => 'Toolbar', - 'MenuDisplayStatusBar' => 'Bottom bar', + 'MenuDisplayMenu' => 'Εμφάνιση', + 'MenuDisplayFullScreen' => 'Πλήρης οθόνη', + 'MenuDisplayMenuBar' => 'Μενού', + 'MenuDisplayToolBar' => 'Γραμμή εργαλείων', + 'MenuDisplayStatusBar' => 'Κάτω γραμμή', 'MenuDisplayOptions' => '_Εμφάνιση Πληροφοριών', 'MenuBorrowers' => '_Δανειολήπτες', 'MenuToolbarConfiguration' => '_Κουμπιά γραμμής εργαλειών', @@ -409,7 +409,7 @@ Logo and webdesign by le Spektre', 'ImagesOptionsBgTooltip' => 'Αλλαγή χρώματος παρασκηνίου', 'ImagesOptionsFgTooltip'=> 'Αλλαγή χρώματος επιλογής', 'ImagesOptionsResizeImgList' => 'Αυτόματη ρύθμιση του αριθμού των στηλών', - 'ImagesOptionsAnimateImgList' => 'Use animations', + 'ImagesOptionsAnimateImgList' => 'Χρήση κίνησης', 'ImagesOptionsSizeLabel' => 'Μέγεθος', 'ImagesOptionsSizeList' => {0 => 'Πολύ μικρό', 1 => 'Μικρό', 2 => 'Μεσαίο', 3 => 'Μεγάλο', 4 => 'Πολύ μεγάλο'}, 'ImagesOptionsSizeTooltip' => 'Επιλέξτε το μέγεθος της εικόνας', diff --git a/lib/gcstar/GCLang/SV/GCstar.pm b/lib/gcstar/GCLang/SV/GCstar.pm index 6cad462..a2e7df8 100644 --- a/lib/gcstar/GCLang/SV/GCstar.pm +++ b/lib/gcstar/GCLang/SV/GCstar.pm @@ -135,11 +135,11 @@ För att avgöra vilken hemsida som äger informationen, så kan du använda <b> 'MenuNoFilter' => '_Någon', 'MenuConfiguration' => '_Inställningar', - 'MenuDisplayMenu' => 'Display', - 'MenuDisplayFullScreen' => 'Full screen', - 'MenuDisplayMenuBar' => 'Menus', - 'MenuDisplayToolBar' => 'Toolbar', - 'MenuDisplayStatusBar' => 'Bottom bar', + 'MenuDisplayMenu' => 'Visa', + 'MenuDisplayFullScreen' => 'Fullskärm', + 'MenuDisplayMenuBar' => 'Meny', + 'MenuDisplayToolBar' => 'Verktygsfält', + 'MenuDisplayStatusBar' => 'Nedre fält', 'MenuDisplayOptions' => '_Visad Information', 'MenuBorrowers' => '_Låntagare', 'MenuToolbarConfiguration' => '_Verktygsfältets kontroller', @@ -405,7 +405,7 @@ Logotyper och webbdesign skapad av le Spektre', 'ImagesOptionsBgTooltip' => 'Ändra bakgrundsfärg', 'ImagesOptionsFgTooltip'=> 'Ändra markeringsfärg', 'ImagesOptionsResizeImgList' => 'Ändra automatiskt antalet kolumner', - 'ImagesOptionsAnimateImgList' => 'Use animations', + 'ImagesOptionsAnimateImgList' => 'Använd amimationer', 'ImagesOptionsSizeLabel' => 'Storlek', 'ImagesOptionsSizeList' => {0 => 'Väldigt liten', 1 => 'Liten', 2 => 'Mellan', 3 => 'Stor', 4 => 'Extra Stor'}, 'ImagesOptionsSizeTooltip' => 'Välj en bildstorlek', diff --git a/lib/gcstar/GCModel.pm b/lib/gcstar/GCModel.pm index 2223e3e..65803ef 100644 --- a/lib/gcstar/GCModel.pm +++ b/lib/gcstar/GCModel.pm @@ -1176,18 +1176,15 @@ our $linkNameSeparator = '##'; sub getGroups { my $self = shift; - - if (!$self->{groupsHash}) + + $self->{groupsHash} = {}; + foreach (@{$self->{groups}}) { - $self->{groupsHash} = {}; - foreach (@{$self->{groups}}) - { - $self->{groupsHash}->{$_->{id}} = { - id => $_->{id}, - label => $_->{label}, - displayed => $self->getDisplayedText($_->{label}) - }; - } + $self->{groupsHash}->{$_->{id}} = { + id => $_->{id}, + label => $_->{label}, + displayed => $self->getDisplayedText($_->{label}) + }; } return $self->{groupsHash}; } diff --git a/lib/gcstar/GCPlugins/GCcomics/GCbedetheque.pm b/lib/gcstar/GCPlugins/GCcomics/GCbedetheque.pm index 457194a..636fd4f 100644 --- a/lib/gcstar/GCPlugins/GCcomics/GCbedetheque.pm +++ b/lib/gcstar/GCPlugins/GCcomics/GCbedetheque.pm @@ -39,11 +39,11 @@ use GCPlugins::GCcomics::GCcomicsCommon; my ( $self, $word ) = @_; if ($self->{searchField} eq 'series') { - return "http://www.bedetheque.com/index.php?R=1&RechSerie=$word"; + return "http://www.bedetheque.com/search/albums?RechSerie=$word"; } elsif ($self->{searchField} eq 'writer') { - return "http://www.bedetheque.com/index.php?R=1&RechAuteur=$word"; + return "http://www.bedetheque.com/search/albums?RechAuteur=$word"; } else { @@ -64,6 +64,7 @@ use GCPlugins::GCcomics::GCcomicsCommon; my @array = split( /#/, $url ); $self->{site_internal_id} = $array[1]; + # print "getItemUrl $url\n\n"; return $url if $url =~ /^http:/; return "http://www.bedetheque.com/" . $url; } @@ -143,14 +144,30 @@ use GCPlugins::GCcomics::GCcomicsCommon; } else { - $html =~ m/(<div class="box main reeditions">.+)/; - - #$html =~ m/(<div class="album.+)/; + # print $html ; + $html =~ m/(<div class="single-title-wrap serie-wrap">.+)/; $html = $1; $self->{isResultsTable} = 0; $self->{parsingEnded} = 0; $self->{isCover} = 0; - $self->{itemIdx}++;; + $self->{isTabs} = 0; + $self->{isLabel} = 0; + $self->{itemIdx}++; + # + $self->{doneColourist} = 0 ; + $self->{doneCost} = 0 ; + $self->{doneFormat} = 0 ; + $self->{doneIllustrator} = 0 ; + $self->{doneISBN} = 0 ; + $self->{doneNumberboards} = 0 ; + $self->{donePublishdate} = 0 ; + $self->{donePublishdate} = 0 ; + $self->{donePublisher} = 0 ; + $self->{doneSerie} = 0 ; + $self->{doneSynopsis} = 0 ; + $self->{doneTitle} = 0 ; + $self->{doneVolume} = 0 ; + $self->{doneWriter} = 0 ; } return $html; @@ -178,69 +195,100 @@ use GCPlugins::GCcomics::GCcomicsCommon; #$self->{itemsList}[ $self->{itemIdx} ]->{url} = # "http://www.bedetheque.com/" . $attr->{href}; } - elsif ( $tagname eq "i" ) - { + elsif ( ( $tagname eq "ul" ) && ( $attr->{class} eq "search-list" ) ) { + $self->{inTable} = 1; + } + elsif ( ($self->{inTable}) && ( $tagname eq "li" ) ) { + $self->{isVolume} = 1; + } + elsif ( ($self->{inTable}) && ( $tagname eq "a" ) && ( $attr->{title} eq "tooltip" ) ) { + $self->{itemsList}[$self->{itemIdx}]->{image} = $attr->{rel}; + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + } + elsif ( ($self->{isVolume}) && ( $tagname eq "span" ) && ( $attr->{class} eq "titre" ) ) { + $self->{isTitle} = 1; + } + elsif ( ($self->{isVolume}) && ( $tagname eq "span" ) && ( $attr->{class} eq "serie" ) ) { $self->{isSerie} = 1; } + elsif ( ($self->{isVolume}) && ( $tagname eq "span" ) && ( $attr->{class} eq "num" ) ) { + $self->{isNumber} = 1; + } } else { - if ( ( $tagname eq "table" ) && ( $attr->{id} eq "albums_serie" ) ) { + if ( ( $tagname eq "ul" ) && ( $attr->{class} eq "search-list" ) ) { $self->{inTable} = 1; } - elsif ( ($self->{inTable}) && ( $tagname eq "td" ) && ( $attr->{class} eq "num" ) ) { + elsif ( ($self->{inTable}) && ( $tagname eq "li" ) ) { $self->{itemIdx}++; $self->{isVolume} = 1; } - elsif ( ($self->{inTable}) && ( $tagname eq "a" ) && ( $attr->{href} =~ m/serie-/ ) ) { + elsif ( ($self->{inTable}) && ( $tagname eq "a" ) && ( $attr->{title} eq "tooltip" ) ) { + $self->{itemsList}[$self->{itemIdx}]->{image} = $attr->{rel}; $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + } + elsif ( ($self->{isVolume}) && ( $tagname eq "span" ) && ( $attr->{class} eq "titre" ) ) { $self->{isTitle} = 1; } + elsif ( ($self->{isVolume}) && ( $tagname eq "span" ) && ( $attr->{class} eq "serie" ) ) { + $self->{isSerie} = 1; + } elsif ( ( $self->{isSynopsis} ) && ( $tagname eq "br" ) && ( $self->{startSynopsis} ) ) { # This is a stop! for br ;-) and complementary of the p in the end section # should be ( ( $tagname eq "p" ) || ( $tagname eq "br" ) ) $self->{isSynopsis} = 0; $self->{startSynopsis} = 0; - $self->{parsingEnded} = 1; + $self->{parsingEnded} = 1; } } } else { - if ( $tagname eq "title") - { - $self->{isIssue} = 1; - $self->{isTitle} = 1; - } - - if ( ( $self->{isCover} == 0 ) && ( $tagname eq "a" ) && ( $attr->{href} =~ m/Couvertures\/.*\.[jJ][pP][gG]/ ) ) - { - $self->{curInfo}->{image} = 'http://www.bedetheque.com/' . $attr->{href}; + if ( ( $self->{isCover} == 0 ) && ( $tagname eq "a" ) && ( $attr->{href} =~ m/Couvertures\/.*\.[jJ][pP][gG]/ ) ) { + $self->{curInfo}->{image} = $attr->{href}; $self->{isCover} = 1; } - elsif ( ( $tagname eq "div") && ( $attr->{class} eq "titre" ) ) { - $self->{isVolume} = 1; - } - elsif ( ( $tagname eq "ul") && ( $attr->{class} eq "infos" ) ) { - $self->{isResultsTable} = 1; + elsif ( $tagname eq "label" ) { + $self->{isLabel} = 1; } - elsif ( ( $self->{isResultsTable} ) && ( $tagname eq "label" ) ) { - $self->{current_field} = ''; - $self->{openlabel} = 1; + elsif ( ( $tagname eq "ul" ) && ( $attr->{class} eq "tabs-album" ) && ( ! $self->{doneSerie} ) ) { + $self->{isTabs} = 1; } - elsif ( ( $tagname eq "div" ) && ( $attr->{class} eq "title" ) && ( !defined( $self->{curInfo}->{title} ) || ( $self->{curInfo}->{title} =~ /^$/ ) ) ) { + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "name" ) && ( ! $self->{doneTitle} ) ) { $self->{isTitle} = 1; } - elsif ( ( $tagname eq "span" ) && ( $attr->{class} eq "type" ) ) { + elsif ( ( $tagname eq "span" ) && ( $attr->{class} eq "titre-rubrique" ) && ( ! $self->{doneSerie} ) && ( $self->{isTabs} ) ) { $self->{isSerie} = 1; } - elsif ( $tagname eq "em" ) { + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "author" ) && ( ! $self->{doneWriter} ) ) { + $self->{isWriter} = 1; + } + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "illustrator" ) && ( ! $self->{doneIllustrator} ) ) { + $self->{isIllustrator} = 1; + } + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "illustrator" ) && ( ! $self->{doneColourist} ) && ( $self->{doneIllustrator} ) ) { + $self->{isColourist} = 1; + } + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "publisher" ) && ( ! $self->{donePublisher} ) ) { + $self->{isPublisher} = 1; + } + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "isbn" ) && ( ! $self->{doneISBN} ) ) { + $self->{isISBN} = 1; + } + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "numberOfPages" ) && ( ! $self->{doneNumberboards} ) ) { + $self->{isNumberboards} = 1; + } + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "description" ) && ( ! $self->{doneSynopsis} ) ) { $self->{isSynopsis} = 1; } - elsif ( ( $tagname eq "a" ) && ( $attr->{class} eq "titre eo" ) ) { - if ( $attr->{title} =~ m/.+\s-(\d+)-\s.+/ ) { - $self->{curInfo}->{volume} = $1; - } + elsif ( ( $tagname eq "ul" ) && ( $attr->{class} eq "liste-albums" ) ) { + $self->{doneColourist} = 1; # To avoid getting mess with illustrator } +# elsif ( ( $tagname eq "a" ) && ( $attr->{class} eq "titre eo" ) ) { +# if ( $attr->{title} =~ m/.+\s-(\d+)-\s.+/ ) { +# $self->{curInfo}->{volume} = $1; +# } +# } } } @@ -260,6 +308,17 @@ use GCPlugins::GCcomics::GCcomicsCommon; $self->{itemsList}[ $self->{itemIdx} ]->{series} = $origtext; $self->{isSerie} = 0; } + elsif ( $self->{isTitle} == 1) + { + $self->{itemsList}[ $self->{itemIdx} ]->{title} = $origtext; + $self->{isTitle} = 0; + } + elsif ( $self->{isNumber} == 1) + { + $self->{itemsList}[ $self->{itemIdx} ]->{volume} = $origtext; + $self->{itemsList}[ $self->{itemIdx} ]->{volume} =~ s/#//; + $self->{isNumber} = 0; + } else { if ($self->{isCollection} == 1) @@ -296,8 +355,8 @@ use GCPlugins::GCcomics::GCcomicsCommon; "Scénario :" => 'writer', "Dessin :" => 'illustrator', "Couleurs :" => 'colourist', - "Dépot légal :" => 'publishdate', - "Achevé impr. :" => 'printdate ', + "Dépot légal :" => 'publishdate', + "Achevé impr. :" => 'printdate ', "Estimation :" => 'cost', "Editeur :" => 'publisher', "Collection : " => 'collection', @@ -317,27 +376,86 @@ use GCPlugins::GCcomics::GCcomicsCommon; $self->{current_field} = ""; } } - elsif ( $self->{isVolume} ) - { - $self->{curInfo}->{volume} = $origtext; - $self->{isVolume} = 0 ; - } - - if ( $self->{isTitle} ) - { + elsif ( $self->{isTitle} ) { $self->{curInfo}->{title} = $origtext; + $self->{isTitle} = 0 ; + $self->{doneTitle} = 1 ; } elsif ( $self->{isSerie} ) { $self->{curInfo}->{series} = $origtext; $self->{curInfo}->{series} =~s/^\s+//; + $self->{isSerie} = 0 ; + $self->{doneSerie} = 1 ; + $self->{isTabs} = 0 ; + } + elsif ( $self->{isWriter} ) { + $self->{curInfo}->{writer} = $origtext; + $self->{isWriter} = 0 ; + $self->{doneWriter} = 1 ; + } + elsif ( $self->{isIllustrator} ) { + $self->{curInfo}->{illustrator} = $origtext; + $self->{isIllustrator} = 0 ; + $self->{doneIllustrator} = 1 ; + } + elsif ( $self->{isColourist} ) { + $self->{curInfo}->{colourist} = $origtext; + $self->{isColourist} = 0 ; + $self->{doneColourist} = 1 ; + } + elsif ( $self->{isPublisher} ) { + $self->{curInfo}->{publisher} = $origtext; + $self->{isPublisher} = 0 ; + $self->{donePublisher} = 1 ; } - elsif ( ( $self->{isSynopsis} ) && ( ( $origtext =~ /Résumé de l'album :/ ) || ( $origtext =~ /Résumé de la série :/ ) ) ) { - $self->{startSynopsis} = 1; + elsif ( $self->{isISBN} ) { + $self->{curInfo}->{isbn} = $origtext; + $self->{isISBN} = 0 ; + $self->{doneISBN} = 1 ; } - elsif ( ( $self->{isSynopsis} ) && ( $self->{startSynopsis} ) ) { - $self->{curInfo}->{synopsis} .= " ".$origtext; + elsif ( $self->{isNumberboards} ) { + $self->{curInfo}->{numberboards} = $origtext; + $self->{isNumberboards} = 0 ; + $self->{doneNumberboards} = 1 ; + } + elsif ( $self->{isVolume} ) { + $self->{curInfo}->{volume} = $origtext; + $self->{isVolume} = 0 ; + $self->{doneVolume} = 1 ; + } + elsif ( ( $self->{isLabel} ) && ( $origtext =~ m/Dépot légal/ ) && ( ! $self->{donePublishdate} ) ) { + $self->{isPublishdate} = 1 ; + $self->{isLabel} = 0 ; + } + elsif ( $self->{isPublishdate} ) { + $self->{curInfo}->{publishdate} = $origtext; + $self->{isPublishdate} = 0 ; + $self->{donePublishdate} = 1 ; + } + elsif ( ( $self->{isLabel} ) && ( $origtext =~ m/Estimation/ ) && ( ! $self->{doneCost} ) ) { + $self->{isCost} = 1 ; + $self->{isLabel} = 0 ; + } + elsif ( $self->{isCost} ) { + $self->{curInfo}->{cost} = $origtext; + $self->{isCost} = 0 ; + $self->{doneCost} = 1 ; + } + elsif ( ( $self->{isLabel} ) && ( $origtext =~ m/Format/ ) && ( ! $self->{doneFormat} ) ) { + $self->{isFormat} = 1 ; + $self->{isLabel} = 0 ; + } + elsif ( $self->{isFormat} ) { + $self->{curInfo}->{format} = $origtext; + $self->{isFormat} = 0 ; + $self->{doneFormat} = 1 ; + } + elsif ( $self->{isSynopsis} ) { + $self->{curInfo}->{synopsis} = $origtext; $self->{curInfo}->{synopsis} =~ s/^(\s)*//; $self->{curInfo}->{synopsis} =~ s/(\s)*$//; + $self->{isSynopsis} = 0 ; + $self->{doneSynopsis} = 1 ; } } } @@ -359,9 +477,9 @@ use GCPlugins::GCcomics::GCcomicsCommon; $self->{isCollection} = 0; } } else { - if ( ( $self->{inTable} ) && ( $tagname eq "a" ) ) { + if ( ( $self->{inTable} ) && ( $tagname eq "span" ) ) { $self->{isTitle} = 0; - } elsif ( ( $self->{inTable} ) && ( $tagname eq "td" ) ) { + } elsif ( ( $self->{inTable} ) && ( $tagname eq "li" ) ) { $self->{isVolume} = 0; } } @@ -373,18 +491,20 @@ use GCPlugins::GCcomics::GCcomicsCommon; $self->{isIssue} = 0; $self->{isResultsTable} = 0; } - elsif ( ( $self->{isResultsTable} ) && ( $tagname eq "label" ) ) { + elsif ( $tagname eq "label" ) { $self->{openlabel} = 0; + $self->{isLabel} = 0; } - elsif ( ( $self->{isTitle} ) && ( ( $tagname eq "div" ) || ( $tagname eq "h1" ) ) ) { - $self->{isTitle} = 0; - } - elsif ( ( $self->{isSerie} ) && ( $tagname eq "a" ) ) { - $self->{isSerie} = 0; - } - elsif ( ( $self->{isSynopsis} ) && ( $tagname eq "em" ) && ( !$self->{startSynopsis} ) ) { - $self->{isSynopsis} = 0; - $self->{startSynopsis} = 0; + elsif ( $tagname eq "span" ) { + $self->{isColourist} = 0; + $self->{isIllustrator} = 0; + $self->{isISBN} = 0; + $self->{isNumberboards} = 0; + $self->{isPublisher} = 0; + $self->{isSerie} = 0; + $self->{isSynopsis} = 0; + $self->{isTitle} = 0; + $self->{isWriter} = 0; } elsif ( ( $self->{isSynopsis} ) && ( ( $tagname eq "p" ) || ( $tagname eq "br" ) ) && ( $self->{startSynopsis} ) ) { $self->{isSynopsis} = 0; @@ -395,4 +515,4 @@ use GCPlugins::GCcomics::GCcomicsCommon; } } -1;
\ No newline at end of file +1; diff --git a/lib/gcstar/GCPlugins/GCfilms/GCAlpacineES.pm b/lib/gcstar/GCPlugins/GCfilms/GCAlpacineES.pm deleted file mode 100644 index 75c6854..0000000 --- a/lib/gcstar/GCPlugins/GCfilms/GCAlpacineES.pm +++ /dev/null @@ -1,435 +0,0 @@ -package GCPlugins::GCfilms::GCAlpacineES; - -################################################### -# -# 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::GCfilms::GCfilmsCommon; - -{ - package GCPlugins::GCfilms::GCPluginAlpacineES; - - use base qw(GCPlugins::GCfilms::GCfilmsPluginsBase); - - - # text - # Called each time some plain text (between tags) is processed. - # $origtext is the read text. - sub text - { - my ($self, $origtext) = @_; - - return if length($origtext) < 2; - - # Código para procesar el resultado de la busqueda - if ($self->{parsingList}){ - # Guardamos la fecha. - if ($self->{inside}->{li} && $self->{insideInfos}){ - $origtext =~ /. \(([0-9]{4})\)/; - $self->{itemsList}[$self->{itemIdx}]->{date} = $origtext; - } - # Guardamos el título - if ($self->{inside}->{a} && $self->{insideInfos}){ - $self->{itemsList}[$self->{itemIdx}]->{title} = $origtext; - } - } - - else{ - # Eliminamos espacios iniciales, espacios dobles y espacios finales del texto - $origtext =~ s/^\s*|\s{2,}|\s*$//g; - # Estamos procesando el titulo - if ($self->{insideTitle}) - { - # Obtenemos titulo y fecha - $origtext =~ /(.*) \(([0-9]{4})\)/; - $self->{curInfo}->{title} = $1; - $self->{curInfo}->{date} = $2; - $self->{insideTitle} = 0; - return; - } - - # Si existe el hipervinculo "Ampliar" cambiamos la imagen por la ampliada - if ($self->{inside}->{a} && $origtext eq "Ampliar"){ - $self->{curInfo}->{image} =~ /(http:\/\/img.alpacine.com\/carteles\/.*)-[0-9]*(\.jpg)/; - $self->{curInfo}->{image} = $1 . $2; - return; - } - # Estamos en la puntuación real - if($self->{insideRating}){ - $self->{curInfo}->{ratingpress} = int( $origtext + 0.5 ); - $self->{insideRating} = 0; - } - # No hay puntuación real, asignamos 0 por defecto - if($self->{inside}->{div}){ - if($origtext =~ /Esperando \d votos/){ - $self->{curInfo}->{ratingpress} = 0; - } - } - # Procesamos el titulo original - if ($self->{isOrigTit} eq 1) { - $self->{isOrigTit} = 0; - $self->{curInfo}->{original} = $origtext; - return; - } - # Procesamos los generos (gen, gen, gen, gen...) - if ($self->{isGenres} eq 1) { - if($origtext ne ""){ - # hacemos uso de sus propias comas - $self->{curInfo}->{genre} .= $origtext; - } - else{ - $self->{isGenres} = 0; - } - return; - } - # Procesamos el país - if ($self->{isCountry} eq 1) { - $self->{isCountry} = 0; - $self->{curInfo}->{country} = $origtext; - return; - } - # Procesamos la duración - if ($self->{isTime} eq 1) { - $self->{isTime} = 0; - $self->{curInfo}->{time} = $origtext; - return; - } - # Procesamos los directores - if ($self->{isDirector} eq 1) { - if($origtext ne ""){ - if($self->{curInfo}->{director} eq ""){ - $self->{curInfo}->{director} .= $origtext; - } - else{ - $self->{curInfo}->{director} .= ", $origtext"; - } - } - else{ - $self->{isDirector} = 0; - } - return; - } - # Actores - if ($self->{isActors} eq 1) { - if($origtext ne ""){ - if($self->{curInfo}->{actors} eq ""){ - $self->{curInfo}->{actors} .= $origtext; - } - else{ - $self->{curInfo}->{actors} .= ", $origtext"; - } - } - else{ - $self->{isActors} = 0; - } - return; - } - # Procesamos la Sinopsis - if ($self->{isSynopsis} eq 1) { - $self->{isSynopsis} = 0; - $self->{curInfo}->{synopsis} = $origtext; - return; - } - # Procesamos los premios - if ($self->{isAwards} eq 1) { - $self->{isAwards} = 0; - $self->{curInfo}->{synopsis} = $self->{curInfo}->{synopsis}. "\n\nPremios:\n\t".$origtext; - $self->{insideInfos} = 0; - return; - } - - # Condiciones para procesar los campos en el siguiente ciclo - if($self->{insideInfos}){ - $self->{isOrigTit} = 1 if $origtext eq "Título original:"; - $self->{isGenres} = 1 if $origtext eq "Género:"; - $self->{isCountry} = 1 if $origtext eq "País:"; - $self->{isTime} = 1 if $origtext eq "Duración:"; - $self->{isDirector} = 1 if $origtext eq "Dirección:"; - $self->{isActors} = 1 if $origtext eq "Interpretación:"; - $self->{isSynopsis} = 1 if $origtext eq "Sinopsis:"; - $self->{isAwards} = 1 if $origtext eq "Premios:"; - } - } - } - - - # end - # Called each time a HTML tag ends. - # $tagname is the tag name. - sub end - { - my ($self, $tagname) = @_; - $self->{inside}->{$tagname}--; - - # Código para procesar el resultado de la busqueda - #if ($self->{parsingList}){ - #} - # Código para procesar la información de la pelicula seleccionada - #else { - #} - } - - # In processing functions below, self->{parsingList} can be used. - # If true, we are processing a search results page - # If false, we are processing a item information page. - - # $self->{inside}->{tagname} (with correct value for tagname) can be used to test - # if we are in the corresponding tag. - - # You have a counter $self->{itemIdx} that have to be used when processing search results. - # It is your responsability to increment it! - - # When processing search results, you have to fill the available fields for results - # - # $self->{itemsList}[$self->{movieIdx}]->{field_name} - # - # When processing a movie page, you need to fill the fields (if available) - # in $self->{curInfo}. - # - # $self->{curInfo}->{field_name} - - # start - # Called each time a new HTML tag begins. - # $tagname is the tag name. - # $attr is reference to an associative array of tag attributes. - # $attrseq is an array reference containing all the attributes name. - # $origtext is the tag text as found in source file - # Returns nothing - sub start - { - my ($self, $tagname, $attr, $attrseq, $origtext) = @_; - $self->{inside}->{$tagname}++; - - # Código para procesar el resultado de la busqueda para generar el listado - if ($self->{parsingList}) - { - # Comprobamos si estamos dentro de un título utilizando el atributo class - if( ($tagname eq "li" ) && ($attr->{class} ne "mas" )){ - $self->{itemIdx}++; - $self->{insideInfos} = 1 ; - return; - } - if( ($tagname eq "li" ) && ($attr->{class} eq "mas" )){ - $self->{insideInfos} = 0; - return; - } - # Si estamos en un título y encontramos una tag a, es un enlace a ficha - if ($tagname eq "a" && $self->{insideInfos}){ - $self->{itemsList}[$self->{itemIdx}]->{url} = "http://www.alpacine.com".$attr->{href}; - return; - } - } - # Código para procesar la información de la pelicula seleccionada - else { - if ($tagname eq "h1"){ - $self->{insideTitle} = 1; - return; - } - # Si estamos dentro de una imagen y el src es el del thumb lo asignamos como imagen - if ($tagname eq "img") - { - # Extraemos la dirección de la imagen thumb - if ($attr->{src} =~ /http:\/\/img.alpacine.com\/carteles\/.*\.jpg/) - { - $self->{curInfo}->{image} = $attr->{src}; - } - return; - } - - if ($tagname eq "div" && $attr->{class} eq "voto"){ - $self->{insideRating} = 1; - return; - } - - if( $tagname eq "div" && $attr->{class} eq "datos" ){ - $self->{insideInfos} = 1 ; - return; - } - } - } - - # preProcess - # Called before each page is processed. You can use it to do some substitutions. - # $html is the page content. - # Returns modified version of page content. - sub preProcess - { - my ($self, $html) = @_; - - # Anulamos el html si coincide con el patron de no resultados - if($html =~ /^.*No hay resultados para.*$/s){ - $html = ""; - return $html; - } - - # Recorta el código del listado de resultados, quedandose solo con la parte que nos interesa del html - # el modificador s/.../$1/s trata el flujo como una sola cadena y reemplaza todo el cuerpo con la parte que nos interesa - if($html =~ s/^.*<div class="titulo">Pel.culas <span class="resultados">\([0-9]* resultado[s]?\)<\/span><\/div><ul>(<li><a.*<\/a> \([0-9]*\)<\/li>).*$/$1/s){ - return $html; - } - - # Recorta el código de la ficha, quedandose solo con la parte que nos interesa del html - # Comprobamos si la pelicula contiene o no premios y nos quedamos con lo que corresponda - if($html =~ /^.*<div class="titulo">Premios:.*más\.\.\.<\/a><\/div><\/div>.*$/s){ - $html =~ s/^.*<div id="titulo">(.*<\/div><\/div>.*\n.*<div class="datox"><div class="titulo">Premios:.*)más\.\.\.<\/a><\/div><\/div>.*$/$1/s; - } - else{ - $html =~ s/^.*<div id="titulo">(.*<\/div><\/div>)\n\n\t\t\t\t\n\n\t\t\t\t<hr \/>.*$/$1/s; - } - return $html; - } - - # changeUrl - # Can be used to change URL if item URL and the one used to - # extract information are different. - # Return the modified URL. - #sub changeUrl - #{ - # my ($self, $url) = @_; - # return $url; - #} - - # getExtra - # Used if the plugin wants an extra column to be displayed in search results - # Return the column title or empty string to hide the column. - #sub getExtra - #{ - # return 'Extra'; - #} - - - # getLang - # Used to fill in plugin list with user language plugins - # Return the language used for this site (2 letters code). - sub getLang - { - return "ES"; - } - - - # getAuthor - # Used to display the plugin author in GUI. - # Returns the plugin author name. - sub getAuthor - { - return "DoVerMan"; - } - - - # getName - # Used to display plugin name in GUI. - # Returns the plugin name. - sub getName - { - return 'Alpacine'; - } - - - # getCharset - # Used to convert charset in web pages. - # Returns the charset as specified in pages. - #sub getCharset - #{ - # my $self = shift; - # # Charset de la web - # return "UTF-8"; - #} - - - # getItemUrl - # Used to get the full URL of an item page. - # Useful when url on results pages are relative. - # $url is the URL as found with a search. - # Returns the absolute URL. - sub getItemUrl - { - my ($self, $url) = @_; - return $url; - } - - - # getSearchUrl - # Used to get the URL that to be used to perform searches. - # $word is the query - # Returns the full URL. - sub getSearchUrl - { - my ($self, $word) = @_; - # Hack para evitar problemas con acentos - $word =~ s/%E1/a/g; - $word =~ s/%E9/e/g; - $word =~ s/%ED/i/g; - $word =~ s/%F3/o/g; - $word =~ s/%FA/u/g; - $word =~ s/%C1/A/g; - $word =~ s/%C9/E/g; - $word =~ s/%CD/I/g; - $word =~ s/%D3/O/g; - $word =~ s/%DA/U/g; - - return "http://www.alpacine.com/buscar/?buscar=" . $word; - - } - - - # Constructor - sub new - { - # Inicialización - my $proto = shift; - my $class = ref($proto) || $proto; - my $self = $class->SUPER::new(); - bless ($self, $class); - - # Campos que devuelve el plugin (1 si, 0 no). Son los que apareceran - # en el listado de resultados - $self->{hasField} = { - title => 1, - date => 1, - director => 0, - actors => 0, - }; - - # Indica si estamos procesando información útil - $self->{insideInfos} = 0; - - # Indican el estado del procesado del listado de resultados - $self->{insideRating} = 0; - $self->{insideTitle} = 0; - - $self->{isOrigTit} = 0; - $self->{isGenres} = 0; - $self->{isCountry} = 0; - $self->{isTime} = 0; - $self->{isDirector} = 0; - $self->{isActors} = 0; - $self->{isSynopsis} = 0; - $self->{isAwards} = 0; - - return $self; - } - -} - -1; diff --git a/lib/gcstar/GCPlugins/GCfilms/GCImdb.pm b/lib/gcstar/GCPlugins/GCfilms/GCImdb.pm index 70af804..0d12717 100644 --- a/lib/gcstar/GCPlugins/GCfilms/GCImdb.pm +++ b/lib/gcstar/GCPlugins/GCfilms/GCImdb.pm @@ -1,439 +1,449 @@ -package GCPlugins::GCfilms::GCImdb; - -################################################### -# -# Copyright 2010 groms -# -# Features: -# + Multiple directors separated by comma -# + Multiple countries separated by comma -# + Correct URL in case of redirection -# + Fetches Original Title -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -################################################### - -use strict; - -use GCPlugins::GCfilms::GCfilmsCommon; - -{ - package GCPlugins::GCfilms::GCPluginImdb; - - use base qw(GCPlugins::GCfilms::GCfilmsPluginsBase); - - sub start - { - my ($self, $tagname, $attr, $attrseq, $origtext) = @_; - - $self->{inside}->{$tagname}++; - - if ($self->{parsingEnded}) - { - return; - } - - if ($self->{parsingList}) - { - if ($tagname eq "a") - { - my $url = $attr->{href}; - if (($url =~ /^\/title\//) && (!$self->{alreadyListed}->{$url})) - { - $self->{isMovie} = 1; - $self->{isInfo} = 1; - $self->{itemIdx}++; - $self->{itemsList}[$self->{itemIdx}]->{url} = $url; - $self->{alreadyListed}->{$url} = 1; - } - } - } - else - { - - if ($tagname eq "link") - { - if ($attr->{rel} eq "canonical") - { - $self->{curInfo}->{webPage} = $attr->{href}; - } - } - elsif ($tagname eq "h1") - { - if ($attr->{class} eq "header") - { - $self->{insideHeader} = 1; - } - } - elsif ($tagname eq "div") - { - if ($attr->{class} eq "infobar") - { - $self->{insideInfobar} = 1; - } - } - elsif ($tagname eq "table") - { - if ($attr->{class} eq "cast_list") - { - $self->{insideCastList} = 1; - } - } - elsif ($tagname eq "span") - { - if ($attr->{itemprop} eq "ratingValue") - { - $self->{insideRating} = 1; - } - elsif ($attr->{class} eq "title-extra") - { - $self->{insideOriginalTitle} = 1; - } - } - elsif ($tagname eq "img") - { - if ($self->{insidePrimaryImage}) - { - if (!($attr->{src} =~ m/nopicture/)) - { - ($self->{curInfo}->{image} = $attr->{src}) =~ s/_V1\._.+\./_V1\._SX1000_SY1000_\./; - } - } - elsif ($self->{insideInfobar} && $attr->{src} =~ m|/certificates/us/|) - { - my $cert = $attr->{title}; - $self->{curInfo}->{age} = 1 if ($cert eq 'Unrated') || ($cert eq 'Open'); - $self->{curInfo}->{age} = 2 if ($cert eq 'G') || ($cert eq 'Approved'); - $self->{curInfo}->{age} = 5 if ($cert eq 'PG') || ($cert eq 'M') || ($cert eq 'GP'); - $self->{curInfo}->{age} = 13 if $cert eq 'PG_13'; - $self->{curInfo}->{age} = 17 if $cert eq 'R'; - $self->{curInfo}->{age} = 18 if ($cert eq 'NC_17') || ($cert eq 'X'); - } - } - elsif ($tagname eq "a") - { - if ($self->{insideHeader} && $attr->{href} =~ m/year/) - { - $self->{insideYear} = 1; - } - elsif ($self->{insideInfobar} && $attr->{href} =~ m/genre/) - { - $self->{insideGenre} = 1; - } - } - elsif ($tagname eq 'td') - { - if ($self->{insideCastList}) - { - if ($attr->{class} eq 'name') - { - $self->{insideActor} = 1; - } - elsif ($attr->{class} eq 'character') - { - $self->{insideRole} = 1; - } - } - elsif ($attr->{id} eq "img_primary") { - $self->{insidePrimaryImage} = 1; - } - } - } - } - - sub end - { - my ($self, $tagname) = @_; - - $self->{inside}->{$tagname}--; - if ($self->{parsingList}) - { - if ($self->{isMovie} && ($tagname eq 'a')) - { - $self->{isMovie} = 0; - my $url = $self->{itemsList}[$self->{itemIdx}]->{url}; - if (!$self->{itemsList}[$self->{itemIdx}]->{title}) - { - $self->{alreadyListed}->{$url} = 0; - $self->{itemIdx}--; - } - } - } else { - if ($tagname eq "h1") - { - $self->{insideHeader} = 0; - } - elsif ($tagname eq "a") - { - $self->{insideYear} = 0; - $self->{insideGenre} = 0; - $self->{insideActor} = 0; - $self->{insideRole} = 0; - } - elsif ($tagname eq "div") - { - $self->{insideInfobar} = 0; - $self->{insideNat} = 0; - $self->{insideDirector} = 0; - $self->{insideStoryline} = 0; - $self->{insideReleaseDate} = 0; - } - elsif ($tagname eq "span") - { - $self->{insideRating} = 0; - $self->{insideOriginalTitle} = 0; - } - elsif ($tagname eq "table") - { - $self->{insideCastList} = 0; - } - elsif ($tagname eq "td") - { - $self->{insidePrimaryImage} = 0; - } - elsif ($self->{insideCastList}) - { - if ($self->{actor} && $self->{role}) - { - $self->{actor} =~ s/^\s+|\s+$//g; - $self->{actor} =~ s/\s{2,}/ /g; - push @{$self->{curInfo}->{actors}}, [$self->{actor}]; - $self->{role} =~ s/^\s+|\s+$//g; - $self->{role} =~ s/\s{2,}/ /g; - push @{$self->{curInfo}->{actors}->[$self->{actorsCounter}]}, $self->{role}; - $self->{actorsCounter}++; - } - $self->{actor} = ""; - $self->{role} = ""; - } - } - } - - sub text - { - my ($self, $origtext) = @_; - - return if length($origtext) < 2; - - $origtext =~ s/^\s+|\s+$//g; - - return if ($self->{parsingEnded}); - - if ($self->{parsingList}) - { - if ($self->{inside}->{h1} && $origtext !~ m/IMDb\s*Title\s*Search/i) - { - $self->{parsingEnded} = 1; - $self->{itemIdx} = 0; - $self->{itemsList}[0]->{url} = $self->{loadedUrl}; - } - if ($self->{isMovie}) - { - $self->{itemsList}[$self->{itemIdx}]->{title} = $origtext; - $self->{isMovie} = 0; - $self->{isInfo} = 1; - return; - } - if ($self->{isInfo}) - { - $self->{itemsList}[$self->{itemIdx}]->{date} = $1 if $origtext =~ m|\(([0-9]*)(/I+)?\)|; - $self->{isInfo} = 0; - } - } - else - { - if ($self->{insideHeader}) - { - if ($self->{insideYear}) - { - $self->{curInfo}->{date} = $origtext; - } - elsif (!$self->{curInfo}->{title}) - { - $self->{curInfo}->{title} = $origtext; - if (!$self->{curInfo}->{original}) - { - $self->{curInfo}->{original} = $origtext; - } - } - elsif ($self->{insideOriginalTitle} && !$self->{inside}->{i}) - { - $self->{curInfo}->{original} = $origtext; - } - } - elsif ($self->{insideInfobar}) - { - if ($self->{insideGenre}) - { - if ($self->{curInfo}->{genre}) - { - $self->{curInfo}->{genre} .= ","; - } - $self->{curInfo}->{genre} .= $origtext; - } - elsif ($origtext =~ m/([0-9]+ min)/) - { - $self->{curInfo}->{time} = $1; - } - } - elsif ($self->{insideRating} && $origtext =~ m/[0-9]\.[0-9]/) - { - $self->{curInfo}->{ratingpress} = int($origtext + 0.5); - } - elsif ($self->{insideSynopsis}) - { - $self->{curInfo}->{synopsis} .= $origtext; - } - elsif ($self->{insideNat}) - { - if ($origtext =~ m/[^\s].+/) - { - if ($self->{curInfo}->{country} =~ m/.+/) - { - $self->{curInfo}->{country} .= ", ".$origtext; - } - else - { - $self->{curInfo}->{country} = $origtext; - } - } - } - elsif ($self->{insideCastList}) - { - if ($self->{insideActor}) - { - $self->{actor} .= $origtext; - } - elsif ($self->{insideRole}) - { - $self->{role} .= $origtext; - } - } - elsif ($self->{insideStoryline} && $self->{inside}{p}) - { - $self->{curInfo}->{synopsis} = $origtext; - $self->{insideStoryline} = 0; - } - elsif ($self->{insideDirector} && $self->{inside}->{div}) - { - $origtext =~ s/,/, /; - $self->{curInfo}->{director} .= $origtext; - } - elsif ($self->{insideReleaseDate} && !$self->{curInfo}->{date}) { - if ($origtext =~ m/([0-9]{4})/) - { - $self->{curInfo}->{date} = $1; - $self->{insideReleaseDate} = 0; - } - } - - if ($self->{inside}->{h2}) - { - $self->{insideStoryline} = 1 if ($origtext eq "Storyline"); - } - elsif ($self->{inside}->{h4}) - { - $self->{insideDirector} = 1 if $origtext =~ m/Directors?:/; - $self->{insideTime} = 1 if $origtext =~ m/Runtime:/; - $self->{insideNat} = 1 if $origtext =~ m/Country:/; - $self->{insideReleaseDate} = 1 if $origtext =~ m/Release Date:/; - } - } - } - - sub new - { - my $proto = shift; - my $class = ref($proto) || $proto; - my $self = $class->SUPER::new(); - bless ($self, $class); - - $self->{hasField} = { - title => 1, - date => 1, - director => 0, - actors => 0, - }; - - $self->{isInfo} = 0; - $self->{isMovie} = 0; - $self->{curName} = undef; - $self->{curUrl} = undef; - - return $self; - } - - sub preProcess - { - my ($self, $html) = @_; - - $self->{parsingEnded} = 0; - - if ($self->{parsingList}) - { - $self->{alreadyListed} = {}; - } - else - { - #$html =~ s|<a href="synopsis">[^<]*</a>||gi; - #$html =~ s|<a href="/name/.*?"[^>]*>([^<]*)</a>|$1|gi; - #$html =~ s|<a href="/character/ch[0-9]*/">([^<]*)</a>|$1|gi; - #$html =~ s|<a href="/Sections/.*?">([^<]*)</a>|$1|gi; - - # Commented out this line, causes bug #14420 when importing from named lists - #$self->{curInfo}->{actors} = []; - } - - - return $html; - } - - sub getSearchUrl - { - my ($self, $word) = @_; - - return "http://www.imdb.com/find?s=tt&q=$word"; - } - - sub getItemUrl - { - my ($self, $url) = @_; - - return "http://www.imdb.com" if $url eq ""; - return $url if $url =~ /^http:/; - return "http://www.imdb.com".$url; - } - - sub getName - { - return "IMDb"; - } - - sub getAuthor - { - return 'groms'; - } - - sub getLang - { - return 'EN'; - } - -} - -1; +package GCPlugins::GCfilms::GCImdb;
+
+###################################################
+#
+# Features:
+# + Multiple directors separated by comma
+# + Multiple countries separated by comma
+# + Correct URL in case of redirection
+# + Fetches Original Title
+#
+###################################################
+#
+# Copyright 2005-2014 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 GCPlugins::GCfilms::GCfilmsCommon;
+
+{
+ package GCPlugins::GCfilms::GCPluginImdb;
+
+ use base qw(GCPlugins::GCfilms::GCfilmsPluginsBase);
+
+ sub start
+ {
+ my ($self, $tagname, $attr, $attrseq, $origtext) = @_;
+
+ $self->{inside}->{$tagname}++;
+
+ if ($self->{parsingEnded})
+ {
+ return;
+ }
+
+ if ($self->{parsingList})
+ {
+ if ($tagname eq "a")
+ {
+ my $url = $attr->{href};
+ if (($url =~ /^\/title\//) && (!$self->{alreadyListed}->{$url}))
+ {
+ $self->{isMovie} = 1;
+ $self->{isInfo} = 1;
+ $self->{itemIdx}++;
+ $self->{itemsList}[$self->{itemIdx}]->{url} = $url;
+ $self->{alreadyListed}->{$url} = 1;
+ }
+ }
+ }
+ else
+ {
+
+ if ($tagname eq "link")
+ {
+ if ($attr->{rel} eq "canonical")
+ {
+ $self->{curInfo}->{webPage} = $attr->{href};
+ }
+ }
+ elsif ($tagname eq "h1")
+ {
+ if ($attr->{class} eq "header")
+ {
+ $self->{insideHeader} = 1;
+ }
+ }
+ elsif ($tagname eq "div")
+ {
+ if ($attr->{class} eq "infobar")
+ {
+ $self->{insideInfobar} = 1;
+ }
+ }
+ elsif ($tagname eq "table")
+ {
+ if ($attr->{class} eq "cast_list")
+ {
+ $self->{insideCastList} = 1;
+ }
+ }
+ elsif ($tagname eq "span")
+ {
+ if ($attr->{itemprop} eq "ratingValue")
+ {
+ $self->{insideRating} = 1;
+ }
+ elsif ($attr->{class} eq "title-extra")
+ {
+ $self->{insideOriginalTitle} = 1;
+ }
+ elsif ($self->{insideCastList})
+ {
+ if ($attr->{itemprop} eq 'name')
+ {
+ $self->{insideActor} = 1;
+ }
+ }
+ }
+ elsif ($tagname eq "img")
+ {
+ if ($self->{insidePrimaryImage})
+ {
+ if (!($attr->{src} =~ m/nopicture/))
+ {
+ ($self->{curInfo}->{image} = $attr->{src}) =~ s/_V1\._.+\./_V1\._SX1000_SY1000_\./;
+ }
+ }
+ elsif ($self->{insideInfobar} && $attr->{src} =~ m|/certificates/us/|)
+ {
+ my $cert = $attr->{title};
+ $self->{curInfo}->{age} = 1 if ($cert eq 'Unrated') || ($cert eq 'Open');
+ $self->{curInfo}->{age} = 2 if ($cert eq 'G') || ($cert eq 'Approved');
+ $self->{curInfo}->{age} = 5 if ($cert eq 'PG') || ($cert eq 'M') || ($cert eq 'GP');
+ $self->{curInfo}->{age} = 13 if $cert eq 'PG_13';
+ $self->{curInfo}->{age} = 17 if $cert eq 'R';
+ $self->{curInfo}->{age} = 18 if ($cert eq 'NC_17') || ($cert eq 'X');
+ }
+ }
+ elsif ($tagname eq "a")
+ {
+ if ($self->{insideHeader} && $attr->{href} =~ m/year/)
+ {
+ $self->{insideYear} = 1;
+ }
+ elsif ($self->{insideInfobar} && $attr->{href} =~ m/genre/)
+ {
+ $self->{insideGenre} = 1;
+ }
+ }
+ elsif ($tagname eq 'td')
+ {
+ if ($self->{insideCastList})
+ {
+ #if ($attr->{class} eq 'name')
+ #{
+ #$self->{insideActor} = 1;
+ #}
+ if ($attr->{class} eq 'character')
+ {
+ $self->{insideRole} = 1;
+ }
+ }
+ elsif ($attr->{id} eq "img_primary") {
+ $self->{insidePrimaryImage} = 1;
+ }
+ }
+ }
+ }
+
+ sub end
+ {
+ my ($self, $tagname) = @_;
+
+ $self->{inside}->{$tagname}--;
+ if ($self->{parsingList})
+ {
+ if ($self->{isMovie} && ($tagname eq 'a'))
+ {
+ $self->{isMovie} = 0;
+ my $url = $self->{itemsList}[$self->{itemIdx}]->{url};
+ if (!$self->{itemsList}[$self->{itemIdx}]->{title})
+ {
+ $self->{alreadyListed}->{$url} = 0;
+ $self->{itemIdx}--;
+ }
+ }
+ } else {
+ if ($tagname eq "h1")
+ {
+ $self->{insideHeader} = 0;
+ }
+ elsif ($tagname eq "a")
+ {
+ $self->{insideYear} = 0;
+ $self->{insideGenre} = 0;
+ $self->{insideActor} = 0;
+ $self->{insideRole} = 0;
+ }
+ elsif ($tagname eq "div")
+ {
+ $self->{insideInfobar} = 0;
+ $self->{insideNat} = 0;
+ $self->{insideDirector} = 0;
+ $self->{insideStoryline} = 0;
+ $self->{insideReleaseDate} = 0;
+ }
+ elsif ($tagname eq "span")
+ {
+ $self->{insideRating} = 0;
+ $self->{insideOriginalTitle} = 0;
+ }
+ elsif ($tagname eq "table")
+ {
+ $self->{insideCastList} = 0;
+ }
+ elsif ($tagname eq "td")
+ {
+ $self->{insidePrimaryImage} = 0;
+ }
+ elsif ($self->{insideCastList})
+ {
+ if ($self->{actor} && $self->{role})
+ {
+ $self->{actor} =~ s/^\s+|\s+$//g;
+ $self->{actor} =~ s/\s{2,}/ /g;
+ push @{$self->{curInfo}->{actors}}, [$self->{actor}];
+ $self->{role} =~ s/^\s+|\s+$//g;
+ $self->{role} =~ s/\s{2,}/ /g;
+ push @{$self->{curInfo}->{actors}->[$self->{actorsCounter}]}, $self->{role};
+ $self->{actorsCounter}++;
+ }
+ $self->{actor} = "";
+ $self->{role} = "";
+ }
+ }
+ }
+
+ sub text
+ {
+ my ($self, $origtext) = @_;
+
+ return if length($origtext) < 2;
+
+ $origtext =~ s/^\s+|\s+$//g;
+
+ return if ($self->{parsingEnded});
+
+ if ($self->{parsingList})
+ {
+ #if ($self->{inside}->{h1} && $origtext !~ m/IMDb\s*Title\s*Search/i)
+ if ($self->{inside}->{title} && $origtext !~ m/Find\s-\sIMDb/i)
+ {
+ $self->{parsingEnded} = 1;
+ $self->{itemIdx} = 0;
+ $self->{itemsList}[0]->{url} = $self->{loadedUrl};
+ }
+ if ($self->{isMovie})
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{title} = $origtext;
+ $self->{isMovie} = 0;
+ $self->{isInfo} = 1;
+ return;
+ }
+ if ($self->{isInfo})
+ {
+ $self->{itemsList}[$self->{itemIdx}]->{date} = $1 if $origtext =~ m|\(([0-9]*)(/I+)?\)|;
+ $self->{isInfo} = 0;
+ }
+ }
+ else
+ {
+ if ($self->{insideHeader})
+ {
+ if ($self->{insideYear})
+ {
+ $self->{curInfo}->{date} = $origtext;
+ }
+ elsif (!$self->{curInfo}->{title})
+ {
+ $self->{curInfo}->{title} = $origtext;
+ if (!$self->{curInfo}->{original})
+ {
+ $self->{curInfo}->{original} = $origtext;
+ }
+ }
+ elsif ($self->{insideOriginalTitle} && !$self->{inside}->{i})
+ {
+ $self->{curInfo}->{original} = $origtext;
+ }
+ }
+ elsif ($self->{insideInfobar})
+ {
+ if ($self->{insideGenre})
+ {
+ if ($self->{curInfo}->{genre})
+ {
+ $self->{curInfo}->{genre} .= ",";
+ }
+ $self->{curInfo}->{genre} .= $origtext;
+ }
+ elsif ($origtext =~ m/([0-9]+ min)/)
+ {
+ $self->{curInfo}->{time} = $1;
+ }
+ }
+ elsif ($self->{insideRating} && $origtext =~ m/[0-9]\.[0-9]/)
+ {
+ $self->{curInfo}->{ratingpress} = int($origtext + 0.5);
+ }
+ elsif ($self->{insideSynopsis})
+ {
+ $self->{curInfo}->{synopsis} .= $origtext;
+ }
+ elsif ($self->{insideNat})
+ {
+ if ($origtext =~ m/[^\s].+/)
+ {
+ if ($self->{curInfo}->{country} =~ m/.+/)
+ {
+ $self->{curInfo}->{country} .= ", ".$origtext;
+ }
+ else
+ {
+ $self->{curInfo}->{country} = $origtext;
+ }
+ }
+ }
+ elsif ($self->{insideCastList})
+ {
+ if ($self->{insideActor})
+ {
+ $self->{actor} .= $origtext;
+ }
+ elsif ($self->{insideRole})
+ {
+ $self->{role} .= $origtext;
+ }
+ }
+ elsif ($self->{insideStoryline} && $self->{inside}{p})
+ {
+ $self->{curInfo}->{synopsis} = $origtext;
+ $self->{insideStoryline} = 0;
+ }
+ elsif ($self->{insideDirector} && $self->{inside}->{div})
+ {
+ $origtext =~ s/,/, /;
+ $self->{curInfo}->{director} .= $origtext;
+ }
+ elsif ($self->{insideReleaseDate} && !$self->{curInfo}->{date}) {
+ if ($origtext =~ m/([0-9]{4})/)
+ {
+ $self->{curInfo}->{date} = $1;
+ $self->{insideReleaseDate} = 0;
+ }
+ }
+
+ if ($self->{inside}->{h2})
+ {
+ $self->{insideStoryline} = 1 if ($origtext eq "Storyline");
+ }
+ elsif ($self->{inside}->{h4})
+ {
+ $self->{insideDirector} = 1 if $origtext =~ m/Directors?:/;
+ $self->{insideTime} = 1 if $origtext =~ m/Runtime:/;
+ $self->{insideNat} = 1 if $origtext =~ m/Country:/;
+ $self->{insideReleaseDate} = 1 if $origtext =~ m/Release Date:/;
+ }
+ }
+ }
+
+ sub new
+ {
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self = $class->SUPER::new();
+ bless ($self, $class);
+
+ $self->{hasField} = {
+ title => 1,
+ date => 1,
+ director => 0,
+ actors => 0,
+ };
+
+ $self->{isInfo} = 0;
+ $self->{isMovie} = 0;
+ $self->{curName} = undef;
+ $self->{curUrl} = undef;
+
+ return $self;
+ }
+
+ sub preProcess
+ {
+ my ($self, $html) = @_;
+
+ $self->{parsingEnded} = 0;
+
+ if ($self->{parsingList})
+ {
+ $self->{alreadyListed} = {};
+ }
+ else
+ {
+ #$html =~ s|<a href="synopsis">[^<]*</a>||gi;
+ #$html =~ s|<a href="/name/.*?"[^>]*>([^<]*)</a>|$1|gi;
+ #$html =~ s|<a href="/character/ch[0-9]*/">([^<]*)</a>|$1|gi;
+ #$html =~ s|<a href="/Sections/.*?">([^<]*)</a>|$1|gi;
+
+ # Commented out this line, causes bug #14420 when importing from named lists
+ #$self->{curInfo}->{actors} = [];
+ }
+
+
+ return $html;
+ }
+
+ sub getSearchUrl
+ {
+ my ($self, $word) = @_;
+
+ return "http://www.imdb.com/find?s=tt&q=$word";
+ }
+
+ sub getItemUrl
+ {
+ my ($self, $url) = @_;
+
+ return "http://www.imdb.com" if $url eq "";
+ return $url if $url =~ /^http:/;
+ return "http://www.imdb.com".$url;
+ }
+
+ sub getName
+ {
+ return "IMDb";
+ }
+
+ sub getAuthor
+ {
+ return 'groms';
+ }
+
+ sub getLang
+ {
+ return 'EN';
+ }
+
+}
+
+1;
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/'/'/g;
+ $name =~ s/&/&/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|’|'|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;
+ $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/';
diff --git a/lib/gcstar/GCStats.pm b/lib/gcstar/GCStats.pm index 439c6d1..4cf18a8 100644 --- a/lib/gcstar/GCStats.pm +++ b/lib/gcstar/GCStats.pm @@ -66,6 +66,7 @@ BEGIN { {
my ($self, $items, $sort, $type, $useNumbers) = @_;
my %stats;
+ $self->{yMax} = 0;
foreach my $item(@$items)
{
if (ref($item) eq 'ARRAY')
@@ -94,7 +95,9 @@ BEGIN { $val = $key;
$val .= ' ('.$stats{$key}.')' if $useNumbers;
push @val1, $val;
- push @val2, $stats{$key};
+ my $stat = $stats{$key};
+ push @val2, $stat;
+ $self->{yMax} = $stat if $stat > $self->{yMax};
}
$self->{data} = [\@val1, \@val2];
}
@@ -155,6 +158,7 @@ BEGIN { $_ += $prev;
$prev = $_;
}
+ $self->{yMax} = $prev;
}
# Transform dates into numbers of days
# Reference is the 1st one as they are ordered
@@ -171,6 +175,7 @@ BEGIN { @refDate = Date::Calc::Add_Delta_Days(@refDate, -1);
$self->{data}->[0]->[0] = sprintf('%d/%02d/%02d', @refDate);
}
+ @refDate = GCPreProcess::completePartialDate(@refDate);
my $prev = -1;
my @newDates;
my $dateFormat = $self->{parent}->{options}->dateFormat;
@@ -183,6 +188,7 @@ BEGIN { next;
}
my @cmpDate = split m|/|, $date;
+ @cmpDate = GCPreProcess::completePartialDate(@cmpDate);
my $diff = Date::Calc::Delta_Days(@refDate, @cmpDate);
if ($diff > $prev + 1)
{
@@ -245,8 +251,9 @@ BEGIN { l_margin => 20,
r_margin => 20,
text_space => 20,
+ y_max_value => $self->{yMax},
+ y_number_format => "%d",
);
-
my $gd = $graph->plot($self->{data});
# Now, resample the graph down to the desired size, effectively anti-aliasing the sharp edges
@@ -300,6 +307,15 @@ BEGIN { $self->{accumulateOption}->setValue(1);
$self->{useNumberOption} = new GCCheckBox($parent->{lang}->{StatsDisplayNumber});
$self->{useNumberOption}->setValue(0);
+
+ $self->{groupDatesByChoices} = [
+ {value => 'days', displayed => 'Days'},
+ {value => 'months', displayed => 'Months'},
+ {value => 'years', displayed => 'Years'},
+ ];
+ $self->{groupDatesByOption} = new GCMenuList($self->{groupDatesByChoices});
+ $self->{groupDatesByOption}->setValue('days');
+ my $groupDatesByLabel = new GCLabel('Group dates by');
my $widthLabel = new GCLabel($parent->{lang}->{StatsWidth});
$self->{widthOption} = new GCCheckedText('0-9');
@@ -334,6 +350,8 @@ BEGIN { $table->attach($self->{sortByNumberOption}, 3, 5, 1, 2, 'fill', 'fill', 0, 0);
$table->attach($self->{accumulateOption}, 3, 5, 1, 2, 'fill', 'fill', 0, 0);
$table->attach($self->{useNumberOption}, 6, 8, 1, 2, 'fill', 'fill', 0, 0);
+ $table->attach($groupDatesByLabel, 9, 10, 1, 2, 'fill', 'fill', 0, 0);
+ $table->attach($self->{groupDatesByOption}, 10, 11, 1, 2, 'fill', 'fill', 0, 0);
$self->{image} = Gtk2::Image->new;
@@ -412,6 +430,7 @@ BEGIN { my $accumulate = $self->{accumulateOption}->getValue;
my $useNumber = ($graphType =~ /pie/) && $self->{useNumberOption}->getValue;
my $showValues = ($graphType !~ /pie/) && $self->{useNumberOption}->getValue;
+ my $groupDatesBy = $self->{groupDatesByOption}->getValue;
my $width = $self->{widthOption}->getValue;
my $height = $self->{heightOption}->getValue;
my $fontSize = $self->{fontOption}->getValue;
@@ -420,7 +439,10 @@ BEGIN { my @valuesList;
if ($type eq 'date')
{
- @valuesList = map {GCPreProcess::reverseDate($_->{$sortField})} @{$self->{data}};
+ @valuesList = map {GCPreProcess::cutReversedDate(
+ GCPreProcess::reverseDate($_->{$sortField}),
+ $self->{groupDatesByOption}->getValue)}
+ @{$self->{data}};
}
else
{
diff --git a/lib/gcstar/GCUtils.pm b/lib/gcstar/GCUtils.pm index cc0e0d9..1921363 100644 --- a/lib/gcstar/GCUtils.pm +++ b/lib/gcstar/GCUtils.pm @@ -317,6 +317,23 @@ sub RtfToString return $text; } + sub cutReversedDate + { + my ($date, $group) = @_; + return $date if $group eq 'days'; + $date =~ m|([0-9]{4})/([0-9]{2})/([0-9]{2})|; + my $result = $1; + $result .= "/$2" if $group eq 'months'; + return $result; + } + + sub completePartialDate + { + my (@date) = @_; + push @date, "01" while @date < 3; + return @date; + } + # Useful to compare date sub reverseDate { |