From 126bb8cb6b93240bb4d3a2b816b74c286c3d422b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 6 Jul 2014 15:20:38 +0200 Subject: Imported Upstream version 1.7.0 --- lib/gcstar/GCPlugins/GCPluginsBase.pm | 396 ++++++++++++ .../GCPlugins/GCTVepisodes/GCTVepisodesCommon.pm | 67 ++ lib/gcstar/GCPlugins/GCTVepisodes/GCTvdb.pm | 360 +++++++++++ lib/gcstar/GCPlugins/GCTVepisodes/GCTvdbES.pm | 61 ++ lib/gcstar/GCPlugins/GCTVepisodes/GCTvdbFR.pm | 61 ++ lib/gcstar/GCPlugins/GCTVepisodes/GCTvdbIT.pm | 60 ++ .../GCPlugins/GCTVseries/GCTVseriesCommon.pm | 53 ++ lib/gcstar/GCPlugins/GCTVseries/GCThemoviedb.pm | 340 ++++++++++ lib/gcstar/GCPlugins/GCTVseries/GCTvdb.pm | 466 ++++++++++++++ lib/gcstar/GCPlugins/GCTVseries/GCTvdbES.pm | 61 ++ lib/gcstar/GCPlugins/GCTVseries/GCTvdbFR.pm | 61 ++ lib/gcstar/GCPlugins/GCTVseries/GCTvdbIT.pm | 60 ++ .../GCPlugins/GCboardgames/GCReservoirJeux.pm | 418 ++++++++++++ .../GCPlugins/GCboardgames/GCboardgamegeek.pm | 278 ++++++++ .../GCPlugins/GCboardgames/GCboardgamesCommon.pm | 58 ++ lib/gcstar/GCPlugins/GCboardgames/GCtrictrac.pm | 462 ++++++++++++++ lib/gcstar/GCPlugins/GCbooks/GCAdlibrisFI.pm | 59 ++ lib/gcstar/GCPlugins/GCbooks/GCAdlibrisSV.pm | 59 ++ lib/gcstar/GCPlugins/GCbooks/GCAlapage.pm | 391 ++++++++++++ lib/gcstar/GCPlugins/GCbooks/GCAmazon.pm | 352 +++++++++++ lib/gcstar/GCPlugins/GCbooks/GCAmazonCA.pm | 61 ++ lib/gcstar/GCPlugins/GCbooks/GCAmazonDE.pm | 56 ++ lib/gcstar/GCPlugins/GCbooks/GCAmazonFR.pm | 57 ++ lib/gcstar/GCPlugins/GCbooks/GCAmazonUK.pm | 61 ++ lib/gcstar/GCPlugins/GCbooks/GCBDGest.pm | 477 ++++++++++++++ .../GCPlugins/GCbooks/GCBibliotekaNarodowa.pm | 374 +++++++++++ lib/gcstar/GCPlugins/GCbooks/GCBokkilden.pm | 295 +++++++++ lib/gcstar/GCPlugins/GCbooks/GCBol.pm | 485 ++++++++++++++ lib/gcstar/GCPlugins/GCbooks/GCBuscape.pm | 479 ++++++++++++++ lib/gcstar/GCPlugins/GCbooks/GCCasadelibro.pm | 420 +++++++++++++ lib/gcstar/GCPlugins/GCbooks/GCChapitre.pm | 430 +++++++++++++ lib/gcstar/GCPlugins/GCbooks/GCDoubanbook.pm | 238 +++++++ lib/gcstar/GCPlugins/GCbooks/GCFnac.pm | 462 ++++++++++++++ lib/gcstar/GCPlugins/GCbooks/GCFnacPT.pm | 390 ++++++++++++ lib/gcstar/GCPlugins/GCbooks/GCISBNdb.pm | 370 +++++++++++ .../GCPlugins/GCbooks/GCInternetBokHandeln.pm | 464 ++++++++++++++ lib/gcstar/GCPlugins/GCbooks/GCInternetBookShop.pm | 376 +++++++++++ lib/gcstar/GCPlugins/GCbooks/GCLeLivre.pm | 334 ++++++++++ lib/gcstar/GCPlugins/GCbooks/GCLiberOnWeb.pm | 418 ++++++++++++ lib/gcstar/GCPlugins/GCbooks/GCMareno.pm | 365 +++++++++++ lib/gcstar/GCPlugins/GCbooks/GCMediabooks.pm | 333 ++++++++++ lib/gcstar/GCPlugins/GCbooks/GCMerlin.pm | 389 ++++++++++++ lib/gcstar/GCPlugins/GCbooks/GCNUKat.pm | 447 +++++++++++++ lib/gcstar/GCPlugins/GCbooks/GCNooSFere.pm | 462 ++++++++++++++ lib/gcstar/GCPlugins/GCbooks/GCSaraiva.pm | 303 +++++++++ .../GCPlugins/GCbooks/GCbooksAdlibrisCommon.pm | 331 ++++++++++ .../GCPlugins/GCbooks/GCbooksAmazonCommon.pm | 65 ++ lib/gcstar/GCPlugins/GCbooks/GCbooksCommon.pm | 61 ++ lib/gcstar/GCPlugins/GCcomics/GCbedetheque.pm | 398 ++++++++++++ lib/gcstar/GCPlugins/GCcomics/GCcomicbookdb.pm | 546 ++++++++++++++++ lib/gcstar/GCPlugins/GCcomics/GCcomicsCommon.pm | 49 ++ lib/gcstar/GCPlugins/GCcomics/GCmangasanctuary.pm | 503 +++++++++++++++ lib/gcstar/GCPlugins/GCfilms/GCAlapage.pm | 267 ++++++++ lib/gcstar/GCPlugins/GCfilms/GCAllmovie.pm | 431 +++++++++++++ lib/gcstar/GCPlugins/GCfilms/GCAllocine.pm | 403 ++++++++++++ lib/gcstar/GCPlugins/GCfilms/GCAlpacineES.pm | 435 +++++++++++++ lib/gcstar/GCPlugins/GCfilms/GCAmazon.pm | 281 +++++++++ lib/gcstar/GCPlugins/GCfilms/GCAmazonDE.pm | 291 +++++++++ lib/gcstar/GCPlugins/GCfilms/GCAmazonFR.pm | 304 +++++++++ lib/gcstar/GCPlugins/GCfilms/GCAmazonUK.pm | 264 ++++++++ lib/gcstar/GCPlugins/GCfilms/GCAniDB.pm | 279 ++++++++ lib/gcstar/GCPlugins/GCfilms/GCAnimator.pm | 236 +++++++ lib/gcstar/GCPlugins/GCfilms/GCAnimeNfoA.pm | 266 ++++++++ lib/gcstar/GCPlugins/GCfilms/GCAnimeka.pm | 295 +++++++++ lib/gcstar/GCPlugins/GCfilms/GCBeyazPerde.pm | 340 ++++++++++ .../GCPlugins/GCfilms/GCCartelesPeliculasES.pm | 351 +++++++++++ lib/gcstar/GCPlugins/GCfilms/GCCinemaClock.pm | 271 ++++++++ lib/gcstar/GCPlugins/GCfilms/GCCinemotions.pm | 284 +++++++++ lib/gcstar/GCPlugins/GCfilms/GCCsfd.pm | 699 +++++++++++++++++++++ lib/gcstar/GCPlugins/GCfilms/GCCulturalia.pm | 241 +++++++ lib/gcstar/GCPlugins/GCfilms/GCDVDEmpire.pm | 427 +++++++++++++ lib/gcstar/GCPlugins/GCfilms/GCDVDFr.pm | 374 +++++++++++ lib/gcstar/GCPlugins/GCfilms/GCDVDPost.pm | 269 ++++++++ lib/gcstar/GCPlugins/GCfilms/GCDicshop.pm | 343 ++++++++++ lib/gcstar/GCPlugins/GCfilms/GCDoubanfilm.pm | 255 ++++++++ lib/gcstar/GCPlugins/GCfilms/GCFilmAffinityEN.pm | 334 ++++++++++ lib/gcstar/GCPlugins/GCfilms/GCFilmAffinityES.pm | 334 ++++++++++ lib/gcstar/GCPlugins/GCfilms/GCFilmUP.pm | 252 ++++++++ lib/gcstar/GCPlugins/GCfilms/GCFilmWeb.pm | 369 +++++++++++ lib/gcstar/GCPlugins/GCfilms/GCIbs.pm | 409 ++++++++++++ lib/gcstar/GCPlugins/GCfilms/GCImdb.pm | 439 +++++++++++++ lib/gcstar/GCPlugins/GCfilms/GCKinopoisk.pm | 386 ++++++++++++ lib/gcstar/GCPlugins/GCfilms/GCMediadis.pm | 316 ++++++++++ lib/gcstar/GCPlugins/GCfilms/GCMetropoliES.pm | 382 +++++++++++ lib/gcstar/GCPlugins/GCfilms/GCMonsieurCinema.pm | 272 ++++++++ lib/gcstar/GCPlugins/GCfilms/GCMovieMeter.pm | 429 +++++++++++++ lib/gcstar/GCPlugins/GCfilms/GCMoviecovers.pm | 246 ++++++++ lib/gcstar/GCPlugins/GCfilms/GCNasheKino.pm | 222 +++++++ lib/gcstar/GCPlugins/GCfilms/GCOFDb.pm | 304 +++++++++ lib/gcstar/GCPlugins/GCfilms/GCOdeonHU.pm | 305 +++++++++ lib/gcstar/GCPlugins/GCfilms/GCOnet.pm | 327 ++++++++++ lib/gcstar/GCPlugins/GCfilms/GCPortHU.pm | 343 ++++++++++ lib/gcstar/GCPlugins/GCfilms/GCStopklatka.pm | 355 +++++++++++ lib/gcstar/GCPlugins/GCfilms/GCThemoviedb.pm | 337 ++++++++++ lib/gcstar/GCPlugins/GCfilms/GCThemoviedbDE.pm | 56 ++ lib/gcstar/GCPlugins/GCfilms/GCThemoviedbES.pm | 56 ++ lib/gcstar/GCPlugins/GCfilms/GCThemoviedbFR.pm | 56 ++ .../GCPlugins/GCfilms/GCfilmsAmazonCommon.pm | 59 ++ lib/gcstar/GCPlugins/GCfilms/GCfilmsCommon.pm | 70 +++ lib/gcstar/GCPlugins/GCgames/GCAlapage.pm | 262 ++++++++ lib/gcstar/GCPlugins/GCgames/GCAmazon.pm | 115 ++++ lib/gcstar/GCPlugins/GCgames/GCAmazonCA.pm | 115 ++++ lib/gcstar/GCPlugins/GCgames/GCAmazonDE.pm | 114 ++++ lib/gcstar/GCPlugins/GCgames/GCAmazonFR.pm | 118 ++++ lib/gcstar/GCPlugins/GCgames/GCAmazonJP.pm | 120 ++++ lib/gcstar/GCPlugins/GCgames/GCAmazonUK.pm | 115 ++++ lib/gcstar/GCPlugins/GCgames/GCDicoDuNet.pm | 291 +++++++++ lib/gcstar/GCPlugins/GCgames/GCGameSpot.pm | 490 +++++++++++++++ lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm | 447 +++++++++++++ lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm | 425 +++++++++++++ lib/gcstar/GCPlugins/GCgames/GCLudus.pm | 367 +++++++++++ lib/gcstar/GCPlugins/GCgames/GCMobyGames.pm | 541 ++++++++++++++++ lib/gcstar/GCPlugins/GCgames/GCNextGame.pm | 480 ++++++++++++++ lib/gcstar/GCPlugins/GCgames/GCTheLegacy.pm | 316 ++++++++++ .../GCPlugins/GCgames/GCgamesAmazonCommon.pm | 314 +++++++++ lib/gcstar/GCPlugins/GCgames/GCgamesCommon.pm | 87 +++ lib/gcstar/GCPlugins/GCmusics/GCDiscogs.pm | 333 ++++++++++ lib/gcstar/GCPlugins/GCmusics/GCDoubanmusic.pm | 238 +++++++ lib/gcstar/GCPlugins/GCmusics/GCMusicBrainz.pm | 309 +++++++++ lib/gcstar/GCPlugins/GCmusics/GCmusicsCommon.pm | 62 ++ lib/gcstar/GCPlugins/GCstar/GCAmazonCommon.pm | 132 ++++ 121 files changed, 34677 insertions(+) create mode 100644 lib/gcstar/GCPlugins/GCPluginsBase.pm create mode 100644 lib/gcstar/GCPlugins/GCTVepisodes/GCTVepisodesCommon.pm create mode 100644 lib/gcstar/GCPlugins/GCTVepisodes/GCTvdb.pm create mode 100644 lib/gcstar/GCPlugins/GCTVepisodes/GCTvdbES.pm create mode 100644 lib/gcstar/GCPlugins/GCTVepisodes/GCTvdbFR.pm create mode 100644 lib/gcstar/GCPlugins/GCTVepisodes/GCTvdbIT.pm create mode 100644 lib/gcstar/GCPlugins/GCTVseries/GCTVseriesCommon.pm create mode 100644 lib/gcstar/GCPlugins/GCTVseries/GCThemoviedb.pm create mode 100644 lib/gcstar/GCPlugins/GCTVseries/GCTvdb.pm create mode 100644 lib/gcstar/GCPlugins/GCTVseries/GCTvdbES.pm create mode 100644 lib/gcstar/GCPlugins/GCTVseries/GCTvdbFR.pm create mode 100644 lib/gcstar/GCPlugins/GCTVseries/GCTvdbIT.pm create mode 100644 lib/gcstar/GCPlugins/GCboardgames/GCReservoirJeux.pm create mode 100644 lib/gcstar/GCPlugins/GCboardgames/GCboardgamegeek.pm create mode 100644 lib/gcstar/GCPlugins/GCboardgames/GCboardgamesCommon.pm create mode 100644 lib/gcstar/GCPlugins/GCboardgames/GCtrictrac.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCAdlibrisFI.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCAdlibrisSV.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCAlapage.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCAmazon.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCAmazonCA.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCAmazonDE.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCAmazonFR.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCAmazonUK.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCBDGest.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCBibliotekaNarodowa.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCBokkilden.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCBol.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCBuscape.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCCasadelibro.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCChapitre.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCDoubanbook.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCFnac.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCFnacPT.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCISBNdb.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCInternetBokHandeln.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCInternetBookShop.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCLeLivre.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCLiberOnWeb.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCMareno.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCMediabooks.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCMerlin.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCNUKat.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCNooSFere.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCSaraiva.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCbooksAdlibrisCommon.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCbooksAmazonCommon.pm create mode 100644 lib/gcstar/GCPlugins/GCbooks/GCbooksCommon.pm create mode 100644 lib/gcstar/GCPlugins/GCcomics/GCbedetheque.pm create mode 100644 lib/gcstar/GCPlugins/GCcomics/GCcomicbookdb.pm create mode 100644 lib/gcstar/GCPlugins/GCcomics/GCcomicsCommon.pm create mode 100644 lib/gcstar/GCPlugins/GCcomics/GCmangasanctuary.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCAlapage.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCAllmovie.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCAllocine.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCAlpacineES.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCAmazon.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCAmazonDE.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCAmazonFR.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCAmazonUK.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCAniDB.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCAnimator.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCAnimeNfoA.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCAnimeka.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCBeyazPerde.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCCartelesPeliculasES.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCCinemaClock.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCCinemotions.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCCsfd.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCCulturalia.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCDVDEmpire.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCDVDFr.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCDVDPost.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCDicshop.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCDoubanfilm.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCFilmAffinityEN.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCFilmAffinityES.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCFilmUP.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCFilmWeb.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCIbs.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCImdb.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCKinopoisk.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCMediadis.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCMetropoliES.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCMonsieurCinema.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCMovieMeter.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCMoviecovers.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCNasheKino.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCOFDb.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCOdeonHU.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCOnet.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCPortHU.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCStopklatka.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCThemoviedb.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCThemoviedbDE.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCThemoviedbES.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCThemoviedbFR.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCfilmsAmazonCommon.pm create mode 100644 lib/gcstar/GCPlugins/GCfilms/GCfilmsCommon.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCAlapage.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCAmazon.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCAmazonCA.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCAmazonDE.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCAmazonFR.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCAmazonJP.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCAmazonUK.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCDicoDuNet.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCGameSpot.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCJeuxVideoCom.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCLudus.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCMobyGames.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCNextGame.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCTheLegacy.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCgamesAmazonCommon.pm create mode 100644 lib/gcstar/GCPlugins/GCgames/GCgamesCommon.pm create mode 100644 lib/gcstar/GCPlugins/GCmusics/GCDiscogs.pm create mode 100644 lib/gcstar/GCPlugins/GCmusics/GCDoubanmusic.pm create mode 100644 lib/gcstar/GCPlugins/GCmusics/GCMusicBrainz.pm create mode 100644 lib/gcstar/GCPlugins/GCmusics/GCmusicsCommon.pm create mode 100644 lib/gcstar/GCPlugins/GCstar/GCAmazonCommon.pm (limited to 'lib/gcstar/GCPlugins') diff --git a/lib/gcstar/GCPlugins/GCPluginsBase.pm b/lib/gcstar/GCPlugins/GCPluginsBase.pm new file mode 100644 index 0000000..728e23a --- /dev/null +++ b/lib/gcstar/GCPlugins/GCPluginsBase.pm @@ -0,0 +1,396 @@ +package GCPlugins::GCPluginsBase; + +################################################### +# +# 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; + +{ + package GCPluginParser; + use base qw(HTML::Parser); + use LWP::Simple qw($ua); + use HTTP::Cookies::Netscape; + use URI::Escape; + use HTML::Entities; + use Encode; + use File::Spec; + + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + + $ua->agent('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041111 Firefox/1.0'); + $ua->default_header('Accept-Encoding' => 'x-gzip'); + $ua->default_header('Accept' => 'text/html'); + $self->{ua} = $ua; + + $self->{itemIdx} = -1; + $self->{itemsList} = (); + + bless ($self, $class); + return $self; + } + + sub getItemsNumber + { + my ($self) = @_; + + return $self->{itemIdx} + 1; + } + + sub getItems + { + my ($self) = @_; + return @{$self->{itemsList}}; + } + + sub load + { + my $self = shift; + + $self->checkProxy; + $self->checkCookieJar; + + $self->{itemIdx} = -1; + $self->{isInfo} = 0; + $self->{itemsList} = (); + + #my $word = uri_escape_utf8($self->{title}); + my $title2 = encode($self->getSearchCharset, $self->{title}); + my $word = uri_escape($title2); + $word =~ s/%20/+/g; + + my $post; + my $html; + + # For multi-pass plugins, the plugin will have set the url to load for + # the next pass as nextUrl. If this doesn't exist, we're either on the + # first pass, or only using a one-pass plugin, so call getSearchUrl + # to find the url to retrieve + if ($self->{nextUrl}) + { + $html = $self->loadPage($self->{nextUrl}); + } + else + { + $html = $self->loadPage($self->getSearchUrl($word)); + } + + $self->{parsingList} = 1; + $html = $self->preProcess($html); + decode_entities($html) + if $self->decodeEntitiesWanted; + $self->{inside} = undef; + $self->parse($html); + + my @noConversion = @{$self->getNotConverted}; + foreach my $item (@{$self->{itemsList}}) + { + foreach (keys %{$item}) + { + next if $_ eq 'url'; + $item->{$_} = $self->convertCharset($item->{$_}) + if ! GCUtils::inArrayTest($_, @noConversion); + } + } + + } + + sub loadPage + { + my ($self, $url, $post, $noSave) = @_; + my $debugPhase = $ENV{GCS_DEBUG_PLUGIN_PHASE}; + my $debugFile; + $debugFile = File::Spec->tmpdir.'/'.GCUtils::getSafeFileName($url) + if ($debugPhase > 0); + $self->{loadedUrl} = $url if ! $noSave; + my $response; + my $result; + if ($debugPhase != 2) + { + if ($post) + { + $response = $ua->post($url, $post); + } + else + { + $response = $ua->get($url); + } + + #UnclePetros 03/07/2011: + #code to handle correctly 302 response messages + my $label1 = $response->code; + if($response->code == '302'){ + my $location = $response->header("location"); + $response = $ua->get($location); + $self->{loadedUrl} = $location; + } + + eval { + $result = $response->decoded_content; + }; + if ($debugPhase == 1) + { + open DEBUG_FILE, ">$debugFile"; + print DEBUG_FILE ($result || $response->content); + close DEBUG_FILE; + } + } + else + { + local $/; + open DEBUG_FILE, "$debugFile"; + $result = ; + utf8::decode($result); + } + return $result || ($response && $response->content); + } + + sub capWord + { + my ($self, $msg) = @_; + + use locale; + + (my $newmsg = lc $msg) =~ s/(\s|,|^)(\w)(\w)(\w*?)/$1\U$2\E$3$4/gi; + return $newmsg; + } + + sub getSearchFieldsArray + { + return ['']; + } + + sub getSearchFields + { + my ($self, $model) = @_; + + my $result = ''; + $result .= $model->getDisplayedLabel($_).', ' foreach (@{$self->getSearchFieldsArray}); + $result =~ s/, $//; + return $result; + } + + sub hasField + { + my ($self, $field) = @_; + + return $self->{hasField}->{$field}; + } + + sub getExtra + { + return ''; + } + + # Character set for web page text + sub getCharset + { + my $self = shift; + + return "ISO-8859-1"; + } + + # Character set for encoding search term, can sometimes be different + # to the page encoding, but we default to the same as the page set + sub getSearchCharset + { + my $self = shift; + + return getCharset; + } + + # For some plugins, we need extra checks to determine if urls match + # the language the plugin is written for. This allows us to correctly determine + # if a drag and dropped url is handled by a particular plugin. If these + # checks are necessary, return 1, and make sure plugin handles the + # the testURL function correctly + sub needsLanguageTest + { + return 0; + } + + # Used to test if a given url is handled by the plugin. Only required if + # needsLanguageTest is true. + sub testURL + { + my ($self, $url) = @_; + return 1 + } + + # Determines whether plugin should be the default plugins gcstar uses. + # Plugins with this attribute set will appear first in plugin list, + # and will be highlighted with a star icon. A returned value of 1 + # means the plugin is preferred if it's language matches the user's language, + # a returned value of 2 mean's it's preferred regardless of the language. + sub isPreferred + { + return 0; + } + + sub getPreferred + { + return isPreferred; + } + + sub getNotConverted + { + my $self = shift; + return []; + } + + sub decodeEntitiesWanted + { + return 1; + } + + sub getDefaultPictureSuffix + { + return ''; + } + + sub convertCharset + { + my ($self, $value) = @_; + + my $result = $value; + if (ref($value) eq 'ARRAY') + { + foreach my $line(@{$value}) + { + my $i = 0; + map {$_ = decode($self->getCharset, $_)} @{$line}; + } + } + else + { + eval { + $result = decode($self->getCharset, $result); + }; + } + return $result; + } + + sub getItemInfo + { + my $self = shift; + + eval { + $self->init; + }; + my $idx = $self->{wantedIdx}; + my $url = $self->getItemUrl($self->{itemsList}[$idx]->{url}); + $self->loadUrl($url); + return $self->{curInfo}; + } + + sub changeUrl + { + my ($self, $url) = @_; + + return $url; + } + + sub loadUrl + { + my ($self, $url) = @_; + $self->checkProxy; + $self->checkCookieJar; + my $realUrl = $self->changeUrl($url); + my $html = $self->loadPage($realUrl); + $self->{parsingList} = 0; + #$html = $self->convertCharset($html); + $self->{curInfo} = {}; + + $html = $self->preProcess($html); + decode_entities($html) + if $self->decodeEntitiesWanted; + + $self->{curInfo}->{$self->{urlField}} = $url; + $self->{inside} = undef; + $self->parse($html); + + my @noConversion = @{$self->getNotConverted}; + foreach (keys %{$self->{curInfo}}) + { + next if $_ eq $self->{urlField}; + $self->{curInfo}->{$_} = $self->convertCharset($self->{curInfo}->{$_}) + if ! GCUtils::inArrayTest($_, @noConversion); + if (ref($self->{curInfo}->{$_}) ne 'ARRAY') + { + $self->{curInfo}->{$_} =~ s/\|/,/gm; + $self->{curInfo}->{$_} =~ s/\r//gm; + $self->{curInfo}->{$_} =~ s/[ \t]*$//gm; + } + } + $self->{curInfo}->{$self->{urlField}} .= $GCModel::linkNameSeparator.$self->getName; + return $self->{curInfo}; + } + + sub setProxy + { + my ($self, $proxy) = @_; + + $self->{proxy} = $proxy; + } + + sub checkProxy + { + my $self = shift; + $ua->proxy(['http'], $self->{proxy}); + #$self->{ua}->proxy(['http'], $self->{proxy}); + } + + sub setCookieJar + { + my ($self, $cookieJar) = @_; + $self->{cookieJar} = $cookieJar; + } + + sub checkCookieJar + { + my $self = shift; + $ua->cookie_jar(HTTP::Cookies::Netscape->new( + 'file' => "$self->{cookieJar}", + 'autosave' => 1,)); + } + + # Used to set the number of passes the plugin requires + sub getNumberPasses + { + # Most plugins only need to search once, so default to one pass + return 1; + } + + # Returns undef if it doesn't support search using barcode scanner + sub getEanField + { + return undef; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCTVepisodes/GCTVepisodesCommon.pm b/lib/gcstar/GCPlugins/GCTVepisodes/GCTVepisodesCommon.pm new file mode 100644 index 0000000..478f1b8 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCTVepisodes/GCTVepisodesCommon.pm @@ -0,0 +1,67 @@ +package GCPlugins::GCTVepisodes::GCTVepisodesCommon; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; + +our $MAX_ACTORS = 10; +our $MAX_DIRECTORS = 4; + +use GCPlugins::GCPluginsBase; + +{ + package GCPlugins::GCTVepisodes::GCTVepisodesPluginsBase; + + use base qw(GCPluginParser); + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + return $self; + } + + sub getSearchFieldsArray + { + return ['series']; + } + + sub loadUrl + { + my ($self, $url) = @_; + + $self->SUPER::loadUrl($url); + + if (! $self->{curInfo}->{title} && $self->{curInfo}->{original}) + { + $self->{curInfo}->{title} = $self->{curInfo}->{original}; + $self->{curInfo}->{original} = ''; + } + return $self->{curInfo}; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCTVepisodes/GCTvdb.pm b/lib/gcstar/GCPlugins/GCTVepisodes/GCTvdb.pm new file mode 100644 index 0000000..f275ca5 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCTVepisodes/GCTvdb.pm @@ -0,0 +1,360 @@ +package GCPlugins::GCTVepisodes::GCTvdb; + +################################################### +# +# Copyright 2005-2007 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; + +use GCPlugins::GCTVepisodes::GCTVepisodesCommon; + + +{ + package GCPlugins::GCTVepisodes::GCPluginTvdb; + + use base qw(GCPlugins::GCTVepisodes::GCTVepisodesPluginsBase); + use XML::Simple; + use Encode; + use LWP::Simple qw($ua); + + sub parse + { + my ($self, $page) = @_; + return if $page =~ /^new; + + if ($self->{pass} eq 1) + { + # Searching on series name + $xml = $xs->XMLin( + $page, + ForceArray => ['Series'], + KeyAttr => [] + ); + + foreach my $series ( @{$xml->{Series}}) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{nextUrl} = "http://www.thetvdb.com/api/A8CC4AF70D0385F3/series/".$series->{id}."/all/".$self->siteLanguage().".xml"; + $self->{itemsList}[$self->{itemIdx}]->{name} = $series->{SeriesName}; + $self->{itemsList}[$self->{itemIdx}]->{firstaired} = $series->{FirstAired}; + } + } + else + { + if ($self->{parsingList}) + { + # Searching on episodes + $xml = $xs->XMLin( + $page, + ForceArray => ['Episode'], + KeyAttr => [], + + ); + + foreach my $episode (@{$xml->{Episode}}) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{name} = $episode->{EpisodeName} + if (!ref($episode->{EpisodeName})); + $self->{itemsList}[$self->{itemIdx}]->{season} = $episode->{SeasonNumber}; + $self->{itemsList}[$self->{itemIdx}]->{episode} = $episode->{EpisodeNumber}; + $self->{itemsList}[$self->{itemIdx}]->{director} = $episode->{Director} + if (!ref($episode->{Director})); + $self->{itemsList}[$self->{itemIdx}]->{writer} = $episode->{Writer} + if (!ref($episode->{Writer})); + $self->{itemsList}[$self->{itemIdx}]->{overview} = $episode->{Overview} + if (!ref($episode->{Overview})); + $self->{itemsList}[$self->{itemIdx}]->{image} = "http://thetvdb.com/banners/".$episode->{filename} + if (!ref($episode->{filename})); + $self->{itemsList}[$self->{itemIdx}]->{series} = $xml->{Series}->{SeriesName} + if (!ref($xml->{Series}->{SeriesName})); + $self->{itemsList}[$self->{itemIdx}]->{firstaired} = $xml->{Series}->{FirstAired} + if (!ref($xml->{Series}->{FirstAired})); + $self->{itemsList}[$self->{itemIdx}]->{actors} = $xml->{Series}->{Actors} + if (!ref($xml->{Series}->{Actors})); + $self->{itemsList}[$self->{itemIdx}]->{genre} = $xml->{Series}->{Genre} + if (!ref($xml->{Series}->{Genre})); + $self->{itemsList}[$self->{itemIdx}]->{runtime} = $xml->{Series}->{Runtime} + if (!ref($xml->{Series}->{Runtime})); + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://www.thetvdb.com/?tab=episode&seriesid=".$episode->{seriesid}."&seasonid=".$episode->{seasonid}."&id=".$episode->{id}."&lid=".$self->siteLanguageCode(); + } + } + elsif ($self->{pass} != 2) + { + # Process a given url + $xml = $xs->XMLin( + $page, + ForceArray => ['Episode'], + KeyAttr => [], + ); + + # Need to grab the generic series info too + my $response = $ua->get('http://www.thetvdb.com/api/A8CC4AF70D0385F3/series/'.$xml->{Episode}[0]->{seriesid}.'/'.$self->siteLanguage().'.xml'); + my $result; + eval { + $result = $response->decoded_content; + }; + my $seriesxml = $xs->XMLin( + $result, + ForceArray => ['Series'], + KeyAttr => [], + ); + $self->{curInfo}->{season} = $xml->{Episode}[0]->{SeasonNumber}; + $self->{curInfo}->{episode} = $xml->{Episode}[0]->{EpisodeNumber}; + $self->{curInfo}->{name} = $xml->{Episode}[0]->{EpisodeName}; + $self->{curInfo}->{series} = $seriesxml->{Series}[0]->{SeriesName}; + $self->{curInfo}->{director} = $xml->{Episode}[0]->{Director} + if (!ref($xml->{Episode}[0]->{Director})); + $self->{curInfo}->{director} =~ s/^\|//; + $self->{curInfo}->{director} =~ s/\|$//; + $self->{curInfo}->{firstaired} = $xml->{Episode}[0]->{FirstAired} + if (!ref($xml->{Episode}[0]->{FirstAired})); + $self->{curInfo}->{writer} = $xml->{Episode}[0]->{Writer} + if (!ref($xml->{Episode}[0]->{Writer})); + $self->{curInfo}->{writer} =~ s/^\|//; + $self->{curInfo}->{writer} =~ s/\|$//; + + if (!ref($seriesxml->{Series}[0]->{Actors})) + { + my $actorString = $seriesxml->{Series}[0]->{Actors}; + $actorString =~ s/^\|//; + $actorString =~ s/\|$//; + for my $actor (split(/\|/, $actorString)) + { + push @{$self->{curInfo}->{actors}}, [$actor]; + } + } + + if (!ref($seriesxml->{Series}[0]->{Genre})) + { + my $genreString = $seriesxml->{Series}[0]->{Genre}; + $genreString =~ s/^\|//; + $genreString =~ s/\|$//; + for my $genre (split(/\|/, $genreString)) + { + push @{$self->{curInfo}->{genre}}, [$genre]; + } + } + + $self->{curInfo}->{time} = $seriesxml->{Series}[0]->{Runtime}; + $self->{curInfo}->{image} = "http://thetvdb.com/banners/".$xml->{Episode}[0]->{filename} + if (!ref($xml->{Episode}[0]->{filename})); + $self->{curInfo}->{synopsis} = $xml->{Episode}[0]->{Overview} + if (!ref($xml->{Episode}[0]->{Overview})); + $self->{curInfo}->{webPage} = "http://www.thetvdb.com/?tab=episode&seriesid=".$xml->{Episode}[0]->{seriesid}."&seasonid=".$xml->{Episode}[0]->{seasonid}."&id=".$xml->{Episode}[0]->{id}."&lid=".$self->siteLanguageCode(); + } + else + { + $self->{curInfo}->{season} = $self->{itemsList}[$self->{wantedIdx}]->{season}; + $self->{curInfo}->{episode} = $self->{itemsList}[$self->{wantedIdx}]->{episode}; + $self->{curInfo}->{name} = $self->{itemsList}[$self->{wantedIdx}]->{name}; + $self->{curInfo}->{series} = $self->{itemsList}[$self->{wantedIdx}]->{series}; + $self->{curInfo}->{director} = $self->{itemsList}[$self->{wantedIdx}]->{director}; + $self->{curInfo}->{director} =~ s/^\|//; + $self->{curInfo}->{director} =~ s/\|$//; + $self->{curInfo}->{firstaired} = $self->{itemsList}[$self->{wantedIdx}]->{firstaired}; + $self->{curInfo}->{writer} = $self->{itemsList}[$self->{wantedIdx}]->{writer}; + $self->{curInfo}->{writer} =~ s/^\|//; + $self->{curInfo}->{writer} =~ s/\|$//; + + my $actorString = $self->{itemsList}[$self->{wantedIdx}]->{actors}; + $actorString =~ s/^\|//; + $actorString =~ s/\|$//; + for my $actor (split(/\|/, $actorString)) + { + push @{$self->{curInfo}->{actors}}, [$actor]; + } + + my $genreString = $self->{itemsList}[$self->{wantedIdx}]->{genre}; + $genreString =~ s/^\|//; + $genreString =~ s/\|$//; + for my $genre (split(/\|/, $genreString)) + { + push @{$self->{curInfo}->{genre}}, [$genre]; + } + $self->{curInfo}->{time} = $self->{itemsList}[$self->{wantedIdx}]->{runtime}; + $self->{curInfo}->{image} = $self->{itemsList}[$self->{wantedIdx}]->{image}; + $self->{curInfo}->{synopsis} = $self->{itemsList}[$self->{wantedIdx}]->{overview}; + $self->{curInfo}->{webPage} = $self->{itemsList}[$self->{wantedIdx}]->{url}; + } + + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{curName} = undef; + $self->{curUrl} = undef; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + return "http://www.thetvdb.com/api/GetSeries.php?seriesname=$word&language=".$self->siteLanguage(); + } + + sub getItemUrl + { + my ($self, $url) = @_; + if (!$url) + { + # If we're not passed a url, return a hint so that gcstar knows what type + # of addresses this plugin handles + $url = "http://www.thetvdb.com"; + } + elsif (index($url, "api") < 0) + { + # Url isn't for the tvdb api, so we need to find the episode id + # and return a url corresponding to the api page for this movie + + $url =~ /[\?&]id=([0-9]+)*/; + my $id = $1; + $url = "http://www.thetvdb.com/api/A8CC4AF70D0385F3/episodes/$id/".$self->siteLanguage().".xml"; + } + return $url; + } + + sub changeUrl + { + my ($self, $url) = @_; + # Make sure the url is for the api, not the main movie page + return $self->getItemUrl($url); + } + + sub getNumberPasses + { + return 2; + } + + sub getName + { + return "Tvdb"; + } + + sub needsLanguageTest + { + return 1; + } + + sub testURL + { + my ($self, $url) = @_; + $url =~ /[\?&]lid=([0-9]+)*/; + my $id = $1; + return ($id == $self->siteLanguageCode()); + } + + sub getReturnedFields + { + my $self = shift; + + if ($self->{pass} == 1) + { + $self->{hasField} = { + name => 1, + firstaired => 1, + }; + } + else + { + $self->{hasField} = { + name => 1, + season => 1, + episode => 1, + }; + } + } + + sub getAuthor + { + return 'Zombiepig'; + } + + sub getLang + { + return 'EN'; + } + + sub isPreferred + { + return 1; + } + + sub getSearchCharset + { + my $self = shift; + + # Need urls to be double character encoded + return "utf8"; + } + + sub getCharset + { + my $self = shift; + + return "UTF-8"; + } + + sub decodeEntitiesWanted + { + return 0; + } + + sub siteLanguage + { + my $self = shift; + + return 'en'; + } + + sub convertCharset + { + my ($self, $value) = @_; + return $value; + } + + + sub siteLanguageCode + { + my $self = shift; + + return 7; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCTVepisodes/GCTvdbES.pm b/lib/gcstar/GCPlugins/GCTVepisodes/GCTvdbES.pm new file mode 100644 index 0000000..dc753f1 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCTVepisodes/GCTvdbES.pm @@ -0,0 +1,61 @@ +package GCPlugins::GCTVepisodes::GCTvdbES; + +################################################### +# +# 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 GCPlugins::GCTVepisodes::GCTvdb; + + +{ + package GCPlugins::GCTVepisodes::GCPluginTvdbES; + + use base qw(GCPlugins::GCTVepisodes::GCPluginTvdb); + + sub getLang + { + return 'ES'; + } + + sub getName + { + return "Tvdb ES"; + } + + sub siteLanguage + { + my $self = shift; + + return 'es'; + } + + sub siteLanguageCode + { + my $self = shift; + + return 16; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCTVepisodes/GCTvdbFR.pm b/lib/gcstar/GCPlugins/GCTVepisodes/GCTvdbFR.pm new file mode 100644 index 0000000..791cee7 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCTVepisodes/GCTvdbFR.pm @@ -0,0 +1,61 @@ +package GCPlugins::GCTVepisodes::GCTvdbFR; + +################################################### +# +# 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 GCPlugins::GCTVepisodes::GCTvdb; + + +{ + package GCPlugins::GCTVepisodes::GCPluginTvdbFR; + + use base qw(GCPlugins::GCTVepisodes::GCPluginTvdb); + + sub getLang + { + return 'FR'; + } + + sub getName + { + return "Tvdb FR"; + } + + sub siteLanguage + { + my $self = shift; + + return 'fr'; + } + + sub siteLanguageCode + { + my $self = shift; + + return 17; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCTVepisodes/GCTvdbIT.pm b/lib/gcstar/GCPlugins/GCTVepisodes/GCTvdbIT.pm new file mode 100644 index 0000000..c3eab7b --- /dev/null +++ b/lib/gcstar/GCPlugins/GCTVepisodes/GCTvdbIT.pm @@ -0,0 +1,60 @@ +package GCPlugins::GCTVepisodes::GCTvdbIT; + +################################################### +# +# 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 GCPlugins::GCTVepisodes::GCTvdb; + + +{ + package GCPlugins::GCTVepisodes::GCPluginTvdbIT; + + use base qw(GCPlugins::GCTVepisodes::GCPluginTvdb); + + sub getLang + { + return 'IT'; + } + + sub getName + { + return "Tvdb IT"; + } + + sub siteLanguage + { + my $self = shift; + + return 'it'; + } + + sub siteLanguageCode + { + my $self = shift; + + return 15; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCTVseries/GCTVseriesCommon.pm b/lib/gcstar/GCPlugins/GCTVseries/GCTVseriesCommon.pm new file mode 100644 index 0000000..119b1df --- /dev/null +++ b/lib/gcstar/GCPlugins/GCTVseries/GCTVseriesCommon.pm @@ -0,0 +1,53 @@ +package GCPlugins::GCTVseries::GCTVseriesCommon; + +################################################### +# +# Copyright 2005-2009 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; + +our $MAX_ACTORS = 10; +our $MAX_DIRECTORS = 4; + +use GCPlugins::GCPluginsBase; + +{ + package GCPlugins::GCTVseries::GCTVseriesPluginsBase; + + use base qw(GCPluginParser); + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + return $self; + } + + sub getSearchFieldsArray + { + return ['series']; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCTVseries/GCThemoviedb.pm b/lib/gcstar/GCPlugins/GCTVseries/GCThemoviedb.pm new file mode 100644 index 0000000..e4d4eb2 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCTVseries/GCThemoviedb.pm @@ -0,0 +1,340 @@ +package GCPlugins::GCTVseries::GCthemoviedb; + +################################################### +# +# 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::GCTVseries::GCTVseriesCommon; + +{ + + package GCPlugins::GCTVseries::GCPluginThemoviedb; + + use base 'GCPlugins::GCTVseries::GCTVseriesPluginsBase'; + use XML::Simple; + + sub parse + { + my ($self, $page) = @_; + return if $page =~ /^new; + + if ($self->{parsingList}) + { + if ($page !~ m/>Nothing found.<\/movie/) + { + $xml = $xs->XMLin( + $page, + ForceArray => [ 'movie', 'alternative_name' ], + KeyAttr => ['id'] + ); + my $movie; + foreach $movie (keys(%{$xml->{'movies'}->{'movie'}})) + { + # We only want movies, not series and everything else the api returns + if ($xml->{'movies'}->{'movie'}->{$movie}->{'type'} eq "movie") + { + $self->{itemIdx}++; + my $url = "http://api.themoviedb.org/2.1/Movie.getInfo/en/xml/9fc8c3894a459cac8c75e3284b712dfc/" . $movie; + # If the release date is missing, it will be returned as an array, so only save the release if + # it's not an array + my $released = ""; + if (!ref($xml->{'movies'}->{'movie'}->{$movie}->{'released'})) + { + $released = $xml->{'movies'}->{'movie'}->{$movie}->{'released'}; + } + $self->{itemsList}[ $self->{itemIdx} ]->{firstaired} = $released; + $self->{itemsList}[ $self->{itemIdx} ]->{url} = $url; + $self->{itemsList}[ $self->{itemIdx} ]->{title} = + $xml->{'movies'}->{'movie'}->{$movie}->{'name'}; + # Now, check if there's any alternative names, and if so, add them in as + # additional search results. + for my $alternateName ( + @{$xml->{'movies'}->{'movie'}->{$movie}->{alternative_name}}) + { + if (!ref($alternateName)) + { + $self->{itemIdx}++; + $self->{itemsList}[ $self->{itemIdx} ]->{firstaired} = $released; + $self->{itemsList}[ $self->{itemIdx} ]->{url} = $url; + $self->{itemsList}[ $self->{itemIdx} ]->{title} = $alternateName; + } + } + + } + } + } + } + else + { + $xml = $xs->XMLin( + $page, + ForceArray => [ 'country', 'person', 'category', 'size', 'alternative_name' ], + KeyAttr => [''] + ); + + if ( + ( + $xml->{movies}->{movie}->{name} ne + $self->{itemsList}[ $self->{wantedIdx} ]->{title} + ) + && ($self->{itemsList}[ $self->{wantedIdx} ]->{title}) + ) + { + # Name returned by tmdb is different to the one the user selected + # this means they choose an translated name, so use the name they choose + # as the default + $self->{curInfo}->{title} = $self->{itemsList}[ $self->{wantedIdx} ]->{title}; + } + else + { + $self->{curInfo}->{title} = $xml->{movies}->{movie}->{name}; + } + + # Try and guess the series name + $xml->{movies}->{movie}->{name} =~ /^(.*):/; + if ($1 ne '') + { + $self->{curInfo}->{series} = $1; + } + else + { + $self->{curInfo}->{series} = $xml->{movies}->{movie}->{name}; + } + + # Set season to 0 and set special flag + $self->{curInfo}->{season} = 0; + $self->{curInfo}->{specialep} = 1; + + $self->{curInfo}->{webPage} = $xml->{movies}->{movie}->{url}; + + # The following fields could be missing from the xml, so we need to check if they're blank + # (in which case they'll be a array) + $self->{curInfo}->{synopsis} = $xml->{movies}->{movie}->{overview} + if (!ref($xml->{movies}->{movie}->{overview})); + $self->{curInfo}->{ratingpress} = $xml->{movies}->{movie}->{rating} + if (!ref($xml->{movies}->{movie}->{rating})); + $self->{curInfo}->{firstaired} = $xml->{movies}->{movie}->{released} + if (!ref($xml->{movies}->{movie}->{released})); + $self->{curInfo}->{time} = $xml->{movies}->{movie}->{runtime} . " mins" + if (!ref($xml->{movies}->{movie}->{runtime})); + + if (!ref($xml->{movies}->{movie}->{certification})) + { + my $certification; + $certification = $xml->{movies}->{movie}->{certification}; + $self->{curInfo}->{age} = 1 + if ($certification eq 'Unrated') || ($certification eq 'Open'); + $self->{curInfo}->{age} = 2 + if ($certification eq 'G') || ($certification eq 'Approved'); + $self->{curInfo}->{age} = 5 + if ($certification eq 'PG') + || ($certification eq 'M') + || ($certification eq 'GP'); + $self->{curInfo}->{age} = 13 if $certification eq 'PG-13'; + $self->{curInfo}->{age} = 17 if $certification eq 'R'; + $self->{curInfo}->{age} = 18 + if ($certification eq 'NC-17') || ($certification eq 'X'); + } + + for my $country (@{$xml->{movies}->{movie}->{countries}->{country}}) + { + $self->{curInfo}->{country} .= $country->{name} . ', '; + } + $self->{curInfo}->{country} =~ s/, $//; + for my $person (@{$xml->{movies}->{movie}->{cast}->{person}}) + { + my $name = $person->{name}; + # Strip any blank spaces from start and end of name + $name =~ s/\s*$//; + $name =~ s/^\s*//; + if ($person->{job} eq "Director") + { + $self->{curInfo}->{director} .= $name . ', '; + } + if ($person->{job} eq "Producer") + { + $self->{curInfo}->{producer} .= $name . ', '; + } + if ($person->{job} eq "Music") + { + $self->{curInfo}->{music} .= $name . ', '; + } + elsif ($person->{job} eq "Actor") + { + if ($self->{actorsCounter} < $GCPlugins::GCTVseries::GCTVseriesCommon::MAX_ACTORS) + { + + push @{$self->{curInfo}->{actors}}, [$name]; + my $role = $person->{character}; + $role =~ s/\s*$//; + $role =~ s/^\s*//; + push @{$self->{curInfo}->{actors}->[ $self->{actorsCounter} ]}, $role; + $self->{actorsCounter}++; + } + } + } + $self->{curInfo}->{director} =~ s/, $//; + $self->{curInfo}->{producer} =~ s/, $//; + $self->{curInfo}->{music} =~ s/, $//; + for my $category (@{$xml->{movies}->{movie}->{categories}->{category}}) + { + push @{$self->{curInfo}->{genre}}, [ $category->{name} ] + if ($category->{type} eq 'genre'); + } + for my $image (@{$xml->{movies}->{movie}->{images}->{image}}) + { + if ($image->{type} eq "poster") + { + # Fetch either the big original pic, or just the small thumbnail pic + if ( (($self->{bigPics}) && ($image->{size} eq "original")) + || (!($self->{bigPics}) && ($image->{size} eq "thumb"))) + { + if (!$self->{curInfo}->{image}) + { + $self->{curInfo}->{image} = $image->{url}; + } + } + } + } + + # We have to return something as the name, even though this field will get automatically + # calculated for tv series collections. + $self->{curInfo}->{name} = "temp"; + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless($self, $class); + + $self->{hasField} = { + title => 1, + firstaired => 1 + }; + + return $self; + } + + sub getItemUrl + { + my ($self, $url) = @_; + + if (!$url) + { + # If we're not passed a url, return a hint so that gcstar knows what type + # of addresses this plugin handles + $url = "http://www.themoviedb.org"; + } + elsif (index($url, "api") < 0) + { + # Url isn't for the movie db api, so we need to find the movie id + # and return a url corresponding to the api page for this movie + my $found = index(reverse($url), "/"); + if ($found >= 0) + { + my $id = substr(reverse($url), 0, $found); + $url = +"http://api.themoviedb.org/2.1/Movie.getInfo/en/xml/9fc8c3894a459cac8c75e3284b712dfc/" + . reverse($id); + } + } + return $url; + } + + sub preProcess + { + my ($self, $html) = @_; + + return $html; + } + + sub decodeEntitiesWanted + { + return 0; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + return +"http://api.themoviedb.org/2.1/Movie.search/en/xml/9fc8c3894a459cac8c75e3284b712dfc/$word"; + } + + sub changeUrl + { + my ($self, $url) = @_; + # Make sure the url is for the api, not the main movie page + return $self->getItemUrl($url); + } + + sub getName + { + return "The Movie DB"; + } + + sub getAuthor + { + return 'Zombiepig'; + } + + sub getLang + { + return 'EN'; + } + + sub getCharset + { + my $self = shift; + + return "UTF-8"; + } + + sub getSearchCharset + { + my $self = shift; + + # Need urls to be double character encoded + return "utf8"; + } + + sub convertCharset + { + my ($self, $value) = @_; + return $value; + } + + sub getNotConverted + { + my $self = shift; + return []; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCTVseries/GCTvdb.pm b/lib/gcstar/GCPlugins/GCTVseries/GCTvdb.pm new file mode 100644 index 0000000..ca4dc68 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCTVseries/GCTvdb.pm @@ -0,0 +1,466 @@ +package GCPlugins::GCTVseries::GCTvdb; + +################################################### +# +# Copyright 2005-2007 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; + +use GCPlugins::GCTVseries::GCTVseriesCommon; + + +{ + package GCPlugins::GCTVseries::GCPluginTvdb; + + use base qw(GCPlugins::GCTVseries::GCTVseriesPluginsBase); + use XML::Simple; + use Encode; + use LWP::Simple qw($ua); + + sub parse + { + my ($self, $page) = @_; + return if $page =~ /^new; + + if ($self->{pass} eq 1) + { + $xml = $xs->XMLin( + $page, + ForceArray => ['Series'], + KeyAttr => [] + ); + + foreach my $series ( @{$xml->{Series}}) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{nextUrl} = "http://www.thetvdb.com/api/A8CC4AF70D0385F3/series/".$series->{id}."/all/".$self->siteLanguage().".xml"; + $self->{itemsList}[$self->{itemIdx}]->{series} = $series->{SeriesName}; + $self->{itemsList}[$self->{itemIdx}]->{firstaired} = $series->{FirstAired}; + } + } + else + { + if ($self->{parsingList}) + { + # Searching on episodes + $xml = $xs->XMLin( + $page, + ForceArray => ['Episode'], + KeyAttr => [], + ); + + # Need to grab the banners info too + my $response = $ua->get('http://www.thetvdb.com/api/A8CC4AF70D0385F3/series/'.$xml->{Episode}[0]->{seriesid}.'/banners.xml'); + my $result; + eval { + $result = $response->decoded_content; + }; + my $bannersxml = $xs->XMLin( + $result, + ForceArray => ['Banner'], + KeyAttr => [], + ); + + my @seasonNumbers; + foreach my $episode (@{$xml->{Episode}}) + { + if (!grep(/\b$episode->{SeasonNumber}\b/,@seasonNumbers)) + { + push (@seasonNumbers, $episode->{SeasonNumber}); + $self->{itemIdx}++; + + $self->{itemsList}[$self->{itemIdx}]->{series} = $xml->{Series}->{SeriesName} + if (!ref($xml->{Series}->{SeriesName})); + $self->{itemsList}[$self->{itemIdx}]->{season} = $episode->{SeasonNumber}; + $self->{itemsList}[$self->{itemIdx}]->{overview} = $xml->{Series}->{Overview} + if (!ref($xml->{Series}->{Overview})); + + # Find banner + foreach my $banner (@{$bannersxml->{Banner}}) + { + if ($banner->{Season} == $episode->{SeasonNumber}) + { + $self->{itemsList}[$self->{itemIdx}]->{image} = "http://thetvdb.com/banners/".$banner->{BannerPath} + if (!$self->{itemsList}[$self->{itemIdx}]->{image}); + } + } + + my $seasonEpisodes; + # Episodes + my $episodePos = 0; + foreach my $checkEpisode (@{$xml->{Episode}}) + { + if (($checkEpisode->{EpisodeNumber} != 0) || (!ref($checkEpisode->{EpisodeName}))) + { + # Prefer dvd episode numbers + if (($checkEpisode->{DVD_season} == $episode->{SeasonNumber}) + || ((ref($checkEpisode->{DVD_season})) && ($checkEpisode->{SeasonNumber} == $episode->{SeasonNumber}))) + { + if (ref($checkEpisode->{DVD_episodenumber})) + { + push (@{$seasonEpisodes},[ $checkEpisode->{EpisodeNumber}]); + } + else + { + my $trimmedEpNumber = $checkEpisode->{DVD_episodenumber}; + $trimmedEpNumber =~ /^(\d*)/; + push (@{$seasonEpisodes},[ $1]); + } + + push @{$seasonEpisodes->[ $episodePos ]}, $checkEpisode->{EpisodeName}; + $episodePos++; + } + } + } + + # If we found episodes, sort them + if (scalar( $seasonEpisodes) > 0) + { + my @sortedSeasonEpisodes = sort{ $a->[ 0 ] <=> $b->[ 0 ] } @{$seasonEpisodes}; + @{$self->{itemsList}[$self->{itemIdx}]->{episodes}} = @sortedSeasonEpisodes; + } + + + $self->{itemsList}[$self->{itemIdx}]->{firstaired} = $xml->{Series}->{FirstAired} + if (!ref($xml->{Series}->{FirstAired})); + $self->{itemsList}[$self->{itemIdx}]->{actors} = $xml->{Series}->{Actors} + if (!ref($xml->{Series}->{Actors})); + $self->{itemsList}[$self->{itemIdx}]->{genre} = $xml->{Series}->{Genre} + if (!ref($xml->{Series}->{Genre})); + $self->{itemsList}[$self->{itemIdx}]->{runtime} = $xml->{Series}->{Runtime} + if (!ref($xml->{Series}->{Runtime})); + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://www.thetvdb.com/?tab=season&seriesid=".$episode->{seriesid}."&seasonid=".$episode->{seasonid}."&lid=".$self->siteLanguageCode(); + } + } + + } + elsif ($self->{pass} != 2) + { + # Process a given url + $xml = $xs->XMLin( + $page, + ForceArray => ['Episode'], + KeyAttr => [], + ); + + # Need to grab the banners info too + my $response = $ua->get('http://www.thetvdb.com/api/A8CC4AF70D0385F3/series/'.$self->{seriesid}.'/banners.xml'); + my $result; + eval { + $result = $response->decoded_content; + }; + my $bannersxml = $xs->XMLin( + $result, + ForceArray => ['Banner'], + KeyAttr => [], + ); + + $self->{curInfo}->{series} = $xml->{Series}->{SeriesName} + if (!ref($xml->{Series}->{SeriesName})); + $self->{curInfo}->{synopsis} = $xml->{Series}->{Overview} + if (!ref($xml->{Series}->{Overview})); + $self->{curInfo}->{firstaired} = $xml->{Series}->{FirstAired} + if (!ref($xml->{Series}->{FirstAired})); + $self->{curInfo}->{time} = $xml->{Series}->{Runtime} + if (!ref($xml->{Series}->{Runtime})); + + if (!ref($xml->{Series}->{Actors})) + { + my $actorString = $xml->{Series}->{Actors}; + $actorString =~ s/^\|//; + $actorString =~ s/\|$//; + for my $actor (split(/\|/, $actorString)) + { + push @{$self->{curInfo}->{actors}}, [$actor]; + } + } + + if (!ref($xml->{Series}->{Genre})) + { + my $genreString = $xml->{Series}->{Genre}; + $genreString =~ s/^\|//; + $genreString =~ s/\|$//; + for my $genre (split(/\|/, $genreString)) + { + push @{$self->{curInfo}->{genre}}, [$genre]; + } + } + + # Find corresponding season number + foreach my $episode (@{$xml->{Episode}}) + { + if (($episode->{seasonid} == $self->{seasonid}) + && (!$self->{curInfo}->{season})) + { + $self->{curInfo}->{season} = $episode->{SeasonNumber}; + $self->{curInfo}->{webPage} = "http://www.thetvdb.com/?tab=season&seriesid=".$episode->{seriesid}."&seasonid=".$episode->{seasonid}."&lid=".$self->siteLanguageCode(); + } + } + + my $seasonEpisodes; + # Episodes + my $episodePos = 0; + foreach my $checkEpisode (@{$xml->{Episode}}) + { + if (($checkEpisode->{EpisodeNumber} != 0) || (!ref($checkEpisode->{EpisodeName}))) + { + # Prefer dvd episode numbers + if (($checkEpisode->{DVD_season} == $self->{curInfo}->{season}) + || ((ref($checkEpisode->{DVD_season})) && ($checkEpisode->{SeasonNumber} == $self->{curInfo}->{season}))) + { + if (ref($checkEpisode->{DVD_episodenumber})) + { + push (@{$seasonEpisodes},[ $checkEpisode->{EpisodeNumber}]); + } + else + { + my $trimmedEpNumber = $checkEpisode->{DVD_episodenumber}; + $trimmedEpNumber =~ /^(\d*)/; + push (@{$seasonEpisodes},[ $1]); + } + + push @{$seasonEpisodes->[ $episodePos ]}, $checkEpisode->{EpisodeName}; + $episodePos++; + } + } + } + + # If we found episodes, sort them + if (scalar( $seasonEpisodes) > 0) + { + my @sortedSeasonEpisodes = sort{ $a->[ 0 ] <=> $b->[ 0 ] } @{$seasonEpisodes}; + @{$self->{curInfo}->{episodes}} = @sortedSeasonEpisodes; + } + + # Find banner + foreach my $banner (@{$bannersxml->{Banner}}) + { + if ($banner->{Season} == $self->{curInfo}->{season}) + { + $self->{curInfo}->{image} = "http://thetvdb.com/banners/".$banner->{BannerPath} + if (!$self->{curInfo}->{image}); + } + } + + $self->{curInfo}->{name} = "temp"; + + } + else + { + $self->{curInfo}->{season} = $self->{itemsList}[$self->{wantedIdx}]->{season}; + $self->{curInfo}->{episode} = $self->{itemsList}[$self->{wantedIdx}]->{episode}; + $self->{curInfo}->{name} = $self->{itemsList}[$self->{wantedIdx}]->{name}; + $self->{curInfo}->{series} = $self->{itemsList}[$self->{wantedIdx}]->{series}; + $self->{curInfo}->{director} = $self->{itemsList}[$self->{wantedIdx}]->{director}; + $self->{curInfo}->{director} =~ s/^\|//; + $self->{curInfo}->{director} =~ s/\|$//; + $self->{curInfo}->{firstaired} = $self->{itemsList}[$self->{wantedIdx}]->{firstaired}; + $self->{curInfo}->{writer} = $self->{itemsList}[$self->{wantedIdx}]->{writer}; + $self->{curInfo}->{writer} =~ s/^\|//; + $self->{curInfo}->{writer} =~ s/\|$//; + + my $actorString = $self->{itemsList}[$self->{wantedIdx}]->{actors}; + $actorString =~ s/^\|//; + $actorString =~ s/\|$//; + for my $actor (split(/\|/, $actorString)) + { + push @{$self->{curInfo}->{actors}}, [$actor]; + } + + my $genreString = $self->{itemsList}[$self->{wantedIdx}]->{genre}; + $genreString =~ s/^\|//; + $genreString =~ s/\|$//; + for my $genre (split(/\|/, $genreString)) + { + push @{$self->{curInfo}->{genre}}, [$genre]; + } + + $self->{curInfo}->{time} = $self->{itemsList}[$self->{wantedIdx}]->{runtime}; + $self->{curInfo}->{image} = $self->{itemsList}[$self->{wantedIdx}]->{image}; + $self->{curInfo}->{synopsis} = $self->{itemsList}[$self->{wantedIdx}]->{overview}; + $self->{curInfo}->{webPage} = $self->{itemsList}[$self->{wantedIdx}]->{url}; + $self->{curInfo}->{episodes} = $self->{itemsList}[$self->{wantedIdx}]->{episodes}; + } + + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{curName} = undef; + $self->{curUrl} = undef; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + return "http://www.thetvdb.com/api/GetSeries.php?seriesname=$word&language=".$self->siteLanguage(); + } + + sub getItemUrl + { + my ($self, $url) = @_; + if (!$url) + { + # If we're not passed a url, return a hint so that gcstar knows what type + # of addresses this plugin handles + $url = "http://www.thetvdb.com"; + } + elsif (index($url, "api") < 0) + { + # Url isn't for the tvdb api, so we need to find the episode id + # and return a url corresponding to the api page for this movie + + $url =~ /[\?&]id=([0-9]+)*/; + my $id = $1; + $url =~ /[\?&]seriesid=([0-9]+)*/; + $self->{seriesid} = $1; + $url =~ /[\?&]seasonid=([0-9]+)*/; + $self->{seasonid} = $1; + $url = "http://www.thetvdb.com/api/A8CC4AF70D0385F3/series/".$self->{seriesid}."/all/".$self->siteLanguage().".xml"; + } + return $url; + } + + sub changeUrl + { + my ($self, $url) = @_; + # Make sure the url is for the api, not the main movie page + return $self->getItemUrl($url); + } + + sub getNumberPasses + { + return 2; + } + + sub getName + { + return "Tvdb"; + } + + sub needsLanguageTest + { + return 1; + } + + sub testURL + { + my ($self, $url) = @_; + $url =~ /[\?&]lid=([0-9]+)*/; + my $id = $1; + return ($id == $self->siteLanguageCode()); + } + + sub getReturnedFields + { + my $self = shift; + + if ($self->{pass} == 1) + { + $self->{hasField} = { + series => 1, + firstaired => 1, + }; + } + else + { + $self->{hasField} = { + series => 1, + season => 1 + }; + } + } + + sub getAuthor + { + return 'Zombiepig'; + } + + sub getLang + { + return 'EN'; + } + + sub isPreferred + { + return 1; + } + + sub getSearchCharset + { + my $self = shift; + + # Need urls to be double character encoded + return "utf8"; + } + + sub getCharset + { + my $self = shift; + + return "UTF-8"; + } + + sub decodeEntitiesWanted + { + return 0; + } + + sub siteLanguage + { + my $self = shift; + + return 'en'; + } + + sub convertCharset + { + my ($self, $value) = @_; + return $value; + } + + sub siteLanguageCode + { + my $self = shift; + + return 7; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCTVseries/GCTvdbES.pm b/lib/gcstar/GCPlugins/GCTVseries/GCTvdbES.pm new file mode 100644 index 0000000..3943bf0 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCTVseries/GCTvdbES.pm @@ -0,0 +1,61 @@ +package GCPlugins::GCTVseries::GCTvdbES; + +################################################### +# +# 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 GCPlugins::GCTVseries::GCTvdb; + + +{ + package GCPlugins::GCTVseries::GCPluginTvdbES; + + use base qw(GCPlugins::GCTVseries::GCPluginTvdb); + + sub getLang + { + return 'ES'; + } + + sub getName + { + return "Tvdb ES"; + } + + sub siteLanguage + { + my $self = shift; + + return 'es'; + } + + sub siteLanguageCode + { + my $self = shift; + + return 16; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCTVseries/GCTvdbFR.pm b/lib/gcstar/GCPlugins/GCTVseries/GCTvdbFR.pm new file mode 100644 index 0000000..6590f30 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCTVseries/GCTvdbFR.pm @@ -0,0 +1,61 @@ +package GCPlugins::GCTVseries::GCTvdbFR; + +################################################### +# +# 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 GCPlugins::GCTVseries::GCTvdb; + + +{ + package GCPlugins::GCTVseries::GCPluginTvdbFR; + + use base qw(GCPlugins::GCTVseries::GCPluginTvdb); + + sub getLang + { + return 'FR'; + } + + sub getName + { + return "Tvdb FR"; + } + + sub siteLanguage + { + my $self = shift; + + return 'fr'; + } + + sub siteLanguageCode + { + my $self = shift; + + return 17; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCTVseries/GCTvdbIT.pm b/lib/gcstar/GCPlugins/GCTVseries/GCTvdbIT.pm new file mode 100644 index 0000000..cc4da08 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCTVseries/GCTvdbIT.pm @@ -0,0 +1,60 @@ +package GCPlugins::GCTVseries::GCTvdbIT; + +################################################### +# +# 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 GCPlugins::GCTVseries::GCTvdb; + + +{ + package GCPlugins::GCTVseries::GCPluginTvdbIT; + + use base qw(GCPlugins::GCTVseries::GCPluginTvdb); + + sub getLang + { + return 'IT'; + } + + sub getName + { + return "Tvdb IT"; + } + + sub siteLanguage + { + my $self = shift; + + return 'it'; + } + + sub siteLanguageCode + { + my $self = shift; + + return 15; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCboardgames/GCReservoirJeux.pm b/lib/gcstar/GCPlugins/GCboardgames/GCReservoirJeux.pm new file mode 100644 index 0000000..a1a4500 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCboardgames/GCReservoirJeux.pm @@ -0,0 +1,418 @@ +package GCPlugins::GCboardgames::GCReservoirJeux; + +################################################### +# +# 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 GCPlugins::GCboardgames::GCboardgamesCommon; + +{ + package GCPlugins::GCboardgames::GCPluginReservoirJeux; + + use base qw(GCPlugins::GCboardgames::GCboardgamesPluginsBase); + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingEnded}) + { + return; + } + + + if ($self->{parsingList}) + { + # Parse the search results here + if (($tagname eq "h3") && ($attr->{class} =~ /^rusearch_result/)) + { + $self->{itemIdx}++; + $self->{isBoardgame} = 1; + $self->{insideName} = 1; + } + if ($self->{isBoardgame}) + { + if (($tagname eq "a") && ($attr->{href} ne "#") && ($attr->{class} =~ /^lien_item/)) + { + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + $self->{isBoardgame} = 0; + } + } + } + else + { + # Parse the items page here. Basically we do this by seaching for tags which match certain criteria, then preparing to grab + # the text inside these tags + + if (($tagname eq "h1")) + { + $self->{insideName} = 1; + } + elsif (($tagname eq "div")) + { + if ($attr->{id} eq "fiche_technique_image") + { + $self->{insideImage} = 1; + } + elsif ($attr->{id} eq "bloc_centre_extensions") + { + $self->{insideExpansionList} = 1; + } + elsif ($attr->{id} eq "bloc_centre_extensions_bottom") + { + $self->{insideExpansionList} = 0; + } + elsif ($attr->{class} eq "fiche_technique_sep") + { + $self->{insideCategoryRow} = 0; + $self->{insideMechanicRow} = 0; + } + + } + elsif ($tagname eq "img") + { + if ($self->{insideImage}) + { + $self->{curInfo}->{boxpic} = "http://www.reservoir-jeux.com".$attr->{src} if ! $self->{curInfo}->{boxpic}; + $self->{insideImage} = 0; + } + if ($self->{insideExpansionList}) + { + $self->{curInfo}->{expandedby} .= $attr->{alt}.',' + } + } + elsif ($tagname eq "a") + { + if ($attr->{class} eq "lien_item") + { + if ($self->{nextIsExpands}) + { + $self->{insideExpands} = 1; + $self->{nextIsExpands} = 0; + } + + if ($attr->{href} =~ /type=editeur/) + { + $self->{insidePublisher} = 1; + } + elsif ($attr->{href} =~ /type=auteur/) + { + $self->{insideDesigner} = 1; + } + elsif ($attr->{href} =~ /type=illustrateur/) + { + $self->{insideIllustrator} = 1; + } + elsif ($attr->{href} =~ /tag_id=/) + { + if ($self->{insideMechanicRow}) + { + $self->{insideMechanic} = 1; + } + elsif ($self->{insideCategoryRow}) + { + $self->{insideCategory} = 1; + } + } + elsif ($attr->{href} =~ /type=illustrateur/) + { + $self->{insideIllustrator} = 1; + } + + + } + } + elsif (($tagname eq "span") && ($attr->{class} eq "prod_description")) + { + $self->{insideDescription} = 1; + } + + if ($tagname eq "br") + { + if($self->{insideDesignerRow}) + { + $self->{curInfo}->{designedby} =~ s/\s\x2d\s$//g; + $self->{insideDesignerRow} = 0; + } + if($self->{insideIllustratorRow}) + { + $self->{curInfo}->{illustratedby} =~ s/\s\x2d\s$//g; + $self->{insideIllustratorRow} = 0; + } + } + + if ($self->{insideDescription}) + { + if (($tagname eq "br") || ($tagname eq "p")) + { + # neatens up the description a little by starting new line on br tags + $self->{curInfo}->{description} .= "\n"; + } + elsif ($tagname eq "li") + { + # basic formatting of lists + $self->{curInfo}->{description} .= " - "; + } + } + } + } + + sub end + { + my ($self, $tagname) = @_; + $self->{inside}->{$tagname}--; + + if ($self->{insideTechnicalDetails} && $tagname eq "div") + { + $self->{insideTechnicalDetails} = 0; + } + } + + sub text + { + my ($self, $origtext) = @_; + + return if (length($origtext) < 2); + + $origtext =~ s/"/"/g; + $origtext =~ s/³/3/g; + $origtext =~ s/\n//g; + $origtext =~ s/^\s{2,//; + #French accents substitution + $origtext =~ s/à/à/; + $origtext =~ s/À/À/; + $origtext =~ s/é/é/; + + return if ($self->{parsingEnded}); + + if ($self->{parsingList}) + { + if ($self->{isBoardgame} && $self->{insideName}) + { + $self->{itemsList}[$self->{itemIdx}]->{name} = $origtext; + $self->{insideName} = 0; + } + + } + else + { + # Parse the text items page here. + + if ($self->{insideName}) + { + $self->{curInfo}->{name} = $origtext; + $self->{curInfo}->{name} =~ s/^\s+//; + $self->{curInfo}->{name} =~ s/\s+\Z//; + $self->{insideName} = 0; + } + if ($self->{inside}->{h2}) + { + if ($origtext =~ /^Fiche technique/) + { + $self->{insideTechnicalDetails} = 1; + } + elsif ($origtext =~ /^M\xe9canismes/) + { + $self->{insideMechanicRow} = 1; + } + elsif ($origtext =~/^Th\xe8mes/) + { + $self->{insideCategoryRow} = 1; + + } + } + if ($self->{insideTechnicalDetails}) + { + if ($origtext =~ /^Date de sortie/) + { + $self->{curInfo}->{released} = $origtext; + $self->{curInfo}->{released} =~ s/Date de sortie : //g + } + elsif( $origtext =~ /Dur\xe9e : /) + { + $self->{curInfo}->{playingtime} = $origtext; + $self->{curInfo}->{playingtime} =~ s/\s*Dur\xe9e : //g; + } + elsif($origtext =~ /\xc0 partir de\s[0-9]*\sans/) + { + $self->{curInfo}->{suggestedage} = $origtext; + $self->{curInfo}->{suggestedage} =~ s/^\s*//g; + } + elsif ($origtext =~ /De [0-9]* \xe0 [0-9]* joueurs/) + { + $self->{curInfo}->{players} = $origtext; + $self->{curInfo}->{players} =~ s/^\s*De //g; + $self->{curInfo}->{players} =~ s/ joueurs//g; + } + } + if ($self->{insideDesigner}) + { + # Append text (and trailing ,) to existing designer field + $self->{curInfo}->{designedby} .= $origtext." - "; + $self->{insideDesigner} = 0; + } + if ($self->{insideIllustrator}) + { + # Append text (and trailing ,) to existing illustrator field + $self->{curInfo}->{illustratedby} .= $origtext." - "; + $self->{insideIllustrator} = 0; + } + if ($self->{insidePublisher}) + { + $self->{curInfo}->{publishedby} = $origtext; + $self->{insidePublisher} = 0; + } + if ($self->{insideExpands}) + { + $self->{curInfo}->{expansionfor} = $origtext; + $self->{insideExpands} = 0; + } + if ($self->{insideMechanic}) + { + $self->{curInfo}->{mechanics} .= $self->capWord($origtext).','; + $self->{insideMechanic} = 0; + } + if ($self->{insideCategory}) + { + $self->{curInfo}->{category} .= $self->capWord($origtext).','; + $self->{insideCategory} = 0; + } + + + if ($origtext =~ /^\s*Auteur(s)? : /) + { + $self->{insideDesignerRow} = 1; + } + if ($origtext =~ /^\s*Illustrateur(s)? : /) + { + $self->{insideIllustratorRow} = 1; + } + if ($origtext =~ /^Ce produit est une extension de :/) + { + $self->{nextIsExpands} = 1; + } + if ($self->{insideDescription}) + { + $self->{curInfo}->{description} .= $origtext; + } + } + } + + sub comment + { + my ($self, $comment) = @_; + + if ($self->{parsingList}) + { + + } + else + { + if ($comment =~ /\/div/) + { + if($self->{insideDescription}) + { + $self->{insideDescription} = 0; + # remove spaces from start and end of description + $self->{curInfo}->{description} =~ s/^\s+//; + $self->{curInfo}->{description} =~ s/\s+$//; + } + } + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + name => 1, + }; + + $self->{isBoardgame} = 0; + $self->{curName} = undef; + $self->{curUrl} = undef; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + $self->{parsingEnded} = 0; + + $html =~ s/""/'"/g; + $html =~ s/""/"'/g; + $html =~ s|
|
|; + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + # Url returned below is the for the search page, where $word is replaced by the search + return ('http://www.reservoir-jeux.com/recherche.php', ['search' => $word, 'secteurid' => '-1', 'dv' => '30']); + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url if $url =~ /^http:/; + if ($url =~ /^\//) + { + return "http://www.reservoir-jeux.com".$url; + } + else + { + return "http://www.reservoir-jeux.com/".$url; + } + } + + sub getName + { + return "Reservoir Jeux"; + } + + sub getAuthor + { + return 'Florent'; + } + + sub getLang + { + return 'FR'; + } + + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCboardgames/GCboardgamegeek.pm b/lib/gcstar/GCPlugins/GCboardgames/GCboardgamegeek.pm new file mode 100644 index 0000000..038198f --- /dev/null +++ b/lib/gcstar/GCPlugins/GCboardgames/GCboardgamegeek.pm @@ -0,0 +1,278 @@ +package GCPlugins::GCboardgames::GCboardgamegeek; + +################################################### +# +# 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::GCboardgames::GCboardgamesCommon; + +{ + package GCPlugins::GCboardgames::GCPluginboardgamegeek; + + use base qw(GCPlugins::GCboardgames::GCboardgamesPluginsBase); + use XML::Simple; + use HTML::Entities; + use Encode; + + sub parse + { + my ($self, $page) = @_; + return if $page =~ /^new; + + if ($self->{parsingList}) + { + $xml = $xs->XMLin($page, ForceArray => ['boardgame'], KeyAttr => ['objectid']); + my $game; + foreach $game ( keys( %{ $xml -> {'boardgame'}} ) ) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://www.boardgamegeek.com/xmlapi/boardgame/".$game; + # Better check how the name is returned, the bgg api can be a little funny here + if (ref($xml->{'boardgame'}->{$game}->{'name'})) + { + $self->{itemsList}[$self->{itemIdx}]->{name} = $xml->{'boardgame'}->{$game}->{'name'}->{'content'}; + } + else + { + $self->{itemsList}[$self->{itemIdx}]->{name} = $xml->{'boardgame'}->{$game}->{'name'}; + } + + if (!ref($xml->{'boardgame'}->{$game}->{'yearpublished'})) + { + $self->{itemsList}[$self->{itemIdx}]->{released} = $xml->{'boardgame'}->{$game}->{'yearpublished'}; + } + } + } + else + { + $xml = $xs->XMLin($page, ForceArray => ['name','boardgamedesigner','boardgameartist','boardgamepublisher', + 'boardgamecategory','boardgamemechanic','boardgameexpansion'], + KeyAttr => []); + + $self->{curInfo}->{released} = $xml->{boardgame}->{yearpublished}; + $self->{curInfo}->{released} =~ s/([^0-9])//g; + $self->{curInfo}->{players} = $xml->{boardgame}->{minplayers}."-".$xml->{boardgame}->{maxplayers}; + $self->{curInfo}->{playingtime} = $xml->{boardgame}->{playingtime}." mins"; + $self->{curInfo}->{suggestedage} = $xml->{boardgame}->{age}; + + my $primaryName = ""; + for my $name (@{$xml->{boardgame}->{name}}) + { + $primaryName = $name->{content} + if $name->{primary} eq "true"; + } + + if (($primaryName ne $self->{itemsList}[$self->{wantedIdx}]->{name}) + && ($self->{itemsList}[$self->{wantedIdx}]->{name})) + { + # Name returned by boardgamegeek is different to the one the user selected + # this means they choose an translated name, so use the name they choose + # as the default, and put boardgamegeek's name in as the original (untranslated) name of the game + $self->{curInfo}->{name} = $self->{itemsList}[$self->{wantedIdx}]->{name}; + $self->{curInfo}->{original} = $primaryName; + } + else + { + $self->{curInfo}->{name} = $primaryName; + } + + # Have to decode the html type characters here + $self->{curInfo}->{description} = decode_entities($xml->{boardgame}->{description}); + $self->{curInfo}->{description} =~ s/\/\n/g; + $self->{curInfo}->{description} =~ s/<.*?>//g; + + if ($self->{bigPics}) + { + $self->{curInfo}->{boxpic} = $xml->{boardgame}->{image}; + } + else + { + $self->{curInfo}->{boxpic} = $xml->{boardgame}->{thumbnail}; + } + + for my $designer (@{$xml->{boardgame}->{boardgamedesigner}}) + { + $self->{curInfo}->{designedby} .= $designer->{content}.', '; + } + $self->{curInfo}->{designedby} =~ s/, $//; + + for my $artist (@{$xml->{boardgame}->{boardgameartist}}) + { + $self->{curInfo}->{illustratedby} .= $artist->{content}.', '; + } + $self->{curInfo}->{illustratedby} =~ s/, $//; + + for my $publisher (@{$xml->{boardgame}->{boardgamepublisher}}) + { + $self->{curInfo}->{publishedby} .= $publisher->{content}.', '; + } + $self->{curInfo}->{publishedby} =~ s/, $//; + + for my $category (@{$xml->{boardgame}->{boardgamecategory}}) + { + push @{$self->{curInfo}->{category}}, [$category->{content}]; + } + + for my $mechanic (@{$xml->{boardgame}->{boardgamemechanic}}) + { + push @{$self->{curInfo}->{mechanics}}, [$mechanic->{content}]; + } + + for my $expansion (@{$xml->{boardgame}->{boardgameexpansion}}) + { + if ($expansion->{inbound}) + { + if ($self->{curInfo}->{expansionfor}) + { + $self->{curInfo}->{expansionfor} .= ", "; + } + $self->{curInfo}->{expansionfor} .= $expansion->{content}; + } + else + { + push @{$self->{curInfo}->{expandedby}}, [$expansion->{content}]; + } + } + $self->{curInfo}->{web} = "http://boardgamegeek.com/boardgame/".$xml->{boardgame}->{objectid}; + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + name => 1, + released => 1, + }; + + return $self; + } + + sub getItemUrl + { + my ($self, $url) = @_; + + if (!$url) + { + # If we're not passed a url, return a hint so that gcstar knows what type + # of addresses this plugin handles + $url = "http://www.boardgamegeek.com"; + } + elsif (index($url,"xmlapi") < 0) + { + # Url isn't for the bgg api, so we need to find the game id + # and return a url corresponding to the api page for this game + $url =~ /\/([0-9]+)[\/]*/; + my $id = $1; + $url = "http://www.boardgamegeek.com/xmlapi/boardgame/".$id; + } + return $url; + } + + sub preProcess + { + my ($self, $html) = @_; + + return $html; + } + + sub decodeEntitiesWanted + { + return 0; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + # Quick and dirty fixes because the bgg api struggles with some words. Should not be required anymore (7/6/2010) + # $word =~ s/the\+/\+/ig; + # $word =~ s/\+and+/\+/g; + # $word =~ s/\+of\+/\+/g; + + return "http://www.boardgamegeek.com/xmlapi/search?search=$word"; + } + + sub changeUrl + { + my ($self, $url) = @_; + # Make sure the url is for the api, not the main movie page + return $self->getItemUrl($url); + } + + sub getName + { + return "Board Game Geek"; + } + + sub getAuthor + { + return 'Zombiepig'; + } + + sub isPreferred + { + return 1; + } + + sub getLang + { + return 'EN'; + } + + sub getCharset + { + my $self = shift; + + return "UTF-8"; + } + + sub getSearchCharset + { + my $self = shift; + + # Need urls to be double character encoded + return "utf8"; + } + + sub convertCharset + { + my ($self, $value) = @_; + return $value; + } + + sub getNotConverted + { + my $self = shift; + return []; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCboardgames/GCboardgamesCommon.pm b/lib/gcstar/GCPlugins/GCboardgames/GCboardgamesCommon.pm new file mode 100644 index 0000000..088f077 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCboardgames/GCboardgamesCommon.pm @@ -0,0 +1,58 @@ +package GCPlugins::GCboardgames::GCboardgamesCommon; + +################################################### +# +# 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 GCPlugins::GCPluginsBase; + +{ + package GCPlugins::GCboardgames::GCboardgamesPluginsBase; + + use base qw(GCPluginParser); + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + return $self; + } + + sub getSearchFieldsArray + { + return ['name']; + } + + sub loadUrl + { + my ($self, $url) = @_; + + $self->SUPER::loadUrl($url); + + return $self->{curInfo}; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCboardgames/GCtrictrac.pm b/lib/gcstar/GCPlugins/GCboardgames/GCtrictrac.pm new file mode 100644 index 0000000..e30e189 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCboardgames/GCtrictrac.pm @@ -0,0 +1,462 @@ +package GCPlugins::GCboardgames::GCtrictrac; + +################################################### +# +# 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 GCPlugins::GCboardgames::GCboardgamesCommon; + +{ + package GCPlugins::GCboardgames::GCPlugintrictrac; + + use base qw(GCPlugins::GCboardgames::GCboardgamesPluginsBase); + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingEnded}) + { + return; + } + + + if ($self->{parsingList}) + { + # Parse the search results here + + # Check if we are currently parsing an item page, not a search results page (ie - exact match has taken us straight to the page) + # Do this by checking if there is a heading on the page + if (($tagname eq "font") && ($attr->{style} =~ /FONT-SIZE: 20px/)) + { + # Stop parsing results, switch to item parsing + $self->{parsingEnded} = 1; + $self->{itemIdx} = 0; + $self->{itemsList}[0]->{url} = $self->{loadedUrl}; + } + + # Quite easy to parse the search results page since all the information we need (url, title, year) is contained within the + # tag for the image of each search result + + # TODO - check how search results look when they do not have an image?? + + # Check if tag is an , the url referenced is valid (not "#"), and the onmouseover text looks right + if (($tagname eq "a") && ($attr->{href} ne "#") && ($attr->{onmouseover} =~ /^(return overlib)/)) + { + + # Add to search results + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + + my $mouseoverText = $attr->{onmouseover}; + + # Parse some regular expressions to find the name and release date + if ($mouseoverText =~ /(.+)<\/b>/) + { + $self->{itemsList}[$self->{itemIdx}]->{name} = $1; + } + if ($mouseoverText =~ /<\/b> \((\d+)\)/) + { + $self->{itemsList}[$self->{itemIdx}]->{released} = $1; + } + } + } + else + { + # Parse the items page here. Basically we do this by seaching for tags which match certain criteria, then preparing to grab + # the text inside these tags + + if (($tagname eq "font") && ($attr->{style} =~ /FONT-SIZE: 20px/)) + { + $self->{insideName} = 1; + } + elsif (($tagname eq "font") && ($attr->{style} =~ /FONT-SIZE: 12px/)) + { + if ($self->{nextIsPlayers}) + { + $self->{insidePlayers} = 1; + $self->{nextIsPlayers} = 0; + } + if ($self->{nextIsAges}) + { + $self->{insideAges} = 1; + $self->{nextIsAges} = 0; + } + if ($self->{nextIsPlayingTime}) + { + $self->{insidePlayingTime} = 1; + $self->{nextIsPlayingTime} = 0; + } + + } + elsif (($tagname eq "td") && ($attr->{height} eq "250") && ($attr->{width} eq "250")) + { + $self->{insideImage} = 1; + } + elsif ($tagname eq "img") + { + if ($self->{insideImage}) + { + $self->{curInfo}->{boxpic} = "http://trictrac.net".$attr->{src} if ! $self->{curInfo}->{boxpic}; + $self->{insideImage} = 0; + } + } + elsif ($tagname eq "a") + { + if ($self->{nextIsYear}) + { + $self->{insideYear} = 1; + $self->{nextIsYear} = 0; + } + if ($self->{insideDesignerRow}) + { + $self->{insideDesigner} = 1; + } + if ($self->{insideIllustratorRow}) + { + $self->{insideIllustrator} = 1; + } + if ($self->{nextIsPublishers}) + { + $self->{insidePublishers} = 1; + $self->{nextIsPublishers} = 0; + } + if ($self->{insideMechanicRow}) + { + $self->{insideMechanic} = 1; + } + if ($self->{insideCategoryRow}) + { + $self->{insideCategory} = 1; + } + + } + elsif ($tagname eq "b") + { + if ($self->{insideExpansionList}) + { + $self->{insideExpansion} = 1; + } + } + elsif (($tagname eq "p") && ( $attr->{style} =~ /TEXT-ALIGN: justify/)) + { + $self->{insideDescription} = 1; + } + if ($self->{insideDescription}) + { + if ($tagname eq "br") + { + # neatens up the description a little by starting new line on br tags + $self->{curInfo}->{description} .= "\n"; + } + elsif ($tagname eq "li") + { + # basic formatting of lists + $self->{curInfo}->{description} .= " - "; + } + } + } + } + + sub end + { + my ($self, $tagname) = @_; + $self->{inside}->{$tagname}--; + if ($tagname eq "tr") + { + if ($self->{insideDesignerRow}) + { + # Use regex to strip final , off end of line + $self->{curInfo}->{designedby} =~ s/(, )$//; + $self->{insideDesignerRow} = 0; + } + if ($self->{insideIllustratorRow}) + { + # Use regex to strip final , off end of line + $self->{curInfo}->{illustratedby} =~ s/(, )$//; + $self->{insideIllustratorRow} = 0; + } + if ($self->{insideMechanicRow}) + { + $self->{insideMechanicRow} = 0; + } + if ($self->{insideCategoryRow}) + { + $self->{insideCategoryRow} = 0; + } + } + elsif ($tagname eq "table") + { + if ($self->{insideExpansionList}) + { + $self->{insideExpansionList} = 0; + } + } + elsif ($tagname eq "b") + { + if ($self->{insideExpands}) + { + $self->{curInfo}->{expansionfor} =~ s/"//g; + $self->{insideExpands} = 0; + } + } + elsif (($tagname eq "td") && ($self->{insideDescription})) + { + $self->{insideDescription} = 0; + # remove spaces from start and end of description + $self->{curInfo}->{description} =~ s/^\s+//; + $self->{curInfo}->{description} =~ s/\s+$//; + } + } + + sub text + { + my ($self, $origtext) = @_; + + return if (length($origtext) < 2); + + $origtext =~ s/"/"/g; + $origtext =~ s/³/3/g; + $origtext =~ s/\n//g; + $origtext =~ s/^\s{2,//; + #French accents substitution + $origtext =~ s/à/à/; + $origtext =~ s/é/é/; + + return if ($self->{parsingEnded}); + + if ($self->{parsingList}) + { + + } + else + { + # fetching information from page + if ($origtext =~ /^Nom VO/) + { + $self->{curInfo}->{original} = $origtext; + $self->{curInfo}->{original} =~ s/Nom VO : //; + } + if ($self->{insideName}) + { + $self->{curInfo}->{name} = $origtext; + $self->{insideName} = 0; + } + elsif ($self->{insideYear}) + { + $self->{curInfo}->{released} = $origtext; + $self->{curInfo}->{released} =~ s/([^0-9])//g; + $self->{insideYear} = 0; + } + elsif ($self->{insideDesigner}) + { + # Append text (and trailing ,) to existing designer field + $self->{curInfo}->{designedby} .= $origtext.", "; + $self->{insideDesigner} = 0; + } + elsif ($self->{insideIllustrator}) + { + # Append text (and trailing ,) to existing designer field + $self->{curInfo}->{illustratedby} .= $origtext.", "; + $self->{insideIllustrator} = 0; + } + elsif ($self->{insidePublishers}) + { + $self->{curInfo}->{publishedby} = $origtext; + $self->{insidePublishers} = 0; + } + elsif ($self->{insidePlayers}) + { + $self->{curInfo}->{players} = $origtext; + $self->{insidePlayers} = 0; + } + elsif ($self->{insideAges}) + { + $self->{curInfo}->{suggestedage} = $origtext; + $self->{insideAges} = 0; + } + elsif ($self->{insidePlayingTime}) + { + $self->{curInfo}->{playingtime} = $origtext; + $self->{insidePlayingTime} = 0; + } + elsif ($self->{insideExpands}) + { + $self->{curInfo}->{expansionfor} .= $origtext; + + } + elsif ($self->{insideExpansion}) + { + $self->{curInfo}->{expandedby} .= $self->capWord($origtext).','; + $self->{insideExpansion} = 0; + } + elsif ($self->{insideDescription}) + { + $self->{curInfo}->{description} .= $origtext; + } + elsif ($self->{insideMechanic}) + { + $self->{curInfo}->{mechanics} .= $self->capWord($origtext).','; + $self->{insideMechanic} = 0; + } + elsif ($self->{insideCategory}) + { + $self->{curInfo}->{category} .= $self->capWord($origtext).','; + $self->{insideCategory} = 0; + } + + + # Pre-detection based on text (not tags) for various fields + # that have no specific id in tags + if ($origtext =~ /^Ann\xe9e/) + { + $self->{nextIsYear} = 1; + } + if ($origtext =~ /^Auteur/) + { + $self->{insideDesignerRow} = 1; + } + if ($origtext =~ /^Illustrateur/) + { + $self->{insideIllustratorRow} = 1; + } + if ($origtext =~ /^Editeur/) + { + $self->{nextIsPublishers} = 1; + } + if ($origtext =~ /^Joueurs/) + { + $self->{nextIsPlayers} = 1; + } + if ($origtext =~ /^Age/) + { + $self->{nextIsAges} = 1; + } + if ($origtext =~ /^Dur/) + { + $self->{nextIsPlayingTime} = 1; + } + if ($origtext =~ /^Ceci est une extension pour/) + { + $self->{insideExpands} = 1; + } + if ($origtext =~ /canisme\(s\)/) + { + $self->{insideMechanicRow} = 1; + } + if ($origtext =~ /Th.{1,8}me\(s\)/) + { + $self->{insideCategoryRow} = 1; + } + if ($origtext =~ /^Les extensions/) + { + $self->{insideExpansionList} = 1; + } + + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + name => 1, + released => 1, + }; + + $self->{isBoardgame} = 0; + $self->{curName} = undef; + $self->{curUrl} = undef; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + $self->{parsingEnded} = 0; + + $html =~ s/""/'"/g; + $html =~ s/""/"'/g; + $html =~ s|
|
|; + + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + # Url returned below is the for the search page, where $word is replaced by the search + return "http://trictrac.net/index.php3?id=jeux&rub=ludotheque&inf=cat&choix=$word"; + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url if $url =~ /^http:/; + if ($url =~ /^\//) + { + return "http://trictrac.net".$url; + } + else + { + return "http://trictrac.net/".$url; + } + } + + sub getName + { + return "Tric Trac"; + } + + sub getAuthor + { + return 'Florent'; + } + + sub getLang + { + return 'FR'; + } + + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCAdlibrisFI.pm b/lib/gcstar/GCPlugins/GCbooks/GCAdlibrisFI.pm new file mode 100644 index 0000000..34997a8 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCAdlibrisFI.pm @@ -0,0 +1,59 @@ +package GCPlugins::GCbooks::GCAdlibrisFI; + +################################################### +# +# 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 GCPlugins::GCbooks::GCbooksAdlibrisCommon; + +{ + package GCPlugins::GCbooks::GCPluginAdlibrisFI; + + use base qw(GCPlugins::GCbooks::GCbooksAdlibrisPluginsBase); + use URI::Escape; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{isLang} = 'fi'; + + return $self; + } + + sub getName + { + return "Adlibris (FI)"; + } + + sub getLang + { + return 'FI'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCAdlibrisSV.pm b/lib/gcstar/GCPlugins/GCbooks/GCAdlibrisSV.pm new file mode 100644 index 0000000..f17abdb --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCAdlibrisSV.pm @@ -0,0 +1,59 @@ +package GCPlugins::GCbooks::GCAdlibrisSV; + +################################################### +# +# 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 GCPlugins::GCbooks::GCbooksAdlibrisCommon; + +{ + package GCPlugins::GCbooks::GCPluginAdlibrisSV; + + use base qw(GCPlugins::GCbooks::GCbooksAdlibrisPluginsBase); + use URI::Escape; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{isLang} = 'se'; + + return $self; + } + + sub getName + { + return "Adlibris (SV)"; + } + + sub getLang + { + return 'SV'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCAlapage.pm b/lib/gcstar/GCPlugins/GCbooks/GCAlapage.pm new file mode 100644 index 0000000..44f3da0 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCAlapage.pm @@ -0,0 +1,391 @@ +package GCPlugins::GCbooks::GCAlapage; + +################################################### +# +# 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::GCbooks::GCbooksCommon; + +{ + package GCPlugins::GCbooks::GCPluginAlapage; + + use base qw(GCPlugins::GCbooks::GCbooksPluginsBase); + use URI::Escape; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + + if (($tagname eq 'div') && ($attr->{class} eq 'infos_produit')) + { + $self->{isBook} = 1 ; + $self->{isUrl} = 1 ; + } + elsif ($tagname eq 'div') + { + $self->{isBook} = 0 ; + } + elsif (($tagname eq 'a') && ($self->{isUrl}) && ($self->{isBook})) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + $self->{itemsList}[$self->{itemIdx}]->{title} = $attr->{title}; + $self->{isUrl} = 0 ; + } + elsif (($tagname eq 'a') && ( index($attr->{href},"mot_auteurs") >= 0) && ($self->{isBook})) + { + $self->{isAuthor} = 1 ; + } + elsif (($tagname eq 'br') && ($self->{isBook})) + { + $self->{isPublisher} = 1 ; + } + } + else + { + if ($self->{isISBN} eq 1) + { + $self->{isISBN} = 2 ; + } + elsif ($self->{isPublication} eq 1) + { + $self->{isPublication} = 2 ; + } + elsif ($self->{isFormat} eq 1) + { + $self->{isFormat} = 2 ; + } + elsif ($self->{isPage} eq 1) + { + $self->{isPage} = 2 ; + } + elsif ($tagname eq 'h2') + { + $self->{isTitle} = 1 ; + } + elsif (($tagname eq 'tpfcommentaire') && ($self->{isDescription} eq 1)) + { + $self->{isDescription} = 2 ; + } + elsif (($tagname eq 'a') && ( index($attr->{href},"mot_auteurs") >= 0)) + { + $self->{isAuthor} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{class} eq 'thickbox tooltip') && ($self->{curInfo}->{cover} eq '')) + { + my $html = $self->loadPage( "http://www.alapage.com" . $attr->{href}, 0, 1); + my $found = index($html,"\"laplusgrande\""); + if ( $found >= 0 ) + { + my $found2 = index($html,"&m=v"); + $html = substr($html, $found +length('"laplusgrande"'),length($html)- $found -length('"laplusgrande"')); + + my @array = split(/"/,$html); + #" + $self->{curInfo}->{cover} = "http://www.alapage.com" . $array[1]; + if ( $found2 >= 0 ) + { + $self->{curInfo}->{backpic} = $self->{curInfo}->{cover}; + $self->{curInfo}->{backpic} =~ s|&m=r|&m=v|gi; + } + } + } + elsif ($tagname eq 'li') + { + $self->{isAnalyse} = 1 ; + } + elsif (($tagname eq 'a') && ( index($attr->{href},"mot_cdu") >= 0)) + { + $self->{isGenre} = 1 ; + } + elsif (($tagname eq 'a') && ( index($attr->{href},"mot_coll_serie") >= 0)) + { + $self->{isSerie} = 1 ; + } + elsif (($tagname eq 'a') && ( index($attr->{href},"mot_editeur") >= 0) && ( index($attr->{href},"mot_coll_serie") == -1)) + { + $self->{isPublisher} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{name} eq 'comment')) + { + $self->{isDescription} = 1 ; + } + elsif (($tagname eq 'div') && ($attr->{class} eq 'blocWithMargin') && ($self->{isDescription}) && ($self->{curInfo}->{description} eq '') ) + { + $self->{isDescription} = 2 ; + } + elsif (($tagname eq 'a') && ($attr->{name} ne '')) + { + $self->{isDescription} = 0 ; + } + elsif (($tagname eq 'div') && ($attr->{class} eq 'edito FP_commentaire')) + { + $self->{isDescription} = 1 ; + } + + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isAuthor}) + { + # 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}]->{authors} eq '') + { + $self->{itemsList}[$self->{itemIdx}]->{authors} = $origtext; + } + else + { + $self->{itemsList}[$self->{itemIdx}]->{authors} .= ', '; + $self->{itemsList}[$self->{itemIdx}]->{authors} .= $origtext; + } + $self->{isAuthor} = 0 ; + } + elsif ($self->{isPublisher}) + { + my @array = split(/,/,$origtext); + + $self->{itemsList}[$self->{itemIdx}]->{edition} = $array[0]; + $self->{itemsList}[$self->{itemIdx}]->{edition} =~ s/^\s+//; + $self->{itemsList}[$self->{itemIdx}]->{edition} =~ s/\s+$//; + + if ($#array ne 0 ) + { + $self->{itemsList}[$self->{itemIdx}]->{publication} = $array[$#array]; + $self->{itemsList}[$self->{itemIdx}]->{publication} =~ s/^\s+//; + $self->{itemsList}[$self->{itemIdx}]->{publication} =~ s/\s+$//; + } + + $self->{isPublisher} = 0 ; + } + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + if ($self->{isTitle}) + { + $self->{curInfo}->{title} = $origtext; + $self->{curInfo}->{language} = 'Français'; + $self->{isTitle} = 0 ; + } + elsif ($self->{isAuthor}) + { + $self->{curInfo}->{authors} .= $origtext; + $self->{curInfo}->{authors} .= ","; + $self->{isAuthor} = 0 ; + } + elsif ($self->{isAnalyse}) + { + $self->{isISBN} = 1 if ($origtext =~ m/ISBN/i); + $self->{isFormat} = 1 if ($origtext =~ m/Dimensions/i); + $self->{isPublication} = 1 if ($origtext =~ m/Date de parution/i); + $self->{isPage} = 1 if ($origtext =~ m/Nombre de pages/i); + + $self->{isAnalyse} = 0 ; + } + elsif ($self->{isISBN} eq 2) + { + $self->{curInfo}->{isbn} = $origtext; + $self->{isISBN} = 0 ; + } + elsif ($self->{isGenre}) + { + my @array = split(/,/,$origtext); + my $element; + foreach $element (@array) + { + $element =~ s/^\s+//; + $self->{curInfo}->{genre} .= $element; + $self->{curInfo}->{genre} .= ","; + } + $self->{isGenre} = 0 ; + } + elsif ($self->{isPublisher}) + { + $self->{curInfo}->{publisher} = $origtext; + $self->{isPublisher} = 0 ; + } + elsif ($self->{isSerie}) + { + $self->{curInfo}->{serie} = $origtext; + $self->{isSerie} = 0 ; + } + elsif ($self->{isFormat} eq 2) + { + $self->{curInfo}->{format} = $origtext; + $self->{isFormat} = 0 ; + } + elsif ($self->{isPublication} eq 2) + { + $self->{curInfo}->{publication} = $origtext; + $self->{isPublication} = 0 ; + } + elsif ($self->{isPage} eq 2) + { + $self->{curInfo}->{pages} = $origtext; + $self->{isPage} = 0 ; + } + elsif ($self->{isDescription} eq 2) + { + $self->{curInfo}->{description} = $origtext; + $self->{isDescription} = 0 ; + } + + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + authors => 1, + publication => 1, + format => 0, + edition => 1, + serie => 0, + }; + + $self->{isBook} = 0; + $self->{isUrl} = 0; + $self->{isTitle} = 0; + $self->{isAuthor} = 0; + $self->{isPublisher} = 0; + $self->{isAnalyse} = 0; + $self->{isISBN} = 0; + $self->{isGenre} = 0; + $self->{isPublication} = 0; + $self->{isPage} = 0; + $self->{isFormat} = 0; + $self->{isSerie} = 0; + $self->{isDescription} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + $html =~ s|

||gi; + $html =~ s|

||gi; + } + else + { + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|

||gi; + $html =~ s|

||gi; + } + + return $html; + + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + if ($self->{searchField} eq 'isbn') + { + return "http://www.alapage.com/-/Recherche/?type=1&mot_isbn=" . $word; + } + else + { + return "http://www.alapage.com/-/Recherche/?type=1&mot_titre=" . $word; + } + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return "http://www.alapage.com" . $url; + } + + sub getName + { + return "Alapage"; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'FR'; + } + + sub getSearchFieldsArray + { + return ['isbn','title']; + } + + sub getCharset + { + my $self = shift; + return "ISO-8859-15"; + } + + sub getDefaultPictureSuffix + { + return '.jpg'; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCAmazon.pm b/lib/gcstar/GCPlugins/GCbooks/GCAmazon.pm new file mode 100644 index 0000000..7d70ec4 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCAmazon.pm @@ -0,0 +1,352 @@ +package GCPlugins::GCbooks::GCAmazon; + +################################################### +# +# Copyright 2005-2009 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCbooks::GCbooksCommon; + +{ + package GCPlugins::GCbooks::GCPluginAmazon; + + use base qw(GCPlugins::GCbooks::GCbooksPluginsBase); + use XML::Simple; + use LWP::Simple qw($ua); + use Encode; + use HTML::Entities; + use GCUtils; + + sub parse + { + my ($self, $page) = @_; + return if $page =~ /^new; + + if ($self->{parsingList}) + { + $xml = $xs->XMLin($page, ForceArray => ['Item','Author'], KeyAttr => []); + my $book; + foreach $book ( @{ $xml -> {'Items'} -> {'Item'} }) + { + $self->{itemIdx}++; + my $url = $self->baseAWSUrl."&Operation=ItemLookup&ResponseGroup=Large,EditorialReview&ItemId=".$book->{ASIN}; + + $self->{itemsList}[$self->{itemIdx}]->{url} = $url; + $self->{itemsList}[$self->{itemIdx}]->{title} = $book->{ItemAttributes}->{'Title'}; + for my $author (@{$book->{ItemAttributes}->{'Author'}}) + { + $self->{itemsList}[$self->{itemIdx}]->{authors} .= ", " + if $self->{itemsList}[$self->{itemIdx}]->{authors}; + $self->{itemsList}[$self->{itemIdx}]->{authors} .= $author; + } + $self->{itemsList}[$self->{itemIdx}]->{publication} = $book->{ItemAttributes}->{'PublicationDate'}; + $self->{itemsList}[$self->{itemIdx}]->{format} = $book->{ItemAttributes}->{'Binding'}; + $self->{itemsList}[$self->{itemIdx}]->{edition} = $book->{ItemAttributes}->{'Edition'}; + } + } + else + { + $xml = $xs->XMLin($page, ForceArray => ['Author','EditorialReview','Language'], KeyAttr => []); + $self->{curInfo}->{title} = $xml->{Items}->{Item}->{ItemAttributes}->{Title}; + for my $author (@{$xml->{Items}->{Item}->{ItemAttributes}->{Author}}) + { + push @{$self->{curInfo}->{authors}}, [$author]; + } + + my $htmlDescription; + if ($xml->{Items}->{Item}->{EditorialReviews}->{EditorialReview}[0]->{Content}) + { + $htmlDescription = $xml->{Items}->{Item}->{EditorialReviews}->{EditorialReview}[0]->{Content}; + } + else + { + # Unfortunately the api doesn't always return the product description, which is due to + # copyright concerns or something. In this case, grab the product html and parse it for + # the description. + my $response = $ua->get($xml->{Items}->{Item}->{DetailPageURL}); + my $result; + eval { + $result = $response->decoded_content; + }; + + # Replace some bad characters. TODO - will probably need to extend this for de/jp plugins + $result =~ s|\x{92}|'|gi; + $result =~ s|’|'|gi; + $result =~ s|•|*|gi; + $result =~ s|œ|oe|gi; + $result =~ s|…|...|gi; + $result =~ s|\x{85}|...|gi; + $result =~ s|\x{8C}|OE|gi; + $result =~ s|\x{9C}|oe|gi; + $result =~ s|ü|ü|g; + $result =~ s|ß|ß|g; + $result =~ s|ö|ö|g; + $result =~ s|Ü|Ü|g; + $result =~ s|ä|ä|g; + $result =~ s/„/»/gm; + $result =~ s/“/«/gm; + + # Chop out the product description + $result =~ /
(.*?)<(\/)*?div/s; + $htmlDescription = $1; + + # Decode + decode_entities($htmlDescription); + $htmlDescription = decode('ISO-8859-1', $htmlDescription); + } + + # Replace some html with line breaks, strip out the rest + $htmlDescription =~ s/
/\n/ig; + $htmlDescription =~ s/

/\n\n/ig; + $htmlDescription =~ s/<(.*?)>//gi; + $htmlDescription =~ s/^\s*//; + $htmlDescription =~ s/\s*$//; + $htmlDescription =~ s/ {1,}/ /g; + $self->{curInfo}->{description} = $htmlDescription; + + $self->{curInfo}->{publisher} = $xml->{Items}->{Item}->{ItemAttributes}->{Publisher} + if (!ref($xml->{Items}->{Item}->{ItemAttributes}->{Publisher})); + $self->{curInfo}->{publication} = $xml->{Items}->{Item}->{ItemAttributes}->{PublicationDate} + if (!ref($xml->{Items}->{Item}->{ItemAttributes}->{PublicationDate})); + $self->{curInfo}->{language} = $xml->{Items}->{Item}->{ItemAttributes}->{Languages}->{Language}[0]->{Name} + if (ref($xml->{Items}->{Item}->{ItemAttributes}->{Languages}->{Language})); + $self->{curInfo}->{pages} = $xml->{Items}->{Item}->{ItemAttributes}->{NumberOfPages} + if (!ref($xml->{Items}->{Item}->{ItemAttributes}->{NumberOfPages})); + $self->{curInfo}->{isbn} = $xml->{Items}->{Item}->{ItemAttributes}->{EAN} + if (!ref($xml->{Items}->{Item}->{ItemAttributes}->{EAN})); + $self->{curInfo}->{format} = $xml->{Items}->{Item}->{ItemAttributes}->{Binding} + if (!ref($xml->{Items}->{Item}->{ItemAttributes}->{Binding})); + $self->{curInfo}->{edition} = $xml->{Items}->{Item}->{ItemAttributes}->{Edition} + if (!ref($xml->{Items}->{Item}->{ItemAttributes}->{Edition})); + $self->{curInfo}->{web} = $xml->{Items}->{Item}->{DetailPageURL}; + + # Genre handling via Amazon's browsenodes. Stupidly complicated way of doing things, IMO + # Loop through all the nodes: + for my $node (@{$xml->{Items}->{Item}->{BrowseNodes}->{BrowseNode}}) + { + my $genre = ''; + my $ancestor = $node; + + # Push the lowest node to the temporary genre list + my @genre_list = ($node->{Name}); + + # Start stepping down through the current node to find it's children + while ($ancestor->{Ancestors}->{BrowseNode}) + { + $ancestor = $ancestor->{Ancestors}->{BrowseNode}; + if (($ancestor->{Name} eq 'Specialty Stores') || + ($ancestor->{Name} eq 'Refinements') || + ($ancestor->{Name} eq 'Self Service') || + ($ancestor->{Name} eq 'Specialty Boutique')) + { + # Some categories we definetly want to ignore, since they are full of rubbish tags + $genre = 'ignore'; + last; + } + elsif ($ancestor->{Name} =~ m/A\-Z/) + { + # Clear out the current genres from the node, will be full of rubbish like "Authors A-K" + # Keep looping afterwards though, since there could be valid tags below the author + # specific ones + undef(@genre_list); + } + elsif ($ancestor->{Name} eq 'Subjects') + { + # Don't go deeper than a Subjects node + last; + } + else + { + # Add the current node to the temporary list, if it's not already included in either list + push @genre_list, $ancestor->{Name} + if ((!GCUtils::inArrayTest($ancestor->{Name}, @genre_list)) && + (!GCUtils::inArrayTest($ancestor->{Name}, @{$self->{curInfo}->{genre}}))); + } + } + + if ($genre ne 'ignore') + { + # Add temporary list to item info + push @{$self->{curInfo}->{genre}}, [$_] foreach @genre_list; + } + } + + # Let's sort the list for good measure + @{$self->{curInfo}->{genre}} = sort @{$self->{curInfo}->{genre}}; + + + # Fetch either the big original pic, or just the small thumbnail pic + if ($self->{bigPics}) + { + $self->{curInfo}->{cover} = $xml->{Items}->{Item}->{LargeImage}->{URL}; + } + else + { + $self->{curInfo}->{cover} = $xml->{Items}->{Item}->{SmallImage}->{URL}; + } + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + authors => 1, + publication => 1, + format => 1, + edition => 1, + }; + + return $self; + } + + sub getItemUrl + { + my ($self, $url) = @_; + if (!$url) + { + # If we're not passed a url, return a hint so that gcstar knows what type + # of addresses this plugin handles + $url = "http://".$self->baseWWWamazonUrl(); + } + elsif ($url !~ m/sowacs.appspot.com/) + { + # Convert amazon url to aws url + $url =~ /\/dp\/(\w*)[\/|%3F]/; + my $asinid = $1; + $url = $self->baseAWSUrl."&Operation=ItemLookup&ResponseGroup=Large,EditorialReview&ItemId=".$asinid; + } + return $url; + } + + sub preProcess + { + my ($self, $html) = @_; + + return $html; + } + + sub decodeEntitiesWanted + { + return 0; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + my $key = + ($self->{searchField} eq 'authors') ? 'Author' : + ($self->{searchField} eq 'title') ? 'Title' : + ($self->{searchField} eq 'isbn') ? 'Keywords' : + ''; + $word =~ s/\D//g + if $key eq 'Keywords'; + return $self->baseAWSUrl."&Operation=ItemSearch&$key=$word&SearchIndex=Books&ResponseGroup=Medium"; + } + + sub baseAWSUrl + { + my $self = shift; + return "http://sowacs.appspot.com/AWS/%5Bamazon\@gcstar.org%5D".$self->baseAmazonUrl()."/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=AKIAJJ5TJWI62A5OOTQQ&AssociateTag=AKIAJJ5TJWI62A5OOTQQ"; + } + + sub baseAmazonUrl + { + return "ecs.amazonaws.com"; + } + + sub baseWWWamazonUrl + { + return "www.amazon.com"; + } + + sub changeUrl + { + my ($self, $url) = @_; + # Make sure the url is for the api, not the main movie page + return $self->getItemUrl($url); + } + + sub getName + { + return "Amazon (US)"; + } + + sub getAuthor + { + return 'Zombiepig'; + } + + sub getLang + { + return 'EN'; + } + + sub getCharset + { + my $self = shift; + + return "UTF-8"; + } + + sub getSearchCharset + { + my $self = shift; + + # Need urls to be double character encoded + return "utf8"; + } + + sub convertCharset + { + my ($self, $value) = @_; + return $value; + } + + sub getNotConverted + { + my $self = shift; + return []; + } + + sub isPreferred + { + return 1; + } + + sub getSearchFieldsArray + { + return ['title', 'authors', 'isbn']; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCAmazonCA.pm b/lib/gcstar/GCPlugins/GCbooks/GCAmazonCA.pm new file mode 100644 index 0000000..eb51a4c --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCAmazonCA.pm @@ -0,0 +1,61 @@ +package GCPlugins::GCbooks::GCAmazonCA; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; + +use GCPlugins::GCbooks::GCAmazon; + +{ + package GCPlugins::GCbooks::GCPluginAmazonCA; + + use base qw(GCPlugins::GCbooks::GCPluginAmazon); + + sub baseWWWamazonUrl + { + return "www.amazon.ca"; + } + + sub baseAmazonUrl + { + return "ecs.amazonaws.ca"; + } + + sub getName + { + return "Amazon (CA)"; + } + + sub getLang + { + return 'EN'; + } + + sub isPreferred + { + return 0; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCAmazonDE.pm b/lib/gcstar/GCPlugins/GCbooks/GCAmazonDE.pm new file mode 100644 index 0000000..0c87502 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCAmazonDE.pm @@ -0,0 +1,56 @@ +package GCPlugins::GCbooks::GCAmazonDE; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; + +use GCPlugins::GCbooks::GCAmazon; + +{ + package GCPlugins::GCbooks::GCPluginAmazonDE; + + use base qw(GCPlugins::GCbooks::GCPluginAmazon); + + sub baseWWWamazonUrl + { + return "www.amazon.de"; + } + + sub baseAmazonUrl + { + return "ecs.amazonaws.de"; + } + + sub getName + { + return "Amazon (DE)"; + } + + sub getLang + { + return 'DE'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCAmazonFR.pm b/lib/gcstar/GCPlugins/GCbooks/GCAmazonFR.pm new file mode 100644 index 0000000..d87af48 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCAmazonFR.pm @@ -0,0 +1,57 @@ +package GCPlugins::GCbooks::GCAmazonFR; + +################################################### +# +# Copyright 2005-2009 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCbooks::GCAmazon; + +{ + package GCPlugins::GCbooks::GCPluginAmazonFR; + + use base qw(GCPlugins::GCbooks::GCPluginAmazon); + + sub baseWWWamazonUrl + { + return "www.amazon.fr"; + } + + sub baseAmazonUrl + { + return "ecs.amazonaws.fr"; + } + + sub getName + { + return "Amazon (FR)"; + } + + sub getLang + { + return 'FR'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCAmazonUK.pm b/lib/gcstar/GCPlugins/GCbooks/GCAmazonUK.pm new file mode 100644 index 0000000..e39a2de --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCAmazonUK.pm @@ -0,0 +1,61 @@ +package GCPlugins::GCbooks::GCAmazonUK; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; + +use GCPlugins::GCbooks::GCAmazon; + +{ + package GCPlugins::GCbooks::GCPluginAmazonUK; + + use base qw(GCPlugins::GCbooks::GCPluginAmazon); + + sub baseWWWamazonUrl + { + return "www.amazon.co.uk"; + } + + sub baseAmazonUrl + { + return "ecs.amazonaws.co.uk"; + } + + sub getName + { + return "Amazon (UK)"; + } + + sub getLang + { + return 'EN'; + } + + sub isPreferred + { + return 0; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCBDGest.pm b/lib/gcstar/GCPlugins/GCbooks/GCBDGest.pm new file mode 100644 index 0000000..36074aa --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCBDGest.pm @@ -0,0 +1,477 @@ +package GCPlugins::GCbooks::GCBDGest; + +################################################### +# +# Copyright 2005-2006 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCbooks::GCbooksCommon; + +{ + package GCPlugins::GCbooks::GCPluginBDGest; + + use base qw(GCPlugins::GCbooks::GCbooksPluginsBase); + use URI::Escape; + # tableau pour stocker l'identifiant propre à bdgest + my @tableau; + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + # parse une liste de résultat + if ($self->{parsingList}) + { + if (($tagname eq 'tr')) + { + $self->{isBook} = 1 ; + $self->{isUrl} = 1 ; + } + elsif (($tagname eq 'a') && ($self->{isUrl}) && ($self->{isBook}) && (index($attr->{href},"serie-") >= 0)) + { + $self->{itemIdx}++; + $self->{isFound} = 1 ; + $tableau[$self->{itemIdx}] = substr($attr->{href},index( $attr->{href},"#")+1); + #on retravaille l'url pour avoir toutes les pages de la série + my $urlRecherche = substr($attr->{href},0,index($attr->{href},"."))."__10000".substr($attr->{href},index($attr->{href},".")); + $self->{itemsList}[$self->{itemIdx}]->{url} = $urlRecherche; + $self->{isSerie} = 1 ; + $self->{isUrl} = 0 ; + } + elsif (($tagname eq 'a') && ($attr->{name} eq 'TitreAlbum')&& ($self->{isBook}) && ($attr->{title} ne '')) + { + $self->{isTitle} = 1 ; + $self->{itemsList}[$self->{itemIdx}]->{title} = $attr->{title}; + } + elsif (($tagname eq 'td') && $self->{isTitle} eq 1) + { + $self->{isPublisher} = 1 ; + $self->{isTitle} = 0; + } + elsif (($tagname eq 'td') && $self->{isPublisher} eq 2) + { + $self->{isPublication} = 1 ; + $self->{isPublisher} = 0; + } + } + else # parse un item + { + if (($tagname eq 'a') && ($attr->{name} eq $tableau[$self->{wantedIdx}])) + { + $self->{isTitle} = 1 ; + $self->{isCover} = 1; + $self->{isBook} = 1 ; + } + elsif ($tagname eq 'html') + { + $self->{isCover} = 0 ; + } + elsif ($tagname eq 'head') + { + $self->{isCover} = 0 ; + } + elsif (($tagname eq 'a') && ($attr->{name} ne $tableau[$self->{wantedIdx}]) && ($attr->{name} ne '')) + { + $self->{isBook} = 0 ; + } + elsif (($tagname eq 'font') && ($attr->{color} eq '#294A6B') && ($attr->{style} eq 'font-family:Trebuchet MS; FONT-SIZE: 11pt;') && ($self->{isTitle} eq 1)) + { + $self->{isTitle} = 2 ; + } +# elsif (($tagname eq 'a') && ($self->{isCover} eq 0) && (index($attr->{href},"Couvertures") >= 0)) + elsif (($tagname eq 'a') && ($self->{isCover} eq 0)) + { + my $urlimage = $attr->{href}; + $urlimage =~ s/\'//g; + $urlimage =~ s/\)//g; + $urlimage = substr($urlimage,index($urlimage,"Couvertures/")); + $self->{curInfo}->{cover} = 'http://www.bedetheque.com/'.$urlimage; + } + elsif (($tagname eq 'a') && ($self->{isBook}) && (index($attr->{href},"auteur") >= 0)) + { + $self->{isAuthor} = 1 ; + } + elsif (($tagname eq 'td') && ($self->{isPublisher} eq 1)) + { + $self->{isPublisher} = 2 ; + } + elsif (($tagname eq 'td') && $self->{isPublication} eq 1) + { + $self->{isPublication} = 2 ; + } + elsif (($tagname eq 'td') && $self->{isEdition} eq 1) + { + $self->{isEdition} = 2 ; + } + elsif (($tagname eq 'td') && $self->{isFormatPublication} eq 1) + { + $self->{isFormatPublication} = 2 ; + } + elsif (($tagname eq 'td') && $self->{isISBN} eq 1) + { + $self->{isISBN} = 2 ; + } + elsif (($tagname eq 'td') && $self->{isPage} eq 1) + { + $self->{isPage} = 2 ; + } + elsif (($tagname eq 'i') && $self->{isDescription} eq 1) + { + $self->{isDescription} = 2 ; + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{isFound} = 0; + $self->{inside}->{$tagname}--; + + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isSerie}) + { + $self->{itemsList}[$self->{itemIdx}]->{serie} = $origtext; + $self->{isSerie} = 0 ; + } + if ($self->{isPublisher} eq 1) + { + $self->{itemsList}[$self->{itemIdx}]->{edition} = $origtext; + $self->{isPublisher} = 2 ; + } + if ($self->{isPublication} eq 1) + { + $self->{itemsList}[$self->{itemIdx}]->{publication} = $origtext; + $self->{isPublication} = 0 ; + } + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Je reinitialise le champs s il est cense etre vide + $origtext =~ s/#TPFCHAMPSVIDE#//; + if ($self->{isTitle} eq 2) + { + # si le titre contient INT (cas intégrale et donc sans titre de la série) on concaténe la série au titre. + if($origtext =~ /INT/i) + { + # on enléve le préfixe INT ou int et le point + $origtext =~ s/INT//i; + $origtext =~ s/.//; + $self->{curInfo}->{title} = $self->{itemsList}[$self->{wantedIdx}]->{serie}." ".$origtext; + } + else + { + # si numéro avant titre on le transforme en tome et on concaténe avec le nom de la série. + if($origtext =~ /[0-9]./) + { + my $tome = substr($origtext,0,index($origtext,".")); + $tome =~ s/^\s+//; + my $titre = substr($origtext,index($origtext,".")+1); + $titre =~ s/^\s+//; + $self->{curInfo}->{title} = $self->{itemsList}[$self->{wantedIdx}]->{serie}." Tome ".$tome ." : ".$titre; + } + else + { + $self->{curInfo}->{title} = $origtext; + } + } + $self->{curInfo}->{web} = "http://www.bedetheque.com/".$self->{itemsList}[$self->{wantedIdx}]->{url}; + $self->{curInfo}->{serie} = $self->{itemsList}[$self->{wantedIdx}]->{serie}; + $self->{curInfo}->{language} = 'Français'; + $self->{isTitle} = 0 ; + } + elsif (($self->{isAuthor}) && ($self->{nbAuthor} < 3)) + { + # Enleve la virgule entre le nom et le prenom + $origtext =~ s/,//g; + if (($origtext ne '') && ($origtext ne '#TPF NOIR ET BLANC TPF#')) + { + $self->{curInfo}->{authors} .= $origtext; + $self->{curInfo}->{authors} .= ","; + } + $self->{isAuthor} = 0; + $self->{nbAuthor} = $self->{nbAuthor} + 1; + } + elsif ($self->{isPublisher} eq 2) + { + $self->{curInfo}->{publisher} = $origtext; + $self->{isPublisher} = 3 ; + } + elsif ($self->{isPublication} eq 2) + { + $self->{curInfo}->{publication} = $origtext; + $self->{isPublication} = 3 ; + } + elsif ($self->{isEdition} eq 2) + { + $self->{curInfo}->{edition} = $origtext; + $self->{isEdition} = 3 ; + } + elsif ($self->{isFormatPublication} eq 2 ) + { + $self->{curInfo}->{format} = $origtext; + $self->{isFormatPublication} = 3 ; + } + elsif ($self->{isISBN} eq 2) + { + $origtext =~ s/978\-//; + $self->{curInfo}->{isbn} = $origtext; + $self->{isISBN} = 3 ; + } + elsif ($self->{isPage} eq 2) + { + $self->{curInfo}->{pages} = $origtext; + $self->{isPage} = 3 ; + } + elsif ($self->{isDescription} eq 2) + { + if($origtext ne '') + { + if($self->{curInfo}->{description} ne '') + { + $self->{curInfo}->{description} .= "\n\n"; + } + $self->{curInfo}->{description} .= "Info sur cette edition : ".$origtext; + } + $self->{isDescription} = 3 ; + } + elsif ($self->{isBook} eq 1) + { + if (($origtext eq "Editeur :") && ($self->{isPublisher} ne 3)) + { + $self->{isPublisher} = 1; + } + elsif (($origtext eq "Dépot légal :") && ($self->{isPublication} ne 3)) + { + $self->{isPublication} = 1; + } + elsif (($origtext eq "Collection :") && ($self->{isEdition} ne 3)) + { + $self->{isEdition} = 1; + } + elsif (($origtext eq "Taille :") && ($self->{isFormatPublication} ne 3)) + { + $self->{isFormatPublication} = 1; + } + elsif (($origtext eq "ISBN :") && ($self->{isISBN} ne 3)) + { + $self->{isISBN} = 1; + } + elsif (($origtext eq "Planches :") && ($self->{isPage} ne 3)) + { + $self->{isPage} = 1; + } + elsif (($origtext eq "Info édition : ") && ($self->{isDescription} ne 3)) + { + $self->{isDescription} = 1; + } + } + } + } + + sub new + { + #la classe est instancié une seule fois au démarrage de l'appli. + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + serie => 1, + title => 1, + publication => 1, + format => 0, + edition => 1, + }; + $self->{idPage} = 0; + $self->{nbAuthor} = 0; + $self->{isFound} = 0; + $self->{isSerie} = 0; + $self->{isBook} = 0; + $self->{isUrl} = 0; + $self->{isTitle} = 0; + $self->{isAuthor} = 0; + $self->{isFormatPublication} = 0; + $self->{isPublisher} = 0; + $self->{isISBN} = 0; + $self->{isPublication} = 0; + $self->{isFormat} = 0; + $self->{isSerie} = 0; + $self->{isPage} = 0; + $self->{isDescription} = 0; + $self->{isCover} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + #RAZ des variables (entre 2 recherches la classe reste en mémoire) + $self->{idPage} = 0; + $self->{nbAuthor} = 0; + $self->{isFound} = 0; + $self->{isSerie} = 0; + $self->{isEdition} = 0; + $self->{isBook} = 0; + $self->{isUrl} = 0; + $self->{isTitle} = 0; + $self->{isAuthor} = 0; + $self->{isFormatPublication} = 0; + $self->{isPublisher} = 0; + $self->{isISBN} = 0; + $self->{isPublication} = 0; + $self->{isFormat} = 0; + $self->{isSerie} = 0; + $self->{isPage} = 0; + $self->{isDescription} = 0; + $self->{isCover} = 0; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s|||gi; + $html =~ s|

  • |\n* |gi; + $html =~ s|
    |\n|gi; + $html =~ s|
    |\n|gi; + $html =~ s|||gi; + $html =~ s|||gi; +# $html =~ s|||gi; +# $html =~ s|||gi; + $html =~ s|

    |\n|gi; + $html =~ s|

    ||gi; + $html =~ s|\x{92}|'|g; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + + # Quand un champs n est pas renseigne il peut y avoir un souci + $html =~ s||#TPFCHAMPSVIDE#|gi; + + $html =~ s|||gi; + $html =~ s|||gi; + # Ce n est pas un coloriste donc il ne faut pas le rajouter a la liste des auteurs + $html =~ s|<N&B>|#TPF NOIR ET BLANC TPF#|gi; + } + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + # si isbn renseigné alors url de recherche différent + if((length($word) eq 13 || length($word) eq 10) && ($word =~ /[0-9]/)) + { + # si contient pas de caractére - alors insertion de ceux ci pour recherche chez bdgest (ISBN sur 10 au lieu de 13) + if($word =~ /\-/) + { + $word =~ s/978\-//; + return "http://www.bedetheque.com/index.php?R=1&RechISBN=". $word; + } + else + { + # Ajouts des - et enléve le 978 en début si présent + $word =~ s/978//; + + #re calcul de la clé de vérification + my $total = substr($word,0,1)*10; + $total = $total + (substr($word,1,1)*9); + $total = $total + (substr($word,2,1)*8); + $total = $total + (substr($word,3,1)*7); + $total = $total + (substr($word,4,1)*6); + $total = $total + (substr($word,5,1)*5); + $total = $total + (substr($word,6,1)*4); + $total = $total + (substr($word,7,1)*3); + $total = $total + (substr($word,8,1)*2); + $total = 11 - ($total%11); + + if($total eq 10) + { + $total = 'X'; + } + + $word = substr($word,0,1)."-".substr($word,1,2)."%25-%25".substr($word,7,2)."-".$total; + return "http://www.bedetheque.com/index.php?R=1&RechISBN=". $word; + } + } + else + { + return "http://www.bedetheque.com/index.php?R=1&RechSerie=". $word; + } + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return "http://www.bedetheque.com/" . $url; + } + + sub getName + { + return "BDGest"; + } + + sub getCharset + { + my $self = shift; + return "ISO-8859-1"; + } + + sub getAuthor + { + return 'Rataflo'; + } + + sub getLang + { + return 'FR'; + } + + sub getSearchFieldsArray + { + return ['isbn','title']; + } + + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCBibliotekaNarodowa.pm b/lib/gcstar/GCPlugins/GCbooks/GCBibliotekaNarodowa.pm new file mode 100644 index 0000000..927be0b --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCBibliotekaNarodowa.pm @@ -0,0 +1,374 @@ +package GCPlugins::GCbooks::GCbooksBibliotekaNarodowa; + +################################################### +# +# 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::GCbooks::GCbooksCommon; + +my $searchISBN = ""; + +{ + package GCPlugins::GCbooks::GCPluginBibliotekaNarodowa; + + use base qw(GCPlugins::GCbooks::GCbooksPluginsBase); + use URI::Escape; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + if ($tagname eq 'frameset') #od razu mamy wynik + { + $self->{isBook} = 7; + $self->{itemIdx}++; + } + if (($tagname eq 'frame') && ($attr->{name} eq 'bib_frame') && $self->{isBook} == 7) #od razu mamy wynik + { + $self->{isUrl} = 1; + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://alpha.bn.org.pl".$attr->{src}; + $self->{isUrl} = 0; + $self->{isBook} = 0; + } + + if (($tagname eq 'tr') && ($attr->{class} eq 'browseEntry')) + { + $self->{isBook} = 1; + $self->{itemIdx}++; + } + if (($tagname eq 'td') && ($attr->{class} eq 'browseEntryData') && ($self->{isBook} == 1)) + { + $self->{isAuthor} = 2; + } + if (($tagname eq 'a') && ($self->{isBook} == 1) && ($self->{isAuthor} > 0)) + { + $self->{isUrl} = 1; + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://alpha.bn.org.pl".$attr->{href}; + $self->{itemsList}[$self->{itemIdx}]->{url} =~ s|frameset|bibframe|; + $self->{isUrl} = 0; + $self->{isAuthor} = 0; + $self->{isTitle} = 1; + } + if (($tagname eq 'td') && ($attr->{class} eq 'browseEntryYear') && ($self->{isBook} == 1)) + { + $self->{isPublication} = 1; + } + } + else + { + if (($tagname eq 'div') && ($attr->{id} eq 'wrgTIAUTR')) + { + $self->{isTitle} = 1; + $self->{isAuthor} = 1; + $self->{isTranslator} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgISBN')) + { + $self->{isISBN} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgPAGES')) + { + $self->{isPage} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgPUBPD')) + { + $self->{isPublisher} = 1; + $self->{isPublication} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgSERIA')) + { + $self->{isSerie} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgEDITI')) + { + $self->{isEdition} = 1; + } + } + } + + + sub end + { + my ($self, $tagname) = @_; + + if ($self->{parsingList}) + { + if (($tagname eq 'tr') && ($self->{isBook} == 1)) + { + $self->{isBook} = 0; + } + } + + $self->{isFound} = 0; + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + $origtext =~ s|^\s*||m; + $origtext =~ s|\s*$||m; + + if ($self->{parsingList}) + { + if ($self->{isBook} == 1) + { + if ($self->{isTitle} == 1) + { + $self->{itemsList}[$self->{itemIdx}]->{title} = $origtext; + $self->{isTitle} = 0; + } + if ($self->{isAuthor} > 0) + { + $origtext =~ s|\s*\/\s*(.*)\s*;|$1|; + $self->{itemsList}[$self->{itemIdx}]->{authors} = $1; + $self->{isAuthor} = 1; + } + if ($self->{isPublication} == 1) + { + $self->{itemsList}[$self->{itemIdx}]->{edition} = $origtext; + $self->{isPublication} = 0; + } + } + + } + else + { + if (($self->{isTitle} == 1) && ($self->{isAuthor} == 1) && ($self->{isTranslator} == 1)) + { + my ($ti, $au, $tr, $bubu); + $origtext =~ m|.*(\.){1}$|; + $bubu = $1; + if ($bubu eq '.') + { + $origtext =~ s|(.*)\.$|$1|; + } + $origtext =~ m/([^\/]+)(\/\s+[^;]*)?(;\s*.*(tł|przeł|przekł)\..*)?$/; +# $origtext =~ m|([^/]+)(/\s[^;]+)?(;.*)?$|; + $ti = $1; + $au = $2; + $tr = $3; + $ti =~ s|([^:]*):?.*$|$1|; + $ti =~ s|\s*$||; + $self->{curInfo}->{title} = $ti; + $self->{isTitle} = 0; + $au =~ s|^(.*)il\..*$|$1|; + $au =~ s/(\/|tekst)//g; + $au =~ s| i |,|g; + $au =~ s|, |,|g; + $au =~ s|^\s*||; + $au =~ s|\s*$||; + $self->{curInfo}->{authors} = $au; + $self->{isAuthor} = 0; + $tr =~ s|[\[\]]||g; + $tr =~ s/;\s*.*(tł|przeł|przekł)\. (\[.*\] )?(.*)\.?$/$3/; + $tr =~ s|(z \w+\. )?(.*)|$2|; + $self->{curInfo}->{translator} = $tr; + $self->{isTranslator} = 0; + } + if (($self->{isPublisher} == 1) && ($self->{isPublication} == 1)) + { + my ($pu, $pd); + $origtext =~ m|(.*)\s:\s(.*),\s(.*)|; + $pu = $2; + $pd = $3; + $pu =~ s|([^"]*")?([^"]*)"?|$2|; + $pu =~ s|[\[\]]||g; + $self->{curInfo}->{publisher} = $pu; + $self->{isPublisher} = 0; + $pd =~ s|[^\d]||g; + $self->{curInfo}->{publication} = $pd; + $self->{isPublication} = 0; + } + if ($self->{isISBN} eq '1') + { + my ($pom1, $pom2); + if ($self->{searchField} eq 'isbn') + { + $pom1 = $self->{searchISBN}; + $pom2 = $origtext; + $pom2 =~ s|[^\dX]||g; + $pom1 =~ s|-||g; + $pom2 =~ s|-||g; + if ($pom1 eq $pom2) + { + $self->{curInfo}->{isbn} = $self->{searchISBN}; + } + else + { + $self->{curInfo}->{isbn} = $origtext; + } + } + else + { + $self->{curInfo}->{isbn} = $origtext; + } + $self->{isISBN} = 0; + } + if ($self->{isPage} eq '1') + { + $self->{curInfo}->{pages} = $origtext; + $self->{isPage} = 0; + } + if ($self->{isEdition} eq '1') + { + $origtext =~ s|[\[\]]||g; + $origtext =~ s|(.*)\.{1}$|$1|; + $self->{curInfo}->{edition} = $origtext; + $self->{isEdition} = 0; + } + if ($self->{isSerie} eq '1') + { + $self->{curInfo}->{serie} = $origtext; + $self->{isSerie} = 0; + } + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + authors => 1, + publication => 0, + format => 0, + edition => 1, + }; + + $self->{isBook} = 0; + $self->{isUrl} = 0; + $self->{isEditor_Publication_Format_Lang} = 0 ; + $self->{isAnalyse} = 0; + $self->{isFound} = 0; + $self->{isTitle} = 0; + $self->{isAuthor} = 0; + $self->{isPublisher} = 0; + $self->{isISBN} = 0; + $self->{isFormat} = 0; + $self->{isEdition} = 0; + $self->{isPage} = 0; + $self->{isLanguage} = 0; + $self->{isPublication} = 0; + $self->{isSerie} = 0; + $self->{isDescription} = 0; + $self->{isCover} = 0; + $self->{isTranslator} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + $self->{parsingEnded} = 0; + $self->{insideResults} = 0; + + if ($self->{parsingList}) + { + $html =~ s|(.*?)|$1|gms; + $html =~ s|\s*\s*(.*)\s*|$2|gm; + } + else + { + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + + $html =~ s|ISBN\s*<.*>\s*(\w*)|
    $1
    |m; + $html =~ s|Seria\s*<.*>\s*(.*)\s*|
    $1
    |m; + $html =~ s|
    (.*)( / [^<]*)
    |
    $1
    |; + $html =~ s|Opis fiz\s*<.*>\s*(\d*)\D.*|
    $1
    |m; + $html =~ s|TytuŁ\s*<.*>\s*(.*)\s*|
    $1
    |m; + $html =~ s|Adres wyd\s*<.*>\s*(.*)\s*|
    $1
    |m; + $html =~ s|Wydanie\s*<.*>\s*(.*)\s*|
    $1
    |m; + } + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + my $bubu; + if ($self->{searchField} eq 'isbn') + { + $bubu = "i"; + $self->{searchISBN} = $word; + } + else + { + $bubu = "t"; + $self->{searchISBN} = ""; + } + return "http://alpha.bn.org.pl/search*pol/".$bubu."?SEARCH=".$word; + } + + sub getItemUrl + { + my ($self, $url) = @_; + return $url if $url; + return 'http://alpha.bn.org.pl' + } + + sub getName + { + return "Biblioteka Narodowa"; + } + + sub getCharset + { + my $self = shift; + #return "UTF-8"; + return "ISO-8859-2"; + } + + sub getAuthor + { + return 'WG'; + } + + sub getLang + { + return 'PL'; + } + + sub getSearchFieldsArray + { + return ['isbn', 'title']; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCBokkilden.pm b/lib/gcstar/GCPlugins/GCbooks/GCBokkilden.pm new file mode 100644 index 0000000..d32c1f4 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCBokkilden.pm @@ -0,0 +1,295 @@ +package GCPlugins::GCbooks::GCBokkilden; + +################################################### +# +# 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::GCbooks::GCbooksCommon; + +{ + package GCPlugins::GCbooks::GCPluginBokkilden; + + use base qw(GCPlugins::GCbooks::GCbooksPluginsBase); + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingEnded}) + { + if ($self->{itemIdx} < 0) + { + $self->{itemIdx} = 0; + $self->{itemsList}[0]->{url} = $self->{loadedUrl}; + } + return; + } + + if ($self->{parsingList}) + { + if (($tagname eq 'h1') && ($attr->{class} eq 'normal')) + { + $self->{isBook} = 1; + $self->{itemIdx}++; + } + elsif ($self->{isBook}) + { + if ($tagname eq 'a') + { + if (($attr->{href} =~ /produkt\.do/) + && (!$self->{itemsList}[$self->{itemIdx}]->{title})) + { + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + $self->{isTitle} = 1; + } + elsif ($attr->{href} =~ /sok\.do\?enkeltsok/) + { + $self->{isAuthor} = 1; + } + } + } + } + else + { + if ($tagname eq 'table') + { + $self->{isBook} = 1 + if ($attr->{class} eq 'bokfaktatabell'); + } + elsif ($tagname eq 'div') + { + $self->{isCover} = 1 if ($attr->{class} eq 'img-ilus') + && ($attr->{style} eq 'width:120px;'); + $self->{is} = 'description' if $attr->{id} eq 'omtale-hidden'; + } + elsif ($tagname eq 'img') + { + if ($self->{isCover}) + { + $self->{curInfo}->{cover} = 'http://www.bokkilden.no/SamboWeb/' + . $attr->{src}; + $self->{isCover} = 0; + } + } + elsif ($tagname eq 'h1') + { + $self->{h1Style} = $attr->{style}; + } + } + } + + sub end + { + my ($self, $tagname) = @_; + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + return if ($self->{parsingEnded}); + + if ($self->{parsingList}) + { + if ($self->{inside}->{title}) + { + $self->{parsingEnded} = 1 if $origtext !~ /S..?k p..?/; + } + + elsif ($self->{isTitle}) + { + $self->{itemsList}[$self->{itemIdx}]->{title} = $origtext; + $self->{isTitle} = 0; + } + elsif ($self->{isAuthor}) + { + $self->{itemsList}[$self->{itemIdx}]->{authors} .= ',' + if $self->{itemsList}[$self->{itemIdx}]->{authors}; + $self->{itemsList}[$self->{itemIdx}]->{authors} .= $origtext; + $self->{isAuthor} = 0; + } + elsif ($self->{isBook}) + { + if ($origtext =~ / \| /) + { + $origtext =~ /(\d{4})/; + $self->{itemsList}[$self->{itemIdx}]->{publication} = $1; + $self->{isBook} = 0; + } + } + } + else + { + if ($self->{is}) + { + $origtext =~ s/^\s*//; + $self->{curInfo}->{$self->{is}} = $origtext; + if ($self->{is} eq 'genre') + { + $self->{curInfo}->{genre} =~ s/;\s*/,/g; + } + elsif ($self->{is} eq 'pages') + { + $self->{curInfo}->{pages} =~ s/[^0-9]//g; + } + $self->{is} = ''; + } + elsif ($self->{inside}->{title}) + { + $self->{tmpTitle} = $origtext; + } + elsif ($self->{inside}->{h1}) + { + if (!$self->{curInfo}->{title}) + { + if ($self->{h1Style}) + { + $self->{tmpTitle} =~ /\s*(.*?) av (.*?) »/gim; + $self->{curInfo}->{title} = $1; + $self->{curInfo}->{authors} = $2; + } + else + { + $self->{curInfo}->{title} = $origtext; + } + } + } + elsif ($self->{inside}->{author}) + { + $self->{curInfo}->{authors} .= ',' + if $self->{curInfo}->{authors}; + $self->{curInfo}->{authors} .= $origtext; + } + if ($self->{inside}->{translator}) + { + $self->{curInfo}->{translator} .= ', ' + if $self->{curInfo}->{translator}; + $self->{curInfo}->{translator} .= $origtext; + } + elsif (($self->{isBook}) && $self->{inside}->{b}) + { + $self->{is} = + ($origtext eq 'Utgitt: ') ? 'publication' + : ($origtext eq 'Forlag: ') ? 'publisher' + : ($origtext eq 'Innb.: ') ? 'format' + : ($origtext =~ /Spr..?k:/) ? 'language' + : ($origtext eq 'Sider: ') ? 'pages' + : ($origtext eq 'ISBN: ') ? 'isbn' + : ($origtext eq 'Utgave: ') ? 'edition' + : ($origtext eq 'Genre:') ? 'genre' + : ''; + } + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + authors => 1, + publication => 1, + format => 0, + edition => 0, + }; + + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + $self->{parsingEnded} = 0; + $self->{isBook} = 0; + if ($self->{parsingList}) + { + $self->{isTitle} = 0; + $self->{isAuthor} = 0; + } + else + { + $self->{is} = ''; + $self->{isCover} = 0; + $html =~ s|(.*?)|$1|gim; + $html =~ s|([^<]*)|$1|gim; + #" + $html =~ s|(.*?)|$1|gim; + } + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + return "http://www.bokkilden.no/SamboWeb/sok.do?rom=MP&enkeltsok=$word&innsnevre=ja"; + } + + sub getItemUrl + { + my ($self, $url) = @_; + return "http://www.bokkilden.no/SamboWeb/$url" + if $url !~ m|http://www.bokkilden.no/|; + return $url; + } + + sub getCharset + { + my $self = shift; + + return 'UTF-8'; + } + + sub getSearchFieldsArray + { + return ['isbn', 'title']; + } + + sub getName + { + return 'Bokkilden'; + } + + sub getLang + { + return 'NO'; + } + + sub getAuthor + { + return 'Tian'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCBol.pm b/lib/gcstar/GCPlugins/GCbooks/GCBol.pm new file mode 100644 index 0000000..6e882b1 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCBol.pm @@ -0,0 +1,485 @@ +package GCPlugins::GCbooks::GCBol; + +################################################### +# +# Copyright 2005-2006 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCbooks::GCbooksCommon; + +{ + package GCPlugins::GCbooks::GCPluginBol; + + use base qw(GCPlugins::GCbooks::GCbooksPluginsBase); + use URI::Escape; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + if ($tagname eq 'td') + { + if($self->{bookStep} == 0) + { + $self->{bookStep} = 1 ; + } + } + elsif ($tagname eq 'img') + { + if($self->{bookStep} == 1) + { + $self->{bookStep} = 2; + } + } + elsif ($tagname eq 'a') + { + if($self->{bookStep}==2) + { + $self->{url} = "http://www.bol.it" . $attr->{href}; + $self->{bookStep} = 3 ; + $self->{isTitle} = 1 ; + } + elsif($self->{bookStep}==3) + { + $self->{bookStep} = 4 ; + $self->{isAuthor} = 1 ; + } + } + elsif ($tagname eq 'br') + { + if($self->{bookStep}==4) + { + $self->{isBook} = 1; + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $self->{url}; + $self->{itemsList}[$self->{itemIdx}]->{title} = $self->{title}; + $self->{itemsList}[$self->{itemIdx}]->{authors} = $self->{author}; + + $self->{isFormat} = 1 ; + #$self->{bookStep} = 0 ; + } + } + elsif ( + (($tagname ne 'h3') || ( ($tagname eq 'h3') && ($self->{bookStep} != 2) )) && + (($tagname ne 'p') || ( ($tagname eq 'p') && ($self->{bookStep} != 3) )) && + (($tagname ne 'span') || ( ($tagname eq 'span') && ($self->{bookStep} != 4) )) + ) + { + $self->{isTitle} = 0; + $self->{isAuthor} = 0; + $self->{isAnalyse} = 0; + $self->{isDescription} = 0; + $self->{isTranslator} = 0; + $self->{isCover} = 0; + $self->{isGenre} = 0; + $self->{isFormat} = 0; + $self->{isPage} = 0; + $self->{isLanguage} = 0; + $self->{isPublisher} = 0; + $self->{isPublication} = 0; + $self->{isISBN} = 0; + + $self->{isBook} = 0; + $self->{bookStep} = 0; + } + } + else + { + if (($tagname eq 'img') && ($attr->{class} eq 'cover')) + { + $self->{curInfo}->{cover} = "http://www.bol.it" . $attr->{src}; + $self->{bookStep} = 1; + } + elsif (($tagname eq 'h1') && ($self->{bookStep} == 1)) + { + $self->{curInfo}->{title} = "http://www.bol.it" . $attr->{src}; + $self->{isTitle} = 1; + $self->{bookStep} = 2; + } + elsif ($self->{bookStep} == 2) + { + if (($tagname eq 'a') && ($self->{areAuthors} == 0)) + { + $self->{isAuthor} = 1; + $self->{areAuthors} = 1; + } + if ($self->{areAuthors} == 1) + { + if ($tagname eq 'a') + { + $self->{isAuthor} = 1; + } + else + { + $self->{bookStep} = 3; + $self->{areAuthors} = 0; + } + } + } + elsif ($self->{bookStep} == 4) + { + if (($tagname eq 'a') && ($self->{areGenres} == 0)) + { + $self->{isGenre} = 1; + $self->{areGenres} = 1; + } + if ($self->{areGenres} == 1) + { + if ($tagname eq 'a') + { + $self->{isGenre} = 1; + } + else + { + $self->{bookStep} = 5; + $self->{areGenres} = 0; + } + } + } + elsif ($self->{bookStep} == 6) + { + if (($tagname eq 'a') && ($self->{areTranslators} == 0)) + { + $self->{isTranslator} = 1; + $self->{areTranslators} = 1; + } + if ($self->{areTranslators} == 1) + { + if ($tagname eq 'a') + { + $self->{isTranslator} = 1; + } + else + { + $self->{bookStep} = 6; + $self->{areTranslators} = 0; + } + } + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isTitle}) + { + $self->{title} = $origtext; + $self->{isTitle} = 0; + } + elsif ($self->{isAuthor}) + { + $self->{author} = $origtext; + $self->{isAuthor} = 0; + } + elsif ($self->{isFormat}) + { + my @array = split(/\|/,$origtext); + + $self->{itemsList}[$self->{itemIdx}]->{format} = $array[0]; + $self->{itemsList}[$self->{itemIdx}]->{format} =~ s/^\s+//; + $self->{isFormat} = 0; + $self->{isPublisher} = 1; + } + elsif ($self->{isPublisher}) + { + $self->{itemsList}[$self->{itemIdx}]->{edition} = $origtext; + $self->{isPublisher} = 0; + $self->{isPublication} = 1; + } + elsif ($self->{isPublication}) + { + my @array = split(/\|/,$origtext); + + $self->{itemsList}[$self->{itemIdx}]->{publication} = $array[1]; + $self->{itemsList}[$self->{itemIdx}]->{publication} =~ s/^\s+//; + $self->{isPublication} = 0; + } + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//g; + + if ($origtext eq 'I contenuti') + { + $self->{isDescription} = 1; + } + elsif ($origtext eq 'Formato:') + { + $self->{isFormat} = 1; + } + elsif (substr($origtext,0,7) eq 'Pagine:') + { + $self->{isPage} = 1; + } + elsif ($origtext eq 'Lingua:') + { + $self->{isLanguage} = 1; + } + elsif ($origtext eq 'Editore:') + { + $self->{isPublisher} = 1; + } + elsif ($origtext eq 'Anno di pubblicazione') + { + $self->{isPublication} = 1; + } + elsif ($origtext eq 'Codice EAN:') + { + $self->{isISBN} = 1; + } + elsif (($origtext eq 'Traduttore:') || ($origtext eq 'Traduttori:')) + { + $self->{bookStep} = 6; + } + elsif ($origtext eq 'Generi:') + { + $self->{bookStep} = 4; + } + elsif ($origtext ne '') + { + if ($self->{isTitle}) + { + $self->{curInfo}->{title} = $origtext; + $self->{isTitle} = 0 ; + } + elsif ($self->{isAuthor}) + { + if ($self->{curInfo}->{authors} eq '') + { + $self->{curInfo}->{authors} = $origtext; + } + else + { + $self->{curInfo}->{authors} .= ", " . $origtext; + } + $self->{isAuthor} = 0 ; + } + elsif ($self->{isDescription}) + { + $self->{curInfo}->{description} = $origtext; + $self->{isDescription} = 0 ; + } + elsif ($self->{isFormat}) + { + $self->{curInfo}->{format} = $origtext; + $self->{isFormat} = 0; + } + elsif ($self->{isPage}) + { + $self->{curInfo}->{pages} = $origtext; + $self->{isPage} = 0; + } + elsif ($self->{isLanguage}) + { + $self->{curInfo}->{language} = $origtext; + $self->{isLanguage} = 0; + } + elsif ($self->{isPublisher}) + { + $self->{curInfo}->{publisher} = $origtext; + $self->{isPublisher} = 0; + } + elsif ($self->{isPublication}) + { + $self->{curInfo}->{publication} = $origtext; + $self->{isPublication} = 0; + } + elsif ($self->{isISBN}) + { + $self->{curInfo}->{isbn} = $origtext; + $self->{isISBN} = 0; + } + elsif ($self->{isGenre}) + { + if ($self->{curInfo}->{genre} eq '') + { + $self->{curInfo}->{genre} = $origtext; + } + else + { + $self->{curInfo}->{genre} .= ", " . $origtext; + } + $self->{isGenre} = 0 ; + } + elsif ($self->{isTranslator}) + { + if ($self->{curInfo}->{translator} eq '') + { + $self->{curInfo}->{translator} = $origtext; + } + else + { + $self->{curInfo}->{translator} .= ", " . $origtext; + } + $self->{isTranslator} = 0 ; + } + } + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + authors => 1, + publication => 1, + format => 1, + edition => 1, + serie => 0, + }; + + $self->{isTitle} = 0; + $self->{isAuthor} = 0; + $self->{isAnalyse} = 0; + $self->{isDescription} = 0; + $self->{isTranslator} = 0; + $self->{isCover} = 0; + $self->{isGenre} = 0; + $self->{isFormat} = 0; + $self->{isPage} = 0; + $self->{isLanguage} = 0; + $self->{isPublisher} = 0; + $self->{isPublication} = 0; + $self->{isISBN} = 0; + $self->{areAuthors} = 0; + $self->{areGenres} = 0; + $self->{areTranslators} = 0; + + $self->{isBook} = 0; + $self->{bookStep} = 0; + $self->{title} = 0; + $self->{author} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + $html =~ s|
    ||gi; + #$html =~ s/[\n\r\t]//g; + } + else + { + my $found = index($html,''); + if ( $found >= 0 ) + { + $html = substr($html, 0, $found); + } + + $html =~ s|||gi; + $html =~ s|
  • |\n* |gi; + #$html =~ s|
    |\n|gi; + #$html =~ s|
    |\n|gi; + #$html =~ s|||gi; + #$html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|

    |\n|gi; + $html =~ s|

    ||gi; + $html =~ s|\x{92}|'|g; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + } + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + if ($self->{searchField} eq 'isbn') + { + return ('http://www.bol.it/libri/ricerca', ["crc" => "100", "crcselect" => "100", "g" => "$word", "tpr" => "10"] ); + } + else + { + $word =~ s/\+/ /g; + return ('http://www.bol.it/libri/ricerca', ["crc" => "100", "crcselect" => "100", "g" => "$word", "tpr" => "10"] ); + } + + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url if $url; + return 'http://www.bol.it'; + } + + sub getName + { + return "Bol"; + } + + sub getCharset + { + my $self = shift; + return "ISO-8859-15"; + } + + sub getAuthor + { + return 'TPF, UnclePetros'; + } + + sub getLang + { + return 'IT'; + } + + sub getSearchFieldsArray + { + return ['isbn', 'title']; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCBuscape.pm b/lib/gcstar/GCPlugins/GCbooks/GCBuscape.pm new file mode 100644 index 0000000..ad46177 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCBuscape.pm @@ -0,0 +1,479 @@ +package GCPlugins::GCbooks::GCBuscape; + +################################################### +# +# Copyright 2005-2006 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCbooks::GCbooksCommon; + +{ + package GCPlugins::GCbooks::GCPluginBuscape; + + use base qw(GCPlugins::GCbooks::GCbooksPluginsBase); + use URI::Escape; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + + if (($tagname eq 'a') && ($attr->{class} eq 'xu')) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + $self->{isTitle} = 1 ; + } + elsif (( $attr->{class} eq 'xj') && ($self->{itemIdx} eq '-1') && ($self->{searchField} eq 'isbn')) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $self->{loadedUrl}; + } + elsif (($tagname eq 'meta') && ($self->{itemIdx} eq '-1') && ($self->{searchField} eq 'isbn')) + { + my $html = $self->loadPage($self->{loadedUrl}, 0, 1); + my $found = index($html,"URL="); + if ( $found >= 0 ) + { + $html = substr($html, $found +length('URL='),length($html)- $found -length('URL=')); + $html = substr($html, 0, index($html,"\"")); + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $html; + } + } + } + else + { + if (( $attr->{class} eq 'xj') && ($self->{isAnalyse} eq 0)) + { + $self->{isAnalyse} = 1 ; + } + elsif (($tagname eq 'img') && ($attr->{onerror} ne '') && ($self->{curInfo}->{title} eq '')) + { + # Attention il y a 2 formats differents pour ce site + if ($attr->{alt} ne '') + { + $self->{curInfo}->{title} = $attr->{alt}; + } + if ($attr->{title} ne '') + { + my @array = split(/\(/,reverse($attr->{title})); + my @array2; + if ($array[1] ne '') + { + $self->{curInfo}->{isbn} = reverse($array[0]); + $self->{curInfo}->{isbn} =~ s/\)//; + # J enleve le premier champs qui est sense etre le code ISBN + shift(@array); + my $element1; + my $element2; + foreach $element1 (@array) + { + if ($element2 eq '') + { + $element2 = $element1; + } + else + { + $element2 .= "(" .$element1; + } + } + @array2 = split(/-/,$element2); + } + else + { + @array2 = split(/-/,$array[0]); + } + + if ($array2[1] ne '') + { + # J enleve le dernier champs qui est l auteur + shift(@array2); + } + my $element; + foreach $element (@array2) + { + if ($self->{curInfo}->{title} eq '') + { + $self->{curInfo}->{title} = $element; + } + else + { + $self->{curInfo}->{title} .= "-" .$element; + } + } + $self->{curInfo}->{title} = reverse($self->{curInfo}->{title}); + } + + $self->{curInfo}->{cover} = $attr->{src}; + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isTitle}) + { + my @array = split(/\(/,reverse($origtext)); + my @array2; + if ($array[1] ne '') + { + # J enleve le premier champs qui est sense etre le code ISBN + shift(@array); + my $element1; + my $element2; + foreach $element1 (@array) + { + if ($element2 eq '') + { + $element2 = $element1; + } + else + { + $element2 .= "(" .$element1; + } + } + @array2 = split(/-/,$element2); + } + else + { + @array2 = split(/-/,$array[0]); + } + + if ($array2[1] ne '') + { + $self->{itemsList}[$self->{itemIdx}]->{authors} = reverse($array2[0]); + my $found = index($self->{itemsList}[$self->{itemIdx}]->{authors}," Cod:"); + if ( $found >= 0 ) + { + $self->{itemsList}[$self->{itemIdx}]->{authors} = substr($self->{itemsList}[$self->{itemIdx}]->{authors}, 0, $found); + } + # Enleve les blancs en debut de chaine + $self->{itemsList}[$self->{itemIdx}]->{authors} =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $self->{itemsList}[$self->{itemIdx}]->{authors} =~ s/\s+$//g; + shift(@array2); + } + my $element; + foreach $element (@array2) + { + if ($self->{itemsList}[$self->{itemIdx}]->{title} eq '') + { + $self->{itemsList}[$self->{itemIdx}]->{title} = $element; + } + else + { + $self->{itemsList}[$self->{itemIdx}]->{title} .= "-" .$element; + } + } + $self->{itemsList}[$self->{itemIdx}]->{title} = reverse($self->{itemsList}[$self->{itemIdx}]->{title}); + $self->{isTitle} = 0 ; + } + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//g; + if ($self->{isAnalyse} eq 1) + { + if ($origtext =~ m/Autor/i) + { + $self->{isAuthor} = 1 ; + $self->{isAnalyse} = 2 ; + } + elsif ($origtext =~ m/Editora/i) + { + $self->{isPublisher} = 1 ; + $self->{isAnalyse} = 2 ; + } + elsif ($origtext =~ m/Ano de edi/i) + { + $self->{isPublication} = 1 ; + $self->{isAnalyse} = 2 ; + } + elsif ($origtext =~ m/N.* de p.*ginas/i) + { + $self->{isPage} = 1 ; + $self->{isAnalyse} = 2 ; + } + elsif ($origtext =~ m/ISBN/i) + { + $self->{isISBN} = 1 ; + $self->{isAnalyse} = 2 ; + } + elsif ($origtext =~ m/Encaderna/i) + { + $self->{isFormat} = 1 ; + $self->{isAnalyse} = 2 ; + } + else + { + $self->{isAnalyse} = 0 ; + } + + } + elsif ($self->{isAuthor} eq 1) + { + $self->{isAuthor} = 2 ; + } + elsif ($self->{isAuthor} eq 2) + { + if ($origtext =~ m/N.*o Cadastrado/i) + { + } + else + { + my @nom_prenom = split(/,/,$origtext); + # Enleve les blancs en debut de chaine + $nom_prenom[0] =~ s/^\s//; + $nom_prenom[1] =~ s/^\s//; + # Enleve les blancs en fin de chaine + $nom_prenom[0] =~ s/\s+$//; + $nom_prenom[1] =~ s/\s+$//; + if ($self->{curInfo}->{authors} eq '') + { + if ($nom_prenom[1] ne '') + { + $self->{curInfo}->{authors} = $nom_prenom[1] ." " . $nom_prenom[0]; + } + else + { + $self->{curInfo}->{authors} = $nom_prenom[0]; + } + } + else + { + if ($nom_prenom[1] ne '') + { + $self->{curInfo}->{authors} .= ", " . $nom_prenom[1] ." " . $nom_prenom[0]; + } + else + { + $self->{curInfo}->{authors} .= ", " . $nom_prenom[0]; + } + } + } + + $self->{isAuthor} = 0 ; + $self->{isAnalyse} = 0 ; + } + elsif ($self->{isISBN} eq 1) + { + $self->{isISBN} = 2 ; + } + elsif ($self->{isISBN} eq 2) + { + $self->{curInfo}->{isbn} = $origtext if ( !($origtext =~ m/N.*o Cadastrado/i) && !($origtext =~ m/n.*o dispon.*vel/i)); + $self->{isISBN} = 0 ; + $self->{isAnalyse} = 0 ; + } + elsif ($self->{isPublisher} eq 1) + { + $self->{isPublisher} = 2 ; + } + elsif ($self->{isPublisher} eq 2) + { + $self->{curInfo}->{publisher} = $origtext if ( !($origtext =~ m/N.*o Cadastrado/i) && !($origtext =~ m/n.*o dispon.*vel/i)); + $self->{isPublisher} = 0 ; + $self->{isAnalyse} = 0 ; + } + elsif ($self->{isPublication} eq 1) + { + $self->{isPublication} = 2 ; + } + elsif ($self->{isPublication} eq 2) + { + $self->{curInfo}->{publication} = $origtext if ( !($origtext =~ m/N.*o Cadastrado/i) && !($origtext =~ m/n.*o dispon.*vel/i)); + $self->{isPublication} = 0 ; + $self->{isAnalyse} = 0 ; + } + elsif ($self->{isPage} eq 1) + { + $self->{isPage} = 2 ; + } + elsif ($self->{isPage} eq 2) + { + $self->{curInfo}->{pages} = $origtext if ( !($origtext =~ m/N.*o Cadastrado/i) && !($origtext =~ m/n.*o dispon.*vel/i)); + $self->{isPage} = 0 ; + $self->{isAnalyse} = 0 ; + } + elsif ($self->{isFormat} eq 1) + { + $self->{isFormat} = 2 ; + } + elsif ($self->{isFormat} eq 2) + { + $self->{curInfo}->{format} = $origtext if ( !($origtext =~ m/N.*o Cadastrado/i) && !($origtext =~ m/n.*o dispon.*vel/i)); + $self->{isFormat} = 0 ; + $self->{isAnalyse} = 0 ; + } + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + authors => 1, + publication => 0, + format => 0, + edition => 0, + serie => 0, + }; + + $self->{isTitle} = 0; + $self->{isAuthor} = 0; + $self->{isAnalyse} = 0; + $self->{isPublisher} = 0; + $self->{isPublication} = 0; + $self->{isPage} = 0; + $self->{isISBN} = 0; + $self->{isFormat} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + $html =~ s|
    ||gi; + } + else + { + my $found = index($html,'
    '); + if ( $found >= 0 ) + { + $html = substr($html, 0, $found); + } + + $html =~ s|||gi; + $html =~ s|
  • |\n* |gi; + $html =~ s|
    |\n|gi; + $html =~ s|
    |\n|gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|

    |\n|gi; + $html =~ s|

    ||gi; + $html =~ s|\x{92}|'|g; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|

    |\n|gi; + $html =~ s|

    ||gi; + $html =~ s|\x{92}|'|g; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + } + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + if ($self->{searchField} eq 'isbn') + { + return "http://www.liberonweb.com/asp/libro.asp?ISBN=" . $word; + } + else + { + return "http://www.liberonweb.com/asp/lista.asp?D1=Titolo&T1=" . $word. "&I1=1"; + } + + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url; + } + + sub getName + { + return "LiberOnWeb"; + } + + sub getCharset + { + my $self = shift; + return "ISO-8859-15"; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'IT'; + } + + sub getSearchFieldsArray + { + return ['isbn', 'title']; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCMareno.pm b/lib/gcstar/GCPlugins/GCbooks/GCMareno.pm new file mode 100644 index 0000000..1afdc67 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCMareno.pm @@ -0,0 +1,365 @@ +package GCPlugins::GCbooks::GCbooksMareno; + +################################################### +# +# 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::GCbooks::GCbooksCommon; + +my $searchURL = ""; + +{ + package GCPlugins::GCbooks::GCPluginMareno; + + use base qw(GCPlugins::GCbooks::GCbooksPluginsBase); + use URI::Escape; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + if ($tagname eq 'title') #od razu mamy wynik? + { + $self->{isBook} = 7; + } + + if (($tagname eq 'table') && ($attr->{class} eq 'bookData')) + { + $self->{itemIdx}++; + $self->{isBook} = 1; + } + if (($tagname eq 'a') && ($self->{isBook} == 1)) + { + $self->{isUrl} = 1; + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://www.mareno.pl".$attr->{href}; + $self->{isUrl} = 0; + $self->{isTitle} = 1; + } + if (($tagname eq 'div') && ($attr->{class} eq 'bookAuthor') && ($self->{isBook} == 1)) + { + $self->{isAuthor} = 1; + $self->{isFormat} = 1; + $self->{isPublisher} = 1; + $self->{isPublication} = 1; + } + } + else + { + if (($tagname eq 'div') && ($attr->{id} eq 'wrgISBN')) + { + $self->{isISBN} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgPAGES')) + { + $self->{isPage} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgPUBLI')) + { + $self->{isPublisher} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgPDATE')) + { + $self->{isPublication} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgFORMAT')) + { + $self->{isFormat} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgDESCR')) + { + $self->{isDescription} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgTITLE')) + { + $self->{isTitle} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgAUTOR')) + { + $self->{isAuthor} = 2; + } + if ($tagname eq 'a') + { + if ($self->{isAuthor} eq '1') + { + $self->{isAuthor} = 2; + } + elsif ($self->{isAuthor} eq '2') + { + $self->{isAuthor} = 1; + } + } + if (($tagname eq 'a') && ($attr->{href} =~ /okladki\/big/)) + { + $self->{isCover} = 1; + $self->{curInfo}->{cover} = "http://www.mareno.pl".$attr->{href}; + $self->{isCover} = 0; + } + } + } + + + sub end + { + my ($self, $tagname) = @_; + + if ($tagname eq 'table') + { + $self->{isBook} = 0; + } + if ($tagname eq 'div') + { + $self->{isAuthor} = 0; + } + + $self->{isFound} = 0; + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isBook} == 7) #od razu mamy wynik? + { + $origtext =~ s|^\s*||gs; + $origtext =~ s|\s*$||gs; + if (($origtext ne '') && ($origtext !~ /wyszukiwanie/)) + { + $self->{isUrl} = 1; + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $searchURL; + $self->{isUrl} = 0; + } + $self->{isBook} = 0; + } + $origtext =~ s/^\s*//m; + $origtext =~ s/\s*$//m; + if ($self->{isAuthor} == 1) + { + my ($au, $fo, $pu, $pd); + $origtext =~ m|(#\^#- [^#]+#\^#)?(okładka\s*[^,]+,\s*)?([^,]+,\s*)?(\d*)?|s; + $au = $1; + $fo = $2; + $pu = $3; + $pd = $4; + $au =~ s|#\^#- ([^#]+)#\^#|$1|g; + $self->{itemsList}[$self->{itemIdx}]->{authors} = $au; + $self->{isAuthor} = 0; + $fo =~ s|okładka\s*([^,]+),\s*|$1|g; + $self->{itemsList}[$self->{itemIdx}]->{format} = $fo; + $self->{isFormat} = 0; + $pu =~ s|([^,]+),\s*|$1|g; + $self->{itemsList}[$self->{itemIdx}]->{publisher} = $pu; + $self->{isPublisher} = 0; + $self->{itemsList}[$self->{itemIdx}]->{publication} = $pd; + $self->{isPublication} = 0; + } + if ($self->{isTitle} == 1) + { + $self->{itemsList}[$self->{itemIdx}]->{title} = $origtext; + $self->{isTitle} = 0; + } + } + else + { + $origtext =~ s/^\s*//m; + $origtext =~ s/\s*$//m; + + if ($self->{isTitle} eq '1') + { + $self->{curInfo}->{title} = $origtext; + $self->{isTitle} = 0; + } + if ($self->{isAuthor} == 1) + { + $origtext =~ s|^\s*||; + $origtext =~ s|\s*$||; + if ($origtext ne '') + { + if ($self->{curInfo}->{authors} ne '') + { + $self->{curInfo}->{authors} .= ","; + } + $self->{curInfo}->{authors} .= $origtext; + } + $self->{isAuthor} = 2; + } + if ($self->{isFormat} == 1) + { + $self->{curInfo}->{format} = $origtext; + $self->{isFormat} = 0; + } + if ($self->{isDescription} == 1) + { + $self->{curInfo}->{description} = $origtext; + $self->{isDescription} = 0; + } + if ($self->{isISBN} eq '1') + { + $self->{curInfo}->{isbn} = $origtext; + $self->{isISBN} = 0; + } + if ($self->{isPage} eq '1') + { + $self->{curInfo}->{pages} = $origtext; + $self->{isPage} = 0; + } + if ($self->{isPublisher} eq '1') + { + $self->{curInfo}->{publisher} = $origtext; + $self->{isPublisher} = 0; + } + if ($self->{isPublication} eq '1') + { + $origtext =~ s|(\S*)\s*(\S{4})|$2|; + $self->{curInfo}->{publication} = $origtext; + $self->{isPublication} = 0; + } + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + authors => 1, + publication => 1, + format => 1, + edition => 0, + }; + + $self->{isBook} = 0; + $self->{isUrl} = 0; + $self->{isEditor_Publication_Format_Lang} = 0 ; + $self->{isAnalyse} = 0; + $self->{isFound} = 0; + $self->{isTitle} = 0; + $self->{isAuthor} = 0; + $self->{isPublisher} = 0; + $self->{isISBN} = 0; + $self->{isFormat} = 0; + $self->{isEdition} = 0; + $self->{isPage} = 0; + $self->{isLanguage} = 0; + $self->{isPublication} = 0; + $self->{isSerie} = 0; + $self->{isDescription} = 0; + $self->{isCover} = 0; + $self->{isTranslator} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + $self->{parsingEnded} = 0; + $self->{insideResults} = 0; + $self->{actorsCounter} = 0; + + if ($self->{parsingList}) + { + $html =~ s/<\/?(b|strong)>//gi; + $html =~ s|]*>||gi; + $html =~ s|
    |#\^#|gi; + $html =~ s|\s*\s*|
    \s*
    |gs; + $html =~ s|||gs; + $html =~ s|||g; + } + else + { + $html =~ s/<\/?(i|br|strong)>//gi; + + $html =~ s|

    ([^<]*)

    |
    $1
    |s; + $html =~ s|

    |
    |s; + $html =~ s|\s*ISBN:\s*([\dX]*)\s*|
    $1
    |s; + $html =~ s|\s*okładka:\s*([^,]*),?\s*(\d*)[^<]*|
    $1
    $2
    |s; + $html =~ s|\s*wydawnictwo:\s*([^,]*),\s*(\d*)\s*|
    $1
    $2
    |s; + $html =~ s|opis produktu:\s*([^<]*)
    |
    $1

    |; +# $html =~ s|
    Seria:
    $*\s*
    (.*)
    |
    $1
    |; +# $html =~ s|
    Wydanie:
    (.*)
    |
    $1
    |; +# $html =~ s|
    Tłumaczenie:\s*
    $*\s*
    |
    |; + } + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + $searchURL = "http://www.mareno.pl/rezultat.php?tytul=".$word; + return $searchURL; + } + + sub getItemUrl + { + my ($self, $url) = @_; + return $url if $url; + return 'http://www.mareno.pl/'; + } + + sub getName + { + return "Mareno"; + } + + sub getCharset + { + my $self = shift; + #return "UTF-8"; + return "ISO-8859-2"; + } + + sub getAuthor + { + return 'WG'; + } + + sub getLang + { + return 'PL'; + } + + sub getSearchFieldsArray + { + return ['isbn', 'title']; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCMediabooks.pm b/lib/gcstar/GCPlugins/GCbooks/GCMediabooks.pm new file mode 100644 index 0000000..6b5f41b --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCMediabooks.pm @@ -0,0 +1,333 @@ +package GCPlugins::GCbooks::GCMediabooks; + +################################################### +# +# Copyright 2005-2006 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; + +use GCPlugins::GCbooks::GCbooksCommon; + +{ + package GCPlugins::GCbooks::GCPluginMediabooks; + + use base qw(GCPlugins::GCbooks::GCbooksPluginsBase); + use URI::Escape; + + use Encode; + use HTML::Entities; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + + if (($tagname eq 'font') && ($attr->{class} eq 'font4Copy')) + { + $self->{isBook} = 1 ; + $self->{isUrl} = 1 ; + $self->{isDescription} = 0 ; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ m|/artigos/popUp_detalhe.jsp|i) && ($self->{isBook}) && ($self->{isUrl})) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + my $found = index($self->{itemsList}[$self->{itemIdx}]->{url},"'"); + if ( $found >= 0 ) + { + $self->{itemsList}[$self->{itemIdx}]->{url} = substr($self->{itemsList}[$self->{itemIdx}]->{url}, $found +length("'"),length($self->{itemsList}[$self->{itemIdx}]->{url})- $found -length("'")); + $found = index($self->{itemsList}[$self->{itemIdx}]->{url},"'"); + if ( $found >= 0 ) + { + $self->{itemsList}[$self->{itemIdx}]->{url} = substr($self->{itemsList}[$self->{itemIdx}]->{url}, 0, $found); + } + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://www.mediabooks.pt" .$self->{itemsList}[$self->{itemIdx}]->{url}; + } + + $self->{isTitle} = 1 ; + $self->{isUrl} = 0 ; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ m|/autores/index.jsp|i) && ($self->{isBook})) + { + $self->{isAuthor} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ m|/editores/index.jsp|i) && ($self->{isBook})) + { + $self->{isPublisher} = 1 ; + } + elsif (($tagname eq 'input') && ($attr->{type} eq 'hidden')) + { + $self->{isBook} = 0 ; + } + } + else + { + if (($tagname eq 'a') && ($attr->{href} =~ m|/autores/index.jsp|i)) + { + $self->{isAuthor} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ m|/editores/index.jsp|i)) + { + $self->{isPublisher} = 1 ; + } + elsif ($self->{isISBN} eq 1) + { + $self->{isISBN} = 2 ; + } + elsif (($tagname eq 'span') && ($self->{isTitle})) + { + $self->{isTitle} = 2 ; + } + elsif (($tagname eq 'span') && ($attr->{class} eq 'font4Copy')) + { + $self->{isAnalyse} = 1 ; + } + elsif (($tagname eq 'img') && ($attr->{src} =~ m|/artigos/imagens/|i)) + { + if ($origtext =~ m|/artigos/imagens/livros|i) + { + } + else + { + $self->{curInfo}->{cover} = 'http://www.mediabooks.pt' .$attr->{src}; + } + + $self->{isTitle} = 1 ; + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{isFound} = 0 ; + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isTitle}) + { + $self->{itemsList}[$self->{itemIdx}]->{title} = $origtext; + $self->{isTitle} = 0 ; + } + elsif ($self->{isAuthor} eq 1) + { + # Enleve les retours chariots + $origtext =~ s/\n//g; + $origtext =~ s/\r//g; + if (($self->{itemsList}[$self->{itemIdx}]->{authors} eq '') && ($origtext ne '')) + { + $self->{itemsList}[$self->{itemIdx}]->{authors} = $origtext; + } + elsif ($origtext ne '') + { + $self->{itemsList}[$self->{itemIdx}]->{authors} .= ', '; + $self->{itemsList}[$self->{itemIdx}]->{authors} .= $origtext; + } + $self->{isAuthor} = 0 ; + } + elsif ($self->{isPublisher}) + { + $self->{itemsList}[$self->{itemIdx}]->{edition} = $origtext; + $self->{isPublisher} = 0 ; + } + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//g; + if ($self->{isTitle} eq '2') + { + $self->{curInfo}->{title} = $origtext; + $self->{isTitle} = 0 ; + } + elsif ($self->{isAuthor} eq 1) + { + if ($origtext ne '') + { + $self->{curInfo}->{authors} .= $origtext; + $self->{curInfo}->{authors} .= ","; + } + $self->{isAuthor} = 0 ; + } + elsif ($self->{isAnalyse}) + { + $self->{isISBN} = 1 if ($origtext =~ m/ISBN/i); + $self->{isFormat} = 1 if ($origtext =~ m/Formato/i); + $self->{isDescription} = 1 if ($origtext =~ m/Breve Descri/i); + $self->{isPublication} = 1 if ($origtext =~ m/Ano de Edi/i); + $self->{isPage} = 1 if ($origtext =~ m/P.ginas/i); + + $self->{isAnalyse} = 0 ; + } + elsif ($self->{isISBN} eq 2) + { + $self->{curInfo}->{isbn} = $origtext; + $self->{isISBN} = 0 ; + } + elsif ($self->{isPublisher}) + { + $self->{curInfo}->{publisher} = $origtext; + $self->{isPublisher} = 0 ; + } + elsif ($self->{isFormat}) + { + $self->{curInfo}->{format} = $origtext; + $self->{isFormat} = 0 ; + } + elsif ($self->{isPublication}) + { + $self->{curInfo}->{publication} = $origtext; + $self->{isPublication} = 0 ; + } + elsif ($self->{isPage}) + { + $self->{curInfo}->{pages} = $origtext; + $self->{isPage} = 0 ; + } + elsif ($self->{isDescription}) + { + $self->{curInfo}->{description} .= $origtext; + } + + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + authors => 1, + publication => 0, + format => 0, + edition => 1, + }; + + $self->{isFound} = 0; + $self->{isBook} = 0; + $self->{isUrl} = 0; + $self->{isTitle} = 0; + $self->{isAuthor} = 0; + $self->{isFormatPublication} = 0; + $self->{isPublisher} = 0; + $self->{isISBN} = 0; + $self->{isPublication} = 0; + $self->{isFormat} = 0; + $self->{isPage} = 0; + $self->{isDescription} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s|\n||gi; + $html =~ s|\r||gi; + $html =~ s|\t||gi; + + $html =~ s|
  • |\n* |gi; + $html =~ s|
    |\n|gi; + $html =~ s|
    |\n|gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|

    |\n|gi; + $html =~ s|

    ||gi; + $html =~ s|||gi; + $html =~ s|\x{92}|'|g; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + } + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + if ($self->{searchField} eq 'isbn') + { + return ('http://www.mediabooks.pt/pesquisa/result_pesq.jsp', ["v_sec_id" => "1", "v_prev_sec_id" => "", "v_pes_id" => "2", "v_pesquisa" => "$word", "image.x" => "5", "image.y" => "7"] ); + } + else + { + return ('http://www.mediabooks.pt/pesquisa/result_pesq.jsp', ["v_sec_id" => "1", "v_prev_sec_id" => "", "v_pes_id" => "1", "v_pesquisa" => "$word", "image.x" => "5", "image.y" => "7"] ); + } + + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url if $url; + return 'http://www.mediabooks.pt/'; + } + + sub getName + { + return "Mediabooks"; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'PT'; + } + + sub getSearchFieldsArray + { + return ['isbn', 'title']; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCMerlin.pm b/lib/gcstar/GCPlugins/GCbooks/GCMerlin.pm new file mode 100644 index 0000000..5c5129a --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCMerlin.pm @@ -0,0 +1,389 @@ +package GCPlugins::GCbooks::GCbooksMerlin; + +################################################### +# +# 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::GCbooks::GCbooksCommon; + +{ + package GCPlugins::GCbooks::GCPluginMerlin; + + use base qw(GCPlugins::GCbooks::GCbooksPluginsBase); + use URI::Escape; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + if (($tagname eq 'li') && ($attr->{class} eq 'tytul')) + { + $self->{isBook} = 1; + $self->{isUrl} = 1; + $self->{itemIdx}++; + } + if (($tagname eq 'li') && ($attr->{class} eq 'wydawca')) + { + $self->{isPublisher} = 1; + } + if (($tagname eq 'a') + && ($self->{isUrl} eq '1')) + { + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://www.merlin.com.pl".$attr->{href}; + $self->{isUrl} = 0; + } + } + else + { + if (($tagname eq 'div') && ($attr->{id} eq 'wrgISBN')) + { + $self->{isISBN} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgPAGES')) + { + $self->{isPage} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgPUBLI')) + { + $self->{isPublisher} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgPDATE')) + { + $self->{isPublication} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgSERIA')) + { + $self->{isSerie} = 2; + } + if (($tagname eq 'a') && ($self->{isSerie} eq '2')) + { + $self->{isSerie} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'wrgEDITI')) + { + $self->{isEdition} = 1; + } + if (($tagname eq 'div') && ($attr->{id} eq 'prodHead')) + { + $self->{isCover} = 2; + $self->{isTitle} = 2; + $self->{isFormat} = 2; + } + if (($tagname eq 'h1') && ($attr->{class} eq 'prodTitle') && ($self->{isTitle} eq '2')) + { + $self->{isTitle} = 1; + } + if (($tagname eq 'h2') && ($attr->{class} eq 'prodPerson')) + { + $self->{isAuthor} = 2; + } + if ($tagname eq 'a') + { + if ($self->{isAuthor} eq '1') + { + $self->{isAuthor} = 2; + } + elsif ($self->{isAuthor} eq '2') + { + $self->{isAuthor} = 1; + } + } + if (($tagname eq 'dd') && ($attr->{id} eq 'wrgTRANS')) + { + $self->{isTranslator} = 2; + } + if ($tagname eq 'a') + { + if ($self->{isTranslator} eq '1') + { + $self->{isTranslator} = 2; + } + elsif ($self->{isTranslator} eq '2') + { + $self->{isTranslator} = 1; + } + } + if (($tagname eq 'div') && ($attr->{id} eq 'prodImg') && ($self->{isCover} eq '2')) + { + $self->{isCover} = 1; + } + if (($tagname eq 'img') && ($self->{isCover} eq '1')) + { + $self->{curInfo}->{cover} = "http://www.merlin.com.pl".$attr->{src}; + $self->{isCover} = 0; + } + if (($tagname eq 'div') && ($attr->{class} eq 'prodFeatureSpec') && ($self->{isFormat} eq '2')) + { + $self->{isFormat} = 1; + } + if (($tagname eq 'div') && ($attr->{class} eq 'productDesc')) + { + $self->{isDescription} = 1; + } + } + } + + + sub end + { + my ($self, $tagname) = @_; + + if ($tagname eq 'h2') + { + $self->{isAuthor} = 0; + } + if ($tagname eq 'dd') + { + $self->{isTranslator} = 0; + } + + $self->{isFound} = 0; + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isBook} eq '1') + { + $origtext =~ s/^\s*//m; + $origtext =~ s/\s*$//m; + $self->{isBook} = 0; + if ($self->{inside}->{a}) + { + $self->{itemsList}[$self->{itemIdx}]->{title} = $origtext; + $self->{isBook} = 1; + } + else + { + $self->{itemsList}[$self->{itemIdx}]->{authors} = $origtext; + } + } + if ($self->{isPublisher} eq '1') + { + $origtext =~ s/^\s*//m; + $origtext =~ s/\s*$//m; + $self->{itemsList}[$self->{itemIdx}]->{edition} = $origtext; + $self->{isPublisher} = 0; + } + + } + else + { + $origtext =~ s/^\s*//m; + $origtext =~ s/\s*$//m; + + if ($self->{isTitle} eq '1') + { + $self->{curInfo}->{title} = $origtext; + $self->{isTitle} = 0; + } + if ($self->{isAuthor} eq '1') + { + $origtext =~ s|^\s*||; + $origtext =~ s|\s*$||; + if ($origtext ne '') + { + $self->{curInfo}->{authors} .= $origtext; + } + $self->{isAuthor} = 2; + } + if ($self->{isTranslator} eq '1') + { + $origtext =~ s|^\s*||; + $origtext =~ s|\s*$||; + if ($self->{curInfo}->{translator} eq '') + { + $self->{curInfo}->{translator} = $origtext; + } + else + { + $self->{curInfo}->{translator} .= ", ".$origtext; + } + $self->{isTranslator} = 2; + } + if ($self->{isFormat} eq '1') + { + $origtext =~ s|okładka: ||m; + $self->{curInfo}->{format} = $origtext; + $self->{isFormat} = 0; + } + if ($self->{isDescription} eq '1') + { + $self->{curInfo}->{description} = $origtext; + $self->{isDescription} = 0; + } + + if ($self->{isISBN} eq '1') + { + $self->{curInfo}->{isbn} = $origtext; + $self->{isISBN} = 0; + } + if ($self->{isPage} eq '1') + { + $self->{curInfo}->{pages} = $origtext; + $self->{isPage} = 0; + } + if ($self->{isEdition} eq '1') + { + $self->{curInfo}->{edition} = $origtext; + $self->{isEdition} = 0; + } + if ($self->{isPublisher} eq '1') + { + $self->{curInfo}->{publisher} = $origtext; + $self->{isPublisher} = 0; + } + if ($self->{isPublication} eq '1') + { + $origtext =~ s|(\S*)\s*(\S{4})|$2|; + $self->{curInfo}->{publication} = $origtext; + $self->{isPublication} = 0; + } + if ($self->{isSerie} eq '1') + { + $self->{curInfo}->{serie} = $origtext; + $self->{isSerie} = 0; + } + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + authors => 1, + publication => 0, + format => 0, + edition => 1, + }; + + $self->{isBook} = 0; + $self->{isUrl} = 0; + $self->{isEditor_Publication_Format_Lang} = 0 ; + $self->{isAnalyse} = 0; + $self->{isFound} = 0; + $self->{isTitle} = 0; + $self->{isAuthor} = 0; + $self->{isPublisher} = 0; + $self->{isISBN} = 0; + $self->{isFormat} = 0; + $self->{isEdition} = 0; + $self->{isPage} = 0; + $self->{isLanguage} = 0; + $self->{isPublication} = 0; + $self->{isSerie} = 0; + $self->{isDescription} = 0; + $self->{isCover} = 0; + $self->{isTranslator} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + $self->{parsingEnded} = 0; + $self->{insideResults} = 0; + $self->{actorsCounter} = 0; + + if ($self->{parsingList}) + { + $html =~ s|(.*?)|$1|gms; + $html =~ s|
  • (.*)
  • \s*
  • |
  • $1
  • |gm; + } + else + { + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|(.*?)||gs; + + $html =~ s|
    ISBN:
    (.*)
    |
    $1
    |; + $html =~ s|
    Liczba stron:
    (.*)
    |
    $1
    |; + $html =~ s|
    Seria:
    \s*
    (.*)
    |
    $1
    |m; + $html =~ s|
    Wydanie:
    (.*)
    |
    $1
    |; + $html =~ s|
    Wydawnictwo:
    \s*
    \s*(.*)\s*,*\s*(.*)\s*
    |
    $1
    $2
    |m; + $html =~ s|
    Tłumaczenie:\s*
    \s*
    |
    |m; + } + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + return "http://www.merlin.com.pl/frontend/browse/search/1.html?phrase=$word"; + } + + sub getItemUrl + { + my ($self, $url) = @_; + return $url if $url; + return 'http://www.merlin.com.pl/'; + } + + sub getName + { + return "Merlin"; + } + + sub getCharset + { + my $self = shift; + #return "UTF-8"; + return "ISO-8859-2"; + } + + sub getAuthor + { + return 'WG'; + } + + sub getLang + { + return 'PL'; + } + + sub getSearchFieldsArray + { + return ['isbn', 'title']; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCNUKat.pm b/lib/gcstar/GCPlugins/GCbooks/GCNUKat.pm new file mode 100644 index 0000000..6bc22eb --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCNUKat.pm @@ -0,0 +1,447 @@ +package GCPlugins::GCbooks::GCbooksNUKat; + +################################################### +# +# 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::GCbooks::GCbooksCommon; + +my $searchURL = ""; +my $searchISBN = ""; + +{ + package GCPlugins::GCbooks::GCPluginNUKat; + + use base qw(GCPlugins::GCbooks::GCbooksPluginsBase); + use URI::Escape; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + if ($tagname eq 'title') #od razu mamy wynik + { + $self->{isBook} = 7; + } + + if (($tagname eq 'tr') && ($attr->{class} eq 'intrRow')) + { + $self->{isBook} = 1; + $self->{itemIdx}++; + } + if (($tagname eq 'td') && ($attr->{class} eq 'intrRowCell1') && ($self->{isBook} == 1)) + { + $self->{isUrl} = 2; + } + if (($tagname eq 'a') && ($self->{isUrl} == 2) && ($origtext =~ /.*function=CARDSCR.*/)) + { + $self->{isUrl} = 1; + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + $self->{itemsList}[$self->{itemIdx}]->{url} =~ s|skin=portal&||; + $self->{isUrl} = 0; + } + if (($tagname eq 'td') && ($attr->{class} eq 'intrAutor') && ($self->{isBook} == 1)) + { + $self->{isAuthor} = 1; + } + if (($tagname eq 'td') && ($attr->{class} eq 'intrTytul') && ($self->{isBook} == 1)) + { + $self->{isTitle} = 1; + } + if (($tagname eq 'td') && ($attr->{class} eq 'intrWydaw') && ($self->{isBook} == 1)) + { + $self->{isPublication} = 1; + } + } + else + { + if (($tagname eq 'td') && ($attr->{class} eq 'wrgTITLE')) + { + $self->{isTitle} = 1; + $self->{isAuthor} = 1; + $self->{isTranslator} = 1; + $self->{isArtist} = 1; + $self->{isISBN} = 2; + } + if (($tagname eq 'td') && ($attr->{class} eq 'wrgPAGES')) + { + $self->{isPage} = 1; + } + if (($tagname eq 'td') && ($attr->{class} eq 'wrgSERIA')) + { + $self->{isSerie} = 1; + } + if (($tagname eq 'td') && ($attr->{class} eq 'wrgPUBLI')) + { + $self->{isPublisher} = 1; + $self->{isPublication} = 1; + } + if (($tagname eq 'td') && ($attr->{class} eq 'wrgEDITI')) + { + $self->{isEdition} = 1; + } + if (($tagname eq 'td') && ($attr->{class} eq 'wrgISBN') && ($self->{isISBN} == 2)) + { + $self->{isISBN} = 1; + } + + if (($tagname eq 'div') && ($attr->{class} eq 'prodFeatureSpec') && ($self->{isFormat} eq '2')) + { + $self->{isFormat} = 1; + } + } + } + + + sub end + { + my ($self, $tagname) = @_; + + $self->{isFound} = 0; + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isBook} == 7) #od razu mamy wynik? + { + if ($origtext =~ /Pełny opis/) + { + $self->{isUrl} = 1; + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $searchURL; + $self->{isUrl} = 0; + $self->{isBook} = 0; + } + } + if ($self->{isBook} == 1) + { + $origtext =~ s/^\s*//m; + $origtext =~ s/\s*$//m; + if ($self->{isTitle} == 1) + { + $origtext =~ s|^\s*([^/]*)/?|$1|m; + $origtext =~ s|^\s*([^:]*):?|$1|m; + $origtext =~ s|\s*$||m; + $self->{itemsList}[$self->{itemIdx}]->{title} = $origtext; + $self->{isTitle} = 0; + } + if ($self->{isAuthor} == 1) + { + $origtext =~ s|\s*\/\s*(.*)\s*|$1|; + $origtext =~ s|^\s*([^\.]*)\.?|$1|m; + $origtext =~ s|([^\(]*)(\([^\)]*\))?|$1|; + $origtext =~ s|\s*$||m; + $origtext =~ s|([^,]*), (.*)|$2 $1|m; + $self->{itemsList}[$self->{itemIdx}]->{authors} = $origtext; + $self->{isAuthor} = 0; + } + if ($self->{isPublication} == 1) + { + $origtext =~ s|(.*)(\d{4})\D*|$2|s; + $origtext =~ s|^\s*([^\.]*)\.?|$1|m; + $self->{itemsList}[$self->{itemIdx}]->{edition} = $origtext; + $self->{isPublication} = 0; + $self->{isBook} = 0; + } + } + + } + else + { + $origtext =~ s/^\s*//m; + $origtext =~ s/\s*$//m; + + if ($self->{isFormat} eq '1') + { + $origtext =~ s|okładka: ||m; + $self->{curInfo}->{format} = $origtext; + $self->{isFormat} = 0; + } + + + + if ($self->{isISBN} eq '1') + { + my ($pom1, $pom2); + if ($self->{searchField} eq 'isbn') + { + $pom1 = $self->{searchISBN}; + $pom2 = $origtext; + $pom2 =~ s|[^\dX]||g; + $pom1 =~ s|-||g; + $pom2 =~ s|-||g; + if ($pom1 eq $pom2) + { + $self->{curInfo}->{isbn} = $origtext; + $self->{isISBN} = 0; + } + else + { + $self->{isISBN} = 2; + } + } + else + { + $origtext =~ s|[^\dX]||g; + $self->{curInfo}->{isbn} = $origtext; + $self->{isISBN} = 0; + } + } + if ($self->{isTitle} eq '1') + { + my ($pom1, $pom2, $ti, $au, $tr, $il); + $origtext =~ m|([^/]*)/\s*([^;]*)(; )?([^;]*)(; )?([^;]*)$|; + $ti = $1; + $au = $2; + $pom1 = $4; + $pom2 = $6; + $ti =~ s|^\s*||; + $ti =~ s|\s*$||; + $self->{curInfo}->{title} = $ti; + $self->{isTitle} = 0; + $au =~ s| i |,|g; + $au =~ s|, |,|g; + $au =~ s|[\[\]]||g; + $au =~ s|tekst||g; + $au =~ s|^\s*||; + $au =~ s|\s*$||; + $au =~ s|(.*)(\.{1})|$1|; + $self->{curInfo}->{authors} = $au; + $self->{isAuthor} = 0; + $pom1 =~ s|[\[\]]||g; + $pom1 =~ m|(.*)(.{1})|; + if ($2 eq '.') + { + $pom1 = $1; + } + $pom2 =~ s|[\[\]]||g; + $pom2 =~ m|(.*)(.{1})|; + if ($2 eq '.') + { + $pom2 = $1; + } + if ($pom2 =~ /(przeł\.|przekł\.|tł\.|tłum\.)/) + { + $tr = $pom2; + } + if ($pom2 =~ /(il\.|oprac\. graf\.)/) + { + $il = $pom2; + } + if ($pom1 =~ /(przeł\.|przekł\.|tł\.|tłum\.)/) + { + $tr = $pom1; + } + if ($pom1 =~ /(il\.|oprac\. graf\.)/) + { + $il = $pom1; + } + $tr =~ s/(przeł\.|przekł\.|tł\.|tłum\.)//; + $tr =~ s|z \w+\.||; + $tr =~ s|^\s*||; + $tr =~ s|\s*$||; + $tr =~ s| i |,|g; + $tr =~ s|, |,|g; + $self->{curInfo}->{translator} = $tr; + $self->{isTranslator} = 0; + $il =~ s/(il\.|oprac\. graf\.)//; + $il =~ s|^\s*||; + $il =~ s|\s*$||; + $il =~ s| i |,|g; + $il =~ s|, |,|g; + $self->{curInfo}->{artist} = $il; + $self->{isArtist} = 0; + } + if ($self->{isPage} eq '1') + { + $origtext =~ s|(\d*)\D.*|$1|; + $self->{curInfo}->{pages} = $origtext; + $self->{isPage} = 0; + } + if ($self->{isEdition} eq '1') + { + $origtext =~ s|\D*(\d*)\D.*|$1|; + $self->{curInfo}->{edition} = $origtext; + $self->{isEdition} = 0; + } + if ($self->{isPublisher} eq '1') + { + my $pom = $origtext; + $origtext =~ s|[^:]*:\s*(.*),.*|$1|; + $origtext =~ s|^\s*||; + $origtext =~ s|"(.*)"|$1|; + $self->{curInfo}->{publisher} = $origtext; + $pom =~ s|(.*)(\d{4})(\D*)|$2|; + $self->{curInfo}->{publication} = $pom; + $self->{isPublisher} = 0; + $self->{isPublication} = 0; + } + if ($self->{isSerie} eq '1') + { + $origtext =~ s|([^;]*)(;.*)|$1|; + $origtext =~ s|\s*$||; + $self->{curInfo}->{serie} = $origtext; + $self->{isSerie} = 0; + } + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + authors => 1, + publication => 0, + format => 0, + edition => 1, + }; + + $self->{isBook} = 0; + $self->{isUrl} = 0; + $self->{isEditor_Publication_Format_Lang} = 0 ; + $self->{isAnalyse} = 0; + $self->{isFound} = 0; + $self->{isTitle} = 0; + $self->{isAuthor} = 0; + $self->{isPublisher} = 0; + $self->{isISBN} = 0; + $self->{isFormat} = 0; + $self->{isEdition} = 0; + $self->{isPage} = 0; + $self->{isLanguage} = 0; + $self->{isPublication} = 0; + $self->{isSerie} = 0; + $self->{isDescription} = 0; + $self->{isCover} = 0; + $self->{isTranslator} = 0; + $self->{isArtist} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + $self->{parsingEnded} = 0; + $self->{insideResults} = 0; + $self->{actorsCounter} = 0; + + if ($self->{parsingList}) + { + $html =~ s|(.*?)|$1|gms; + $html =~ s|||g; + $html =~ s|||g; + $html =~ s|$1|gs; + $html =~ s|]*>Tytuł\s*
  • "); + if ( $found2 >= 0 ) + { + $html2 = substr($html2, 0, $found2); + } + + $html2 =~ s|
  • |\n* |gi; + $html2 =~ s|
    |\n|gi; + $html2 =~ s|
    |\n|gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + $html2 =~ s|

    |\n|gi; + $html2 =~ s|

    ||gi; + $html2 =~ s|||gi; + $html2 =~ s|\x{92}|'|g; + $html2 =~ s|’|'|gi; + $html2 =~ s|•|*|gi; + $html2 =~ s|œ|oe|gi; + $html2 =~ s|…|...|gi; + $html2 =~ s|\x{85}|...|gi; + $html2 =~ s|\x{8C}|OE|gi; + $html2 =~ s|\x{9C}|oe|gi; + + $html = substr($html, 0, $found) . ">" . $html2 .""; + + } + + $html =~ s|

    ||gmi; + $html =~ s|

    |
    |gmi; + $html =~ s|
    <|<|gmi; + } + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + if ($self->{searchField} eq 'isbn') + { + return "http://www.noosfere.org/icarus/livres/cyborg_livre.asp?mini=1000&maxi=3000&mode=Idem&EtOuParution=NS&isbn=". $word; + } + else + { + return "http://www.noosfere.org/icarus/livres/cyborg_livre.asp?mini=1000&maxi=3000&mode=Idem&EtOuParution=NS&titre=". $word; + } + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url if $url; + return 'http://www.noosfere.org/'; + } + + sub getName + { + return "nooSFere"; + } + + sub getCharset + { + my $self = shift; + return "ISO-8859-15"; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'FR'; + } + + sub getSearchFieldsArray + { + return ['isbn', 'title']; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCSaraiva.pm b/lib/gcstar/GCPlugins/GCbooks/GCSaraiva.pm new file mode 100644 index 0000000..54dd119 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCSaraiva.pm @@ -0,0 +1,303 @@ +package GCPlugins::GCbooks::GCSaraiva; + +################################################### +# +# Plugin for a brazilian bookstore named "Saraiva". +# Code written by Guilherme "nirev" Nogueira. +# guilherme at nirev dot org +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCbooks::GCbooksCommon; + +{ + package GCPlugins::GCbooks::GCPluginSaraiva; + + use base qw(GCPlugins::GCbooks::GCbooksPluginsBase); + use URI::Escape; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + if (($tagname eq 'div') && ($attr->{class} eq 'hsliceLista')) + { + $self->{isResult} = 1; + $self->{linkCount} = 0; + $self->{itemIdx}++; + } + if (($tagname eq 'span') && ($attr->{class} eq 'entry-title')) + { + $self->{isTitle} = 1; + } + if (($tagname eq 'h2') && ($attr->{class} eq 'titulo_autor')) + { + $self->{isAuthor} = 1; + } + if (($tagname eq 'a') && $self->{isResult} && $self->{linkCount} == 0 ) + { + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + $self->{linkCount}++; + } + elsif (($tagname eq 'div') && ($attr->{class} eq 'entry-content')) + { + $self->{isResult} = 0; + } + } + else + { + if (($tagname eq 'img') && ($attr->{id} eq 'imgProd')) + { + my $imgid = $attr->{src}; + $imgid =~ s/(.)*pro_id=//; + $imgid =~ s/&.*$//; + $self->{curInfo}->{cover} = 'http://www.livrariasaraiva.com.br/imagem/imagem.dll?tam=2&pro_id='.$imgid; + } + elsif (($tagname eq 'div') && ($attr->{id} eq 'aba1')) + { + $self->{isDescription} = 1; + } + elsif (($tagname eq 'div') && ($attr->{id} eq 'aba2')) + { + $self->{divInfo} = 1; + } + elsif (($tagname eq 'div') && ($attr->{id} eq 'produtosAbasMenus')) + { + $self->{divInfo} = 0; + } + elsif (($tagname eq 'div') && ($attr->{id} eq 'tituloprod')) + { + $self->{isTitle} = 1; + } + elsif (($tagname eq 'a') && ($attr->{href} eq 'javascript:PesquisaAutor();')) + { + $self->{isAuthor} = 1; + } + elsif (($tagname eq 'a') && ($attr->{href} eq 'javascript:PesquisaMarca();')) + { + $self->{isPublisher} = 1; + } + elsif (($tagname eq 'font')) + { + $self->{isAnalyse} = 1; + } + elsif (($tagname eq 'b') && $self->{divInfo} == 1) + { + $self->{isAnalyse} = 1; + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isTitle}) + { + my $texto = $origtext; + $self->{itemsList}[$self->{itemIdx}]->{title} = $texto; + $self->{isTitle} = 0; + } + if ($self->{isAuthor}) + { + my $texto = $origtext; + $texto =~ s/
    //; + my @dados = split(' / ', $texto); + $self->{itemsList}[$self->{itemIdx}]->{authors} = $dados[0]; + $self->{isAuthor} = 0; + } + } + else + { + if ($self->{isAuthor}) + { + my @authors = split(';', $origtext); + my $authors = ''; + my $tam = @authors; + my $count = 0; + for($count = 0; $count < $tam; $count++) + { + $authors[$count] =~ s/^\s*//gi; + $authors[$count] =~ s/\s*$//gi; + my @names = split(', ', $authors[$count]); + $authors .= ',' if ($count); + $authors .= $names[1].' '.$names[0]; + + } + $self->{curInfo}->{authors} = $authors; + $self->{isAuthor} = 0; + } + elsif ($self->{isPublisher}) + { + $self->{curInfo}->{publisher} = $origtext; + $self->{isPublisher} = 0; + } + elsif ($self->{isTitle}) + { + $self->{curInfo}->{title} = $origtext; + $self->{isTitle} = 0; + } + elsif ($self->{isDescription}) + { + $self->{curInfo}->{description} = $origtext; + $self->{curInfo}->{description} =~ s/^\s*//; + $self->{curInfo}->{description} =~ s/\s+/ /; + $self->{isDescription} = 0; + } + elsif ($self->{isAnalyse}) + { + $self->{isISBN} = 1 if ($origtext =~ m/I\.S\.B\.N/i); + $self->{isFormat} = 1 if ($origtext =~ m/Acabamento/i); + $self->{isPublication} = 1 if ($origtext =~ m/Edição/i); + $self->{isPage} = 1 if ($origtext =~ m/Número de Paginas/i); + $self->{isAnalyse} = 0 ; + } + elsif ($self->{isISBN}) + { + $self->{curInfo}->{isbn} = $origtext; + $self->{isISBN} = 0; + } + elsif ($self->{isFormat}) + { + $self->{curInfo}->{format} = $origtext; + $self->{isFormat} = 0; + } + elsif ($self->{isPublication}) + { + $self->{curInfo}->{publication} = $origtext; + $self->{isPublication} = 0; + } + elsif ($self->{isPage}) + { + $self->{curInfo}->{pages} = $origtext; + $self->{isPage} = 0; + } + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + authors => 1, + publication => 0, + format => 0, + edition => 0, + serie => 0, + }; + + $self->{isTitle} = 0; + $self->{isAuthor} = 0; + $self->{isAnalyse} = 0; + $self->{isPublisher} = 0; + $self->{isPublication} = 0; + $self->{isPage} = 0; + $self->{isISBN} = 0; + $self->{isFormat} = 0; + $self->{isDescription} = 0; + $self->{isResult} = 0; + $self->{linkCount} = 0; + $self->{divInfo} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + my $inicio_res = index($html,'

    '); + if ( $inicio_res >= 0 ) + { + $html = substr($html, $inicio_res); + } + my $fim_res = index($html,''); + if ( $fim_res >= 0 ) + { + $html = substr($html, 0, $fim_res); + } + $html = '' if ($inicio_res < 0); + } + else + { + + } + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + $word =~ s|\s+|\+|; + + if ($self->{searchField} eq 'isbn') + { + return "http://www.livrariasaraiva.com.br/pesquisaweb/pesquisaweb.dll/pesquisa?ORDEMN2=E&ESTRUTN1=0301&PALAVRASN1=".$word; + } + else + { + return "http://www.livrariasaraiva.com.br/pesquisaweb/pesquisaweb.dll/pesquisa?ORDEMN2=E&ESTRUTN1=0301&PALAVRASN1=".$word; + } + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return "http://www.livrariasaraiva.com.br".$url; + } + + sub getName + { + return "Saraiva"; + } + + sub getCharset + { + my $self = shift; + return "ISO-8859-1"; + } + + sub getAuthor + { + return 'nirev'; + } + + sub getLang + { + return 'PT'; + } + + sub getSearchFieldsArray + { + return ['isbn', 'title']; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCbooksAdlibrisCommon.pm b/lib/gcstar/GCPlugins/GCbooks/GCbooksAdlibrisCommon.pm new file mode 100644 index 0000000..ee556dc --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCbooksAdlibrisCommon.pm @@ -0,0 +1,331 @@ +package GCPlugins::GCbooks::GCbooksAdlibrisCommon; + +################################################### +# +# 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 GCPlugins::GCbooks::GCbooksCommon; + +{ + package GCPlugins::GCbooks::GCbooksAdlibrisPluginsBase; + + use base qw(GCPlugins::GCbooks::GCbooksPluginsBase); + use URI::Escape; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + if ( (($tagname eq 'div') && ($attr->{class} eq 'productTitleFormat')) + || (($tagname eq 'a') && ($attr->{id} eq 'ctl00_main_frame_ctrlproduct_linkProductTitle')) + ) + { + $self->{isFound} = 1 ; + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $self->{loadedUrl}; + } + elsif (($tagname eq 'a') && ($attr->{id} =~ m/_hlkTitle/i) && ($self->{isFound} eq '0')) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://www.adlibris.com/" . $self->{isLang} . "/" . $attr->{href}; + $self->{isTitle} = 1 ; + } + elsif (($tagname eq 'span') && ($attr->{id} =~ m/ctl00_main_frame_ctrlsearchhit_rptSearchHit_ctl/i) && ($attr->{id} =~ m/_Label2/i) && ($self->{isFound} eq '0')) + { + $self->{isAuthor} = 1 ; + } + elsif (($tagname eq 'span') && ($attr->{id} =~ m/ctl00_main_frame_ctrlsearchhit_rptSearchHit_ctl/i) && ($attr->{id} =~ m/_Label4/i) && ($self->{isFound} eq '0')) + { + $self->{isFormat} = 1 ; + } + } + else + { + if (($tagname eq 'h1')) + { + $self->{isTitle} = 1 ; + } + elsif (($tagname eq 'li') && ($attr->{id} eq 'ctl00_main_frame_ctrlproduct_liISBN13')) + { + $self->{isbnLevel} = 1 ; + } + elsif ($self->{isbnLevel} > 0) + { + if ($self->{isbnLevel} < 5) + { + $self->{isbnLevel}++ ; + } + else + { + $self->{isISBN} = 1 ; + $self->{isbnLevel} = 0 ; + } + } + elsif (($tagname eq 'a') && (($attr->{id} eq 'ctl00_main_frame_ctrlproduct_rptAuthor_ctl00_linkAuthor')) || ($attr->{id} eq 'ctl00_main_frame_ctrlproduct_rptAuthor_ctl01_linkAuthor')) + { + $self->{isAuthor} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{id} eq 'ctl00_main_frame_ctrlproduct_linkPublisher')) + { + $self->{isPublisher} = 1 ; + } + elsif (($tagname eq 'span') && ($attr->{id} eq 'ctl00_main_frame_ctrlproduct_lblPublished')) + { + $self->{isPublication} = 1 ; + } + elsif (($tagname eq 'span') && ($attr->{id} eq 'ctl00_main_frame_ctrlproduct_lblPages')) + { + $self->{isPages} = 1 ; + } + elsif (($tagname eq 'span') && ($attr->{id} eq 'ctl00_main_frame_ctrlproduct_lblLanguage')) + { + $self->{isLanguage} = 1 ; + } + elsif (($tagname eq 'span') && ($attr->{id} eq 'ctl00_main_frame_ctrlproduct_lblFormat')) + { + $self->{isReliure} = 1 ; + } + elsif (($tagname eq 'div') && ($attr->{class} eq 'productDescription')) + { + $self->{isDescription} = 1 ; + } + elsif (($tagname eq 'img') && ($attr->{id} eq 'ctl00_main_frame_ctrlproduct_imgProduct_ProductImageNotLinked') && !($attr->{src} =~ m/\/noimage./i)) + { + $self->{curInfo}->{cover} = $attr->{src} ; + } + + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{isFound} = 0 ; + $self->{inside}->{$tagname}--; + if (($self->{isDescription}) && ($tagname eq 'div')) + { + $self->{isDescription} = 0; + $self->{curInfo}->{description} =~ s/^Beskrivning://g ; + $self->{curInfo}->{description} =~ s/^Kuvaus://g ; + } + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isTitle}) + { + $self->{itemsList}[$self->{itemIdx}]->{title} = $origtext; + $self->{isTitle} = 0 ; + } + elsif ($self->{isAuthor}) + { + my @array = split(/&/,$origtext); + my $element; + foreach $element (@array) + { + my @nom_prenom = split(/,/,$element); + # Enleve les blancs en debut de chaine + $nom_prenom[0] =~ s/^\s+//; + $nom_prenom[1] =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $nom_prenom[0] =~ s/\s$+//; + $nom_prenom[1] =~ s/\s$+//; + if ($self->{itemsList}[$self->{itemIdx}]->{authors} eq '') + { + $self->{itemsList}[$self->{itemIdx}]->{authors} = $nom_prenom[1] ." " . $nom_prenom[0]; + } + else + { + $self->{itemsList}[$self->{itemIdx}]->{authors} .= ", " . $nom_prenom[1] ." " . $nom_prenom[0]; + } + } + + $self->{isAuthor} = 0 ; + } + elsif ($self->{isFormat}) + { + $self->{itemsList}[$self->{itemIdx}]->{format} = $origtext; + $self->{isFormat} = 0 ; + } + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + $origtext =~ s/\s+$//; + if ($self->{isTitle}) + { + $self->{curInfo}->{title} = $origtext; + $self->{isTitle} = 0 ; + } + elsif ($self->{isAuthor}) + { + $self->{curInfo}->{authors} .= $origtext; + $self->{curInfo}->{authors} .= ","; + $self->{isAuthor} = 0 ; + } + elsif ($self->{isISBN}) + { + $self->{curInfo}->{isbn} = $origtext; + $self->{curInfo}->{isbn} =~ s/\s//g; + $self->{isISBN} = 0 ; + } + elsif ($self->{isPublisher}) + { + $self->{curInfo}->{publisher} = $origtext; + $self->{isPublisher} = 0 ; + } + elsif ($self->{isPublication}) + { + $self->{curInfo}->{publication} = $origtext; + $self->{curInfo}->{publication} =~ s/(\d\d\d\d)(\d\d)/01\/$2\/$1/g; + $self->{isPublication} = 0 ; + } + elsif ($self->{isPages}) + { + $self->{curInfo}->{pages} = $origtext; + $self->{isPages} = 0 ; + } + elsif ($self->{isLanguage}) + { + $self->{curInfo}->{language} = $origtext; + $self->{isLanguage} = 0 ; + } + elsif ($self->{isReliure}) + { + $self->{curInfo}->{format} = $origtext; + $self->{isReliure} = 0 ; + } + elsif ($self->{isDescription}) + { + $self->{curInfo}->{description} .= $origtext ; + } + + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + authors => 1, + publication => 0, + format => 1, + edition => 0, + }; + + $self->{isLang} = 'se'; + $self->{isFound} = 0; + $self->{isTitle} = 0; + $self->{isAuthor} = 0; + $self->{isFormat} = 0; + $self->{isPublisher} = 0; + $self->{isISBN} = 0; + $self->{isPublicationAndPages} = 0; + $self->{isLangAndReliure} = 0; + $self->{isDescription} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s|
  • |\n* |g; + $html =~ s|
    |\n|g; + $html =~ s|
    |\n|g; + $html =~ s|

    |\n|g; + $html =~ s|||g; + $html =~ s|||g; + $html =~ s|||g; + $html =~ s|||g; + } + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + if ($self->{searchField} eq 'isbn') + { + return "http://www.adlibris.com/" . $self->{isLang} . "/searchresult.aspx?isbn=" . $word. "&%3BfromProduct=true"; + } + else + { + return "http://www.adlibris.com/" . $self->{isLang} . "/searchresult.aspx?title=" . $word. "&%3BfromProduct=true"; + } + + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url; + } + + sub getName + { + return "Adlibris"; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'SW'; + } + + sub getSearchFieldsArray + { + return ['isbn', 'title']; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCbooksAmazonCommon.pm b/lib/gcstar/GCPlugins/GCbooks/GCbooksAmazonCommon.pm new file mode 100644 index 0000000..bc75766 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCbooksAmazonCommon.pm @@ -0,0 +1,65 @@ +package GCPlugins::GCbooks::GCbooksAmazonCommon; + +################################################### +# +# 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 GCPlugins::GCbooks::GCbooksCommon; +use GCPlugins::GCstar::GCAmazonCommon; + +{ + package GCPlugins::GCbooks::GCbooksAmazonPluginsBase; + + use base ('GCPlugins::GCbooks::GCbooksPluginsBase', 'GCPlugins::GCstar::GCPluginAmazonCommon'); + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{codeField} = 'isbn'; + + return $self; + } + + sub isEAN + { + my ($self, $value) = @_; + + return $value =~ /^978/; + } + + sub getSearchFieldsArray + { + return ['isbn', 'title']; + } + + sub getEanField + { + return 'isbn'; + } +} + +1; \ No newline at end of file diff --git a/lib/gcstar/GCPlugins/GCbooks/GCbooksCommon.pm b/lib/gcstar/GCPlugins/GCbooks/GCbooksCommon.pm new file mode 100644 index 0000000..a74e35a --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCbooksCommon.pm @@ -0,0 +1,61 @@ +package GCPlugins::GCbooks::GCbooksCommon; + +################################################### +# +# 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 GCPlugins::GCPluginsBase; + +{ + package GCPlugins::GCbooks::GCbooksPluginsBase; + + use base qw(GCPluginParser); + use HTML::Entities; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + $self->{searchType} = 'books'; + return $self; + } + + sub getSearchFieldsArray + { + return ['title']; + } + + sub getEanField + { + my $self = shift; + my $fields = $self->getSearchFieldsArray; + return 'isbn' + if $fields->[0] eq 'isbn'; + return undef; + } + +} + +1; \ No newline at end of file diff --git a/lib/gcstar/GCPlugins/GCcomics/GCbedetheque.pm b/lib/gcstar/GCPlugins/GCcomics/GCbedetheque.pm new file mode 100644 index 0000000..457194a --- /dev/null +++ b/lib/gcstar/GCPlugins/GCcomics/GCbedetheque.pm @@ -0,0 +1,398 @@ +package GCPlugins::GCcomics::GCbedetheque; + +################################################### +# +# 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::GCcomics::GCcomicsCommon; + +{ + + package GCPlugins::GCcomics::GCPluginbedetheque; + + use LWP::Simple qw($ua); + + use base qw(GCPlugins::GCcomics::GCcomicsPluginsBase); + sub getSearchUrl + { + my ( $self, $word ) = @_; + if ($self->{searchField} eq 'series') + { + return "http://www.bedetheque.com/index.php?R=1&RechSerie=$word"; + } + elsif ($self->{searchField} eq 'writer') + { + return "http://www.bedetheque.com/index.php?R=1&RechAuteur=$word"; + } + else + { + return ''; + } + + #return "http://www.bedetheque.com/index.php?R=1&RechTexte=$word"; + } + + sub getSearchFieldsArray + { + return ['series', 'writer']; + } + + sub getItemUrl + { + my ( $self, $url ) = @_; + my @array = split( /#/, $url ); + $self->{site_internal_id} = $array[1]; + + return $url if $url =~ /^http:/; + return "http://www.bedetheque.com/" . $url; + } + + sub getNumberPasses + { + return 1; + } + + sub getName + { + return "Bedetheque"; + } + + sub getAuthor + { + return 'Mckmonster'; + } + + sub getLang + { + return 'FR'; + } + + sub getSearchCharset + { + my $self = shift; + + # Need urls to be double character encoded + return "utf8"; + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless( $self, $class ); + + $self->{hasField} = { + series => 1, + title => 1, + volume => 1, + }; + + $self->{isResultsTable} = 0; + $self->{isCover} = 0; + $self->{itemIdx} = 0; + $self->{last_cover} = ""; + $self->{site_internal_id} = ""; + $self->{serie} = ""; + $self->{synopsis} = ""; + $self->{current_field} = ""; + + return $self; + } + + sub preProcess + { + my ( $self, $html ) = @_; + + $self->{parsingEnded} = 0; + $html =~ s/\s+/ /g; + $html =~ s/\r?\n//g; + + if ( $self->{parsingList} ) + { + if ( $html =~ m/(\d+\salbum\(s\).+)/ ) { + + #keep only albums, no series or objects + $html = $1; + $self->{alternative} = 0; + } elsif ( $html =~ m/(

    .+)/ ) { + $html = $1; + $self->{alternative} = 1; + } + } + else + { + $html =~ m/(
    .+)/; + + #$html =~ m/(
    {href} =~ m/album-/ ) ) + { + $self->{isCollection} = 1; + $self->{itemIdx}++; + + my $searchUrl = substr($attr->{href},0,index($attr->{href},".")).substr($attr->{href},index($attr->{href},".")); + $self->{itemsList}[$self->{itemIdx}]->{url} = $searchUrl; + $self->{itemsList}[$self->{itemIdx}]->{title} = $attr->{title}; + + #$self->{itemsList}[ $self->{itemIdx} ]->{url} = + # "http://www.bedetheque.com/" . $attr->{href}; + } + elsif ( $tagname eq "i" ) + { + $self->{isSerie} = 1; + } + } else { + if ( ( $tagname eq "table" ) && ( $attr->{id} eq "albums_serie" ) ) { + $self->{inTable} = 1; + } + elsif ( ($self->{inTable}) && ( $tagname eq "td" ) && ( $attr->{class} eq "num" ) ) { + $self->{itemIdx}++; + $self->{isVolume} = 1; + } + elsif ( ($self->{inTable}) && ( $tagname eq "a" ) && ( $attr->{href} =~ m/serie-/ ) ) { + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + $self->{isTitle} = 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; + } + } + } + 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}; + $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 ( ( $self->{isResultsTable} ) && ( $tagname eq "label" ) ) { + $self->{current_field} = ''; + $self->{openlabel} = 1; + } + elsif ( ( $tagname eq "div" ) && ( $attr->{class} eq "title" ) && ( !defined( $self->{curInfo}->{title} ) || ( $self->{curInfo}->{title} =~ /^$/ ) ) ) { + $self->{isTitle} = 1; + } + elsif ( ( $tagname eq "span" ) && ( $attr->{class} eq "type" ) ) { + $self->{isSerie} = 1; + } + elsif ( $tagname eq "em" ) { + $self->{isSynopsis} = 1; + } + elsif ( ( $tagname eq "a" ) && ( $attr->{class} eq "titre eo" ) ) { + if ( $attr->{title} =~ m/.+\s-(\d+)-\s.+/ ) { + $self->{curInfo}->{volume} = $1; + } + } + } + } + + sub text + { + my ( $self, $origtext ) = @_; + + return if ( $origtext eq " " ); + + return if ( $self->{parsingEnded} ); + + if ( $self->{parsingList} ) + { + if ( !defined ($self->{alternative}) || (!$self->{alternative}) ) { + if ( $self->{isSerie} == 1) + { + $self->{itemsList}[ $self->{itemIdx} ]->{series} = $origtext; + $self->{isSerie} = 0; + } + else + { + if ($self->{isCollection} == 1) + { + + #sometimes the field is "-vol-title", sometimes "--vol-title" + $origtext =~ s/-+/-/; + if ( $origtext =~ m/(.+)\s-(\d+)-\s(.+)/ ) { + $self->{itemsList}[ $self->{itemIdx} ]->{series} = $1; + $self->{itemsList}[ $self->{itemIdx} ]->{volume} = $2; + } elsif ( $origtext =~ /-/ ){ + my @fields = split( /-/, $origtext ); + $self->{itemsList}[ $self->{itemIdx} ]->{series} = $fields[0]; + $self->{itemsList}[ $self->{itemIdx} ]->{volume} = $fields[1]; + } + $self->{isCollection} = 0; + } + } + } else { + if ( ( $self->{inTable} ) && ( $self->{isTitle} ) ) { + $self->{itemsList}[ $self->{itemIdx} ]->{title} = $origtext; + } elsif ( ( $self->{inTable} ) && ( $self->{isVolume} ) ) { + $self->{itemsList}[ $self->{itemIdx} ]->{volume} = $origtext; + } + } + } + else + { + if ( $self->{isResultsTable} == 1 ) + { + $origtext=~s/:\s+/:/; + my %td_fields_map = ( + "Identifiant :" => '', + "Scénario :" => 'writer', + "Dessin :" => 'illustrator', + "Couleurs :" => 'colourist', + "Dépot légal :" => 'publishdate', + "Achevé impr. :" => 'printdate ', + "Estimation :" => 'cost', + "Editeur :" => 'publisher', + "Collection : " => 'collection', + "Taille :" => 'format', + "ISBN :" => 'isbn', + "Planches :" => 'numberboards' + ); + + if ( ( $self->{openlabel} ) && ( exists $td_fields_map{$origtext} ) ) { + $self->{current_field} = $td_fields_map{$origtext}; + } + elsif ( defined ( $self->{current_field} ) && ( $self->{current_field} !~ /^$/ ) ) + { + $origtext=~s/ / /g; + $origtext=~s/\s+$//g; + $self->{curInfo}->{$self->{current_field}} = $origtext; + $self->{current_field} = ""; + } + } + elsif ( $self->{isVolume} ) + { + $self->{curInfo}->{volume} = $origtext; + $self->{isVolume} = 0 ; + } + + if ( $self->{isTitle} ) + { + $self->{curInfo}->{title} = $origtext; + } + elsif ( $self->{isSerie} ) { + $self->{curInfo}->{series} = $origtext; + $self->{curInfo}->{series} =~s/^\s+//; + } + elsif ( ( $self->{isSynopsis} ) && ( ( $origtext =~ /Résumé de l'album :/ ) || ( $origtext =~ /Résumé de la série :/ ) ) ) { + $self->{startSynopsis} = 1; + } + elsif ( ( $self->{isSynopsis} ) && ( $self->{startSynopsis} ) ) { + $self->{curInfo}->{synopsis} .= " ".$origtext; + $self->{curInfo}->{synopsis} =~ s/^(\s)*//; + $self->{curInfo}->{synopsis} =~ s/(\s)*$//; + } + } + } + + sub end + { + my ( $self, $tagname ) = @_; + + return if ( $self->{parsingEnded} ); + + if ( $self->{parsingList} ) + { + if ( !defined ($self->{alternative}) || (!$self->{alternative}) ) { + if ( ( $tagname eq "i" ) && $self->{isCollection} == 1) + { + + #end of collection, next field is title + $self->{isTitle} = 1; + $self->{isCollection} = 0; + } + } else { + if ( ( $self->{inTable} ) && ( $tagname eq "a" ) ) { + $self->{isTitle} = 0; + } elsif ( ( $self->{inTable} ) && ( $tagname eq "td" ) ) { + $self->{isVolume} = 0; + } + } + } + else + { + if ( ( $tagname eq "ul" ) && $self->{isResultsTable} == 1 ) + { + $self->{isIssue} = 0; + $self->{isResultsTable} = 0; + } + elsif ( ( $self->{isResultsTable} ) && ( $tagname eq "label" ) ) { + $self->{openlabel} = 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 ( ( $self->{isSynopsis} ) && ( ( $tagname eq "p" ) || ( $tagname eq "br" ) ) && ( $self->{startSynopsis} ) ) { + $self->{isSynopsis} = 0; + $self->{startSynopsis} = 0; + $self->{parsingEnded} = 1; + } + } + } +} + +1; \ No newline at end of file diff --git a/lib/gcstar/GCPlugins/GCcomics/GCcomicbookdb.pm b/lib/gcstar/GCPlugins/GCcomics/GCcomicbookdb.pm new file mode 100644 index 0000000..80b299b --- /dev/null +++ b/lib/gcstar/GCPlugins/GCcomics/GCcomicbookdb.pm @@ -0,0 +1,546 @@ +package GCPlugins::GCcomics::GCcomicbookdb; + +################################################### +# +# Copyright 2005-2012 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::GCcomics::GCcomicsCommon; + +{ + + package GCPlugins::GCcomics::GCPlugincomicbookdb; + + use LWP::Simple qw($ua); + use HTTP::Cookies; + + use base qw(GCPlugins::GCcomics::GCcomicsPluginsBase); + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + if ($self->{pass} == 1) + { + # First pass, searching for series name + if ($tagname eq "h2") + { + $self->{isAtResults} = 1; + } + if ( ($tagname eq "a") + && ($self->{isAtResults}) + && !($attr->{href} =~ m/ebay\.com/)) + { + $self->{isCollection} = 1; + $self->{itemIdx}++; + + $self->{itemsList}[ $self->{itemIdx} ]->{nextUrl} = + "http://www.comicbookdb.com/" . $attr->{href}; + } + } + else + { + # Second pass, or fetching item info + if ($self->{parsingList}) + { + + if ( ($tagname eq "tbody") + && ($self->{isResultsTable}) + && ($self->{isSpecialIssue} == 1)) + { + $self->{isSpecialIssue} = 2; + } + # Parsing issue list + if (($tagname eq "a") && ($self->{isResultsTable})) + { + if ($attr->{href} =~ m/javascript/) + { + # Multiple editions of the one issue, need to be + # handled differently + $self->{isSpecialIssue} = 1; + } + elsif ($attr->{href} =~ m/storyarc.php/) + { + # Prevent story arcs from populating lists + } + elsif ($self->{isSpecialIssue} == 1) + { + $self->{resultsTableColumn}++; + if ($self->{resultsTableColumn} == 1) + { + $self->{isSpecialIssueNo} = 1; + $self->{isIssue} = 1; + $self->{itemIdx}++; + $self->{itemsList}[ $self->{itemIdx} ]->{url} = + "http://www.comicbookdb.com/" . $attr->{href}; + } + elsif ($self->{resultsTableColumn} == 2) + { + $self->{isTitle} = 1; + $self->{isSpecialTitle} = 1; + } + } + elsif ($self->{isSpecialIssue} == 2) + { + $self->{itemIdx}++; + $self->{itemsList}[ $self->{itemIdx} ]->{url} = + "http://www.comicbookdb.com/" . $attr->{href}; + $self->{isTitle} = 1; + } + else + { + $self->{resultsTableColumn}++; + if ($self->{resultsTableColumn} == 1) + { + $self->{isIssue} = 1; + $self->{itemIdx}++; + $self->{itemsList}[ $self->{itemIdx} ]->{url} = + "http://www.comicbookdb.com/" . $attr->{href}; + } + elsif ($self->{resultsTableColumn} == 2) + { + $self->{isTitle} = 1; + } + } + } + } + else + { + # Fetching item info + if ( ($tagname eq "span") + && ((index $attr->{class}, "page_headline") > -1)) + { + $self->{insideHeadline} = 1; + } + elsif (($tagname eq "a") + && ($self->{insideHeadline}) + && ($attr->{href} =~ m/title.php/)) + { + $self->{insideName} = 1; + } + elsif (($tagname eq "a") + && ($self->{insideHeadline}) + && ($attr->{href} =~ m/issue_number.php/)) + { + $self->{insideNumber} = 1; + } + elsif (($tagname eq "a") && ($self->{nextisWriters})) + { + $self->{insideWriters} = 1; + $self->{insidePencillers} = 0; + $self->{insideColorists} = 0; + } + elsif (($tagname eq "a") && ($self->{nextisPencillers})) + { + $self->{insideWriters} = 0; + $self->{insidePencillers} = 1; + $self->{insideColorists} = 0; + } + elsif (($tagname eq "a") && ($self->{nextisColorists})) + { + $self->{insideWriters} = 0; + $self->{insidePencillers} = 0; + $self->{insideColorists} = 1; + } + elsif (($tagname eq "a") && ($attr->{href} =~ /imprint.php/)) + { + $self->{insidePublisher} = 1; + } + elsif (($tagname eq "a") + && ($attr->{href} =~ /publisher.php/) + && (!$self->{curInfo}->{publisher})) + { + $self->{insidePublisher} = 1; + } + elsif (($tagname eq "a") && ($attr->{href} =~ /coverdate.php/)) + { + $self->{insideCoverDate} = 1; + } + if ( ($tagname eq "span") + && ((index $attr->{class}, "test") > -1) + && ((index $attr->{class}, "page_subheadline") > -1)) + { + $self->{insideSubHeadline} = 1; + } + elsif (($tagname eq "a") + && ($attr->{href} =~ /^graphics\/comic_graphics\//)) + { + $self->{curInfo}->{image} = + "http://www.comicbookdb.com/" . $attr->{href}; + } + elsif (($tagname eq "img") + && ($attr->{src} =~ /^graphics\/comic_graphics\//) + && (!$self->{curInfo}->{image})) + { + $self->{curInfo}->{image} = + "http://www.comicbookdb.com/" . $attr->{src}; + } + + } + } + } + + sub end + { + my ($self, $tagname) = @_; + $self->{inside}->{$tagname}--; + + if ($self->{isResultsTable}) + { + if ($tagname eq "table") + { + $self->{isResultsTable} = 0; + } + elsif ($tagname eq "tr") + { + $self->{resultsTableColumn} = 0; + } + } + + if ($tagname eq "tbody") + { + $self->{isSpecialIssue} = 0; + } + elsif ($tagname eq "span") + { + $self->{insideHeadline} = 0; + $self->{insideSubHeadline} = 0; + $self->{insideNumber} = 0; + } + elsif ($tagname eq "td") + { + $self->{isAtResults} = 0; + $self->{nextisWriters} = 0; + $self->{nextisPencillers} = 0; + $self->{nextisColorists} = 0; + $self->{insideWriters} = 0; + $self->{insidePencillers} = 0; + $self->{insideColorists} = 0; + } + elsif ($tagname eq "a") + { + $self->{insidePublisher} = 0; + $self->{insideCoverDate} = 0; + } + } + + sub text + { + my ($self, $origtext) = @_; + + return if ($origtext eq " "); + + return if ($self->{parsingEnded}); + + if ($self->{parsingList}) + { + if ($self->{isCollection}) + { + $self->{itemsList}[ $self->{itemIdx} ]->{series} = $origtext; + $self->{isCollection} = 0; + } + if ($origtext eq "Cover Date") + { + $self->{isResultsTable} = 1; + } + if ($self->{isIssue}) + { + $self->{itemsList}[ $self->{itemIdx} ]->{volume} = $origtext; + $self->{isIssue} = 0; + } + if ($self->{isSpecialIssueNo}) + { + $self->{specialIssueNo} = $origtext; + $self->{isSpecialIssueNo} = 0; + } + if ($self->{isTitle}) + { + if ($self->{isSpecialIssue} == 2) + { + $self->{itemsList}[ $self->{itemIdx} ]->{volume} = + $self->{specialIssueNo}; + $self->{itemsList}[ $self->{itemIdx} ]->{title} = + $self->{specialTitle} . $origtext; + } + else + { + $self->{itemsList}[ $self->{itemIdx} ]->{title} = $origtext; + } + $self->{isTitle} = 0; + } + if ($self->{isSpecialTitle}) + { + $self->{specialTitle} = $origtext; + $self->{isSpecialTitle} = 0; + } + } + else + { + if ($self->{insideName}) + { + $self->{curInfo}->{series} = $origtext; + #$self->{curInfo}->{series} =~ s/(\s\([0-9]*\))$//; + $self->{insideName} = 0; + } + elsif (($self->{insideNumber}) && ($origtext =~ /^\s*#(\d+)/)) + { + # volume where #XX is in {curInfo}->{volume} = $1; + $self->{insideNumber} = 0; + } + elsif (($self->{insideHeadline}) && ($origtext =~ /-\s#(\d+)/)) + { + # volume where #XX isn't in {curInfo}->{volume} = $1; + $self->{insideNumber} = 0; + } + elsif (($self->{insideHeadline}) && ($origtext =~ /-\s*TPB/)) + { + # Trade paperback + $self->{curInfo}->{series} .= " TPB"; + + # Get volume number. Default to 1. + if ($origtext =~ /vol\. (\d+)/) + { + $self->{curInfo}->{volume} = $1; + } + else + { + $self->{curInfo}->{volume} = 1; + } + $self->{insideNumber} = 0; + } + elsif (($self->{insideHeadline}) && ($origtext =~ /vol\. (\d+)/)) + { + $self->{curInfo}->{volume} = $1; + $self->{insideNumber} = 0; + } + elsif (($self->{insideHeadline}) && ($origtext =~ /-\s*Annual\s*(\d+)/)) + { + # Annual volume where #XX isn't in {curInfo}->{volume} = $1; + $self->{curInfo}->{series} .= " Annual"; + $self->{insideNumber} = 0; + } + elsif (($self->{insideSubHeadline}) && ($origtext =~ /\"(.*)\"/)) + { + $self->{curInfo}->{title} = $1; + + # Get printing or other note if present + if ($origtext =~ /\((.*)\)/) + { + $self->{curInfo}->{title} .= " (" . $1 . ")"; + } + } + elsif ($self->{insidePublisher}) + { + $self->{curInfo}->{publisher} = $origtext; + $self->{insidePublisher} = 0; + } + elsif ($origtext eq "Writer(s):") + { + $self->{nextisWriters} = 1; + $self->{nextisPencillers} = 0; + $self->{nextisColorists} = 0; + } + elsif ($origtext eq "Penciller(s):") + { + $self->{nextisWriters} = 0; + $self->{nextisPencillers} = 1; + $self->{nextisColorists} = 0; + } + elsif ($origtext eq "Colorist(s):") + { + $self->{nextisWriters} = 0; + $self->{nextisPencillers} = 0; + $self->{nextisColorists} = 1; + } + elsif (($origtext eq "Letterer(s):") + || ($origtext eq "Inker(s):") + || ($origtext eq "Editor(s):") + || ($origtext eq "Cover Artist(s):") + || ($origtext eq "Characters:") + || ($origtext eq "Groups:")) + { + $self->{nextisWriters} = 0; + $self->{nextisPencillers} = 0; + $self->{nextisColorists} = 0; + } + elsif ($self->{insideWriters}) + { + if ($self->{curInfo}->{writer} eq "") + { + $self->{curInfo}->{writer} = $origtext; + } + elsif ((index $self->{curInfo}->{writer}, $origtext) == -1) + { + $self->{curInfo}->{writer} .= ", "; + $self->{curInfo}->{writer} .= $origtext; + } + + $self->{insideWriters} = 0; + } + elsif ($self->{insidePencillers}) + { + if ($self->{curInfo}->{illustrator} eq "") + { + $self->{curInfo}->{illustrator} = $origtext; + } + elsif ((index $self->{curInfo}->{illustrator}, $origtext) == -1) + { + $self->{curInfo}->{illustrator} .= ", "; + $self->{curInfo}->{illustrator} .= $origtext; + } + + $self->{insidePencillers} = 0; + } + elsif ($self->{insideColorists}) + { + if ($self->{curInfo}->{colourist} eq "") + { + $self->{curInfo}->{colourist} = $origtext; + } + elsif ((index $self->{curInfo}->{colourist}, $origtext) == -1) + { + $self->{curInfo}->{colourist} .= ", "; + $self->{curInfo}->{colourist} .= $origtext; + } + + $self->{insideColorists} = 0; + } + elsif ($origtext eq "Synopsis: ") + { + $self->{nextisSynopsis} = 1; + } + elsif ($self->{nextisSynopsis}) + { + if ($origtext !~ /None entered./) + { + $self->{curInfo}->{synopsis} = $origtext; + $self->{curInfo}->{synopsis} =~ s/^(\s)*//; + $self->{curInfo}->{synopsis} =~ s/(\s)*$//; + } + $self->{nextisSynopsis} = 0; + } + elsif ($self->{insideCoverDate}) + { + $self->{curInfo}->{printdate} = $origtext; + $self->{curInfo}->{printdate} =~ s/^(\s)*//; + + # Translate date string to date + $self->{curInfo}->{printdate} = + GCUtils::strToTime($self->{curInfo}->{printdate}, "%B %Y"); + $self->{curInfo}->{publishdate} = $self->{curInfo}->{printdate}; + } + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + + $self->{ua}->cookie_jar(HTTP::Cookies->new); + + bless($self, $class); + + $self->{isResultsTable} = 0; + $self->{itemIdx} = 0; + $self->{resultsTableColumn} = 0; + $self->{curName} = undef; + $self->{curUrl} = undef; + + return $self; + } + + sub getReturnedFields + { + my $self = shift; + + if ($self->{pass} == 1) + { + $self->{hasField} = {series => 1,}; + } + else + { + $self->{hasField} = { + title => 1, + volume => 1, + }; + } + } + + sub preProcess + { + my ($self, $html) = @_; + + $self->{parsingEnded} = 0; + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + $word =~ s/\+%28\d{4}%29$//; # strip year from end of $word (title) + + # Grab the home page first, or the pages fetched are blank + # (who knows why... must be something funky with the website) + my $response = $ua->get('http://www.comicbookdb.com/'); + + return + "http://www.comicbookdb.com/search.php?form_search=$word&form_searchtype=Title"; + } + + sub getItemUrl + { + my ($self, $url) = @_; + return $url if $url =~ /^http:/; + + return "http://www.comicbookdb.com" . $url; + } + + sub getNumberPasses + { + return 2; + } + + sub getName + { + return "Comic Book DB"; + } + + sub getAuthor + { + return 'Zombiepig'; + } + + sub getLang + { + return 'EN'; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCcomics/GCcomicsCommon.pm b/lib/gcstar/GCPlugins/GCcomics/GCcomicsCommon.pm new file mode 100644 index 0000000..3b1229c --- /dev/null +++ b/lib/gcstar/GCPlugins/GCcomics/GCcomicsCommon.pm @@ -0,0 +1,49 @@ +package GCPlugins::GCcomics::GCcomicsCommon; + +################################################### +# +# 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 GCPlugins::GCPluginsBase; + +{ + package GCPlugins::GCcomics::GCcomicsPluginsBase; + + use base qw(GCPluginParser); + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + return $self; + } + + sub getSearchFieldsArray + { + return ['series']; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCcomics/GCmangasanctuary.pm b/lib/gcstar/GCPlugins/GCcomics/GCmangasanctuary.pm new file mode 100644 index 0000000..d05d0c8 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCcomics/GCmangasanctuary.pm @@ -0,0 +1,503 @@ +package GCPlugins::GCcomics::GCmangasanctuary; + +################################################### +# +# Copyright 2005-2007 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCcomics::GCcomicsCommon; + +{ + + package GCPlugins::GCcomics::GCPluginmangasanctuary; + + use LWP::Simple qw($ua); + + use base qw(GCPlugins::GCcomics::GCcomicsPluginsBase); + + sub start + { + my ( $self, $tagname, $attr, $attrseq, $origtext ) = @_; + if ( $self->{parsingList} )# partie en rapport à la page de résultats + { + + #The interesting part to parse looks like this : + #
  • Rebirth #2 Manhwa
  • + if ( $tagname eq "a" ) + { + $self->{isDebut} = 1; + $self->{itemIdx}++; + $self->{itemsList}[ $self->{itemIdx} ]->{url} = "http://www.manga-sanctuary.com" . $attr->{href}; + $attr->{href} =~ m/\/(.*?)-.*-vol-\d+-(.*?)-s\d+-p\d+.html/; + $self->{itemsList}[ $self->{itemIdx} ]->{type} = $1; + $self->{itemsList}[ $self->{itemIdx} ]->{format} = $2; + } + } + else# partie en rapport à la page de l'élément + { + + #Commencer par récupérer l'image + # + if ( ( $tagname eq "a" ) && ( $attr->{href} =~ m/couvertures.*\.[jJ][pP][gG]/ ) ) + { + my $response = $ua->get("http://www.manga-sanctuary.com" . $attr->{href}); + if ($response->content_type =~ m/text\/html/) #la grande image n'existe pas + { + $self->{downloadThumbnail} = 1; + } + else#la grande image existe + { + $self->{curInfo}->{image} = "http://www.manga-sanctuary.com" . $attr->{href}; + } + } + if ( ( $tagname eq "img" ) && ( $attr->{src} =~ m/couvertures.*\.[jJ][pP][gG]/ ) && ($self->{downloadThumbnail} == 1) ) + { + $self->{curInfo}->{image} = "http://www.manga-sanctuary.com" . $attr->{src}; + $self->{downloadThumbnail} =0; + } + #Code général détection dt et dd + if ( $tagname eq "dt") + { + $self->{tagDTdetected} =1; + }elsif ( $tagname eq "dd") + { + $self->{tagDDdetected} =1; + }elsif ( $tagname eq "h3") + { + $self->{tagH3detected} =1; + }elsif ( $tagname eq "p") + { + $self->{tagPdetected} =1; + }elsif ( $tagname eq "a") + { + $self->{tagAdetected} =1; + } + #Code pour différencier les types de titres (original /français) + if ( ( $tagname eq "img") && ( $attr->{src} =~ m/\/design\/img\/flags/ ) && ($self->{titleDetected} == 1) ) + { + $attr->{src} =~ m/\/(\d*)\.png$/; + if ($1 == 77) + { + $self->{titreFrancais} = 1; + } + else + { + $self->{titreFrancais} = 0; + } + } + #Code pour récupérer la notation + #
      \nStaff MS:
    + if ( ( $tagname eq "ul") && ( $attr->{id} =~ m/notation/ ) ) + { + $self->{notationDetected} = 1; + }elsif ( ( $tagname eq "img") && ( $self->{notationDetected} == 1 ) ) + { + $attr->{title} =~ m/^(\d*\.?\d*)\/10/; + $self->{curInfo}->{rating} = $1; + $self->{notationDetected} = 0; + + #Récupération du format dans l'adresse de la page. + #http://www.manga-sanctuary.com/manga-duds-hunt-vol-1-simple-s1169-p1477.html + #Peut être fait dès que webPage est renseigné, placé ici pour être sûr de n'être lancé qu'une seule fois. + $self->{curInfo}->{webPage} =~ m/vol-\d+-(.*?)-s\d+-p\d+\.html/; + $self->{curInfo}->{format} = $1; + } + } + } + + sub end + { + my ( $self, $tagname ) = @_; + if ( $self->{parsingList} )# partie en rapport à la page de résultats + { + if ( ( $tagname eq "a" ) && $self->{isFin} == 1 ) + { + #end of collection, next field is title + $self->{isFin} = 0; + } + } + else# partie en rapport à la page de l'élément + { + #Code général détection dt et dd + if ( $tagname eq "dt") + { + $self->{tagDTdetected} =0; + }elsif ( $tagname eq "dd") + { + $self->{tagDDdetected} =0; + #RAZ en cas de champ vide + $self->{titleDetected} =0; + $self->{titreFrancais} = 1; + $self->{publisherDetected} =0; + $self->{collectionDetected} =0; + $self->{publishdateDetected} =0; + $self->{costDetected} =0; + $self->{typeDetected} =0; + $self->{categoryDetected} =0; + $self->{genresDetected} =0; + $self->{scenaristeDetected} =0; + $self->{dessinateurDetected} =0; + }elsif ( $tagname eq "div")#Le code à récupérer pour un titre h3 donné se trouve après la balise <\h3> donc on ne peut pas l'utiliser. + { + $self->{tagH3detected} =0; + }elsif ( $tagname eq "p") + { + $self->{tagPdetected} =0; + #RAZ en cas de champ vide + $self->{synopsisDetected} =0; + $self->{critiquesDetected} =0; + $self->{reactionsDetected} =0; + }elsif ( $tagname eq "a") + { + $self->{tagAdetected} =0; + }elsif ( $tagname eq "ul" ) + { + $self->{notationDetected} = 0; + } + } + } + + sub text + { + my ( $self, $origtext ) = @_; + + return if ( $origtext eq " " ); + + return if ( $self->{parsingEnded} ); + + if ( $self->{parsingList} )# partie en rapport à la page de résultats + { + if ( $self->{isDebut} ) + { + $self->{itemsList}[ $self->{itemIdx} ]->{title} = $origtext; + $self->{isDebut} = 0; + $self->{isFin} = 1; + } + } + else# partie en rapport à la page de l'élément + { + + if ( $self->{tagDTdetected} == 1 ) + { + #Title + #
    銃夢 Last Order
    Gunnm Last Order
    + if ($origtext =~ m/^Titre/) + { + $self->{titleDetected} =1; + } + #Volume + #
    \n
    1/23
    + elsif ($origtext =~ m/^Volume/) + { + $self->{volumeDetected} =1; + } + #Publisher + #
    \n
    Glénat
    + elsif ($origtext =~ m/^Editeur/) + { + $self->{publisherDetected} =1; + } + #collection + #
    \n
    Kana Shonen
    + elsif ($origtext =~ m/^Label/) + { + $self->{collectionDetected} =1; + } + #PublishDate + #
    \n
    31/10/2002
    + elsif ($origtext =~ m/^Date de sortie/) + { + $self->{publishdateDetected} =1; + } + #cost + #
    \n
    6.5 EUR
    + elsif ($origtext =~ m/^Prix/) + { + $self->{costDetected} =1; + } + #type + #
    \n
    Manga
    + elsif ($origtext =~ m/^Type/) + { + $self->{typeDetected} =1; + } + #category + #
    \n
    Seinen
    + elsif ($origtext =~ m/^Catégorie/) + { + $self->{categoryDetected} =1; + } + #Genres [NOTE: pas d'accès aux tags alors je le mets dans synopsis] + #
    \n
    Action, SF
    + elsif ($origtext =~ m/^Genres/) + { + $self->{genresDetected} =1; + } + #scenariste [de la fiche série] + #
    + elsif ($origtext =~ m/^Scénariste/) + { + $self->{scenaristeDetected} =1; + } + #dessinateur [de la fiche série] + #
    + elsif ($origtext =~ m/^Dessinateur/) + { + $self->{dessinateurDetected} =1; + } + } + + if ( $self->{tagDDdetected} == 1 ) + { + if ($self->{titleDetected} == 1) + { + $origtext =~ m/^\s*(.*?)\s*$/; + if ($self->{titreFrancais} == 1) + { + #$self->{curInfo}->{title} = $1; #Je désactive le titre car c'est le même que la série + $self->{curInfo}->{series} = $1; + } + else + { + $self->{curInfo}->{synopsis} .= "Titre original :".$1."\n"; + } + $self->{titleDetected} = 0; + } + elsif ($self->{volumeDetected} == 1) + { + $origtext =~ m/^(\d*)\//; + $self->{curInfo}->{volume} = $1; + $self->{volumeDetected} =0; + } + elsif ($self->{publisherDetected} == 1) + { + $self->{curInfo}->{publisher} = $origtext; + $self->{publisherDetected} =0; + } + elsif ($self->{collectionDetected} == 1) + { + $self->{curInfo}->{collection} = $origtext; + $self->{collectionDetected} =0; + } + elsif ($self->{publishdateDetected} == 1) + { + $self->{curInfo}->{publishdate} = $origtext; + $self->{publishdateDetected} =0; + } + elsif ($self->{costDetected} == 1) + { + $origtext =~ m/^\s*(\d*\.\d*)/; + $self->{curInfo}->{cost} = $1; + $self->{costDetected} =0; + } + elsif ($self->{typeDetected} == 1) + { + $self->{curInfo}->{type} = $origtext; + $self->{typeDetected} =0; + } + elsif ($self->{categoryDetected} == 1) + { + $self->{curInfo}->{category} = $origtext; + $self->{categoryDetected} =0; + } + elsif ($self->{genresDetected} == 1) + { + $origtext =~ m/^\s*(.*?)\s*$/; + $self->{curInfo}->{synopsis} .= "Genres : ".$1."\n\n"; + $self->{genresDetected} =0; + } + } + if ( $self->{tagH3detected} == 1 ) + { + #Code détection synopsis + #

    Synopsis

    + if ($origtext =~ m/^Synopsis/) + { + $self->{synopsisDetected} =1; + $self->{curInfo}->{synopsis} .= "Synopsis :\n" + } + #Code détection critiques + #

    Critiques du staff

    + elsif ($origtext =~ m/^Critiques du staff/) + { + $self->{critiquesDetected} =1; + $self->{curInfo}->{synopsis} .= "\n\nCritiques du staff :\n"; + } + #Réactions désactivées car pas super intéressant + # #Code détection reactions + # #

    Réactions

    + # elsif ($origtext =~ m/^Réactions/) + # { + # $self->{reactionsDetected} =1; + # $self->{curInfo}->{synopsis} .= "\n\nRéactions :\n"; + # } + } + if ( $self->{tagPdetected} == 1 ) + { + if ($self->{synopsisDetected} == 1) + { + $origtext =~ m/^\s*(.*?)\s*$/; + $self->{curInfo}->{synopsis} .= $1."\n"; + $self->{genresDetected} =0; + }elsif ($self->{critiquesDetected} == 1) + { + $origtext =~ m/^\s*(.*?)\s*$/; + $self->{curInfo}->{synopsis} .= $1."\n"; + $self->{genresDetected} =0; + } + #Réactions désactivées car pas super intéressant + # elsif ($self->{reactionsDetected} == 1) + # { + # $origtext =~ m/^\s*(.*?)\s*$/; + # $self->{curInfo}->{synopsis} .= $1."\n"; + # $self->{genresDetected} =0; + # } + } + if ( $self->{tagAdetected} == 1 ) + { + if ($self->{scenaristeDetected} == 1) + { + $self->{curInfo}->{writer} = $origtext; + $self->{scenaristeDetected} =0; + } + elsif ($self->{dessinateurDetected} == 1) + { + $self->{curInfo}->{illustrator} = $origtext; + $self->{dessinateurDetected} =0; + } + } + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless( $self, $class ); +#pour la recherche: +# $self->{hasField} = { +# series => 1, +# title => 1, +# volume => 1, +# }; + $self->{hasField} = { + title => 1, + type => 1, + format => 1, + }; + + + + $self->{itemIdx} = 0; + $self->{downloadThumbnail} = 0; + $self->{tagDTdetected} =0; + $self->{tagDDdetected} =0; + $self->{tagH3detected} =0; + $self->{tagPdetected} =0; + $self->{titleDetected} =0; + $self->{titreFrancais} = 1;#défaut francais + $self->{publisherDetected} =0; + $self->{collectionDetected} =0; + $self->{publishdateDetected} =0; + $self->{costDetected} =0; + $self->{typeDetected} =0; + $self->{categoryDetected} =0; + $self->{genresDetected} =0; + $self->{synopsisDetected} =0; + $self->{critiquesDetected} =0; + $self->{reactionsDetected} =0; + $self->{scenaristeDetected} =0; + $self->{dessinateurDetected} =0; + $self->{notationDetected} = 0; + + return $self; + } + + sub preProcess + { + my ( $self, $html ) = @_; + + if ( $self->{parsingList} ) # partie en rapport à la page de résultats + { + #keep only Volumes + $html =~ m/

    Volumes\s\(\d+\)<\/h3>\s*(.*?)\s*

    Critiques/s; + $html = $1; + } + else # partie en rapport à la page de l'élément + { + $html =~ m/
    \s*(

    \s*?\s*?
    \s*]*>]*)>\s*||gm; + $html =~ s| \s*|\n
    |gm; + $html =~ s|
    ]*>([^<]*)|$1|gs; + $html =~ s|]*>Adres wyd.\s*||gs; + } + else + { + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + + $html =~ s|]*>Tytuł\s*\s*]*>([^<]*)|$1|gs; + $html =~ s|]*>Strefa serii\s*\s*]*>([^<]*)|$1|gs; + $html =~ s|]*>Adres wydawniczy\s*||gs; + $html =~ s|]*>Opis fizyczny\s*||gs; + $html =~ s|]*>Oznaczenie wydania\s*||gs; + $html =~ s|]*>ISBN\s*||gs; + } + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + my $bubu; + if ($self->{searchField} eq 'isbn') + { + $bubu = "7"; + $self->{searchISBN} = $word; + } + else + { + $bubu = "4"; + $self->{searchISBN} = ""; + } + $searchURL = "http://www.nukat.edu.pl/cgi-bin/gw_43_3/chameleon?host=193.0.118.2%2b1111%2bDEFAULT&search=KEYWORD&function=INITREQ&conf=.%2fchameleon.conf&lng=pl&u1=".$bubu."&t1=".$word; + return $searchURL; + } + + sub getItemUrl + { + my ($self, $url) = @_; + return $url if $url; + return 'http://www.nukat.edu.pl/'; + } + + sub getName + { + return "NUKat"; + } + + sub getCharset + { + my $self = shift; + return "UTF-8"; + #return "ISO-8859-2"; + } + + sub getAuthor + { + return 'WG'; + } + + sub getLang + { + return 'PL'; + } + + sub getSearchFieldsArray + { + return ['isbn', 'title']; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCbooks/GCNooSFere.pm b/lib/gcstar/GCPlugins/GCbooks/GCNooSFere.pm new file mode 100644 index 0000000..c878af9 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCbooks/GCNooSFere.pm @@ -0,0 +1,462 @@ +package GCPlugins::GCbooks::GCNooSFere; + +################################################### +# +# Copyright 2005-2006 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCbooks::GCbooksCommon; + +{ + package GCPlugins::GCbooks::GCPluginNooSFere; + + use base qw(GCPlugins::GCbooks::GCbooksPluginsBase); + use URI::Escape; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + return if ( $self->{isFound} eq 2 ); + if (($tagname eq 'td') && ($attr->{class} eq 'onglet_bleu')) + { + $self->{isFound} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ m/editionslivre.asp\?numitem=/i) && !($attr->{href} =~ m/numediteur=/i) && !($attr->{href} =~ m/tri=/i)) + { + $self->{isTitle} = 1 ; + $self->{isAuthor} = 0 ; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ m|/icarus/livres/auteur.asp\?NumAuteur=|i) && ($self->{isAuthor} eq 0)) + { + $self->{isAuthor} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ m|./editeur.asp\?numediteur=|i)) + { + $self->{isPublisher} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ m|./serie.asp\?NumSerie=|i)) + { + $self->{isSerie} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ m/editionslivre.asp\?numitem=/i) && ($attr->{href} =~ m/numediteur=/i)) + { + + my $html = $self->loadPage( "http://www.noosfere.org/icarus/livres/" . $attr->{href}, 0, 1 ); + my $found = index($html,"Fiche livre : les éditions"); + if ( $found >= 0 ) + { + + while (index($html,"./niourf.asp?numlivre=")) + { + $found = index($html,"./niourf.asp?numlivre="); + if ( $found >= 0 ) + { + $html = substr($html, $found +length('./niourf.asp?numlivre='),length($html)- $found -length('./niourf.asp?numlivre=')); + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{title} = $self->{saveTitle}; + $self->{itemsList}[$self->{itemIdx}]->{authors} = $self->{saveAuthor}; + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://www.noosfere.org/icarus/livres/niourf.asp?numlivre=" . substr($html, 0, index($html,"\"")); + } + else + { + last; + } + + } + } + else + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{title} = $self->{saveTitle}; + $self->{itemsList}[$self->{itemIdx}]->{authors} = $self->{saveAuthor}; + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://www.noosfere.org/icarus/livres/" . $attr->{href}; + } + } + elsif ($tagname eq 'h1') + { + $self->{isTitle} = 1 ; + $self->{isAuthor} = 0 ; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ m|./niourf.asp\?numlivre=|i)) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{title} = $self->{saveTitle}; + $self->{itemsList}[$self->{itemIdx}]->{authors} = $self->{saveAuthor}; + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://www.noosfere.org/icarus/livres/" . $attr->{href}; + } + elsif (($tagname eq 'td') && ($attr->{class} eq 'onglet_biblio1')) + { + $self->{isAuthor} = 2 ; + } + elsif (($tagname eq 'table') && ($attr->{class} eq 'piedpage')) + { + $self->{isAuthor} = 0 ; + } + } + else + { + if (($tagname eq 'mytpf') && ($attr->{id} eq 'TPFENDCOMMENTTPF')) + { + $self->{isDescription} = 0 ; + } + elsif (($tagname eq 'font') && ($attr->{class} eq 'TitreNiourf')) + { + $self->{isAnalyse} = 0 ; + $self->{isTitle} = 1 ; + $self->{isAuthor} = 0 ; + } + elsif (($tagname eq 'font') && ($attr->{class} eq 'AuteurNiourf')) + { + $self->{isAuthor} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ m|/icarus/livres/auteur.asp\?NumAuteur=|i) && ($self->{isAuthor} eq 1)) + { + $self->{isAuthor} = 2 ; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ m|actu_mois.asp\?|i)) + { + $self->{isPublication} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ m|editeur.asp\?numediteur=|i) && ($self->{curInfo}->{publisher} eq '')) + { + $self->{isPublisher} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ m|collection.asp\?NumCollection=|i) && ($self->{curInfo}->{serie} eq '')) + { + $self->{isSerie} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ m|/icarus/livres/auteur.asp\?NumAuteur=|i) && ($self->{isTranslator} eq 1)) + { + $self->{isTranslator} = 2 ; + } + elsif ($tagname eq 'br') + { + $self->{isAnalyseTrans} = 1 ; + } + elsif (($tagname eq 'font') && ($attr->{style} eq 'font-size:12px;') && ($self->{isAnalyse} eq 0)) + { + $self->{isAnalyse} = 1 ; + } + elsif (($tagname eq 'img') && ($attr->{name} eq 'couverture')) + { + $self->{curInfo}->{cover} = "http://www.noosfere.org/icarus/livres/" . $attr->{src} ; + } + elsif (($tagname eq 'mytpf') && ($attr->{id} eq 'TPFSTARTCOMMENTTPF')) + { + $self->{isDescription} = 1 ; + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{isFound} = 0 ; + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isTitle}) + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//g; + $self->{saveTitle} = $origtext; + $self->{saveAuthor} = ''; + $self->{isTitle} = 0 ; + } + elsif ($self->{isAuthor} eq 1) + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//g; + if (($self->{saveAuthor} eq '') && ($origtext ne '')) + { + $self->{saveAuthor} = $origtext; + } + elsif ($origtext ne '') + { + $self->{saveAuthor} .= ', '; + $self->{saveAuthor} .= $origtext; + } + $self->{isAuthor} = 0 ; + } + elsif ($self->{isPublisher}) + { + $self->{itemsList}[$self->{itemIdx}]->{edition} = $origtext; + $self->{isPublisher} = 0 ; + } + elsif ($self->{isSerie}) + { + $self->{itemsList}[$self->{itemIdx}]->{serie} = $origtext; + $self->{isSerie} = 0 ; + } + elsif ($self->{isFound} eq 1) + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//g; + if ($origtext eq 'Fiche livre') + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $self->{loadedUrl}; + $self->{isFound} = 2 ; + } + else + { + $self->{isFound} = 0 ; + } + } + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//g; + if ($self->{isTitle} eq '1') + { + $self->{curInfo}->{title} = $origtext; + $self->{isTitle} = 0 ; + } + elsif ($self->{isAnalyse} eq 1) + { + my $found = index($origtext," pages"); + if ( $found >= 0 ) + { + $self->{curInfo}->{pages} = substr($origtext, 0, $found); + } + $found = index($origtext,"ISBN : "); + if ( $found >= 0 ) + { + $self->{curInfo}->{isbn} = substr($origtext, $found +length('ISBN : '),length($origtext)- $found -length('ISBN : ')); + } + + $self->{isAnalyse} = 2 ; + } + elsif ($self->{isAnalyseTrans}) + { + $self->{isTranslator} = 1 if ($origtext =~ m/Traduction/i); + + $self->{isAnalyseTrans} = 0 ; + } + elsif ($self->{isAuthor} eq 2) + { + if (($self->{curInfo}->{authors} eq '') && ($origtext ne '')) + { + $self->{curInfo}->{authors} = $origtext; + } + elsif ($origtext ne '') + { + $self->{curInfo}->{authors} .= ', '; + $self->{curInfo}->{authors} .= $origtext; + } + $self->{isAuthor} = 1 ; + } + elsif ($self->{isPublisher}) + { + $self->{curInfo}->{publisher} = $origtext; + $self->{isPublisher} = 0 ; + } + elsif ($self->{isSerie}) + { + $self->{curInfo}->{serie} = $origtext; + $self->{isSerie} = 0 ; + } + elsif ($self->{isPublication}) + { + $self->{curInfo}->{publication} = $origtext; + $self->{isPublication} = 0 ; + } + elsif ($self->{isTranslator} eq 2) + { + $self->{curInfo}->{translator} = $origtext; + $self->{isTranslator} = 0 ; + } + elsif ($self->{isDescription}) + { + if ($origtext =~ m/Pas de texte sur la quatri.me de couverture\./i) + { + } + else + { + $self->{curInfo}->{description} .= $origtext ."\n"; + } + } + + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + authors => 1, + publication => 0, + format => 0, + edition => 1, + serie => 1, + }; + + $self->{saveTitle} = ''; + $self->{saveAuthor} = ''; + $self->{isFound} = 0; + $self->{isTitle} = 0; + $self->{isAuthor} = 0; + $self->{isPublisher} = 0; + $self->{isPublication} = 0; + $self->{isSerie} = 0; + $self->{isDescription} = 0; + $self->{isTranslator} = 0; + $self->{isAnalyseTrans} = 0; + $self->{isAnalyse} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + # Le descriptif pouvant contenir des balises html je le repere maintenant + my $found = index($html,"Id=\"R"); + if ( $found >= 0 ) + { + my $html2 = substr($html, $found +length('Id="R'),length($html)- $found -length('Id="R')); + my $found2 = index($html2,""); + if ( $found2 >= 0 ) + { + $html2 = substr($html2, $found2 +length(''),length($html2)- $found2 -length('')); + } + + $found2 = index($html2,"([^<]*)<\/TD>[^<]*([^<]*)<\/TD>/$1 $2<\/td>/gi; + $html =~ s/([^<]*)<\/td>[^<]*<\/TD>[^<]*([0-9]* mn)<\/td>/$1 $2<\/td>/gi; +#>>> + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + return "http://alapage.com/mx/?type=41&tp=L&fulltext=" . $word; + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return "http://alapage.com" . $url; + } + + sub getName + { + return "Alapage.com"; + } + + sub getAuthor + { + return 'MeV'; + } + + sub getLang + { + return 'FR'; + } + + sub getCharset + { + my $self = shift; + + return "ISO-8859-1"; + } + + sub getDefaultPictureSuffix + { + return '.jpg'; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCfilms/GCAllmovie.pm b/lib/gcstar/GCPlugins/GCfilms/GCAllmovie.pm new file mode 100644 index 0000000..e8117c5 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCfilms/GCAllmovie.pm @@ -0,0 +1,431 @@ +package GCPlugins::GCfilms::GCAllmovie; + +################################################### +# +# 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 GCPlugins::GCfilms::GCfilmsCommon; + +{ + + package GCPlugins::GCfilms::GCPluginAllmovie; + + 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") && ($self->{isFilm})) + { + my $url = $attr->{href}; + $self->{isMovie} = 1; + $self->{isInfo} = 1; + $self->{itemIdx}++; + $self->{itemsList}[ $self->{itemIdx} ]->{url} = $url; + $self->{isFilm} = 0; + } + if ($tagname eq "td") + { + if ($attr->{style} =~ m/284px/) + { + $self->{isFilm} = 1; + } + elsif ($attr->{style} =~ m/70px/) + { + $self->{isYear} = 1; + } + elsif ($attr->{style} =~ m/190px/) + { + $self->{isDirector} = 1; + } + } + elsif ($tagname eq "tr") + { + $self->{isFound} = 1; + } + elsif ($tagname eq "title") + { + $self->{insideHTMLtitle} = 1; + } + } + else + { + if (($tagname eq "span") && ($attr->{class} eq "title")) + { + $self->{insideTitle} = 1; + } + elsif ( + ($tagname eq "div") + && ( ($attr->{id} eq "left-sidebar-title") + || ($attr->{id} eq "left-sidebar-title-small")) + ) + { + $self->{insideLeftSidebarTitle} = 1; + } + elsif ($tagname eq "a") + { + if ($attr->{href} =~ m/sql=B/) + { + $self->{insideActors} = 1; + } + elsif ($self->{insideDirectorList}) + { + $self->{insideDirector} = 1; + } + elsif ($self->{insideYearRuntime}) + { + $self->{insideYear} = 1; + $self->{insideYearRuntime} = 0; + } + elsif ($self->{insideCountriesRating}) + { + $self->{insideCountry} = 1; + $self->{insideCountriesRating} = 0; + } + elsif ($self->{nextIsSeries}) + { + $self->{insideSeries} = 1; + $self->{nextIsSeries} = 0; + } + } + elsif ($tagname eq "img") + { + if ($attr->{src} =~ /http\:\/\/image\.allmusic\.com/) + { + $self->{curInfo}->{image} = ($attr->{src}); + } + elsif ($self->{insideRatingStars}) + { + $attr->{title} =~ /([\d\.]+) Stars/; + $self->{curInfo}->{ratingpress} = $1 * 2; + $self->{insideRatingStars} = 0; + } + } + elsif ($tagname eq "li") + { + if ($self->{insideGenreList}) + { + $self->{insideGenre} = 1; + } + } + elsif ($tagname eq "td") + { + if ( ($self->{insideAKA}) + && ($attr->{class} =~ m/formed-sub/)) + { + $self->{insideOtherTitles} = 1; + } + elsif ($self->{nextIsRating}) + { + $self->{insideRating} = 1; + $self->{nextIsRating} = 0; + } + elsif ($self->{nextIsRuntime}) + { + $self->{insideTime} = 1; + $self->{nextIsRuntime} = 0; + } + elsif ($attr->{colspan} == 2) + { + if ($attr->{class} eq "large-list-title") + { + } + else + { + $self->{insideSynopsis} = 1; + } + } + elsif ($attr->{class} eq "rating-stars") + { + $self->{insideRatingStars} = 1; + } + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + + if ($tagname eq "td") + { + $self->{insideSynopsis} = 0; + } + if ($tagname eq "div") + { + $self->{insideLeftSidebarTitle} = 0; + } + if ($tagname eq "table") + { + $self->{insideGenreList} = 0; + $self->{insideAKA} = 0; + $self->{curInfo}->{original} =~ s/(, )$//; + } + } + + sub text + { + my ($self, $origtext) = @_; + return if ((length($origtext) == 0) || ($origtext eq " ")); + + $origtext =~ s/"/"/g; + $origtext =~ s/³/3/g; + $origtext =~ s/&#[0-9]*;//g; + $origtext =~ s/\n//g; + + return if ($self->{parsingEnded}); + + if ($self->{parsingList}) + { + if (($self->{insideHTMLtitle})) + { + if ($origtext !~ m/Results/) + { + $self->{parsingEnded} = 1; + $self->{itemIdx} = 0; + $self->{itemsList}[0]->{url} = $self->{loadedUrl}; + } + $self->{insideHTMLtitle} = 0; + } + if ($self->{isMovie}) + { + $self->{itemsList}[ $self->{itemIdx} ]->{title} = $origtext; + $self->{isMovie} = 0; + $self->{isInfo} = 1; + return; + } + if ($self->{isYear}) + { + $self->{itemsList}[ $self->{itemIdx} ]->{date} = $origtext + if $origtext =~ m/^[0-9]{4}?/; + $self->{isYear} = 0; + } + if ($self->{isDirector}) + { + $self->{itemsList}[ $self->{itemIdx} ]->{director} = $origtext; + $self->{isDirector} = 0; + } + if ($self->{isInfo}) + { + $self->{itemsList}[ $self->{itemIdx} ]->{date} = $1 + if $origtext =~ m|\(([0-9]*)(/I+)?\)|; + $self->{isInfo} = 0; + } + } + else + { + if ($self->{insideLeftSidebarTitle}) + { + if ($origtext eq "Genres") + { + $self->{insideGenreList} = 1; + $self->{insideLeftSidebarTitle} = 0; + } + elsif ($origtext eq "Director") + { + $self->{insideDirectorList} = 1; + $self->{insideLeftSidebarTitle} = 0; + } + elsif ($origtext eq "Year") + { + $self->{insideYearRuntime} = 1; + $self->{insideLeftSidebarTitle} = 0; + } + elsif ($origtext eq "Countries") + { + $self->{insideCountriesRating} = 1; + $self->{insideLeftSidebarTitle} = 0; + } + elsif ($origtext eq "AKA") + { + $self->{insideAKA} = 1; + $self->{insideLeftSidebarTitle} = 0; + } + } + elsif ($origtext =~ /Is part of the series:$/) + { + $self->{nextIsSeries} = 1; + } + if ($self->{insideActors}) + { + $self->{curInfo}->{actors} .= $origtext . ', ' + if ($self->{actorsCounter} < $GCPlugins::GCfilms::GCfilmsCommon::MAX_ACTORS); + $self->{actorsCounter}++; + $self->{insideActors} = 0; + } + + if ($self->{insideYear}) + { + $self->{curInfo}->{date} = $origtext; + $self->{insideYear} = 0; + $self->{nextIsRuntime} = 1; + } + if ($self->{insideTitle}) + { + $self->{curInfo}->{title} = $origtext; + $self->{insideTitle} = 0; + } + elsif ($self->{insideGenre}) + { + $self->{curInfo}->{genre} .= $self->capWord($origtext) . ','; + $self->{insideGenre} = 0; + } + elsif ($self->{insideDirector}) + { + $self->{curInfo}->{director} = $origtext; + $self->{insideDirector} = 0; + $self->{insideDirectorList} = 0; + } + elsif ($self->{insideSynopsis}) + { + $self->{curInfo}->{synopsis} .= $origtext; + } + elsif ($self->{insideCountry}) + { + $self->{curInfo}->{country} = $origtext; + $self->{insideCountry} = 0; + $self->{nextIsRating} = 1; + } + elsif ($self->{insideTime}) + { + $self->{curInfo}->{time} = $origtext; + $self->{curInfo}->{time} =~ s/.[0-9]*?://; + $self->{insideTime} = 0; + } + elsif ($self->{insideRating}) + { + $self->{curInfo}->{age} = 1 + if ($origtext eq 'Unrated') || ($origtext eq 'Open'); + $self->{curInfo}->{age} = 2 + if ($origtext eq 'G') || ($origtext eq 'Approved'); + $self->{curInfo}->{age} = 5 + if ($origtext eq 'PG') || ($origtext eq 'M') || ($origtext eq 'GP'); + $self->{curInfo}->{age} = 13 if $origtext eq 'PG13'; + $self->{curInfo}->{age} = 17 if $origtext eq 'R'; + $self->{curInfo}->{age} = 18 + if ($origtext eq 'NC17') || ($origtext eq 'X'); + $self->{insideRating} = 0; + } + elsif ($self->{insideOtherTitles}) + { + $self->{tempOriginal} = $origtext; + $self->{tempOriginal} =~ s/\s*$//; + $self->{tempOriginal} =~ s/^\s*//; + + $self->{curInfo}->{original} .= $self->{tempOriginal} . ', '; + $self->{insideOtherTitles} = 0; + } + elsif ($self->{insideSeries}) + { + $self->{curInfo}->{serie} = $origtext; + $self->{curInfo}->{serie} =~ s/( \[.*\])//; + $self->{insideSeries} = 0; + } + } + } + + 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 => 1, + actors => 0, + }; + + $self->{isInfo} = 0; + $self->{isMovie} = 0; + $self->{curName} = undef; + $self->{curUrl} = undef; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + $self->{parsingEnded} = 0; + + $html =~ s/""/'"/g; + $html =~ s/""/"'/g; + $html =~ s|
    |
    |; + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + my $wordFiltered = $word; + + # Allmovie doesn't return correct results if searching with a prefix like 'the' + $wordFiltered =~ s/^(the|a)?[+\s]+[^ a-zA-Z0-9]*\s*//i; +# return ('http://allmovie.com/search/all', ['q' => $wordFiltered,'submit' => 'SEARCH']); + return ('http://allmovie.com/search/all/' . $wordFiltered); + + } + + sub getItemUrl + { + my ($self, $url) = @_; + return $url if $url =~ /^http:/; + return "http://allmovie.com" . $url; + } + + sub getName + { + return "Allmovie"; + } + + sub getAuthor + { + return 'Zombiepig'; + } + + sub getLang + { + return 'EN'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCfilms/GCAllocine.pm b/lib/gcstar/GCPlugins/GCfilms/GCAllocine.pm new file mode 100644 index 0000000..db37774 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCfilms/GCAllocine.pm @@ -0,0 +1,403 @@ +package GCPlugins::GCfilms::GCAllocine; + +################################################### +# +# 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::GCPluginAllocine; + + use base qw(GCPlugins::GCfilms::GCfilmsPluginsBase); + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + if ($self->{insideResults} eq 1) + { + if ( ($tagname eq "a") + && ($attr->{href} =~ /^\/film\/fichefilm_gen_cfilm=/) + && ($self->{isMovie} eq 0)) + { + my $url = $attr->{href}; + $self->{isMovie} = 1; + $self->{isInfo} = 0; + $self->{itemIdx}++; + $self->{itemsList}[ $self->{itemIdx} ]->{url} = $url; + } + elsif (($tagname eq "td") && ($self->{isMovie} eq 1)) + { + $self->{isMovie} = 2; + } + elsif (($tagname eq "a") && ($self->{isMovie} eq 2)) + { + $self->{isMovie} = 3; + } + elsif (($tagname eq "br") && ($self->{isMovie} eq 3)) + { + $self->{itemsList}[ $self->{itemIdx} ]->{title} =~ s/^\s*//; + $self->{itemsList}[ $self->{itemIdx} ]->{title} =~ s/\s*$//; + $self->{itemsList}[ $self->{itemIdx} ]->{title} =~ s/\s+/ /g; + $self->{isMovie} = 4; + } + elsif (($tagname eq "span") + && ($attr->{class} eq "fs11") + && ($self->{isMovie} eq 4)) + { + $self->{isInfo} = 1; + $self->{isMovie} = 0; + } + elsif (($tagname eq "br") && ($self->{isInfo} eq 1)) + { + $self->{isInfo} = 2; + } + elsif (($tagname eq "br") && ($self->{isInfo} eq 2)) + { + $self->{isInfo} = 3; + } + } + } + else + { + if (($tagname eq "div") && ($attr->{class} eq "poster")) + { + $self->{insidePicture} = 1; + } + elsif (($tagname eq "img") && ($self->{insidePicture} eq 1)) + { + my $src = $attr->{src}; + if (!$self->{curInfo}->{image}) + { + if ($src =~ /r_160_240/) + { + $self->{curInfo}->{image} = $src; + } + else + { + $self->{curInfo}->{image} = "empty"; + } + } + } + elsif ($tagname eq "h1") + { + $self->{insideTitle} = 1; + } + elsif (($tagname eq "span") && ($self->{insideDate} eq 1)) + { + $self->{insideDate} = 2; + } + elsif (($tagname eq "span") && ($attr->{itemprop} eq "duration")) + { + $self->{insideTime} = 1; + } + elsif (($tagname eq "span") && ($self->{insideDirector} eq 1)) + { + $self->{insideDirector} = 2; + } + elsif (($tagname eq "a") && ($self->{insideActor} eq 1)) + { + $self->{insideActor} = 2; + } + elsif (($tagname eq "span") && ($self->{insideGenre} eq 1)) + { + $self->{insideGenre} = 2; + } + elsif (($tagname eq "span") && ($self->{insideCountry} eq 1)) + { + $self->{insideCountry} = 2; + } + elsif (($tagname eq "span") && ($attr->{class} eq "note") && ($self->{insidePressRating} eq 1)) + { + $self->{insidePressRating} = 2; + } + elsif (($tagname eq "div") && ($attr->{class} eq "breaker")) + { + $self->{insidePressRating} = 0; + } + elsif (($tagname eq "p") && ($attr->{itemprop} eq "description")) + { + $self->{insideSynopsis} = 1; + } + elsif (($tagname eq "td") && ($self->{insideOriginal} eq 1)) + { + $self->{insideOriginal} = 2; + } + + } + } + + sub end + { + my ($self, $tagname) = @_; + $self->{inside}->{$tagname}--; + + if ($tagname eq "li") + { + $self->{insideDirector} = 0; + $self->{insideActor} = 0; + $self->{insideGenre} = 0; + } + elsif ($tagname eq "div") + { + $self->{insideCountry} = 0; + $self->{insideSynopsis} = 0; + $self->{insideActor} = 0; + } + elsif ($tagname eq "th") + { + $self->{insideSynopsis} = 0; + } + elsif ($tagname eq "table") + { + $self->{insideResults} = 0; + } + + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if (($origtext =~ m/(\d+) r..?sultats? trouv..?s? dans les titres de films/) && ($1 > 0)) + { + $self->{insideResults} = 1; + } + if ($self->{isMovie} eq 3) + { + $self->{itemsList}[ $self->{itemIdx} ]->{title} .= $origtext; + } + if ($self->{isInfo} eq 1) + { + if ($origtext =~ /\s*([0-9]{4})/) + { + $self->{itemsList}[ $self->{itemIdx} ]->{date} = $1; + } + } + elsif ($self->{isInfo} eq 2) + { + if ($origtext =~ /^\s*de (.*)/) + { + $self->{itemsList}[ $self->{itemIdx} ]->{director} = $1; + } + } + elsif ($self->{isInfo} eq 3) + { + if ( ($origtext =~ m/^\s*avec (.*)/) + && (!$self->{itemsList}[ $self->{itemIdx} ]->{actors})) + { + $self->{itemsList}[ $self->{itemIdx} ]->{actors} = $1; + } + $self->{isInfo} = 0; + } + } + else + { + my ($self, $origtext) = @_; + $origtext =~ s/[\r\n]//g; + $origtext =~ s/^\s*//; + $origtext =~ s/\s*$//; + + if ($self->{insideTitle} eq 1) + { + $self->{curInfo}->{title} = $origtext; + $self->{insideTitle} = 0; + } + elsif (($self->{insideDate} eq 2) && (length($origtext) > 1)) + { + $self->{curInfo}->{date} = $origtext + if !($origtext =~ /inconnu/); + $self->{insideDate} = 0; + } + elsif (($origtext =~ /^Date de sortie/) + && (!$self->{curInfo}->{date})) + { + $self->{insideDate} = 1; + } + elsif (($origtext =~ /^Date de reprise/) + && (!$self->{curInfo}->{date})) + { + $self->{insideDate} = 1; + } + elsif ($self->{insideTime} eq 1) + { + $origtext =~ /(\d+)h\s*(\d+)m/; + my $time = ($1*60) + $2; + $self->{curInfo}->{time} = $time." m."; + $self->{insideTime} = 0; + } + elsif ($self->{insideDirector} eq 2) + { + $origtext = ", " if $origtext =~ m/^,/; + $self->{curInfo}->{director} .= $origtext; + } + elsif ($origtext =~ /^R..?alis..? par/) + { + $self->{insideDirector} = 1; + } + elsif ($self->{insideActor} eq 2) + { + $origtext =~ s/plus//; + $origtext = "," if $origtext =~ m/^,/; + $self->{curInfo}->{actors} .= $origtext; + } + elsif ($origtext =~ /^Avec/) + { + $self->{insideActor} = 1; + } + elsif ($self->{insideGenre} eq 2) + { + $origtext = "," if $origtext =~ m/^,/; + $self->{curInfo}->{genre} .= $origtext; + } + elsif ($origtext =~ /^[\s\n]*Genre/) + { + $self->{insideGenre} = 1; + } + elsif ($self->{insideCountry} eq 2) + { + $origtext = "," if $origtext =~ m/^,/; + $self->{curInfo}->{country} .= $origtext; + } + elsif ($origtext =~ /Nationalité/) + { + $self->{insideCountry} = 1; + } + elsif ($origtext =~ /^Presse$/) + { + $self->{insidePressRating} = 1; + } + elsif ($self->{insidePressRating} eq 2) + { + $origtext =~ s/,/./; + $self->{curInfo}->{ratingpress} .= $origtext * 2; + } + elsif ($origtext =~ /^Interdit aux moins de (\d+) ans/) + { + $self->{curInfo}->{age} = $1; + } + elsif ($self->{insideSynopsis} eq 1) + { + $self->{curInfo}->{synopsis} .= $origtext; + } + elsif ($self->{insideOriginal} eq 2) + { + $self->{curInfo}->{original} = $origtext; + $self->{insideOriginal} = 0; + } + elsif ($origtext =~ /^Titre original/) + { + $self->{insideOriginal} = 1; + } + + + + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + + $self->{hasField} = { + title => 1, + date => 1, + director => 1, + actors => 1, + }; + + $self->{isInfo} = 0; + $self->{isMovie} = 0; + $self->{insideResults} = 0; + $self->{curName} = undef; + $self->{curUrl} = undef; + $self->{actorsCounter} = 0; + + bless($self, $class); + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + # f=3 ? + # return "http://www.allocine.fr/recherche/?q=$word&f=3&rub=1"; + return "http://www.allocine.fr/recherche/1/?q=$word"; + } + + sub getSearchCharset + { + my $self = shift; + + # Need urls to be double character encoded + return "utf8"; + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return "http://www.allocine.fr" . $url; + } + + sub getName + { + return "Allocine.fr"; + } + + sub getAuthor + { + return 'Tian'; + } + + sub getLang + { + return 'FR'; + } + + sub getCharset + { + # return "UTF-8"; # For 1.5.0 Win32 + return "ISO-8859-1"; # For 1.5.0 Win32 with /lib/gcstar/GCPlugins/ ver.1.5.9svn + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCfilms/GCAlpacineES.pm b/lib/gcstar/GCPlugins/GCfilms/GCAlpacineES.pm new file mode 100644 index 0000000..75c6854 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCfilms/GCAlpacineES.pm @@ -0,0 +1,435 @@ +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/^.*
    Pel.culas \([0-9]* resultado[s]?\)<\/span><\/div>
    ([^:]*): <\/td>\s* ([^<]*) ?<\/td>/([^<]*?)
    \s*?
    |
    $1
    |ms; + + #Remove Headline tag + $html =~ s/>\W*?/>/; + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + return "http://anidb.info/perl-bin/animedb.pl?show=animelist&adb.search=$word"; + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return 'http://anidb.info/perl-bin/' . $url; + } + + sub getName + { + return 'AniDB'; + } + + sub getAuthor + { + return 'MeV'; + } + + sub getLang + { + return 'EN'; + } + + sub getCharset + { + my $self = shift; + + return "UTF-8"; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCfilms/GCAnimator.pm b/lib/gcstar/GCPlugins/GCfilms/GCAnimator.pm new file mode 100644 index 0000000..45704d0 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCfilms/GCAnimator.pm @@ -0,0 +1,236 @@ +package GCPlugins::GCfilms::GCAnimator; + +################################################### +# +# Copyright 2005-2009 zserghei +# +# 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 Encode qw(encode); + +use GCPlugins::GCfilms::GCfilmsCommon; + +{ + + package GCPlugins::GCfilms::GCPluginAnimator; + + use base qw(GCPlugins::GCfilms::GCfilmsPluginsBase); + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + $self->{inside}->{$tagname}++; + if ($self->{parsingList}) + { + if ($tagname eq "a") + { + my $url = $attr->{href}; + if ($url =~ m/\/db\/\?p\=show\_film/) + { + $self->{isMovie} = 1; + $self->{itemIdx}++; + $self->{itemsList}[ $self->{itemIdx} ]->{url} = $url; + } + } + } + else + { + if ($tagname eq "td" && $attr->{class} eq "FilmName") + { + $self->{insideTitle} = 1; + } + elsif ($tagname eq "td" && $attr->{class} eq "FilmType") + { + $self->{insideTime} = 1; + $self->{insideDate} = 1; + } + elsif ($tagname eq "td" && $attr->{class} eq "FilmComments") + { + $self->{insideSynopsis} = 1; + } + elsif ($tagname eq "img") + { + $self->{curInfo}->{image} = $attr->{src} + if !$self->{curInfo}->{image} + && ($attr->{id} eq "SlideShow" || $attr->{width} =~ m/3\d{2}/); + $self->{curInfo}->{image} = "http://www.animator.ru/" . $self->{curInfo}->{image} + if $self->{curInfo}->{image} =~ m/^\//; + $self->{curInfo}->{image} = "http://www.animator.ru/db/" . $self->{curInfo}->{image} + if $self->{curInfo}->{image} =~ m/^\.\.\//; + $self->{insideImage} = 0; + } + } + } + + sub text + { + my ($self, $origtext) = @_; + if ($self->{parsingList}) + { + if ($self->{isMovie}) + { + my ($title, $date); + if ($origtext =~ m/«(.*)»\s\(([0-9]*)\s.+\)/) + { + ($title, $date) = ($1, $2); + $self->{itemsList}[ $self->{itemIdx} ]->{title} = $title; + $self->{itemsList}[ $self->{itemIdx} ]->{date} = $date; + } + else + { + $self->{itemsList}[ $self->{itemIdx} ]->{title} = $origtext; + } + $self->{isMovie} = 0; + return; + } + } + else + { + utf8::decode($origtext); + $origtext =~ s/^\s+//; + $origtext =~ s/\s+$//; + if ($self->{insideTitle}) + { + $origtext =~ s/^\W//; + $origtext =~ s/\W$//; + $origtext = ucfirst(lc($origtext)); + $self->{curInfo}->{title} = $origtext; + $self->{curInfo}->{genre} = "Мультфильм"; + $self->{curInfo}->{audio} = "русский"; + $self->{insideTitle} = 0; + } + elsif ($self->{insideDate}) + { + if ($origtext =~ m/([0-9]+)\sг/) + { + $self->{curInfo}->{date} = $1; + if ($self->{curInfo}->{date} < 1992) + { + $self->{curInfo}->{country} = "СССР"; + } + else + { + $self->{curInfo}->{country} = "Россия"; + } + $self->{insideDate} = 0; + } + } + elsif ($self->{insideDirector}) + { + $self->{curInfo}->{director} = $origtext; + $self->{insideDirector} = 0; + } + elsif ($self->{insideSynopsis}) + { + $self->{curInfo}->{synopsis} .= + $self->{curInfo}->{synopsis} ? "\n" . $origtext : $origtext; + $self->{insideSynopsis} = 0; + } + if ($self->{insideTime}) + { + if ($origtext =~ m/,\s+([0-9]+)\s+мин/) + { + $self->{curInfo}->{time} = $1; + $self->{insideTime} = 0; + } + } + if ($self->{inside}->{td}) + { + $self->{insideDirector} = 1 if $origtext =~ m/режиссер/; + } + } + } + + sub end + { + my ($self, $tagname) = @_; + $self->{inside}->{$tagname}--; + } + + 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 getName + { + return "Animator"; + } + + sub getAuthor + { + return 'zserghei'; + } + + sub getLang + { + return 'RU'; + } + + sub getCharset + { + my $self = shift; + return "KOI8-R"; +# return "Windows-1251"; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + return "http://www.animator.ru/db/?p=search&text=$word"; + } + + sub getItemUrl + { + my ($self, $url) = @_; + return "http://www.animator.ru/" . $url; + } + + sub preProcess + { + my ($self, $html) = @_; + $self->{parsingEnded} = 0; + $html =~ tr + {АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя} + {юабцдефгхийклмнопярстужвьызшэщчъЮАБЦДЕФГХИЙКЛМНОПЯРСТУЖВЬЫЗШЭЩЧЪ}; + return $html; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCfilms/GCAnimeNfoA.pm b/lib/gcstar/GCPlugins/GCfilms/GCAnimeNfoA.pm new file mode 100644 index 0000000..9347637 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCfilms/GCAnimeNfoA.pm @@ -0,0 +1,266 @@ +package GCPlugins::GCfilms::GCAnimeNfoA; + +################################################### +# +# 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 GCPlugins::GCfilms::GCfilmsCommon; + +{ + + package GCPlugins::GCfilms::GCPluginAnimeNfoA; + + use base qw(GCPlugins::GCfilms::GCfilmsPluginsBase); + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + if ($tagname eq "a") + { + if ($attr->{href} =~ m/animetitle,[0-9]*,[a-z]*,[a-z0-9_]*\.html/) + { + $self->{isMovie} = 1; + $self->{isInfo} = 1; + $self->{itemIdx}++; + $self->{itemsList}[ $self->{itemIdx} ]->{url} = $attr->{href}; + } + } + elsif ($tagname eq "td") + { + if ($attr->{class} eq "anime_info") + { + $self->{couldBeYear} = 1; + } + } + } + else + { + if ($tagname eq 'table') + { + if ($attr->{class} eq 'anime_info') + { + $self->{insideInfos} = 1; + } + } + elsif ($tagname eq 'img') + { + if ($attr->{class} eq 'float') + { + $self->{curInfo}->{image} = 'http://www.animenfo.com/' . $attr->{src}; + } + } + elsif ($tagname eq 'a') + { + if ($attr->{href} =~ /animebygenre\.php\?genre=/) + { + $self->{insideGenre} = 1; + } + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + return if (length($origtext) < 2) && ($origtext !~ /\d+$/); + + if ($self->{parsingList}) + { + if ($self->{isMovie}) + { + $self->{itemsList}[ $self->{itemIdx} ]->{"title"} = $origtext; + $self->{isMovie} = 0; + $self->{isInfo} = 1; + return; + } + elsif ($self->{couldBeYear}) + { + $self->{itemsList}[ $self->{itemIdx} ]->{date} = $origtext if $origtext =~ m/^[0-9]{4}$/; + $self->{couldBeYear} = 0; + return; + } + } + else + { + if ($self->{insideInfos}) + { + if ($origtext eq "Title") + { + $self->{insideName} = 1; + } + elsif ($origtext eq "Japanese Title") + { + $self->{insideOrig} = 1; + } + elsif ($origtext eq "Total Episodes") + { + $self->{insideTime} = 1; + } + elsif ($origtext eq "Year Published") + { + $self->{insideDate} = 1; + } + elsif ($origtext eq "Director") + { + $self->{insideDirector} = 1; + } + elsif ($origtext eq "User Rating") + { + $self->{insideRating} = 1; + } + elsif ($origtext =~ m/Description/) + { + $self->{insideSynopsis} = 1; + } + elsif ($self->{insideName}) + { + $self->{curInfo}->{title} = $origtext; + $self->{insideName} = 0; + } + elsif ($self->{insideOrig}) + { + $self->{curInfo}->{original} = $origtext if $origtext ne "Official Site"; + $self->{insideOrig} = 0; + } + elsif ($self->{insideTime}) + { + $origtext =~ s/^(\d+)\s*(.*)/$1 episodes $2/; + $self->{curInfo}->{time} .= $origtext; + $self->{insideTime} = 0; + } + elsif ($self->{insideGenre}) + { + $self->{curInfo}->{genre} .= $origtext . ','; + $self->{insideGenre} = 0; + } + elsif ($self->{insideDate}) + { + $self->{curInfo}->{date} = $origtext if $origtext =~ m/[0-9]{4}/; + $self->{insideDate} = 0; + } + elsif ($self->{insideDirector}) + { + $self->{curInfo}->{director} = $origtext if $origtext ne "US Distribution"; + $self->{insideDirector} = 0; + } + elsif ($self->{insideRating}) + { + $origtext =~ m|([\d\.]+)/10\.0|; + $self->{curInfo}->{ratingpress} = int ($1 + 0.5); + $self->{insideRating} = 0; + } + elsif ($self->{insideSynopsis}) + { + $self->{curInfo}->{synopsis} = $origtext if !$self->{curInfo}->{synopsis}; + $self->{insideSynopsis} = 0; + } + } + } + } + + 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) = @_; + + $html =~ s/
    /\n/g; + $html =~ s/|$1|gms; + } + return $html; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCfilms/GCThemoviedb.pm b/lib/gcstar/GCPlugins/GCfilms/GCThemoviedb.pm new file mode 100644 index 0000000..f7636cc --- /dev/null +++ b/lib/gcstar/GCPlugins/GCfilms/GCThemoviedb.pm @@ -0,0 +1,337 @@ +package GCPlugins::GCfilms::GCthemoviedb; + +################################################### +# +# 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::GCPluginThemoviedb; + + use base 'GCPlugins::GCfilms::GCfilmsPluginsBase'; + use XML::Simple; + + sub parse + { + my ($self, $page) = @_; + return if $page =~ /^new; + + if ($self->{parsingList}) + { + if ($page !~ m/>Nothing found.<\/movie/) + { + $xml = $xs->XMLin( + $page, + ForceArray => [ 'movie', 'alternative_name' ], + KeyAttr => ['id'] + ); + my $movie; + foreach $movie (keys(%{$xml->{'movies'}->{'movie'}})) + { + # We only want movies, not series and everything else the api returns + if ($xml->{'movies'}->{'movie'}->{$movie}->{'type'} eq "movie") + { + $self->{itemIdx}++; + my $url = +"http://api.themoviedb.org/2.1/Movie.getInfo/".$self->siteLanguage()."/xml/9fc8c3894a459cac8c75e3284b712dfc/" + . $movie; + # If the release date is missing, it will be returned as an array, so only save the release if + # it's not an array + my $released = ""; + if (!ref($xml->{'movies'}->{'movie'}->{$movie}->{'released'})) + { + $released = $xml->{'movies'}->{'movie'}->{$movie}->{'released'}; + } + $self->{itemsList}[ $self->{itemIdx} ]->{date} = $released; + $self->{itemsList}[ $self->{itemIdx} ]->{url} = $url; + $self->{itemsList}[ $self->{itemIdx} ]->{title} = + $xml->{'movies'}->{'movie'}->{$movie}->{'name'}; + # Now, check if there's any alternative names, and if so, add them in as + # additional search results. + for my $alternateName ( + @{$xml->{'movies'}->{'movie'}->{$movie}->{alternative_name}}) + { + if (!ref($alternateName)) + { + $self->{itemIdx}++; + $self->{itemsList}[ $self->{itemIdx} ]->{date} = $released; + $self->{itemsList}[ $self->{itemIdx} ]->{url} = $url; + $self->{itemsList}[ $self->{itemIdx} ]->{title} = $alternateName; + } + } + + } + } + } + } + else + { + $xml = $xs->XMLin( + $page, + ForceArray => [ 'country', 'person', 'category', 'size', 'alternative_name' ], + KeyAttr => [''] + ); + my $usingAlternateName = 0; + if ( + ( + $xml->{movies}->{movie}->{name} ne + $self->{itemsList}[ $self->{wantedIdx} ]->{title} + ) + && ($self->{itemsList}[ $self->{wantedIdx} ]->{title}) + ) + { + # Name returned by tmdb is different to the one the user selected + # this means they choose an translated name, so use the name they choose + # as the default, and put tmdb's name in as the original (untranslated) name of the movie + $self->{curInfo}->{title} = $self->{itemsList}[ $self->{wantedIdx} ]->{title}; + $self->{curInfo}->{original} = $xml->{movies}->{movie}->{name}; + } + else + { + $self->{curInfo}->{title} = $xml->{movies}->{movie}->{name}; + } + # Now, add any alternate names + for my $alternateName (@{$xml->{movies}->{movie}->{alternative_name}}) + { + if ((!ref($alternateName)) && ($alternateName ne $self->{curInfo}->{title})) + { + $self->{curInfo}->{original} .= ", " + if $self->{curInfo}->{original}; + $self->{curInfo}->{original} .= $alternateName; + } + } + + $self->{curInfo}->{webPage} = $xml->{movies}->{movie}->{url}; + + # The following fields could be missing from the xml, so we need to check if they're blank + # (in which case they'll be a array) + $self->{curInfo}->{synopsis} = $xml->{movies}->{movie}->{overview} + if (!ref($xml->{movies}->{movie}->{overview})); + $self->{curInfo}->{ratingpress} = $xml->{movies}->{movie}->{rating} + if (!ref($xml->{movies}->{movie}->{rating})); + $self->{curInfo}->{date} = $xml->{movies}->{movie}->{released} + if (!ref($xml->{movies}->{movie}->{released})); + $self->{curInfo}->{time} = $xml->{movies}->{movie}->{runtime} . " mins" + if (!ref($xml->{movies}->{movie}->{runtime})); + + if (!ref($xml->{movies}->{movie}->{certification})) + { + my $certification; + $certification = $xml->{movies}->{movie}->{certification}; + $self->{curInfo}->{age} = 1 + if ($certification eq 'Unrated') || ($certification eq 'Open'); + $self->{curInfo}->{age} = 2 + if ($certification eq 'G') || ($certification eq 'Approved'); + $self->{curInfo}->{age} = 5 + if ($certification eq 'PG') + || ($certification eq 'M') + || ($certification eq 'GP'); + $self->{curInfo}->{age} = 13 if $certification eq 'PG-13'; + $self->{curInfo}->{age} = 17 if $certification eq 'R'; + $self->{curInfo}->{age} = 18 + if ($certification eq 'NC-17') || ($certification eq 'X'); + } + + for my $country (@{$xml->{movies}->{movie}->{countries}->{country}}) + { + push @{$self->{curInfo}->{country}}, $country->{name}; + } + $self->{curInfo}->{country} =~ s/, $//; + for my $person (@{$xml->{movies}->{movie}->{cast}->{person}}) + { + my $name = $person->{name}; + # Strip any blank spaces from start and end of name + $name =~ s/\s*$//; + $name =~ s/^\s*//; + if ($person->{job} eq "Director") + { + $self->{curInfo}->{director} .= $name . ', '; + } + elsif ($person->{job} eq "Actor") + { + if ($self->{actorsCounter} < $GCPlugins::GCfilms::GCfilmsCommon::MAX_ACTORS) + { + push @{$self->{curInfo}->{actors}}, [$name]; + my $role = $person->{character}; + $role =~ s/\s*$//; + $role =~ s/^\s*//; + push @{$self->{curInfo}->{actors}->[ $self->{actorsCounter} ]}, $role; + $self->{actorsCounter}++; + } + } + } + $self->{curInfo}->{director} =~ s/, $//; + for my $category (@{$xml->{movies}->{movie}->{categories}->{category}}) + { + push @{$self->{curInfo}->{genre}}, [ $category->{name} ] + if ($category->{type} eq 'genre'); + } + for my $image (@{$xml->{movies}->{movie}->{images}->{image}}) + { + if ($image->{type} eq "poster") + { + # Fetch either the big original pic, or just the small thumbnail pic + if ( (($self->{bigPics}) && ($image->{size} eq "original")) + || (!($self->{bigPics}) && ($image->{size} eq "thumb"))) + { + if (!$self->{curInfo}->{image}) + { + $self->{curInfo}->{image} = $image->{url}; + } + } + } + } + } + } + + 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, + }; + + return $self; + } + + sub getItemUrl + { + my ($self, $url) = @_; + + if (!$url) + { + # If we're not passed a url, return a hint so that gcstar knows what type + # of addresses this plugin handles + $url = "http://www.themoviedb.org"; + } + elsif (index($url, "api") < 0) + { + # Url isn't for the movie db api, so we need to find the movie id + # and return a url corresponding to the api page for this movie + my $found = index(reverse($url), "/"); + if ($found >= 0) + { + my $id = substr(reverse($url), 0, $found); + $url = +"http://api.themoviedb.org/2.1/Movie.getInfo/".$self->siteLanguage()."/xml/9fc8c3894a459cac8c75e3284b712dfc/" + . reverse($id); + } + } + return $url; + } + + sub preProcess + { + my ($self, $html) = @_; + + return $html; + } + + sub decodeEntitiesWanted + { + return 0; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + return +"http://api.themoviedb.org/2.1/Movie.search/".$self->siteLanguage()."/xml/9fc8c3894a459cac8c75e3284b712dfc/$word"; + } + + sub changeUrl + { + my ($self, $url) = @_; + # Make sure the url is for the api, not the main movie page + return $self->getItemUrl($url); + } + + sub siteLanguage + { + my $self = shift; + + return 'en'; + } + + sub getName + { + return "The Movie DB"; + } + + sub getAuthor + { + return 'Zombiepig'; + } + + sub getLang + { + return 'EN'; + } + + sub getCharset + { + my $self = shift; + + return "UTF-8"; + } + + sub getSearchCharset + { + my $self = shift; + + # Need urls to be double character encoded + return "utf8"; + } + + sub convertCharset + { + my ($self, $value) = @_; + return $value; + } + + sub getNotConverted + { + my $self = shift; + return []; + } + + sub isPreferred + { + return 1; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCfilms/GCThemoviedbDE.pm b/lib/gcstar/GCPlugins/GCfilms/GCThemoviedbDE.pm new file mode 100644 index 0000000..bc55111 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCfilms/GCThemoviedbDE.pm @@ -0,0 +1,56 @@ +package GCPlugins::GCfilms::GCthemoviedbDE; + +################################################### +# +# 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::GCThemoviedb; + +{ + + package GCPlugins::GCfilms::GCPluginThemoviedbDE; + + use base qw(GCPlugins::GCfilms::GCPluginThemoviedb); + use XML::Simple; + + sub siteLanguage + { + my $self = shift; + + return 'de'; + } + + sub getName + { + return "The Movie DB (DE)"; + } + + sub getLang + { + return 'DE'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCfilms/GCThemoviedbES.pm b/lib/gcstar/GCPlugins/GCfilms/GCThemoviedbES.pm new file mode 100644 index 0000000..77dc03a --- /dev/null +++ b/lib/gcstar/GCPlugins/GCfilms/GCThemoviedbES.pm @@ -0,0 +1,56 @@ +package GCPlugins::GCfilms::GCthemoviedbES; + +################################################### +# +# 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::GCThemoviedb; + +{ + + package GCPlugins::GCfilms::GCPluginThemoviedbES; + + use base qw(GCPlugins::GCfilms::GCPluginThemoviedb); + use XML::Simple; + + sub siteLanguage + { + my $self = shift; + + return 'es'; + } + + sub getName + { + return "The Movie DB (ES)"; + } + + sub getLang + { + return 'ES'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCfilms/GCThemoviedbFR.pm b/lib/gcstar/GCPlugins/GCfilms/GCThemoviedbFR.pm new file mode 100644 index 0000000..624b64f --- /dev/null +++ b/lib/gcstar/GCPlugins/GCfilms/GCThemoviedbFR.pm @@ -0,0 +1,56 @@ +package GCPlugins::GCfilms::GCthemoviedbFR; + +################################################### +# +# 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::GCThemoviedb; + +{ + + package GCPlugins::GCfilms::GCPluginThemoviedbFR; + + use base qw(GCPlugins::GCfilms::GCPluginThemoviedb); + use XML::Simple; + + sub siteLanguage + { + my $self = shift; + + return 'fr'; + } + + sub getName + { + return "The Movie DB (FR)"; + } + + sub getLang + { + return 'FR'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCfilms/GCfilmsAmazonCommon.pm b/lib/gcstar/GCPlugins/GCfilms/GCfilmsAmazonCommon.pm new file mode 100644 index 0000000..a7178fa --- /dev/null +++ b/lib/gcstar/GCPlugins/GCfilms/GCfilmsAmazonCommon.pm @@ -0,0 +1,59 @@ +package GCPlugins::GCfilms::GCfilmsAmazonCommon; + +################################################### +# +# 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 GCPlugins::GCfilms::GCfilmsCommon; +use GCPlugins::GCstar::GCAmazonCommon; + +{ + package GCPlugins::GCfilms::GCfilmsAmazonPluginsBase; + + use base ('GCPlugins::GCfilms::GCfilmsPluginsBase', 'GCPlugins::GCstar::GCPluginAmazonCommon'); + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{codeField} = ''; + $self->{searchType} = 'dvd'; + + return $self; + } + + sub getSearchFieldsArray + { + return ['title']; + } + + sub getEanField + { + return 'title'; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCfilms/GCfilmsCommon.pm b/lib/gcstar/GCPlugins/GCfilms/GCfilmsCommon.pm new file mode 100644 index 0000000..d67952f --- /dev/null +++ b/lib/gcstar/GCPlugins/GCfilms/GCfilmsCommon.pm @@ -0,0 +1,70 @@ +package GCPlugins::GCfilms::GCfilmsCommon; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; + +our $MAX_ACTORS = 30; +our $MAX_DIRECTORS = 4; + +use GCPlugins::GCPluginsBase; + +{ + + package GCPlugins::GCfilms::GCfilmsPluginsBase; + + use base qw(GCPluginParser); + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless($self, $class); + return $self; + } + + sub getSearchFieldsArray + { + return ['title']; + } + + sub loadUrl + { + my ($self, $url) = @_; + + $self->{actorsCounter} = 0; + $self->{directorCounter} = 0; + $self->SUPER::loadUrl($url); + + if (!$self->{curInfo}->{title} && $self->{curInfo}->{original}) + { + $self->{curInfo}->{title} = $self->{curInfo}->{original}; + $self->{curInfo}->{original} = ''; + } + return $self->{curInfo}; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCAlapage.pm b/lib/gcstar/GCPlugins/GCgames/GCAlapage.pm new file mode 100644 index 0000000..0d21a94 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCAlapage.pm @@ -0,0 +1,262 @@ +package GCPlugins::GCgames::GCAlapage; + +################################################### +# +# Copyright 2005-2011 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCgames::GCgamesCommon; + +{ + package GCPlugins::GCgames::GCPluginAlapage; + + use base 'GCPlugins::GCgames::GCgamesPluginsBase'; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + if (($tagname eq 'div') && ($attr->{class} eq 'infosProduit')) + { + $self->{itemIdx}++; + $self->{isGame} = 1 ; + } + elsif (($tagname eq 'a') && ($self->{isGame})) + { + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + $self->{itemsList}[$self->{itemIdx}]->{name} = $attr->{title}; + $self->{isGame} = 0 ; + } + elsif (($tagname eq 'span') && ($attr->{class} eq 'liensAriane') && ($self->{isGame}) && ($self->{itemsList}[$self->{itemIdx}]->{platform} eq '')) + { + $self->{isPlatform} = 1 ; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + + if (($tagname eq 'h1') && ($attr->{id} eq 'zm_name_description')) + { + $self->{isName} = 1 ; + } + elsif (($tagname eq 'div') && ($attr->{id} eq 'zm_description_long')) + { + $self->{isDescription} = 1 ; + } + elsif (($tagname eq 'span') && ($attr->{rel} eq 'images nocount') && ($self->{bigPics})) + { + $self->{curInfo}->{boxpic} = $attr->{href_img} ; + } + elsif (($tagname eq 'img') && ($attr->{id} eq 'zm_main_image') && !($self->{bigPics})) + { + $self->{curInfo}->{boxpic} = $attr->{src} ; + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isPlatform}) + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//; + + $origtext =~ s/Sony //i; + $origtext =~ s/Jeux PC/PC/i; + + $self->{itemsList}[$self->{itemIdx}]->{platform} = $origtext; + $self->{Save_plateforme} = $self->{itemsList}[$self->{itemIdx}]->{platform}; + $self->{isPlatform} = 0; + + } + } + elsif ($self->{parsingTips}) + { + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + if ($self->{isName}) + { + $self->{curInfo}->{name} = $origtext; + $self->{curInfo}->{platform} = $self->{Save_plateforme}; + $self->{isName} = 0 ; + + if ($self->{ean} ne '') + { + $self->{curInfo}->{ean} = $self->{ean}; + } + + } + elsif ($self->{isDescription} eq 1) + { + # Enleve les blancs dans le texte + $origtext =~ s/ / /g; + $self->{curInfo}->{description} = $origtext; + $self->{isDescription} = 0 ; + } + + } + } + + sub getTipsUrl + { + my $self = shift; + + return ; + + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + name => 1, + platform => 1, + released => 0, + genre => 0 + }; + + $self->{isName} = 0; + $self->{isGame} = 0; + $self->{isPlatform} = 0; + $self->{Save_plateforme} = ''; + $self->{isDescription} = 0; + $self->{ean} = ''; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s|
    ||gi; + $html =~ s|
    ||gi; + + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|

    |\n|gi; + $html =~ s|

    ||gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|œ|oe|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + } + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + if ($self->{searchField} eq 'ean') + { + $self->{ean} = $word; + } + else + { + $self->{ean} = ''; + } + + return 'http://search.alapage.com/search?a=8584451-0-0&s='.$word; + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url; + } + + sub getName + { + return 'Alapage'; + } + + sub getCharset + { + my $self = shift; + #return "UTF-8"; + return "ISO-8859-15"; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'FR'; + } + + sub getSearchFieldsArray + { + return ['ean', 'name']; + } + + sub getDefaultPictureSuffix + { + return '.jpg'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCAmazon.pm b/lib/gcstar/GCPlugins/GCgames/GCAmazon.pm new file mode 100644 index 0000000..36b7890 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCAmazon.pm @@ -0,0 +1,115 @@ +package GCPlugins::GCgames::GCAmazon; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCgames::GCgamesAmazonCommon; + +{ + package GCPlugins::GCgames::GCPluginAmazon; + + use base 'GCPlugins::GCgames::GCgamesAmazonPluginsBase'; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{suffix} = 'com'; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s/>Product Description<\/tpfdescription>"); + if ( $found >= 0 ) + { + my $html2 = substr($html, $found,length($html)- $found); + + $html2 =~ s|
  • ||gi; + $html2 =~ s|

    |\n\n|gi; + $html2 =~ s|

    ||gi; + $html2 =~ s|
      |\n|gi; + $html2 =~ s|
    |\n\n|gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + + $html = substr($html, 0, $found) . $html2 ; + } + + $html =~ s/Release Date :Platform:<\/b>  <\/tpfplateforme>Platform:<\/b>/<\/tpfplateforme>/gi; + $html =~ s/registerImage\("original_image",/<\/script>||gi; + $html =~ s|
    ||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|
  • |\n*|gi; + $html =~ s|
    |\n|gi; + $html =~ s|
    |\n|gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|œ|oe|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + + } + return $html; + } + + sub getName + { + return 'Amazon (US)'; + } + + sub getLang + { + return 'EN'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCAmazonCA.pm b/lib/gcstar/GCPlugins/GCgames/GCAmazonCA.pm new file mode 100644 index 0000000..a54c4ef --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCAmazonCA.pm @@ -0,0 +1,115 @@ +package GCPlugins::GCgames::GCAmazonCA; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCgames::GCgamesAmazonCommon; + +{ + package GCPlugins::GCgames::GCPluginAmazonCA; + + use base 'GCPlugins::GCgames::GCgamesAmazonPluginsBase'; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{suffix} = 'ca'; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s/>Product Description<\/tpfdescription>"); + if ( $found >= 0 ) + { + my $html2 = substr($html, $found,length($html)- $found); + + $html2 =~ s|
  • ||gi; + $html2 =~ s|

    |\n\n|gi; + $html2 =~ s|

    ||gi; + $html2 =~ s|
      |\n|gi; + $html2 =~ s|
    |\n\n|gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + + $html = substr($html, 0, $found) . $html2 ; + } + + $html =~ s/Release Date :Platform:<\/b>  <\/tpfplateforme>Platform:<\/b>/<\/tpfplateforme>/gi; + $html =~ s/registerImage\("original_image",/<\/script>||gi; + $html =~ s|
    ||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|
  • |\n*|gi; + $html =~ s|
    |\n|gi; + $html =~ s|
    |\n|gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|œ|oe|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + + } + return $html; + } + + sub getName + { + return 'Amazon (CA)'; + } + + sub getLang + { + return 'EN'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCAmazonDE.pm b/lib/gcstar/GCPlugins/GCgames/GCAmazonDE.pm new file mode 100644 index 0000000..1dbc106 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCAmazonDE.pm @@ -0,0 +1,114 @@ +package GCPlugins::GCgames::GCAmazonDE; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCgames::GCgamesAmazonCommon; + +{ + package GCPlugins::GCgames::GCPluginAmazonDE; + + use base 'GCPlugins::GCgames::GCgamesAmazonPluginsBase'; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{suffix} = 'de'; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s/>Produktbeschreibungen<\/tpfdescription>"); + if ( $found >= 0 ) + { + my $html2 = substr($html, $found,length($html)- $found); + + $html2 =~ s|
  • ||gi; + $html2 =~ s|

    |\n\n|gi; + $html2 =~ s|

    ||gi; + $html2 =~ s|
      |\n|gi; + $html2 =~ s|
    |\n\n|gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + + $html = substr($html, 0, $found) . $html2 ; + } + + $html =~ s/Erscheinungsdatum :Plattform:<\/b>  <\/tpfplateforme>Plattform:<\/b>/<\/tpfplateforme>/gi; + $html =~ s/registerImage\("original_image",/<\/script>||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|
  • |*|gi; + $html =~ s|
    |\n|gi; + $html =~ s|
    |\n|gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + + } + return $html; + } + + sub getName + { + return 'Amazon (DE)'; + } + + sub getLang + { + return 'DE'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCAmazonFR.pm b/lib/gcstar/GCPlugins/GCgames/GCAmazonFR.pm new file mode 100644 index 0000000..1bceb23 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCAmazonFR.pm @@ -0,0 +1,118 @@ +package GCPlugins::GCgames::GCAmazonFR; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCgames::GCgamesAmazonCommon; + +{ + package GCPlugins::GCgames::GCPluginAmazonFR; + + use base 'GCPlugins::GCgames::GCgamesAmazonPluginsBase'; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{suffix} = 'fr'; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s/>Description du produit<\/tpfdescription>Descriptions du produit<\/tpfdescription>"); + if ( $found >= 0 ) + { + my $html2 = substr($html, $found,length($html)- $found); + + $html2 =~ s|
  • ||gi; + $html2 =~ s|

    |\n\n|gi; + $html2 =~ s|

    ||gi; + $html2 =~ s|
      |\n|gi; + $html2 =~ s|
    |\n\n|gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + + $html = substr($html, 0, $found) . $html2 ; + } + + $html =~ s/Date de parution :Plate-forme:<\/b>  <\/tpfplateforme>Plate-forme:<\/b>/<\/tpfplateforme>/gi; + $html =~ s/registerImage\("original_image",/<\/script>||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|
  • |*|gi; + $html =~ s|
    |\n|gi; + $html =~ s|
    |\n|gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|œ|oe|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + # Bug sur Shadow of Memories pour PS2 + $html =~ s|Actio\)n|Action|gi; + + } + return $html; + } + + sub getName + { + return 'Amazon (FR)'; + } + + sub getLang + { + return 'FR'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCAmazonJP.pm b/lib/gcstar/GCPlugins/GCgames/GCAmazonJP.pm new file mode 100644 index 0000000..80824ec --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCAmazonJP.pm @@ -0,0 +1,120 @@ +package GCPlugins::GCgames::GCAmazonJP; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCgames::GCgamesAmazonCommon; + +{ + package GCPlugins::GCgames::GCPluginAmazonJP; + + use base 'GCPlugins::GCgames::GCgamesAmazonPluginsBase'; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{suffix} = 'co.jp'; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s/>商品の説明<\/tpfdescription>"); + if ( $found >= 0 ) + { + my $html2 = substr($html, $found,length($html)- $found); + + $html2 =~ s|
  • ||gi; + $html2 =~ s|

    |\n\n|gi; + $html2 =~ s|

    ||gi; + $html2 =~ s|
      |\n|gi; + $html2 =~ s|
    |\n\n|gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + + $html = substr($html, 0, $found) . $html2 ; + } + + $html =~ s/発売日 :プラットフォーム:<\/b>  <\/tpfplateforme>プラットフォーム:<\/b>/<\/tpfplateforme>/gi; + $html =~ s/registerImage\("original_image",/<\/script>||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|
  • |*|gi; + $html =~ s|
    |\n|gi; + $html =~ s|
    |\n|gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + + } + return $html; + } + + sub getName + { + return 'Amazon (JP)'; + } + + sub getCharset + { + my $self = shift; + return "SHIFT_JIS"; + } + + sub getLang + { + return 'JP'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCAmazonUK.pm b/lib/gcstar/GCPlugins/GCgames/GCAmazonUK.pm new file mode 100644 index 0000000..5108e8c --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCAmazonUK.pm @@ -0,0 +1,115 @@ +package GCPlugins::GCgames::GCAmazonUK; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCgames::GCgamesAmazonCommon; + +{ + package GCPlugins::GCgames::GCPluginAmazonUK; + + use base 'GCPlugins::GCgames::GCgamesAmazonPluginsBase'; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{suffix} = 'co.uk'; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s/>Product Description<\/tpfdescription>Reviews<\/tpfdescription>"); + if ( $found >= 0 ) + { + my $html2 = substr($html, $found,length($html)- $found); + + $html2 =~ s|
  • ||gi; + $html2 =~ s|

    |\n\n|gi; + $html2 =~ s|

    ||gi; + $html2 =~ s|
      |\n|gi; + $html2 =~ s|
    |\n\n|gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + $html2 =~ s|||gi; + + $html = substr($html, 0, $found) . $html2 ; + } + + $html =~ s/Release Date :Platform:<\/b>  <\/tpfplateforme>Platform:<\/b>/<\/tpfplateforme>/gi; + $html =~ s/registerImage\("original_image",/<\/script>||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|
  • |*|gi; + $html =~ s|
    |\n|gi; + $html =~ s|
    |\n|gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + + } + return $html; + } + + sub getName + { + return 'Amazon (UK)'; + } + + sub getLang + { + return 'EN'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCDicoDuNet.pm b/lib/gcstar/GCPlugins/GCgames/GCDicoDuNet.pm new file mode 100644 index 0000000..fd130cf --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCDicoDuNet.pm @@ -0,0 +1,291 @@ +package GCPlugins::GCgames::GCDicoDuNet; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCgames::GCgamesCommon; + +{ + package GCPlugins::GCgames::GCPluginDicoDuNet; + + use base 'GCPlugins::GCgames::GCgamesPluginsBase'; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + if (($tagname eq 'div') && ($attr->{class} eq 'cat_produit')) + { + $self->{isGame} = 1 ; + $self->{isUrl} = 1 ; + } + elsif (($tagname eq 'a') && ($self->{isUrl}) && ($self->{isGame})) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + $self->{isUrl} = 0 ; + } + elsif (($tagname eq 'strong') && ($self->{isGame})) + { + $self->{isName} = 1 ; + $self->{isGame} = 0 ; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + + if (($tagname eq 'h3') && ($attr->{class} eq 'produits')) + { + $self->{isGame} = 1 ; + } + elsif (($tagname eq 'span') && ($self->{isGame} eq 1) ) + { + $self->{isName} = 1 ; + $self->{isGame} = 2 ; + } + elsif (($tagname eq 'a') && ($self->{isGame} eq 2)) + { + $self->{isEditor} = 1 ; + $self->{isGame} = 0 ; + } + elsif ($tagname eq 'table') + { + $self->{isGame} = 0 ; + } + elsif (($tagname eq 'div') && ($attr->{id} eq 'vous_etes_ici')) + { + $self->{isPlatform} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{href} ne 'http://www.dicodunet.com/jeux-video/') && ($self->{isPlatform})) + { + $self->{isPlatform} = 2 ; + } + elsif (($tagname eq 'a') && (index($attr->{href},"www.dicodunet.com/jeux-video/img/") >= 0) && ($self->{curInfo}->{boxpic} eq '')) + { + my $html = $self->loadPage($attr->{href}, 0, 1); + my $found = index($html,"

    "); + if ( $found >= 0 ) + { + $html = substr($html, $found +length('

    '),length($html)- $found -length('

    ')); + + my $found = index($html,"= 0 ) + { + $html = substr($html, $found +length('{curInfo}->{boxpic} = $html; + } + } + + } + elsif ($tagname eq 'tpfdateparution') + { + $self->{isDate} = 1 ; + } + elsif ($tagname eq 'tpfean') + { + $self->{isEan} = 1 ; + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isName}) + { + $self->{itemsList}[$self->{itemIdx}]->{name} = $origtext; + $self->{isName} = 0; + + } + } + elsif ($self->{parsingTips}) + { + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + if ($self->{isName}) + { + $self->{curInfo}->{name} = $origtext; + $self->{isName} = 0 ; + } + elsif ($self->{isEditor}) + { + $self->{curInfo}->{editor} = $origtext; + $self->{isEditor} = 0 ; + } + elsif ($self->{isPlatform} eq 2) + { + $origtext =~ s/PlayStation 2/Playstation 2/i; + $origtext =~ s/Jeux PC/PC/i; + $origtext =~ s/Jeux Mac/MAC/i; + + if (($self->{curInfo}->{platform} eq '') && ($origtext ne '')) + { + $self->{curInfo}->{platform} = $origtext; + } + elsif ($origtext ne '') + { + $self->{curInfo}->{platform} .= ', '; + $self->{curInfo}->{platform} .= $origtext; + } + $self->{isPlatform} = 0; + } + elsif ($self->{isDate}) + { + $self->{curInfo}->{released} = $origtext; + $self->{curInfo}->{released} =~ s|([0-9]*)-([0-9]*)-([0-9]*)|$3.'/'.$2.'/'.$1|e; + $self->{isDate} = 0 ; + } + elsif ($self->{isEan}) + { + $self->{curInfo}->{ean} = $origtext; + $self->{isEan} = 0 ; + } + + } + } + + sub getTipsUrl + { + my $self = shift; + + return ; + + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + name => 1, + platform => 0, + genre => 0, + released => 0 + }; + + $self->{isName} = 0; + $self->{isGame} = 0; + $self->{isUrl} = 0; + $self->{isPlatform} = 0; + $self->{isEditor} = 0; + $self->{isDate} = 0; + $self->{isEan} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + my $found = index($html,"class=\"produits_box\""); + if ( $found >= 0 ) + { + $html = substr($html, 0, $found); + } + + $html =~ s/Version sortie le //gi; + $html =~ s/Code EAN : //gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + } + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + return ('http://www.dicodunet.com/jeux-video/recherche.php', ["q" => "$word"] ); + } + + sub getItemUrl + { + my ($self, $url) = @_; + return $url if $url; + return 'http://www.dicodunet.com/'; + } + + sub getName + { + return 'DicoDuNet'; + } + + sub getCharset + { + my $self = shift; + #return "UTF-8"; + return "ISO-8859-15"; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'FR'; + } + + sub getSearchFieldsArray + { + return ['name']; + } +} + +1; + diff --git a/lib/gcstar/GCPlugins/GCgames/GCGameSpot.pm b/lib/gcstar/GCPlugins/GCgames/GCGameSpot.pm new file mode 100644 index 0000000..c5870b4 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCGameSpot.pm @@ -0,0 +1,490 @@ +package GCPlugins::GCgames::GCGameSpot; + +################################################### +# +# Copyright 2005-2011 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCgames::GCgamesCommon; + +{ + package GCPlugins::GCgames::GCPluginGameSpot; + + use base 'GCPlugins::GCgames::GCgamesPluginsBase'; + use Text::Wrap; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + if ($self->{parsingList}) + { + if ($tagname eq 'div') + { + $self->{isGame} = 1 + if $attr->{class} =~ /result_title/; + } + elsif ($tagname eq 'tpfdatetpf') + { + $self->{isDate} = 1; + } + elsif (($tagname eq 'a') && ($self->{isGame})) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + $self->{isName} = 1; + } + } + elsif ($self->{parsingTips}) + { + if (($tagname eq 'h2') && ($attr->{class} eq 'module_title')) + { + $self->{isSection} = 1; + } + elsif (($tagname eq 'th') && ($attr->{scope} eq 'row') && ($attr->{class} eq 'code') && ($self->{section} ne '')) + { + $self->{isCheat} = 1; + } + elsif (($tagname eq 'td') && ($attr->{class} eq 'effect') && ($self->{section} ne '')) + { + $self->{isDesc} = 1; + } + elsif (($tagname eq 'h3') && ($attr->{class} eq 'cheatCodeTitle') && ($self->{section} eq 'Secrets')) + { + $self->{curInfo}->{secrets} .= "\n" if $self->{curInfo}->{secrets}; + } + elsif ($tagname eq 'tpfdebuttpf') + { + $self->{section} = 'Secrets'; + } + elsif (($tagname eq 'div') && ($attr->{class} eq 'head')) + { + $self->{section} = ''; + } + elsif ($tagname eq 'head') + { + $self->{urlTips} = ''; + } + } + else + { + if ($tagname eq 'img') + { + $self->{curInfo}->{boxpic} = ' ' + if $attr->{src} =~ /no_preview/; + if ((! $self->{curInfo}->{boxpic}) && ($attr->{src} =~ /[^xo]boxs[^c]/)) + { + $self->{curInfo}->{boxpic} = $attr->{src}; + } + if ($attr->{src} =~ /thumb/) + { + my $pic = $attr->{src}; + $pic =~ s/thumb00([0-9])/screen00$1/; + if ($1 && ($1 <= 2)) + { + $self->{curInfo}->{'screenshot'.$1} = $pic + if ! $self->{curInfo}->{'screenshot'.$1}; + } + } + } + elsif (($tagname eq 'div') && ($attr->{class} eq 'boxshot')) + { + $self->{isBox} = 1; + } + elsif (($tagname eq 'a') && ($self->{isBox} eq 1)) + { + my $html = $self->loadPage($self->getItemUrl($attr->{href}), 0, 1); + my $found = index($html,"id=\"main_image\" src=\""); + if ( $found >= 0 ) + { + $html = substr($html, $found +length('id="main_image" src="'),length($html)- $found -length('id="main_image" src="')); + + my @array = split(/"/,$html); + #" + if ($self->{bigPics}) + { + $self->{curInfo}->{boxpic} = $array[0]; + } + $self->{curInfo}->{backpic} = $array[0]; + $self->{curInfo}->{backpic} =~ s/_front/_back/; + } + $self->{isBox} = 0; + } + elsif (($tagname eq 'h1') && ($attr->{class} eq 'productPageTitle')) + { + $self->{isName} = 1 if ! $self->{curInfo}->{name}; + } + elsif (($tagname eq 'meta') && ($attr->{name} eq 'description')) + { + $self->{curInfo}->{description} = $attr->{content}; + } + elsif (($tagname eq 'li') && ($attr->{class} =~ /activeFilter/)) + { + $self->{curInfo}->{exclusive} = 0; + } + elsif (($tagname eq 'span') && ($attr->{class} eq 'reviewer')) + { + $self->{isRating} = 1; + } + elsif (($tagname eq 'a') && ($self->{isRating} eq 1)) + { + $self->{isRating} = 2; + } + elsif (($tagname eq 'li') && ($attr->{class} eq 'moreStat play_info number_of_players')) + { + $self->{isPlayers} = 1; + } + elsif (($tagname eq 'p') && ($self->{isPlayers} eq 1)) + { + $self->{isPlayers} = 2; + } + elsif (($tagname eq 'li') && ($attr->{class} eq 'publisher')) + { + $self->{isEditor} = 1; + } + elsif (($tagname eq 'a') && ($self->{isEditor} eq 1)) + { + $self->{isEditor} = 2; + } + elsif (($tagname eq 'li') && ($attr->{class} eq 'developer')) + { + $self->{isDeveloper} = 1; + } + elsif (($tagname eq 'a') && ($self->{isDeveloper} eq 1)) + { + $self->{isDeveloper} = 2; + } + elsif (($tagname eq 'li') && ($attr->{class} eq 'genre')) + { + $self->{isGenre} = 1; + } + elsif (($tagname eq 'a') && ($self->{isGenre})) + { + $self->{curInfo}->{genre} = $attr->{title}; + $self->{isGenre} = 0; + } + elsif (($tagname eq 'li') && ($attr->{class} eq 'date')) + { + $self->{isReleased} = 1; + } + elsif (($tagname eq 'a') && ($self->{isReleased} eq 1)) + { + $self->{isReleased} = 2; + } + elsif (($tagname eq 'a') && ($attr->{href} =~ /\/cheats\//) && ($attr->{class} eq 'navItemAction')) + { + $self->{urlTips} = $attr->{href}; + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + if ($self->{parsingList}) + { + $self->{isGame} = 0 + if ($tagname eq 'div'); + } + elsif ($self->{parsingTips}) + { + } + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isName}) + { + $origtext =~ /^(.*?)\s*\((.*?)\)\s*$/; + $self->{itemsList}[$self->{itemIdx}]->{name} = $1; + $self->{itemsList}[$self->{itemIdx}]->{platform} = $2; + $self->{itemsList}[$self->{itemIdx}]->{url} = $self->{itemsList}[$self->{itemIdx}]->{url} . 'tpfplatformtpf' . $self->{itemsList}[$self->{itemIdx}]->{platform}; + $self->{isName} = 0; + } + elsif ($self->{isDate}) + { + $origtext =~ /^\s*Release Date:\s*(.*?)\s*$/ms; + $self->{itemsList}[$self->{itemIdx}]->{released} = $1; + $self->{isDate} = 0; + } + } + elsif ($self->{parsingTips}) + { + if (($self->{isSection} eq 1) && $self->{inside}->{h2}) + { + $self->{section} = 'Codes' if $origtext =~ /Cheat Codes$/; + $self->{section} = 'Unlockables' if $origtext =~ /Unlockables$/; + $self->{section} = 'Secrets' if $origtext =~ /Secrets$/; + $self->{section} = 'Secrets' if $origtext =~ /Easter Eggs$/; + $self->{isSection} = 0; + } + elsif (($self->{section} eq 'Codes') || ($self->{section} eq 'Unlockables')) + { + $origtext =~ s/^\s*//; + $origtext =~ s/\s*$//; + $Text::Wrap::columns = 80; + $origtext = Text::Wrap::wrap('', '', $origtext); + + if ($self->{isCheat}) + { + if ($self->{section} eq 'Codes') + { + $self->{tmpCheatLine} = []; + push @{$self->{tmpCheatLine}}, $origtext; + } + else + { + $self->{tmpCheatLine} = []; + ${$self->{tmpCheatLine}}[1] = $origtext; + } + $self->{isCheat} = 0; + } + elsif ($self->{isDesc}) + { + if ($self->{section} eq 'Codes') + { + push @{$self->{tmpCheatLine}}, $origtext; + push @{$self->{curInfo}->{code}}, $self->{tmpCheatLine}; + $self->{tmpCheatLine} = []; + } + else + { + ${$self->{tmpCheatLine}}[0] = $origtext; + push @{$self->{curInfo}->{unlockable}}, $self->{tmpCheatLine}; + $self->{tmpCheatLine} = []; + } + $self->{isDesc} = 0; + } + } + elsif ($self->{section} eq 'Secrets') + { + $origtext =~ s/^\s*//; + $origtext =~ s/\s*$//; + return if !$origtext; + $self->{curInfo}->{secrets} .= "\n" if $self->{curInfo}->{secrets}; + $self->{curInfo}->{secrets} .= $origtext; + } + } + else + { + if ($self->{isName}) + { + $origtext =~ s/\n//g; + $self->{curInfo}->{name} = $origtext; + $self->{curInfo}->{platform} = $self->{url_plateforme}; + $self->{curInfo}->{exclusive} = 1; + $self->{isName} = 0; + } + elsif ($self->{isRating} eq 2) + { + $self->{curInfo}->{ratingpress} = $origtext; + $self->{isRating} = 0; + } + else + { + $origtext =~ s/^\s*//; + $origtext =~ s/\s*$//; + return if !$origtext; + if ($self->{isReleased} eq 2) + { + $origtext =~ s/ .$//; + $self->{curInfo}->{released} = $origtext; + $self->{isReleased} = 0; + } + elsif ($self->{isEditor} eq 2) + { + $self->{curInfo}->{editor} = $origtext; + $self->{isEditor} = 0; + } + elsif ($self->{isDeveloper} eq 2) + { + $self->{curInfo}->{developer} = $origtext; + $self->{isDeveloper} = 0; + } + elsif ($self->{isPlayers} eq 2) + { + $origtext =~ s/(Players?)?\s*\(.*?$//; + $self->{curInfo}->{players} = $origtext; + $self->{isPlayers} = 0; + } + } + } + } + + sub getTipsUrl + { + my $self = shift; + return 'http://www.gamespot.com' .$self->{urlTips}; + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + name => 1, + platform => 1, + released => 1, + }; + + $self->{isName} = 0; + $self->{isGame} = 0; + $self->{isDate} = 0; + $self->{isCheat} = 0; + $self->{isDesc} = 0; + $self->{isTip} = 0; + $self->{isRating} = 0; + $self->{section} = ''; + $self->{isSection} = 0; + $self->{isDeveloper} = 0; + $self->{isGenre} = 0; + $self->{isEditor} = 0; + $self->{isReleased} = 0; + $self->{isPlayers} = 0; + $self->{isBox} = 0; + $self->{isExclu} = 0; + $self->{url_plateforme} = ''; + $self->{urlTips} = ""; + $self->{SaveUrl} = ""; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingTips}) + { + $html =~ s|(.*?)|$1|g; + $html =~ s|(.*?)|$1|g; +## It takes too much time +# $html =~ s|
  • Go to Online Walkthrough|'' . $self->RecupSolution($1) . ''|ge; + } + elsif ($self->{parsingList}) + { + $html =~ s|Release Date|Release Date|g; + } + else + { + my $found = index($html,"Similar Games"); + if ( $found >= 0 ) + { + $html = substr($html, 0, $found); + } + } + + return $html; + } + + sub RecupSolution + { + my ($self, $url) = @_; + + my $html = $self->loadPage($url); + + my $found = index($html,"

    "); + if ( $found >= 0 ) + { + $html = substr($html, $found,length($html)- $found); + } + else + { + $found = index($html,""); + if ( $found >= 0 ) + { + $html = substr($html, $found,length($html)- $found); + } + } + + $html = substr($html, 0, index($html, " rel=\"next\">")); + + $html =~ s|
  • Les astuces d|$self->RecupTips($1)|ge; + $html =~ s|

    La solution d|$self->RecupSolution($1)|ge; + $html =~ s|
    ||gi; + $html =~ s|

    Plus d'infos

    ||gi; + $html =~ s|
    ||gi; + $html =~ s|

    ||gi; + $html =~ s|

    ||gi; + $html =~ s|||gi; + $html =~ s|

    ||gi; + $html =~ s|

    ||gi; + $html =~ s|
    |

    |gi; + $html =~ s||

    |gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s||Cercle|gi; + $html =~ s||Croix|gi; + $html =~ s||Carr.|gi; + $html =~ s||Triangle|gi; + $html =~ s||Cercle|gi; + $html =~ s||Croix|gi; + $html =~ s||Carr.|gi; + $html =~ s||Triangle|gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|œ|oe|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + } + else + { + $self->{is} = ''; + $self->{inScreenshots} = 0; + } + return $html; + } + + sub RecupTips + { + my ($self, $url) = @_; + + my $html = $self->loadPage($url); + my $savenexturl = ''; + + my $found = index($html,"

    = 0 ) + { + $savenexturl = substr($html, $found +length('

    "); + if ( $found >= 0 ) + { + $html = substr($html, $found +length('

    '),length($html)- $found -length('
    ')); + $html = substr($html, 0, index($html, "
    ")); + if ( $savenexturl ne "" ) + { + $html .= $self->RecupTips($savenexturl); + } + } + else + { + $html = ''; + } + return "" . $html . ""; + } + + sub RecupSolution + { + my ($self, $url) = @_; + + my $html = $self->loadPage($url); + my $savenexturl = ''; + + my $found = index($html,"

    = 0 ) + { + $savenexturl = substr($html, $found +length('

    "); + if ( $found >= 0 ) + { + $html = substr($html, $found +length('

    '),length($html)- $found -length('
    ')); + $html = substr($html, 0, index($html, "
    ")); + if ( $savenexturl ne "" ) + { + $html .= $self->RecupSolution($savenexturl); + } + } + else + { + $html = ''; + } + return "" . $html . ""; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + $word =~ s/\+/ /g; + return 'http://www.jeuxvideo.com/recherche/jeux/'.$word.'.htm'; + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url if $url; + return 'http://www.jeuxvideo.com/'; + } + + sub getName + { + return 'jeuxvideo.com'; + } + + sub getAuthor + { + return 'Tian & TPF'; + } + + sub getLang + { + return 'FR'; + } + + sub getCharset + { + my $self = shift; + + return "ISO-8859-1"; + } + sub isPreferred + { + return 1; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm b/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm new file mode 100644 index 0000000..bec266f --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCJeuxVideoFr.pm @@ -0,0 +1,425 @@ +package GCPlugins::GCgames::GCJeuxVideoFr; + +################################################### +# +# Copyright 2005-2011 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCgames::GCgamesCommon; + +{ + package GCPlugins::GCgames::GCPluginJeuxVideoFr; + + use base 'GCPlugins::GCgames::GCgamesPluginsBase'; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + if ($self->{parsingList}) + { + if ($tagname eq 'div') + { + $self->{isGame} = 1 + if $attr->{class} eq "jeuDesc"; + } + if ($self->{isGame}) + { + if ($tagname eq 'a') + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + $self->{itemsList}[$self->{itemIdx}]->{name} = $attr->{title}; + } + elsif ( ($tagname eq 'span') & ($attr->{class} eq "bleu2")) + { + $self->{isPlatform} = 1; + } + elsif ( ($tagname eq 'span') & ($attr->{class} eq "bleu6")) + { + $self->{isGenre} = 1; + } + elsif ( ($tagname eq 'p') & ($attr->{class} eq "jeuNote")) + { + $self->{isGame} = 0; + $self->{isEnd} = 1; + } + } + } + elsif ($self->{parsingTips}) + { + } + else + { + if ( ($tagname eq 'input') && ($attr->{id} eq 'titreJeu')) + { + $self->{curInfo}->{name} = $attr->{value}; + $self->{curInfo}->{platform} = $self->{url_plateforme}; + + my $html = $self->loadPage( $self->{url_screenshot} ); + + my $found = index($html,"div class=\"image_slideshow\">"); + if ( $found >= 0 ) + { + $self->{curInfo}->{screenshot1} = substr($html, $found +length('div class="image_slideshow">'),length($html)- $found -length('div class="image_slideshow">')); + $found = index($self->{curInfo}->{screenshot1},"= 0 ) + { + $self->{curInfo}->{screenshot1} = substr($self->{curInfo}->{screenshot1}, $found +length('{curInfo}->{screenshot1} = substr($self->{curInfo}->{screenshot1}, 0,index($self->{curInfo}->{screenshot1},"\"")); + $found = index($html,"\"imageNumberTotal\""); + if ( $found >= 0 ) + { + $self->{curInfo}->{screenshot2} = substr($html, $found +length('"imageNumberTotal"'),length($html)- $found -length('"imageNumberTotal"')); + $found = index($self->{curInfo}->{screenshot2},"href=\""); + if ( $found >= 0 ) + { + $self->{curInfo}->{screenshot2} = substr($self->{curInfo}->{screenshot2}, $found +length('href="'),length($self->{curInfo}->{screenshot2})- $found -length('href="')); + $self->{curInfo}->{screenshot2} = 'http://www.jeuxvideo.fr/' . substr($self->{curInfo}->{screenshot2}, 0,index($self->{curInfo}->{screenshot2},"\"")); + + $html = $self->loadPage( $self->{curInfo}->{screenshot2} ); + $found = index($html,"div class=\"image_slideshow\">"); + if ( $found >= 0 ) + { + $self->{curInfo}->{screenshot2} = substr($html, $found +length('div class="image_slideshow">'),length($html)- $found -length('div class="image_slideshow">')); + $found = index($self->{curInfo}->{screenshot2},"= 0 ) + { + $self->{curInfo}->{screenshot2} = substr($self->{curInfo}->{screenshot2}, $found +length('{curInfo}->{screenshot2} = substr($self->{curInfo}->{screenshot2}, 0,index($self->{curInfo}->{screenshot2},"\"")); + } + } + } + } + } + } + } + elsif (($tagname eq 'div') && ($attr->{class} eq 'clearer spacer10')) + { + $self->{isInfo} = 0; + $self->{is} = ''; + } + elsif (($tagname eq 'div') && ($attr->{class} eq 'listing_apropos')) + { + $self->{isInfo} = 1; + } + elsif (($self->{isInfo} eq '1') && ($tagname eq 'span') && ($attr->{class} eq 'strong')) + { + $self->{isInfo} = 2; + } + elsif (($self->{is}) && ($tagname eq 'span') && ($attr->{class} eq 'noir')) + { + $self->{isInfo} = 3; + } + elsif (($self->{is}) && ($tagname eq 'div') && ($attr->{class} eq 'clearer')) + { + $self->{isInfo} = 1; + $self->{is} = ''; + } + elsif (($tagname eq 'span') && ($attr->{class} eq 'note-jeux orange1') && ($attr->{property} eq 'v:rating')) + { + $self->{isNote} = 1; + } + elsif (($tagname eq 'div') && ($attr->{class} eq 'contentCommentaire')) + { + $self->{isDesc} = 1; + } + elsif (($self->{isDesc}) && ($tagname eq 'div') && ($attr->{class} eq 'clearer')) + { + $self->{isDesc} = 0; + } + elsif ( ($tagname eq 'img') && ($attr->{class} eq 'imgJeu') && !($attr->{src} =~ /blank/i)) + { + $self->{curInfo}->{boxpic} = $attr->{src}; + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + if ($self->{parsingList}) + { + } + elsif ($self->{parsingTips}) + { + } + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//; + + if ($self->{isGenre}) + { + if ($self->{itemsList}[$self->{itemIdx}]->{genre} eq '') + { + $self->{itemsList}[$self->{itemIdx}]->{genre} = $origtext; + $self->{isGenre} = 0; + } + else + { + $self->{itemsList}[$self->{itemIdx}]->{genre} = $self->{itemsList}[$self->{itemIdx}]->{genre} . ' - ' . $origtext; + $self->{isGenre} = 0; + } + } + elsif ($self->{isPlatform}) + { + $origtext =~ s/\|//gi; + if ($self->{itemsList}[$self->{itemIdx}]->{platform} eq '') + { + $self->{itemsList}[$self->{itemIdx}]->{platform} = $origtext; + } + else + { + $self->{itemsList}[$self->{itemIdx}]->{platform} .= ', '; + $self->{itemsList}[$self->{itemIdx}]->{platform} .= $origtext; + } + $self->{isPlatform} = 0; + } + elsif ($self->{isEnd}) + { + my @array = split(/,/,$self->{itemsList}[$self->{itemIdx}]->{platform}); + my $element; + + my $SaveName = $self->{itemsList}[$self->{itemIdx}]->{name}; + my $SaveUrl = $self->{itemsList}[$self->{itemIdx}]->{url}; + my $SaveGenre = $self->{itemsList}[$self->{itemIdx}]->{genre}; + $self->{itemIdx}--; + + foreach $element (@array) + { + # Enleve les blancs en debut de chaine + $element =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $element =~ s/\s+$//; + + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{name} = $SaveName; + $self->{itemsList}[$self->{itemIdx}]->{url} = $SaveUrl . 'tpfplatformtpf' . $element; + $self->{itemsList}[$self->{itemIdx}]->{platform} = $element; + $self->{itemsList}[$self->{itemIdx}]->{genre} = $SaveGenre; + } + $self->{isEnd} = 0; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + if ($self->{isInfo} eq 2) + { + $self->{is} = 'genre' if $origtext =~ /Genre :/; + $self->{is} = 'editor' if $origtext =~ /Editeur :/; + $self->{is} = 'developer' if $origtext =~ /D.veloppeur :/; + $self->{is} = 'players' if $origtext =~ /Nb joueurs :/; + $self->{is} = 'released' if $origtext =~ /Sortie :/; + $self->{is} = 'exclusive' if $origtext =~ /Plateformes :/; + } + elsif ($self->{isInfo} eq 3) + { + # Enleve le caractere | qui separe les champs + $origtext =~ s/\|//gi; + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//; + if ($origtext) + { + if ($self->{is} eq 'players') + { + $origtext =~ s/Exclusivement Solo/1/i; + $origtext =~ s/\s*joueurs?//i; + } + + if ($self->{curInfo}->{$self->{is}} eq '') + { + if ($self->{is} eq 'exclusive') + { + $self->{curInfo}->{$self->{is}} = 'true'; + if ($origtext =~ /$self->{curInfo}->{platform}/i) + { + $self->{curInfo}->{platform} = $origtext; + } + } + else + { + $self->{curInfo}->{$self->{is}} = $origtext; + } + } + else + { + if ($self->{is} eq 'exclusive') + { + $self->{curInfo}->{$self->{is}} = 'false'; + if ($origtext =~ /$self->{curInfo}->{platform}/i) + { + $self->{curInfo}->{platform} = $origtext; + } + } + else + { + $self->{curInfo}->{$self->{is}} = $self->{curInfo}->{$self->{is}} . ', ' . $origtext; + } + } + + } + } + elsif ($self->{isNote} eq 1) + { + $self->{curInfo}->{ratingpress} = $origtext; + $self->{isNote} = 0; + } + elsif ($self->{isDesc} eq 1) + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//; + $self->{curInfo}->{description} .= $origtext; + } + } + } + + sub getTipsUrl + { + my $self = shift; + + return $self->{url_tips}; + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + name => 1, + platform => 1, + released => 0, + genre => 1 + }; + + $self->{isGame} = 0; + $self->{isPlatform} = 0; + $self->{isGenre} = 0; + $self->{isEnd} = 0; + $self->{isInfo} = 0; + $self->{isNote} = 0; + $self->{isDesc} = 0; + $self->{isTip} = 0; + $self->{url_plateforme} = ''; + $self->{url_screenshot} = ''; + $self->{url_tips} = ''; + $self->{is} = ''; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + elsif ($self->{parsingTips}) + { + } + else + { + $html =~ s|
    |\n|gi; + $html =~ s|||gi; + $html =~ s|||gi; + } + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + return 'http://www.jeuxvideo.fr/r/'.$word.'/'; + } + + sub getItemUrl + { + my ($self, $url) = @_; + + my $found = index($url,"tpfplatformtpf"); + if ( $found >= 0 ) + { + $self->{url_plateforme} = substr($url, $found +length('tpfplatformtpf'),length($url)- $found -length('tpfplatformtpf')); + $url = substr($url, 0,$found); + } + + $self->{url_screenshot} = 'http://www.jeuxvideo.fr' . $url . 'image-photo/'; + $self->{url_tips} = 'http://www.jeuxvideo.fr' . $url . 'astuce-code/'; + + return 'http://www.jeuxvideo.fr' . $url; + } + + sub getName + { + return 'jeuxvideo.fr'; + } + + sub getAuthor + { + return 'Tian'; + } + + sub getLang + { + return 'FR'; + } + + sub getCharset + { + my $self = shift; + + return "ISO-8859-1"; + } + + sub isPreferred + { + return 1; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCLudus.pm b/lib/gcstar/GCPlugins/GCgames/GCLudus.pm new file mode 100644 index 0000000..42b42a7 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCLudus.pm @@ -0,0 +1,367 @@ +package GCPlugins::GCgames::GCLudus; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCgames::GCgamesCommon; + +{ + package GCPlugins::GCgames::GCPluginLudus; + + use base 'GCPlugins::GCgames::GCgamesPluginsBase'; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + if ($self->{parsingList}) + { + if (($tagname eq 'span') && ( $attr->{class} eq 'titolini' )) + { + $self->{isGame} = 1 ; + } + elsif (($tagname eq 'img') && ($self->{isGame})) + { + $self->{isGame} = 0 ; + $self->{isInfo} = 0 ; + } + elsif (($tagname eq 'a') && ($self->{isGame})) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://www.ludus.it/" . $attr->{href}; + $self->{isName} = 1 ; + $self->{isInfo} = 1 ; + } + elsif (($tagname eq 'td') && ( $attr->{class} eq 'trat2' ) && ($self->{isInfo} eq '1')) + { + # le deuxieme champs est le type de donnees + $self->{isInfo} = 2 ; + } + elsif (($tagname eq 'td') && ( $attr->{class} eq 'trat2' ) && ($self->{isInfo} eq '2')) + { + # le troisieme champs est la plateforme + $self->{isPlatform} = 1 ; + $self->{isInfo} = 3 ; + } + elsif (($tagname eq 'td') && ( $attr->{class} eq 'trat2' ) && ($self->{isInfo} eq '3')) + { + # le quatrieme champs est la date de sortie + $self->{isDate} = 1 ; + $self->{isInfo} = 0 ; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + if (($tagname eq 'td') && ($attr->{colspan} eq '2') && ($attr->{class} eq 'titoli2')) + { + $self->{isName} = 1 ; + } + elsif (($tagname eq 'span') && ($attr->{class} eq 'testo4')) + { + $self->{isAnalyse} = 1 ; + } + elsif ($self->{isPlatform} eq 1) + { + $self->{isPlatform} = 2 ; + } + elsif ($self->{isEditor} eq 1) + { + $self->{isEditor} = 2 ; + } + elsif ($self->{isDeveloper} eq 1) + { + $self->{isDeveloper} = 2 ; + } + elsif ($self->{isGenre} eq 1) + { + $self->{isGenre} = 2 ; + } + elsif (($tagname eq 'span') && ($attr->{class} eq 'testo') && ($attr->{align} eq '')) + { + $self->{isDescription} = 1 ; + } + elsif (($tagname eq 'tpfsautdeligne') && ($self->{isDescription})) + { + $self->{curInfo}->{description} .= "\n"; + } + elsif (($tagname eq 'table') && ($self->{isDescription})) + { + $self->{isDescription} = 0 ; + } + elsif ( ($tagname eq 'a') && (index($attr->{onclick},"adafl=win") >= 0) && ($self->{curInfo}->{screenshot1} eq '') && ($self->{curInfo}->{screenshot2} eq '')) + { + $self->{isScreen} = 1; + } + elsif ( ($tagname eq 'img') && ($self->{isScreen}) ) + { + if ($self->{curInfo}->{screenshot1} eq '') + { + $self->{curInfo}->{screenshot1} = $attr->{src}; + $self->{curInfo}->{screenshot1} =~ s|//|http://www.ludus.it/|; + my $found = index(reverse($self->{curInfo}->{screenshot1}),"/"); + if ( $found >= 0 ) + { + my $tempscreen = substr(reverse($self->{curInfo}->{screenshot1}), $found +length('/'),length($self->{curInfo}->{screenshot1})- $found -length('/')); + my $tempscreen2 = substr(reverse($self->{curInfo}->{screenshot1}), 0, $found); + $tempscreen2 = "/immagini_grandi/" . reverse($tempscreen2); + $self->{curInfo}->{screenshot1} = reverse($tempscreen) . $tempscreen2; + } + } + elsif ($self->{curInfo}->{screenshot2} eq '') + { + $self->{curInfo}->{screenshot2} = $attr->{src}; + $self->{curInfo}->{screenshot2} =~ s|//|http://www.ludus.it/|; + my $found = index(reverse($self->{curInfo}->{screenshot2}),"/"); + if ( $found >= 0 ) + { + my $tempscreen = substr(reverse($self->{curInfo}->{screenshot2}), $found +length('/'),length($self->{curInfo}->{screenshot2})- $found -length('/')); + my $tempscreen2 = substr(reverse($self->{curInfo}->{screenshot2}), 0, $found); + $tempscreen2 = "/immagini_grandi/" . reverse($tempscreen2); + $self->{curInfo}->{screenshot2} = reverse($tempscreen) . $tempscreen2; + } + $self->{isScreen} = 0; + } + } + elsif (($tagname eq 'a') && (index($attr->{href},"post_form") >= 0)) + { + $self->{curInfo}->{boxpic} = $attr->{href}; + $self->{curInfo}->{boxpic} =~ s|/LINGUA/IT||; + my $found = index(reverse($self->{curInfo}->{boxpic}),"/"); + if ( $found >= 0 ) + { + $self->{curInfo}->{boxpic} = substr(reverse($self->{curInfo}->{boxpic}), 0, $found); + $self->{curInfo}->{boxpic} = "http://www.ludus.it/copertine/giochi/" . reverse($self->{curInfo}->{boxpic}) . ".jpg"; + } + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//; + if ($self->{isName}) + { + $self->{itemsList}[$self->{itemIdx}]->{name} = $origtext; + $self->{isName} = 0; + } + elsif ($self->{isDate}) + { + $self->{itemsList}[$self->{itemIdx}]->{released} = $origtext; + $self->{isDate} = 0; + } + elsif ($self->{isPlatform}) + { + $origtext =~ s/Pc/PC/; + $self->{itemsList}[$self->{itemIdx}]->{platform} = $origtext; + $self->{isPlatform} = 0; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + if ($self->{isName}) + { + my $found = index(reverse($origtext),"-"); + if ( $found >= 0 ) + { + $origtext = substr(reverse($origtext), $found +length('-'),length($origtext)- $found -length('-')); + $origtext = reverse($origtext); + } + $self->{curInfo}->{name} = $origtext; + $self->{curInfo}->{released} = $self->{itemsList}[$self->{wantedIdx}]->{released}; + $self->{isName} = 0 ; + } + elsif ($self->{isAnalyse}) + { + $self->{isPlatform} = 1 if ($origtext =~ m/Piattaforma:/i); + $self->{isEditor} = 1 if ($origtext =~ m/Software House:/i); + $self->{isDeveloper} = 1 if ($origtext =~ m/Sviluppatore:/i); + $self->{isGenre} = 1 if ($origtext =~ m/Genere:/i); + + $self->{isAnalyse} = 0 ; + } + elsif ($self->{isGenre} eq 2) + { + my @array = split(/\//,$origtext); + my $element; + foreach $element (@array) + { + # Enleve les blancs en debut de chaine + $element =~ s/^\s+//; + $self->{curInfo}->{genre} .= $element; + $self->{curInfo}->{genre} .= ","; + } + $self->{isGenre} = 0; + } + elsif ($self->{isDeveloper} eq 2) + { + $self->{curInfo}->{developer} = $origtext; + $self->{isDeveloper} = 0 ; + } + elsif ($self->{isEditor} eq 2) + { + $self->{curInfo}->{editor} = $origtext; + $self->{isEditor} = 0 ; + } + elsif ($self->{isPlatform} eq 2) + { + $origtext =~ s/Pc/PC/; + $self->{curInfo}->{platform} = $origtext; + $self->{isPlatform} = 0; + } + elsif ($self->{isDescription}) + { + $self->{curInfo}->{description} .= $origtext; + } + } + } + + sub getTipsUrl + { + my $self = shift; + + return ; + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + name => 1, + platform => 1, + genre => 0, + released => 1 + }; + + $self->{isInfo} = 0; + $self->{isName} = 0; + $self->{isGame} = 0; + $self->{isPlatform} = 0 ; + $self->{isAnalyse} = 0; + $self->{isEditor} = 0; + $self->{isDeveloper} = 0; + $self->{isDate} = 0; + $self->{isGenre} = 0; + $self->{isScreen} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s|||gi; + $html =~ s|
  • |\n* |gi; + $html =~ s|
    ||gi; + $html =~ s|
    ||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|

    |\n|gi; + $html =~ s|

    ||gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + } + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + $word =~ s/\+/ /g; + return ('http://www.ludus.it/code/lista_alfabetica_giochi/LINGUA/IT', ["categoria" => "2", "SEARCH_STRING" => "$word"] ); + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url; + } + + sub getName + { + return 'Ludus'; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'IT'; + } + + sub getCharset + { + my $self = shift; + + return "ISO-8859-1"; + } + + sub getSearchFieldsArray + { + return ['name']; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCMobyGames.pm b/lib/gcstar/GCPlugins/GCgames/GCMobyGames.pm new file mode 100644 index 0000000..c6650c3 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCMobyGames.pm @@ -0,0 +1,541 @@ +package GCPlugins::GCgames::GCMobyGames; + +################################################### +# +# Copyright 2005-2011 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCgames::GCgamesCommon; + +{ + package GCPlugins::GCgames::GCPluginMobyGames; + + use base 'GCPlugins::GCgames::GCgamesPluginsBase'; + use HTML::Entities; + + sub extractTips + { + my ($self, $html_ini) = @_; + my $answer = ""; + my @tmpAnswer = (); + my $html = $self->loadPage($html_ini, 0, 1); + $html =~ s|
    ||gi;
    +        $html =~ s|
    ||gi; + $html =~ s|||gi; + $html =~ s|||gi; + my $found = index($html,"class=\"sbL sbB sbT\">"); + if ( $found >= 0 ) + { + $answer = substr($html, $found + length("class=\"sbL sbB sbT\">"),length($html)- $found -length("class=\"sbL sbB sbT\">") ); + $answer = substr($answer, 0, index($answer,"

    "); + if ( $found >= 0 ) + { + my $html2 = substr($html, $found + length("class=\"sbR sbL sbB\">

    "),length($html)- $found -length("class=\"sbR sbL sbB\">

    ") ); + $html2 = substr($html2, 0, index($html2,"

    ")); + $html2 =~ s/
    /\n/gi; + $html2 =~ s|

    |\n|gi; + $html2 =~ s|

    ||gi; + + $tmpAnswer[1] = decode_entities($html2); + } + + } + + return @tmpAnswer; + } + + sub extractPlayer + { + my ($self, $html_ini, $word) = @_; + my $html = 0; + my $found = index($html_ini,$word); + if ( $found >= 0 ) + { + $html = substr($html_ini, $found + length($word),length($html_ini)- $found -length($word) ); + $html = substr($html,0, index($html,"
    ") ); + $html = reverse($html); + $html = substr($html,0, index($html,">") ); + $html = reverse($html); + $html =~ s/ / /g; + $html =~ s/1 Player/1/; + } + return $html; + } + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + if ($self->{parsingList}) + { + if ( !$self->{insideSearchImage} + && ($tagname eq 'a') + && ( substr($attr->{href},0,6) eq '/game/' ) ) + { + # Test if there is a platform name in it + # (i.e. if we can find a second slash after game/ ) + if ($attr->{href} =~ m|/game/[^/]*/|) + { + if ($self->{currentName}) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = 'http://www.mobygames.com'.$attr->{href}.''; + $self->{itemsList}[$self->{itemIdx}]->{name} = $self->{currentName}; + $self->{isPlatform} = 1; + } + else + { + # This is a game we want to add + $self->{isGame} = 1; + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = 'http://www.mobygames.com'.$attr->{href}.''; + $self->{isName} = 1 ; + } + } + else + { + # We will need the name later + $self->{isGameName} = 1; + } + } + elsif ( ($tagname eq 'a') && ( substr($attr->{href},0,7) eq '/search' ) ) + { + $self->{isGame} = 0; + } + elsif ($tagname eq 'div') + { + if ($attr->{class} eq 'searchResult') + { + $self->{currentName} = ''; + } + elsif ($attr->{class} eq 'searchImage') + { + $self->{insideSearchImage} = 1; + } + } + elsif ($tagname eq 'em') + { + $self->{isDate} = 1; + } + } + elsif ($self->{parsingTips}) + { + if (($tagname eq 'table') && ($attr->{summary} eq 'List of Tips and Tricks')) + { + $self->{isSectionTips} = 2; + } + elsif ( ($tagname eq 'b') && ($self->{isSectionTips} eq '2') ) + { + $self->{isSectionTips} = 1; + } + elsif ( ($tagname eq 'tr') && (($attr->{class} eq 'mb1') || ($attr->{class} eq 'mb2')) ) + { + $self->{isTip} = 1 if ($self->{isTip} eq 2); + $self->{isCode} = 1 if ($self->{isCode} eq 2); + } + elsif ( ($tagname eq 'a') && ($self->{isTip} eq 1)) + { + my @tips = $self->extractTips('http://www.mobygames.com'.$attr->{href}.''); + if ($tips[0] =~ m/unlock/i) + { + $Text::Wrap::columns = 80; + $tips[1] = Text::Wrap::wrap('', '', $tips[1]); + #$self->{tmpCheatLine} = []; + #push @{$self->{tmpCheatLine}}, @tips; + push @{$self->{curInfo}->{unlockable}}, \@tips; + } + else + { + my $answer = $tips[0]; + $answer .= "\n"; + $answer .= $tips[1]; + if ( ($self->{curInfo}->{secrets}) && ($answer ne "") ) + { + $self->{curInfo}->{secrets} .= "\n\n\n" + } + $self->{curInfo}->{secrets} .= $answer; + } + $self->{isTip} = 2; + } + elsif ( ($tagname eq 'a') && ($self->{isCode} eq 1)) + { + my @tips = $self->extractTips('http://www.mobygames.com'.$attr->{href}.''); + @tips = reverse(@tips); + $Text::Wrap::columns = 80; + $tips[1] = Text::Wrap::wrap('', '', $tips[1]); + #$self->{tmpCheatLine} = []; + #push @{$self->{tmpCheatLine}}, @tips; + push @{$self->{curInfo}->{code}}, \@tips; + + $self->{isCode} = 2; + + } + elsif ($tagname eq 'br') + { + $self->{isTip} = 3; + $self->{isCode} = 3; + $self->{isSectionTips} = 0; + } + elsif ($tagname eq 'head') + { + $self->{isTip} = 0; + $self->{isCode} = 0; + $self->{isSectionTips} = 0; + } + + } + else + { + + if ($tagname eq 'div') + { + for ($attr->{id}) + { + /^gameTitle$/ && ($self->{isName} = 1, last); + /^gamePlatform/ && ($self->{isPlatform} = 1, last); + #/^coreGameCover/ && ($self->{isBox} = 1, last); + /^coreGameRelease/ && ($self->{isEditor} = 1, last); + } + + if ($attr->{class} =~ m/scoreBoxBig/) + { + $self->{isRating} = 1; + } + + if ($self->{curInfo}->{genre}) + { + $self->{isGenre} = 0; + } + + $self->{isDescription} = 0; + + } + elsif ( ($tagname eq 'a') && ($self->{isName}) ) + { + $self->{is} = 'name'; + $self->{curInfo}->{exclusive} = 1; + $self->{isName} = 0; + } + elsif ( ($tagname eq 'a') && ($self->{isPlatform}) ) + { + $self->{is} = 'platform'; + $self->{isPlatform} = 0; + } + elsif ( ($tagname eq 'a') && ($self->{isEditor}) ) + { + $self->{is} = 'editor'; + $self->{isEditor} = 0; + } + elsif ( ($tagname eq 'a') && ($self->{isDeveloper}) ) + { + $self->{is} = 'developer'; + $self->{isDeveloper} = 0; + } + elsif ( ($tagname eq 'a') && ($self->{isDate}) ) + { + $self->{is} = 'released'; + $self->{isDate} = 0; + } + elsif ( ($tagname eq 'a') && ($self->{isGenre}) ) + { + $self->{is} = 'genre'; + } + elsif ($tagname eq 'img') + { + if ($attr->{src} =~ m|covers/small|) + { + $attr->{src} =~ s|/small/|/large/| + if $self->{bigPics}; + $self->{curInfo}->{boxpic} = $attr->{src}; + # From here we try to get back cover + my $covers = $self->loadPage($self->{rootUrl}.'/cover-art', 0, 1); + $covers =~ m|.*?Back Cover{curInfo}->{backpic} = $1; + $self->{curInfo}->{backpic} =~ s|/small/|/large/| + if $self->{bigPics}; + } + } + elsif ($tagname eq 'html') + { + my $html = $self->loadPage($self->{curInfo}->{$self->{urlField}}.'/techinfo', 0, 1); + my $player_offline = $self->extractPlayer($html, "Number of Players: Offline" ); + my $player_online = $self->extractPlayer($html, "Number of Players: Online" ); + my $player_total = $self->extractPlayer($html, "Number of Players Supported" ); + + if ($player_total) + { + $self->{curInfo}->{players} = $player_total; + } + else + { + if ($player_offline) + { + $self->{curInfo}->{players} = 'Offline: '.$player_offline; + } + if ($player_online) + { + if ( $self->{curInfo}->{players} ) + { + $self->{curInfo}->{players} .= '; Online: '.$player_online; + } + else + { + $self->{curInfo}->{players} = 'Online: '.$player_online; + } + } + } + + $html = $self->loadPage($self->{curInfo}->{$self->{urlField}}.'/screenshots', 0, 1); + my $screen = 1; + while ($html =~ m|src="(/images/shots/[^"]*?)"|g) + { + $self->{curInfo}->{'screenshot'.$screen} = 'http://www.mobygames.com' . $1; + $self->{curInfo}->{'screenshot'.$screen} =~ s|/images/shots/s/|/images/shots/l/| + if $self->{bigPics}; + $screen++; + last if $screen > 2; + } + } + elsif ( ($tagname eq 'br') && ($self->{isDescription}) ) + { + $self->{curInfo}->{description} .= "\n"; + } + } + } + + sub end + { + my ($self, $tagname) = @_; + $self->{inside}->{$tagname}--; + if ($self->{parsingList} && ($tagname eq 'div')) + { + $self->{insideSearchImage} = 0; + } + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isName}) + { + #$self->{itemsList}[$self->{itemIdx}]->{name} = $origtext; + if ($origtext !~ /^Game:/) + { + if (!$self->{currentName}) + { + $self->{itemsList}[$self->{itemIdx}]->{name} = $origtext; + } + $self->{isName} = 0; + } + } + elsif ($self->{isPlatform}) + { + $self->{itemsList}[$self->{itemIdx}]->{platform} = $origtext; + $self->{isPlatform} = 0; + } + elsif ($self->{isGameName}) + { + $self->{currentName} = $origtext; + $self->{isGameName} = 0; + } + elsif ($self->{isDate}) + { + # tags enclose both dates and the 'a.k.a.' text, so make sure we + # ignore the aka ones + if ($origtext !~ /^a\.k\.a\./) + { + $self->{itemsList}[$self->{itemIdx}]->{released} = $origtext; + if (! $self->{itemsList}[$self->{itemIdx}]->{platform}) + { + $self->{previous} =~ s/[\s\(]*$//g; + $self->{itemsList}[$self->{itemIdx}]->{platform} = $self->{previous}; + } + } + $self->{isDate} = 0; + } + $self->{previous} = $origtext; + } + elsif ($self->{parsingTips}) + { + if ($self->{isSectionTips} eq 1) + { + if ($origtext =~ m/General Hints\/Tips/i) + { + $self->{isTip} = 2; + $self->{isCode} = 0; + } + elsif ($origtext =~ m/Cheats\/Codes/i) + { + $self->{isTip} = 0; + $self->{isCode} = 2; + } + $self->{isSectionTips} = 2; + } + } + else + { + if ($self->{is}) + { + $origtext =~ s/^\s*//; + + if ($self->{is} eq 'platform') + { + $self->{curInfo}->{$self->{is}} = $origtext; + $self->{curInfo}->{platform} =~ s/DOS/PC/; + $self->{curInfo}->{platform} =~ s/Windows/PC/; + } + elsif ($self->{is} eq 'genre') + { + push @{$self->{curInfo}->{genre}}, [ $origtext ]; + } + else + { + $self->{curInfo}->{$self->{is}} = $origtext; + } + + $self->{is} = ''; + } + elsif ($self->{isRating}) + { + $self->{curInfo}->{ratingpress} = int($origtext/10+0.5); + $self->{isRating} = 0; + } + elsif ($self->{isDescription}) + { + $self->{curInfo}->{description} .= $origtext; + } + elsif ($origtext eq 'Developed by') + { + $self->{isDeveloper} = 1 + } + elsif ( ($origtext eq 'Also For') || (($origtext eq 'Platforms'))) + { + $self->{curInfo}->{exclusive} = 0; + } + elsif ($origtext eq 'Released') + { + $self->{isDate} = 1 + } + elsif ($origtext eq 'Genre') + { + $self->{isGenre} = 1 + } + elsif ($origtext eq 'Description') + { + $self->{isDescription} = 1 + } + } + } + + sub getTipsUrl + { + my $self = shift; + my $url = $self->{curInfo}->{$self->{urlField}}.'/hints'; + $url =~ s/##MobyGames//; + return $url; + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + name => 1, + platform => 1, + released => 1 + }; + + $self->{isName} = 0; + $self->{isGame} = 0; + $self->{isGameName} = 0; + $self->{isPlatform} = 0; + $self->{isEditor} = 0; + $self->{isDeveloper} = 0; + $self->{isDate} = 0; + $self->{isGenre} = 0; + $self->{isDescription} = 0; + $self->{isBox} = 0; + $self->{isSectionTips} = 0; + $self->{isTip} = 0; + $self->{isCode} = 0; + $self->{is} = ''; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + $self->{rootUrl} = $self->{loadedUrl}; + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + return 'http://www.mobygames.com/search/quick?q='.$word.'&p=-1&search=Go&sFilter=1&sG=on'; + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url if $url; + return 'http://www.mobygames.com/'; + } + + sub getName + { + return 'MobyGames'; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'EN'; + } + + sub getCharset + { + my $self = shift; + + return "ISO-8859-1"; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCNextGame.pm b/lib/gcstar/GCPlugins/GCgames/GCNextGame.pm new file mode 100644 index 0000000..b884b54 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCNextGame.pm @@ -0,0 +1,480 @@ +package GCPlugins::GCgames::GCNextGame; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCgames::GCgamesCommon; + +{ + package GCPlugins::GCgames::GCPluginNextGame; + + use base 'GCPlugins::GCgames::GCgamesPluginsBase'; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + if ($self->{isGenre} eq '1') + { + $self->{isGenre} = 2 ; + } + elsif (($tagname eq 'div') && ($attr->{class} eq 'box_searchresult')) + { + $self->{isGame} = 1 ; + $self->{itemIdx}++; + } + elsif (($tagname eq 'ul') && ($attr->{class} eq 'platforms')) + { + $self->{isPlatform} = 1 ; + } + elsif (($tagname eq 'li') && ($self->{isPlatform} eq 1)) + { + $self->{isPlatform} = 2 ; + } + elsif (($tagname eq 'hr') && ($attr->{class} eq 'clear')) + { + $self->{isPlatform} = 0 ; + } + elsif (($tagname eq 'a') && ($attr->{class} eq 'blu')) + { + return if $self->{alreadyRetrieved}->{$attr->{href}}; + $self->{alreadyRetrieved}->{$attr->{href}} = 1; + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + $self->{isName} = 1 ; + } + elsif (($tagname eq 'dt') && ($self->{isGame} eq '1')) + { + $self->{isAnalyse} = 1 ; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + + if ($self->{isDeveloper} eq 1) + { + $self->{isDeveloper} = 2; + } + elsif ($self->{isGenre} eq 1) + { + $self->{isGenre} = 2; + } + elsif ($self->{isEditor} eq 1) + { + $self->{isEditor} = 2 ; + } + elsif ($self->{isDate} eq 1) + { + $self->{isDate} = 2 ; + } + elsif ($self->{isPlayer} eq 1) + { + $self->{isPlayer} = 2; + } + elsif ($self->{isPlatform} eq 1) + { + $self->{isPlatform} = 2; + } + elsif (($tagname eq 'div') && ($attr->{class} eq 'box_liquid')) + { + $self->{isDescription} = 0 ; + } + elsif ($tagname eq 'head') + { + $self->{isDescription} = 0 ; + } + elsif (($tagname eq 'h1') && ($attr->{class} eq 'blu')) + { + $self->{isName} = 1 ; + } + elsif (($tagname eq 'hr') && ($attr->{class} eq 'clear')) + { + $self->{isAnalyse} = 0 ; + } + elsif (($tagname eq 'dl') && ($attr->{class} eq 'datasheet_column')) + { + $self->{isAnalyse} = 1 ; + } + elsif (($tagname eq 'dt') && ($self->{isAnalyse} eq '1')) + { + $self->{isAnalyse} = 2 ; + } + elsif (($tagname eq 'td') && ($attr->{class} eq 'active current')) + { + $self->{isPlatform} = 1 ; + } + elsif (($tagname eq 'img') && ($attr->{id} eq 'datasheet_packshot')) + { + $self->{curInfo}->{boxpic} = $attr->{src}; + if ($self->{bigPics}) + { + $self->{curInfo}->{boxpic} =~ s|.T160.|.|gi; + } + } + elsif ( ($tagname eq 'img') && ($attr->{class} eq 'thumb') ) + { + if ($self->{curInfo}->{screenshot1} eq '') + { + $self->{curInfo}->{screenshot1} = $attr->{src}; + if ($self->{bigPics}) + { + $self->{curInfo}->{screenshot1} =~ s|.T200.|.|gi; + } + } + elsif ($self->{curInfo}->{screenshot2} eq '') + { + $self->{curInfo}->{screenshot2} = $attr->{src}; + if ($self->{bigPics}) + { + $self->{curInfo}->{screenshot2} =~ s|.T200.|.|gi; + } + } + } + elsif (($tagname eq 'a') && ($attr->{name} eq 'REVIEW')) + { + $self->{isDescription} = 1 ; + } + elsif (($tagname eq 'ul') && ($attr->{class} eq 'platforms') && ($self->{isDescription} eq 1)) + { + $self->{isDescription} = 2 ; + } + elsif (($tagname eq 'a') && ($attr->{class} eq 'blu') && ($self->{isDescription} eq 3)) + { + my $html = $self->loadPage( $attr->{href}, 0, 1 ); + $html =~ s|&|&|gi; + my $found = index($html,"
    "); + if ( $found >= 0 ) + { + $html = "<>" . substr($html, $found +length('
    '),length($html)- $found -length('
    ')); + + $found = index($html,"
    "); + if ( $found >= 0 ) + { + $html = substr($html, 0, $found); + } + + my @array = split(/"); + if ( $found >= 0 ) + { + $self->{curInfo}->{description} .= substr($element, $found +length('>'),length($element)- $found -length('>')); + } + } + } + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isName}) + { + $self->{itemsList}[$self->{itemIdx}]->{name} = $origtext; + $self->{isName} = 0; + } + elsif ($self->{isPlatform} eq 2) + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//; + + if (($self->{itemsList}[$self->{itemIdx}]->{platform} eq '') && ($origtext ne '')) + { + $self->{itemsList}[$self->{itemIdx}]->{platform} = $origtext; + } + elsif ($origtext ne '') + { + $self->{itemsList}[$self->{itemIdx}]->{platform} .= ', '; + $self->{itemsList}[$self->{itemIdx}]->{platform} .= $origtext; + } + + $self->{isPlatform} = 1 ; + } + elsif ($self->{isAnalyse}) + { + $self->{isGenre} = 1 if ($origtext =~ m/Genere/i); + + $self->{isAnalyse} = 0 ; + } + elsif ($self->{isGenre} eq 2) + { + $self->{itemsList}[$self->{itemIdx}]->{genre} = $origtext; + + my @array = split(/,/,$self->{itemsList}[$self->{itemIdx}]->{platform}); + my $element; + + my $SaveName = $self->{itemsList}[$self->{itemIdx}]->{name}; + my $SaveUrl = $self->{itemsList}[$self->{itemIdx}]->{url}; + my $SaveGenre = $self->{itemsList}[$self->{itemIdx}]->{genre}; + $self->{itemIdx}--; + + if ($SaveName ne "") + { + foreach $element (@array) + { + # Enleve les blancs en debut de chaine + $element =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $element =~ s/\s+$//; + + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{name} = $SaveName; + $self->{itemsList}[$self->{itemIdx}]->{url} = $SaveUrl . $element .'/'; + $self->{itemsList}[$self->{itemIdx}]->{platform} = $element; + $self->{itemsList}[$self->{itemIdx}]->{genre} = $SaveGenre; + } + } + else + { + $self->{itemIdx}++; + delete $self->{itemsList}[$self->{itemIdx}]; + $self->{itemIdx}--; + } + + $self->{isGenre} = 0; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + if ($self->{isName}) + { + $self->{curInfo}->{name} = $origtext; + $self->{isName} = 0 ; + + if ($self->{ean} ne '') + { + $self->{curInfo}->{ean} = $self->{ean}; + } + + } + elsif ($self->{isPlatform} eq 2) + { + $self->{curInfo}->{platform} = $origtext; + $self->{isPlatform} = 0; + } + elsif ($self->{isAnalyse} eq 2) + { + $self->{isEditor} = 1 if ($origtext =~ m/Produttore/i); + $self->{isDeveloper} = 1 if ($origtext =~ m/Sviluppatore/i); + $self->{isGenre} = 1 if ($origtext =~ m/Genere/i); + $self->{isDate} = 1 if ($origtext =~ m/Disponibile/i); + $self->{isPlayer} = 1 if ($origtext =~ m/Giocatori/i); + + $self->{isAnalyse} = 1 ; + } + elsif ($self->{isDeveloper} eq 2) + { + $self->{curInfo}->{developer} = $origtext; + $self->{isDeveloper} = 0; + } + elsif ($self->{isGenre} eq 2) + { + $self->{curInfo}->{genre} = $origtext; + $self->{isGenre} = 0; + } + elsif ($self->{isEditor} eq 2) + { + $self->{curInfo}->{editor} = $origtext; + $self->{isEditor} = 0 ; + } + elsif ($self->{isDate} eq 2) + { + $self->{curInfo}->{released} = $origtext; + $self->{isDate} = 0 ; + } + elsif ($self->{isPlayer} eq 2) + { + $self->{curInfo}->{players} = $origtext; + $self->{isPlayer} = 0 ; + } + elsif ($self->{isDescription} eq 2) + { + if ($origtext =~ m/$self->{curInfo}->{platform}/i) + { + $self->{isDescription} = 3; + } + else + { + $self->{isDescription} = 1; + } + } + + } + } + + sub getTipsUrl + { + my $self = shift; + + return ; + + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + name => 1, + platform => 1, + genre => 1, + released => 0 + }; + + $self->{isName} = 0; + $self->{isGame} = 0; + $self->{isPlatform} = 0; + $self->{isAnalyse} = 0 ; + $self->{isGenre} = 0; + $self->{isEditor} = 0; + $self->{isDeveloper} = 0; + $self->{isDate} = 0; + $self->{isPlayer} = 0; + $self->{isDescription} = 0; + $self->{ean} = ''; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s|
  • |
      |gi; + $html =~ s|
    • |\n* |gi; + $html =~ s|
      |\n|gi; + $html =~ s|
      |\n|gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|

      |\n|gi; + $html =~ s|

      ||gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|œ|oe|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + } + $self->{alreadyRetrieved} = {}; + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + if ($self->{searchField} eq 'ean') + { + $self->{ean} = $word; + } + else + { + $self->{ean} = ''; + } + + return 'http://next.videogame.it/magazine/review/?name='.$word; + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url if $url; + return 'http://next.videogame.it/'; + } + + sub getName + { + return 'NextGame'; + } + + sub getCharset + { + my $self = shift; + return "ISO-8859-1"; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'IT'; + } + + sub getSearchFieldsArray + { + return ['name']; + } + + sub getDefaultPictureSuffix + { + return '.jpg'; + } +} + +1; + diff --git a/lib/gcstar/GCPlugins/GCgames/GCTheLegacy.pm b/lib/gcstar/GCPlugins/GCgames/GCTheLegacy.pm new file mode 100644 index 0000000..c0759a4 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCTheLegacy.pm @@ -0,0 +1,316 @@ +package GCPlugins::GCgames::GCTheLegacy; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCgames::GCgamesCommon; + +{ + package GCPlugins::GCgames::GCPluginTheLegacy; + + use base 'GCPlugins::GCgames::GCgamesPluginsBase'; + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + if ($self->{parsingList}) + { + if (($tagname eq 'a') && ( $attr->{class} eq 'aa' )) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://www.thelegacy.de/Museum/" . $attr->{href}; + $self->{isName} = 1 ; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + if (($tagname eq 'div') && ($attr->{style} eq 'font-size:14pt; color:#990000; padding-top:0.5em;')) + { + $self->{isName} = 1 ; + } + elsif (($tagname eq 'div') && ($attr->{class} eq 'description') && ($self->{curInfo}->{platform} eq '')) + { + $self->{isPlatform} = 1 ; + } + elsif (($tagname eq 'a') && ($attr->{target} eq 'ListGames') && ($attr->{class} eq 'a') && ($attr->{style} eq '')) + { + $self->{isGenre} = 1 ; + } + elsif (($tagname eq 'img') && ($attr->{src} =~ m|/pics/cover/Thumb|i)) + { + $self->{curInfo}->{boxpic} = "http://www.thelegacy.de" . $attr->{src}; + } + elsif (($tagname eq 'img') && ($attr->{src} =~ m|/pics/backcover/Thumb|i)) + { + $self->{curInfo}->{backpic} = "http://www.thelegacy.de" . $attr->{src}; + } + elsif (($tagname eq 'img') && ($attr->{src} =~ m|/pics/screen|i)) + { + if ($self->{curInfo}->{screenshot1} eq '') + { + $self->{curInfo}->{screenshot1} = "http://www.thelegacy.de" . $attr->{src}; + } + elsif ($self->{curInfo}->{screenshot2} eq '') + { + $self->{curInfo}->{screenshot2} = "http://www.thelegacy.de" . $attr->{src}; + } + } + elsif ( (($tagname eq 'span') ||($tagname eq 'div')) && ($attr->{class} eq 'category')) + { + $self->{isAnalyse} = 1 ; + } + elsif (($self->{isEditor} eq 1) && ($tagname eq 'a') && ($attr->{target} eq 'ListGames') && ($attr->{class} eq 'aa') && ($self->{curInfo}->{editor} eq '')) + { + $self->{isEditor} = 2 ; + } + elsif (($self->{isDeveloper} eq 1) && ($tagname eq 'a') && ($attr->{target} eq 'ListGames') && ($attr->{class} eq 'aa') && ($self->{curInfo}->{developer} eq '')) + { + $self->{isDeveloper} = 2 ; + } + elsif (($self->{isDate} eq 1) && ($tagname eq 'div') && ($attr->{class} eq 'description') && ($self->{curInfo}->{released} eq '')) + { + $self->{isDate} = 2 ; + } + elsif (($tagname eq 'a') && ($attr->{name} =~ m|review_|i)) + { + $self->{isDescription} = 1 ; + } + elsif (($self->{isDescription} eq 1) && ($tagname eq 'a') && ($attr->{class} eq 'aa')) + { + $self->{isDescription} = 2 ; + } + elsif (($tagname eq 'span') && ( $attr->{id} =~ m|review_|i) && ( $attr->{id} =~ m|_less|i)) + { + $self->{isDescription} = 0 ; + } + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//; + if ($self->{isName}) + { + $self->{itemsList}[$self->{itemIdx}]->{name} = $origtext; + $self->{isName} = 0; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//; + if ($self->{isName}) + { + $self->{curInfo}->{name} = $origtext; + $self->{isName} = 0 ; + } + elsif ($self->{isAnalyse}) + { + $self->{isDate} = 0; + $self->{isDeveloper} = 0; + $self->{isEditor} = 0; + + $self->{isDate} = 1 if ($origtext =~ m/ffentlichung/i); + $self->{isDate} = 1 if ($origtext =~ m/Publishing/i); + $self->{isDeveloper} = 1 if ($origtext =~ m/Entwickler/i); + $self->{isDeveloper} = 1 if ($origtext =~ m/developer/i); + $self->{isEditor} = 1 if ($origtext =~ m/Publisher/i); + + $self->{isAnalyse} = 0 ; + } + elsif ($self->{isDate} eq 2) + { + $origtext =~ s/://; + $self->{curInfo}->{released} = $origtext; + $self->{isDate} = 0 ; + } + elsif ($self->{isGenre}) + { + $self->{curInfo}->{genre} .= $origtext; + $self->{curInfo}->{genre} .= ","; + $self->{isGenre} = 0; + } + elsif ($self->{isDeveloper} eq 2) + { + $self->{curInfo}->{developer} = $origtext; + $self->{isDeveloper} = 0 ; + } + elsif ($self->{isEditor} eq 2) + { + $self->{curInfo}->{editor} = $origtext; + $self->{isEditor} = 0 ; + } + elsif ($self->{isPlatform}) + { + $origtext =~ s/PC \(Windows\)/PC/; + my @array = split(/-/,$origtext); + $self->{curInfo}->{platform} = $array[0]; + # Enleve les blancs en fin de chaine + $self->{curInfo}->{platform} =~ s/\s+$//; + $self->{isPlatform} = 0; + } + elsif ($self->{isDescription} eq 1) + { + $self->{curInfo}->{description} .= $origtext; + } + elsif ($self->{isDescription} eq 2) + { + $self->{isDescription} = 1; + } + } + } + + sub getTipsUrl + { + my $self = shift; + + return ; + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + name => 1, + platform => 0, + genre => 0, + released => 0 + }; + + $self->{isInfo} = 0; + $self->{isName} = 0; + $self->{isPlatform} = 0 ; + $self->{isAnalyse} = 0; + $self->{isEditor} = 0; + $self->{isDeveloper} = 0; + $self->{isDate} = 0; + $self->{isGenre} = 0; + $self->{isDescription} = 0; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + if ($self->{parsingList}) + { + } + else + { + $html =~ s|||gi; + $html =~ s|
    • |\n* |gi; + $html =~ s|
      |\n|gi; + $html =~ s|
      |\n|gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|||gi; + $html =~ s|

      |\n|gi; + $html =~ s|

      ||gi; + $html =~ s|\x{92}|'|gi; + $html =~ s|’|'|gi; + $html =~ s|•|*|gi; + $html =~ s|œ|oe|gi; + $html =~ s|…|...|gi; + $html =~ s|\x{85}|...|gi; + $html =~ s|\x{8C}|OE|gi; + $html =~ s|\x{9C}|oe|gi; + } + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + return "http://www.thelegacy.de/Museum/SQLlist_games.php3?logicalSearchConnection[]=AND&SearchValue=" . $word. "&searchEntity=TITLE&Review=&Forum=&type=&changed=&TopTen=&titel_id=&game_id=&titel=&first_letter=&misc=yes&quick=yes"; + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url; + } + + sub getName + { + return 'TheLegacy'; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'DE'; + } + + sub getCharset + { + my $self = shift; + + return "ISO-8859-15"; + } + + sub getSearchFieldsArray + { + return ['name']; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCgamesAmazonCommon.pm b/lib/gcstar/GCPlugins/GCgames/GCgamesAmazonCommon.pm new file mode 100644 index 0000000..ce3b52c --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCgamesAmazonCommon.pm @@ -0,0 +1,314 @@ +package GCPlugins::GCgames::GCgamesAmazonCommon; + +################################################### +# +# Copyright 2005-2010 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCgames::GCgamesCommon; +use GCPlugins::GCstar::GCAmazonCommon; + +{ + package GCPlugins::GCgames::GCgamesAmazonPluginsBase; + + use base ('GCPlugins::GCgames::GCgamesPluginsBase', 'GCPlugins::GCstar::GCPluginAmazonCommon'); + + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + if ( ($tagname eq 'div') && ($attr->{class} eq 'buying') && ($self->{isGame} ne 2) ) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $self->{loadedUrl}; + $self->{isGame} = 2 ; + } + elsif ( ($tagname eq 'h1') && ($attr->{class} eq 'headerblocktitle') && ($self->{isGame} ne 2) ) + { + $self->{isGame} = 1 ; + $self->{isUrl} = 1 ; + } + elsif ( ($tagname eq 'td') && ($attr->{class} eq 'imageColumn') && ($self->{isGame} ne 2) ) + { + $self->{isGame} = 1 ; + $self->{isUrl} = 1 ; + } + elsif ( ($tagname eq 'a') && ($self->{isGame} eq 1) && ($self->{isUrl}) ) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + $self->{isUrl} = 0 ; + } + elsif ( ($tagname eq 'span') && ($attr->{class} eq 'srTitle') && ($self->{isGame} eq 1) ) + { + $self->{isName} = 1 ; + } + elsif ( ($tagname eq 'span') && ($attr->{class} eq 'binding') && ($self->{isGame} eq 1) ) + { + $self->{isPlatform} = 1 ; + } + elsif ( ($tagname eq 'span') && ($attr->{class} eq 'avail') ) + { + $self->{isGame} = 0 ; + } + elsif ( ($tagname eq 'div') && ($attr->{class} eq 'usedPrice') ) + { + $self->{isGame} = 0 ; + } + elsif ( ($tagname eq 'input') && ($attr->{name} eq 'sdp-sai-asin') ) + { + $self->{isCodeEAN} = 1 ; + } + elsif ( ($tagname eq 'a') && ($self->{isCodeEAN})) + { + $self->{SaveUrl} = $attr->{href}; + $self->{isCodeEAN} = 0 ; + } + elsif ( ($tagname eq 'b') && ($attr->{class} eq 'sans') ) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $self->{SaveUrl}; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + + if ( ($tagname eq 'meta') && ($attr->{name} eq 'keywords') ) + { + my ($name, $editor, @genre) = split(/,/,$attr->{content}); + $self->{curInfo}->{name} = $name; + $self->{curInfo}->{editor} = $editor; + my $element; + foreach $element (@genre) + { + $element =~ s/^\s+//; + if ( !($element =~ m/console/i) && !($element =~ m/cartouche/i) && !($element =~ m/video games/i) && !($element =~ /([0-9])/)) + { + $self->{curInfo}->{genre} .= $element; + $self->{curInfo}->{genre} .= ","; + } + } + + # Sur Amazon.com et amazon.co.jp je n ai pas reussi a trouver un critere pertinent pour la recherche des genres + if (($self->{suffix} eq 'com') || ($self->{suffix} eq 'co.jp') ) + { + $self->{curInfo}->{genre} = ''; + } + + if ($self->{ean} ne '') + { + $self->{curInfo}->{ean} = $self->{ean}; + } + } + elsif ($tagname eq 'tpfdateparution') + { + $self->{isDate} = 1 ; + } + elsif ($tagname eq 'tpfplateforme') + { + $self->{isPlatform} = 1 ; + } + elsif ($tagname eq 'tpfcouverture') + { + $self->{curInfo}->{boxpic} = $self->extractImage($attr); + } + elsif ($tagname eq 'tpfscreenshot1') + { + $self->{curInfo}->{screenshot1} = $self->extractImage($attr); + } + elsif ($tagname eq 'tpfscreenshot2') + { + $self->{curInfo}->{screenshot2} = $self->extractImage($attr); + } + elsif (($tagname eq 'tpfdescription') ) + { + $self->{isDesc} = 1; + } + elsif ( ($tagname eq 'div') && ($attr->{class} eq 'bucket') && ($self->{isDesc} eq 1)) + { + $self->{isDesc} = 0; + } + + } + } + + sub end + { + my ($self, $tagname) = @_; + + $self->{inside}->{$tagname}--; + } + + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + if ($self->{isPlatform}) + { + $self->{itemsList}[$self->{itemIdx}]->{platform} = $self->transformPlatform($origtext); + $self->{isPlatform} = 0; + } + elsif ($self->{isName}) + { + $self->{itemsList}[$self->{itemIdx}]->{name} = $origtext; + $self->{isName} = 0; + } + } + elsif ($self->{parsingTips}) + { + } + else + { + # Enleve les blancs en debut de chaine + $origtext =~ s/^\s+//; + # Enleve les blancs en fin de chaine + $origtext =~ s/\s+$//; + + if ($self->{isDate}) + { + $self->{curInfo}->{released} = $origtext; + $self->{isDate} = 0; + } + elsif ($self->{isPlatform}) + { + if ($origtext ne '' ) + { + $self->{curInfo}->{platform} = $self->transformPlatform($origtext); + $self->{isPlatform} = 0; + } + } + elsif (($self->{isDesc}) && ($origtext ne "")) + { + $self->{curInfo}->{description} .= $origtext ."\n"; + } + } + } + + sub transformPlatform + { + my ($self, $platform) = @_; + + $platform =~ s/^([\w ]*)\W{2}.*$/$1/ms; + $platform =~ s/SONY //i; + if ($platform =~ m/windows/i) + { + $platform = 'PC'; + } + return $platform; + } + + sub getTipsUrl + { + my $self = shift; + + return; + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + name => 1, + platform => 1 + }; + + $self->{isCodeEAN} = 0; + $self->{SaveUrl} = ''; + $self->{isName} = 0; + $self->{isGame} = 0; + $self->{isUrl} = 0; + $self->{isPlatform} = 0; + $self->{isDate} = 0; + $self->{isDesc} = 0; + $self->{ean} = ''; + + return $self; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + if ($self->{searchField} eq 'ean') + { + $self->{ean} = $word; + return "http://s1.amazon." . $self->{suffix} . "/exec/varzea/sdp/sai-condition/" . $word; + } + else + { + $self->{ean} = ''; + } + + return 'http://www.amazon.' . $self->{suffix} . '/gp/search/?redirect=true&search-alias=videogames&keywords=' .$word; + } + + sub getItemUrl + { + my ($self, $url) = @_; + + return $url if $url; + return 'http://www.amazon.' . $self->{suffix}; + } + + sub getName + { + return 'Amazon'; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'FR'; + } + + sub getCharset + { + my $self = shift; + + return "ISO-8859-1"; + } + + sub getSearchFieldsArray + { + return ['ean', 'name']; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCgames/GCgamesCommon.pm b/lib/gcstar/GCPlugins/GCgames/GCgamesCommon.pm new file mode 100644 index 0000000..9403652 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCgames/GCgamesCommon.pm @@ -0,0 +1,87 @@ +package GCPlugins::GCgames::GCgamesCommon; + +################################################### +# +# Copyright 2005-2010 Christian Jodar +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; + +our $MAX_ACTORS = 6; +our $MAX_DIRECTORS = 4; + +use GCPlugins::GCPluginsBase; + +{ + package GCPlugins::GCgames::GCgamesPluginsBase; + + use base qw(GCPluginParser); + use HTML::Entities; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + return $self; + } + + sub getSearchFieldsArray + { + return ['name']; + } + + sub getTipsUrl + { + my $self = shift; + + return ''; + } + + sub getTips + { + my $self = shift; + my $url = $self->getTipsUrl; + if ($url) + { + $self->{parsingTips} = 1; + my $html = $self->loadPage($url, 0, 1); + $html = $self->preProcess($html); + decode_entities($html); + $self->{inside} = undef; + $self->parse($html); + $self->{parsingTips} = 0; + } + } + + sub getItemInfo + { + my $self = shift; + + $self->SUPER::getItemInfo; + $self->getTips; + + return $self->{curInfo}; + } + +} + +1; \ No newline at end of file diff --git a/lib/gcstar/GCPlugins/GCmusics/GCDiscogs.pm b/lib/gcstar/GCPlugins/GCmusics/GCDiscogs.pm new file mode 100644 index 0000000..c6e0c87 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCmusics/GCDiscogs.pm @@ -0,0 +1,333 @@ +package GCPlugins::GCmusics::GCDiscogs; + +################################################### +# +# 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::GCmusics::GCmusicsCommon; + +{ + package GCPlugins::GCmusics::GCPluginDiscogs; + + use base 'GCPlugins::GCmusics::GCmusicsPluginsBase'; + use XML::Simple; + + sub parse + { + my ($self, $page) = @_; + return if $page =~ /^new; + my $key = $self->{searchField}; + if ($self->{parsingList}) + { + if ( $key eq 'artist' ) + { + $xml = $xs->XMLin($page); + my $artist = $xml -> {'artist'} -> {'name'}; + my $release; + foreach $release ( keys( %{ $xml -> {'artist'} -> {'releases'} -> {'release'} } ) ) + { + $self->{itemIdx}++; + my $title = $xml -> {'artist'} -> {'releases'} -> {'release'} -> {$release} -> {'title'}; + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://api.discogs.com/release/".$release."?f=xml&api_key=e8f5ae8ba2"; + $self->{itemsList}[$self->{itemIdx}]->{title} = $title; + # Enleve les blancs en debut de chaine + $self->{itemsList}[$self->{itemIdx}]->{title} =~ s/^\s+//; + + $self->{itemsList}[$self->{itemIdx}]->{artist} = $artist; + # Enleve les blancs en fin de chaine + $self->{itemsList}[$self->{itemIdx}]->{artist} =~ s/\s+$//; + } + } + elsif ( $key eq 'label' ) + { + $xml = $xs->XMLin($page); + my $release; + foreach $release ( keys( %{ $xml -> {'label'} -> {'releases'} -> {'release'} } ) ) + { + $self->{itemIdx}++; + my $title = $xml -> {'label'} -> {'releases'} -> {'release'} -> {$release} -> {'title'}; + my $artist = $xml -> {'label'} -> {'releases'} -> {'release'} -> {$release} -> {'artist'}; + $self->{itemsList}[$self->{itemIdx}]->{url} = "http://api.discogs.com/release/".$release."?f=xml&api_key=e8f5ae8ba2"; + $self->{itemsList}[$self->{itemIdx}]->{title} = $title; + # Enleve les blancs en debut de chaine + $self->{itemsList}[$self->{itemIdx}]->{title} =~ s/^\s+//; + + $self->{itemsList}[$self->{itemIdx}]->{artist} = $artist; + # Enleve les blancs en fin de chaine + $self->{itemsList}[$self->{itemIdx}]->{artist} =~ s/\s+$//; + } + } + else + { + $xml = $xs->XMLin($page, + ForceArray => ['result', 'event'], + KeyAttr => {'release' => ''}); + my $release; + foreach $release ( @{ $xml->{'searchresults'}->{result} } ) + { + if ($release->{type} eq 'release') + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = $release->{uri}; + $self->{itemsList}[$self->{itemIdx}]->{release} = $release->{summary}; + + my $found = index($release->{title},"-"); + if ( $found >= 0 ) + { + + $self->{itemsList}[$self->{itemIdx}]->{title} = substr($release->{title}, $found +length('-'),length($release->{title})- $found -length('-')); + # Enleve les blancs en debut de chaine + $self->{itemsList}[$self->{itemIdx}]->{title} =~ s/^\s+//; + + $self->{itemsList}[$self->{itemIdx}]->{artist} = substr($release->{title}, 0, $found); + # Enleve les blancs en fin de chaine + $self->{itemsList}[$self->{itemIdx}]->{artist} =~ s/\s+$//; + + # Clean up release summary + my $tmpTitle = $release->{title}; + $tmpTitle =~ s/\- //; + + # Unsure about this line, seems to not be required anymore, and is breaking parsing + # of search results. EG - searching for "raw animals" + # $self->{itemsList}[$self->{itemIdx}]->{release} =~ s/^$tmpTitle //; + } + else + { + $self->{itemsList}[$self->{itemIdx}]->{title} = $release->{title}; + } + } + } + } + } + else + { + $xml = $xs->XMLin($page, + ForceArray => ['track', 'artist', 'image', 'label', 'genre', 'format'], + KeyAttr => {'track' => ''}); + $self->{curInfo}->{title} = $xml->{release}->{title}; + $self->{curInfo}->{artist} = ''; + for my $art (@{$xml->{release}->{artists}->{artist}}) + { + $self->{curInfo}->{artist} .= $art->{name}.', '; + } + $self->{curInfo}->{artist} =~ s/, $//; + $self->{curInfo}->{producer} = ''; + $self->{curInfo}->{composer} = ''; + for my $rel (@{$xml->{release}->{extraartists}->{artist}}) + { + $self->{curInfo}->{producer} .= $rel->{name}.', ' + if $rel->{role} eq 'Producer'; + $self->{curInfo}->{composer} .= $rel->{name}.', ' + if (($rel->{role} eq 'Composed By') || ($rel->{role} eq 'Score') || ($rel->{role} eq 'Songwriter') || ($rel->{role} eq 'Written-By')); + } + $self->{curInfo}->{producer} =~ s/, $//; + $self->{curInfo}->{composer} =~ s/, $//; + $self->{curInfo}->{release} = $xml->{release}->{released}; + for my $track(@{$xml->{release}->{'tracklist'}->{track}}) + { + my $duree = $track->{duration}; + $duree =~ /([0-9]+):([0-9]+)/; + my $duree2 = int($1*60 + $2); + my $position = ""; + # Sometimes the position is missing, which causes it to be an array + if (!ref($track->{position})) + { + $position = $track->{position}; + } + $self->addTrack($track->{title}, $duree2, $position); + } + $self->{curInfo}->{tracks} = $self->getTracks; + $self->{curInfo}->{running} = $self->getTotalTime; + for my $cover(@{$xml->{release}->{images}->{image}}) + { + if ($self->{curInfo}->{cover} eq '') + { + if ($self->{bigPics}) + { + $self->{curInfo}->{cover} = $cover->{uri}; + } + else + { + $self->{curInfo}->{cover} = $cover->{uri}; + # Change to small res cover + $self->{curInfo}->{cover} =~ s/image\/R-/image\/R-150-/; + } + } + + } + $self->{curInfo}->{label} = ''; + for my $label (@{$xml->{release}->{labels}->{label}}) + { + $self->{curInfo}->{label} .= $label->{name}.', '; + } + $self->{curInfo}->{label} =~ s/, $//; + $self->{curInfo}->{genre} = ''; + for my $genre (@{$xml->{release}->{genres}->{genre}}) + { + $self->{curInfo}->{genre} .= $genre.','; + } + $self->{curInfo}->{genre} =~ s/,$//; + $self->{curInfo}->{origin} = $xml->{release}->{country}; + $self->{curInfo}->{origin} =~ s/,$//; + for my $format(@{$xml->{release}->{formats}->{format}}) + { + if ( $self->{curInfo}->{format} eq '') + { + $self->{curInfo}->{format} = $format->{name}; + $self->{curInfo}->{format} =~ s/,$//; + } + } + $self->{curInfo}->{web} = 'http://www.discogs.com/release/' . $xml->{release}->{id}; + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + artist => 1, + release => 1 + }; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + return $html; + } + + sub decodeEntitiesWanted + { + return 0; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + my $key = $self->{searchField}; + my $url; + if ( $key eq 'title' ) + { + $url = "http://api.discogs.com/search?type=all&q=". $word ."&f=xml&api_key=e8f5ae8ba2"; + } + elsif ( $key eq 'artist' ) + { + $url = "http://api.discogs.com/". $key ."/". $word ."?f=xml&api_key=e8f5ae8ba2"; + } + elsif ( $key eq 'label' ) + { + $url = "http://api.discogs.com/". $key ."/". $word ."?f=xml&api_key=e8f5ae8ba2"; + } + + return $url; +# return "http://api.discogs.com/search?type=all&q=". $word ."&f=xml&api_key=e8f5ae8ba2"; + } + + sub getItemUrl + { + my ($self, $url) = @_; + if (!$url) + { + # If we're not passed a url, return a hint so that gcstar knows what type + # of addresses this plugin handles + $url = "http://www.discogs.com"; + } + elsif (index($url,"api_key") < 0) + { + # Url isn't for the discogs api, so we need to find the release id + # and return a url corresponding to the api page for this release + $url =~ /release\/([0-9]+)/; + my $id = $1; + $url = "http://api.discogs.com/release/". $id ."?f=xml&api_key=e8f5ae8ba2"; + } + return $url; + } + + sub changeUrl + { + my ($self, $url) = @_; + + return $self->getItemUrl($url); + } + + sub getName + { + return 'Discogs'; + } + + sub getAuthor + { + return 'TPF'; + } + + sub getLang + { + return 'EN'; + } + + sub getCharset + { + my $self = shift; + + return "UTF-8"; + } + + sub getSearchCharset + { + my $self = shift; + + # Need urls to be double character encoded + return "utf8"; + } + + sub convertCharset + { + my ($self, $value) = @_; + return $value; + } + + sub getNotConverted + { + my $self = shift; + return []; + } + + sub getSearchFieldsArray + { + return ['title', 'artist', 'label']; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCmusics/GCDoubanmusic.pm b/lib/gcstar/GCPlugins/GCmusics/GCDoubanmusic.pm new file mode 100644 index 0000000..b2d7873 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCmusics/GCDoubanmusic.pm @@ -0,0 +1,238 @@ +package GCPlugins::GCmusics::GCDoubanmusic; + +################################################### +# +# Copyright 2005-2010 Bai Wensimi +# +# 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::GCmusics::GCmusicsCommon; + +{ + package GCPlugins::GCmusics::GCPluginDoubanmusic; + + use base qw(GCPlugins::GCmusics::GCmusicsPluginsBase); + use XML::Simple; + use Encode; + use LWP::Simple qw($ua); + + sub parse + { + my ($self, $page) = @_; + return if (($page =~ /^bad isbn/) & ($page =~ /^The/)); + my $xml; + my $xs = XML::Simple->new; + + if ($self->{parsingList}) + { + if ($page =~ /feed>$/) + { + $xml = $xs->XMLin( + $page, + forceArray=>['author'], + KeyAttr => [''] + ); + foreach my $ItemMusic ( @{$xml->{'entry'}}){ + $self->{itemIdx}++; + $self->{itemsList}[ $self->{itemIdx} ]->{'url'} = $ItemMusic->{'id'}; + $self->{itemsList}[ $self->{itemIdx} ]->{'title'} = $ItemMusic->{'title'}; + foreach my $tmp_author (@{$ItemMusic->{'author'}}){ + {($self->{itemsList}[ $self->{itemIdx} ]->{'artist'} ne '' ) and $self->{itemsList}[ $self->{itemIdx} ]->{'artist'}.=',';} + $self->{itemsList}[ $self->{itemIdx} ]->{'artist'}.=$tmp_author->{'name'}; + } + } + } + else + { + $xml = $xs->XMLin( + $page, + forceArray=>['author'], + KeyAttr => [''] + ); + $self->{itemIdx}++; + $self->{itemsList}[ $self->{itemIdx} ]->{'url'} = $xml->{'id'}; + $self->{itemsList}[ $self->{itemIdx} ]->{'title'} = $xml->{'title'}; + foreach my $tmp_author (@{$xml->{'author'}}){ + $self->{itemsList}[ $self->{itemIdx} ]->{'artist'}.=$tmp_author->{'name'}; + $self->{itemsList}[ $self->{itemIdx} ]->{'artist'}.=','; + } + } + } + else + { + $xml =$xs->XMLin($page, + ForceArray => [ 'author' ], + KeyAttr => {'db:tag'=>'name','link'=>'rel'}); + foreach my $tmp_author (@{$xml->{'author'}}){ + {($self->{curInfo}->{artist} ne '' ) and $self->{curInfo}->{artist}.=','; } + $self->{curInfo}->{artist}.=$tmp_author->{'name'}; + } + $self->{curInfo}->{title}=$xml->{'title'}; + $self->{curInfo}->{web}=$xml->{'link'}->{'alternate'}->{'href'}; + foreach my $check(@{$xml->{'db:attribute'}}){ + my $db_attr=$check->{'name'}; + SWITCH: { + $db_attr eq 'publisher' and $self->{curInfo}->{producer}=$check->{'content'} ,last; + $db_attr eq 'pubdate' and $self->{curInfo}->{release}=$check->{'content'} ,last; + $db_attr eq 'ean' and $self->{curInfo}->{unique}=$check->{'content'} ,last; + $db_attr eq 'media' and $self->{curInfo}->{format}=$check->{'content'} ,last; + if ($db_attr eq 'tracks') { my @chains = split(/(?=\d+\.)/, $check->{'content'}); + foreach my $track ( @chains ){ + my $num=$track;my $name=$track; + $num=~ s/(^\d+).*/$1/; + $num=~ s/\n//g; + $name =~ s/^\d+\.(.*)/$1/; + $name=~s/\n//g; + $num=encode("utf8",$num); + $name=encode("utf8",$name); + $self->addTrack($name,0,$num); + } + last SWITCH;} + ; + } + } + $self->{curInfo}->{tracks} = $self->getTracks; + my $tmp_image=$xml->{'link'}->{'image'}->{'href'}; + $tmp_image =~ s/spic/lpic/; + $self->{curInfo}->{cover}=$tmp_image; + } + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + artist => 1, + publication => 0, + }; + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + return $html; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + return "http://api.douban.com/music/subjects?q=" .$word; + } + + sub getItemUrl + { + my ($self, $url) = @_; + return $url; + } + + sub changeUrl + { + my ($self, $url) = @_; + # Make sure the url is for the api, not the main movie page + return $self->getItemUrl($url); + } + + sub getNumberPasses + { + return 1; + } + + sub getName + { + return "豆瓣"; + } + + + sub testURL + { + my ($self, $url) = @_; + $url =~ /[\?&]lid=([0-9]+)*/; + my $id = $1; + return ($id == $self->siteLanguageCode()); + } + + sub getReturnedFields + { + my $self = shift; + + $self->{hasField} = { + title => 1, + artist => 1, + }; + } + + sub getAuthor + { + return 'BW'; + } + + sub getLang + { + return 'ZH'; + } + + sub isPreferred + { + return 1; + } + + sub getSearchCharset + { + my $self = shift; + + # Need urls to be double character encoded + return "UTF-8"; + } + sub getSearchFieldsArray + { + return ['isbn', 'title']; + } + + sub getCharset + { + my $self = shift; + + return "UTF-8"; + } + + sub decodeEntitiesWanted + { + return 0; + } + + sub siteLanguage + { + my $self = shift; + + return 'ZH'; + } + +} + +1; diff --git a/lib/gcstar/GCPlugins/GCmusics/GCMusicBrainz.pm b/lib/gcstar/GCPlugins/GCmusics/GCMusicBrainz.pm new file mode 100644 index 0000000..f91027f --- /dev/null +++ b/lib/gcstar/GCPlugins/GCmusics/GCMusicBrainz.pm @@ -0,0 +1,309 @@ +package GCPlugins::GCmusics::GCMusicBrainz; + +################################################### +# +# 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::GCmusics::GCmusicsCommon; + +{ + package GCPlugins::GCmusics::GCPluginMusicBrainz; + + use base 'GCPlugins::GCmusics::GCmusicsPluginsBase'; + use XML::Simple; + use Locale::Country; + + sub parse + { + my ($self, $page) = @_; + my $xml; + my $xs = XML::Simple->new; + if ($self->{parsingList}) + { + $xml = $xs->XMLin($page, + ForceArray => ['release', 'event'], + KeyAttr => {'release' => ''}); + my $release; + foreach $release ( @{ $xml->{'release-list'}->{release} } ) + { + $self->{itemIdx}++; + $self->{itemsList}[$self->{itemIdx}]->{url} = 'http://musicbrainz.org/album/'.$release->{id}.'.html'; + $self->{itemsList}[$self->{itemIdx}]->{title} = $release->{title}; + $self->{itemsList}[$self->{itemIdx}]->{artist} = $release->{artist}->{name}; + + my $releaseDate='9999-12-31'; + for my $releaseEvent (@{$release->{'release-event-list'}->{event}}) + { + if ($releaseEvent->{date} lt $releaseDate) + { + # Find the earliest release event + $releaseDate = $releaseEvent->{date}; + } + } + + $self->{itemsList}[$self->{itemIdx}]->{release} = $releaseDate + if $releaseDate ne '9999-12-31'; + } + } + else + { + $xml = $xs->XMLin($page, + ForceArray => ['track', 'event', 'relation', 'relation-list','tag'], + KeyAttr => {'track' => ''}); + $self->{curInfo}->{title} = $xml->{release}->{title}; + $self->{curInfo}->{web} = 'http://musicbrainz.org/release/'.$xml->{release}->{id}.'.html'; + $self->{curInfo}->{artist} = $xml->{release}->{artist}->{name}; + $self->{curInfo}->{ratingpress} = int($xml->{release}->{rating}->{content}) * 2; + $self->{curInfo}->{producer} = ''; + $self->{curInfo}->{composer} = ''; + + # Step through the relations + for my $relation (@{$xml->{release}->{'relation-list'}}) + { + if ($relation->{'target-type'} eq 'Artist') + { + # Artist type relations + for my $rel (@{$relation->{relation}}) + { + # Search for producer or composer relations + $self->{curInfo}->{producer} .= $rel->{artist}->{name}.', ' + if $rel->{type} eq 'Producer'; + $self->{curInfo}->{composer} .= $rel->{artist}->{name}.', ' + if $rel->{type} eq 'Composer'; + } + } + elsif ($relation->{'target-type'} eq 'Url') + { + # Look for url type relations. Currently only jamendo works, but we should also cover the archive.org + # relations + for my $rel (@{$relation->{relation}}) + { + # Alternate cover art sites + if (($rel->{target} =~ m/jamendo.com/) && (!$self->{curInfo}->{cover})) + { + # Cover art should be on jamendo + $rel->{target} =~ /\/([0-9]+)$/; + my $id = $1; + if ($self->{bigPics}) + { + $self->{curInfo}->{cover} = "http://img.jamendo.com/albums/$id/covers/1.0.jpg"; + } + else + { + $self->{curInfo}->{cover} = "http://img.jamendo.com/albums/$id/covers/1.200.jpg"; + } + } + } + } + } + + $self->{curInfo}->{producer} =~ s/, $//; + $self->{curInfo}->{composer} =~ s/, $//; + + my $releaseDate; + my $releaseLabel; + my $releaseCountry; + my $releaseFormat; + my $releaseDateFromCompare='9999-12-12'; + for my $releaseEvent (@{$xml->{release}->{'release-event-list'}->{event}}) + { + my $releaseDateToCompare; + # Check if musicbrainz only has the year, if so, set things up so we'll prefer + # releases with the month & day over year-only releases + if (length($releaseEvent->{date}) == 4) + { + $releaseDateToCompare = $releaseEvent->{date}."-12-31"; + } + else + { + $releaseDateToCompare = $releaseEvent->{date}; + } + + if (($releaseDateToCompare lt $releaseDateFromCompare) || + (($releaseDateToCompare eq $releaseDateFromCompare) && + (($releaseEvent->{country} eq 'US') || ($releaseEvent->{country} eq 'GB')))) + { + # Find the earliest release event, which has a month & day + # Big call, but we're probably more correct choosing a US or UK release if there's two + # release events with the same date, so prioritise them + $releaseDate = $releaseEvent->{date}; + $releaseLabel = $releaseEvent->{label}->{name} + if $releaseEvent->{label}; + $releaseCountry = code2country($releaseEvent->{country}); + $releaseFormat = $releaseEvent->{format}; + $releaseDateFromCompare = $releaseDateToCompare; + } + } + + $self->{curInfo}->{release} = $releaseDate; + $self->{curInfo}->{label} = $releaseLabel; + $self->{curInfo}->{origin} = $releaseCountry; + $self->{curInfo}->{format} = $releaseFormat; + + for my $track(@{$xml->{release}->{'track-list'}->{track}}) + { + $self->addTrack($track->{title}, $track->{duration} / 1000); + } + $self->{curInfo}->{tracks} = $self->getTracks; + $self->{curInfo}->{running} = $self->getTotalTime; + + for my $genre(@{$xml->{release}->{'tag-list'}->{tag}}) + { + # Capitalize first letter of each word + $genre->{content} =~ s/\b(\w+)\b/ucfirst($1)/ge; + # Only add genres if they have more then 1 vote, strips out a lot of + # weird/wrong tags + push @{$self->{curInfo}->{genre}}, [$genre->{content}] + if ($genre->{count} > 1); + } + + # If amazon artwork exists, use it + if (($xml->{release}->{asin}) && (!$self->{curInfo}->{cover})) + { + if ($self->{bigPics}) + { + $self->{curInfo}->{cover} = 'http://images.amazon.com/images/P/'.$xml->{release}->{asin}.'.01.LZZZZZZZ.jpg' + } + else + { + $self->{curInfo}->{cover} = 'http://images.amazon.com/images/P/'.$xml->{release}->{asin}.'.01.MZZZZZZZ.jpg' + } + } + } + } + + sub convertDate + { + my ($self, $date) = @_; + $date =~ /([0-9]{4})-?([0-9]{2})?-?([0-9]{2})?/; + return $3 .($3 ? '/' : '').$2.($2 ? '/' : '').$1; + } + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + + $self->{hasField} = { + title => 1, + artist => 1, + release => 1, + tracks => 1 + }; + + return $self; + } + + sub preProcess + { + my ($self, $html) = @_; + + return $html; + } + + sub decodeEntitiesWanted + { + return 0; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + + my $key = ($self->{searchField} eq 'artist') ? 'artist' : 'title'; + return "http://musicbrainz.org/ws/1/release/?type=xml&$key=$word"; + } + + sub getItemUrl + { + my ($self, $url) = @_; + return $url if $url; + return "http://musicbrainz.org/"; + } + + sub changeUrl + { + my ($self, $url) = @_; + $url =~ s|http://musicbrainz.org/album/(.*?)\.html|http://musicbrainz.org/ws/1/release/$1?type=xml&inc=artist+tracks+release-events+artist-rels+url-rels+ratings+labels+tags|; + $url =~ s|http://musicbrainz.org/release/(.*?)\.html|http://musicbrainz.org/ws/1/release/$1?type=xml&inc=artist+tracks+release-events+artist-rels+url-rels+ratings+labels+tags|; + return $url; + } + + sub getName + { + return 'MusicBrainz'; + } + + sub getAuthor + { + return 'Tian'; + } + + sub getLang + { + return 'EN'; + } + + sub getCharset + { + my $self = shift; + + return "UTF-8"; + } + + sub getSearchCharset + { + my $self = shift; + + # Need urls to be double character encoded + return "utf8"; + } + + sub convertCharset + { + my ($self, $value) = @_; + return $value; + } + + sub getNotConverted + { + my $self = shift; + return []; + } + + sub getSearchFieldsArray + { + return ['title', 'artist']; + } + + sub isPreferred + { + # Return status of 2 means plugin is default regardless of user's language + return 2; + } +} + +1; diff --git a/lib/gcstar/GCPlugins/GCmusics/GCmusicsCommon.pm b/lib/gcstar/GCPlugins/GCmusics/GCmusicsCommon.pm new file mode 100644 index 0000000..186662c --- /dev/null +++ b/lib/gcstar/GCPlugins/GCmusics/GCmusicsCommon.pm @@ -0,0 +1,62 @@ +package GCPlugins::GCmusics::GCmusicsCommon; + +################################################### +# +# 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 GCPlugins::GCPluginsBase; +use GCExtract::GCExtractMusics; + +{ + package GCPlugins::GCmusics::GCmusicsPluginsBase; + + use base ('GCPluginParser', 'GCExtract::GCmusicsExtracter'); + #use base ('GCPluginParser'); + use HTML::Entities; + + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + bless ($self, $class); + return $self; + } + + sub getSearchFieldsArray + { + return ['title']; + } + + sub loadUrl + { + my ($self, $url) = @_; + + $self->resetTracks; + $self->SUPER::loadUrl($url); + return $self->{curInfo}; + } + +} + +1; \ No newline at end of file diff --git a/lib/gcstar/GCPlugins/GCstar/GCAmazonCommon.pm b/lib/gcstar/GCPlugins/GCstar/GCAmazonCommon.pm new file mode 100644 index 0000000..a9ecd80 --- /dev/null +++ b/lib/gcstar/GCPlugins/GCstar/GCAmazonCommon.pm @@ -0,0 +1,132 @@ +package GCPlugins::GCstar::GCAmazonCommon; + +################################################### +# +# 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 GCPlugins::GCPluginsBase; + +{ + package GCPlugins::GCstar::GCPluginAmazonCommon; + + sub text + { + my ($self, $origtext) = @_; + return 0 if ($self->{parsingEnded}); + + if ($self->{parsingList}) + { + if ( + (($self->{inside}->{b}) + || ($self->{inside}->{span}) + || ($self->{inside}->{label})) + ) + { + my $suffix = $self->{suffix}; + if ((($suffix =~ /^co/) && ($origtext =~ /Sort by/)) + || (($suffix eq 'fr' ) && ($origtext =~ /Trier par/)) + || (($suffix eq 'de' ) && ($origtext =~ /Sortieren nach/))) + { + $self->{beginParsing} = 1; + return 1; + } + } + } + + return 0; + } + + sub extractImage + { + my ($self, $attr) = @_; + my $url = $attr->{src}; + return 'http://images.amazon.com/images/'.$1.'/'.$2.$3.'MZZZZZZZ.'.$5 + if ($url =~ m%^http://.*?images[.-]amazon\.com/images/(P)/([A-Z0-9]*)(\.[0-9]+\.)?[-A-Za-z0-9_.,]*?ZZZZZZZ(.*?)\.(jpg|gif)%); + return 'http://images.amazon.com/images/'.$1.'/'.$2.'.'.$3 + if ($url =~ m%^http://.*?images[.-]amazon\.com/images/(I|G)/([-\%A-Z0-9a-z+]*)\._.*?_\.(jpg|gif)%); + if ($attr->{id} eq 'prodImage') + { + $url =~ s/_AA[0-9]*_//; + return $url; + } + return ''; + } + + sub isEAN + { + my ($self, $value) = @_; + + my $l = length($value); + return 1 + if ($l == 8) + || ($l == 13) + || ($l == 15) + || ($l == 18); + return 0; + } + + sub isItemUrl + { + my ($self, $url) = @_; + return $1 + if (($url =~ m|/dp/[A-Z0-9]*/sr=([0-3]-[0-9]*)/qid=[0-9]*|) + || ($url =~ m|/dp/[A-Z0-9]*/ref=(?:sr\|pd)_([a-z0-9_]*)/[0-9]*|) + || ($url =~ m|/dp/[A-Z0-9]*/ref=(?:sr\|pd)_([a-z0-9_]*)/[0-9]*|)); + return undef; + } + + sub getSearchUrl + { + my ($self, $word) = @_; + return "http://www.amazon.".$self->{suffix}."/gp/search/?redirect=true&search-alias=".$self->{searchType}."&keywords=$word"; + } + + sub getItemUrl + { + my ($self, $url) = @_; + return $url if $url; + return 'http://www.amazon.'.$self->{suffix}; + } + + sub getAuthor + { + return 'Tian'; + } + + sub preProcess + { + my ($self, $html) = @_; + if ($self->{parsingList}) + { + $html =~ s|([^<]*)|$1|gim; + $html =~ s|.*?||gim; + } + else + { + $html =~ s|([^<]*)|$1|gim; + } + return $html; + } +} + +1; -- cgit v1.2.3