diff options
Diffstat (limited to 'lib/gcstar/GCPlugins/GCcomics')
-rw-r--r-- | lib/gcstar/GCPlugins/GCcomics/GCbedetheque.pm | 246 |
1 files changed, 183 insertions, 63 deletions
diff --git a/lib/gcstar/GCPlugins/GCcomics/GCbedetheque.pm b/lib/gcstar/GCPlugins/GCcomics/GCbedetheque.pm index 457194a..636fd4f 100644 --- a/lib/gcstar/GCPlugins/GCcomics/GCbedetheque.pm +++ b/lib/gcstar/GCPlugins/GCcomics/GCbedetheque.pm @@ -39,11 +39,11 @@ use GCPlugins::GCcomics::GCcomicsCommon; my ( $self, $word ) = @_; if ($self->{searchField} eq 'series') { - return "http://www.bedetheque.com/index.php?R=1&RechSerie=$word"; + return "http://www.bedetheque.com/search/albums?RechSerie=$word"; } elsif ($self->{searchField} eq 'writer') { - return "http://www.bedetheque.com/index.php?R=1&RechAuteur=$word"; + return "http://www.bedetheque.com/search/albums?RechAuteur=$word"; } else { @@ -64,6 +64,7 @@ use GCPlugins::GCcomics::GCcomicsCommon; my @array = split( /#/, $url ); $self->{site_internal_id} = $array[1]; + # print "getItemUrl $url\n\n"; return $url if $url =~ /^http:/; return "http://www.bedetheque.com/" . $url; } @@ -143,14 +144,30 @@ use GCPlugins::GCcomics::GCcomicsCommon; } else { - $html =~ m/(<div class="box main reeditions">.+)/; - - #$html =~ m/(<div class="album.+)/; + # print $html ; + $html =~ m/(<div class="single-title-wrap serie-wrap">.+)/; $html = $1; $self->{isResultsTable} = 0; $self->{parsingEnded} = 0; $self->{isCover} = 0; - $self->{itemIdx}++;; + $self->{isTabs} = 0; + $self->{isLabel} = 0; + $self->{itemIdx}++; + # + $self->{doneColourist} = 0 ; + $self->{doneCost} = 0 ; + $self->{doneFormat} = 0 ; + $self->{doneIllustrator} = 0 ; + $self->{doneISBN} = 0 ; + $self->{doneNumberboards} = 0 ; + $self->{donePublishdate} = 0 ; + $self->{donePublishdate} = 0 ; + $self->{donePublisher} = 0 ; + $self->{doneSerie} = 0 ; + $self->{doneSynopsis} = 0 ; + $self->{doneTitle} = 0 ; + $self->{doneVolume} = 0 ; + $self->{doneWriter} = 0 ; } return $html; @@ -178,69 +195,100 @@ use GCPlugins::GCcomics::GCcomicsCommon; #$self->{itemsList}[ $self->{itemIdx} ]->{url} = # "http://www.bedetheque.com/" . $attr->{href}; } - elsif ( $tagname eq "i" ) - { + elsif ( ( $tagname eq "ul" ) && ( $attr->{class} eq "search-list" ) ) { + $self->{inTable} = 1; + } + elsif ( ($self->{inTable}) && ( $tagname eq "li" ) ) { + $self->{isVolume} = 1; + } + elsif ( ($self->{inTable}) && ( $tagname eq "a" ) && ( $attr->{title} eq "tooltip" ) ) { + $self->{itemsList}[$self->{itemIdx}]->{image} = $attr->{rel}; + $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + } + elsif ( ($self->{isVolume}) && ( $tagname eq "span" ) && ( $attr->{class} eq "titre" ) ) { + $self->{isTitle} = 1; + } + elsif ( ($self->{isVolume}) && ( $tagname eq "span" ) && ( $attr->{class} eq "serie" ) ) { $self->{isSerie} = 1; } + elsif ( ($self->{isVolume}) && ( $tagname eq "span" ) && ( $attr->{class} eq "num" ) ) { + $self->{isNumber} = 1; + } } else { - if ( ( $tagname eq "table" ) && ( $attr->{id} eq "albums_serie" ) ) { + if ( ( $tagname eq "ul" ) && ( $attr->{class} eq "search-list" ) ) { $self->{inTable} = 1; } - elsif ( ($self->{inTable}) && ( $tagname eq "td" ) && ( $attr->{class} eq "num" ) ) { + elsif ( ($self->{inTable}) && ( $tagname eq "li" ) ) { $self->{itemIdx}++; $self->{isVolume} = 1; } - elsif ( ($self->{inTable}) && ( $tagname eq "a" ) && ( $attr->{href} =~ m/serie-/ ) ) { + elsif ( ($self->{inTable}) && ( $tagname eq "a" ) && ( $attr->{title} eq "tooltip" ) ) { + $self->{itemsList}[$self->{itemIdx}]->{image} = $attr->{rel}; $self->{itemsList}[$self->{itemIdx}]->{url} = $attr->{href}; + } + elsif ( ($self->{isVolume}) && ( $tagname eq "span" ) && ( $attr->{class} eq "titre" ) ) { $self->{isTitle} = 1; } + elsif ( ($self->{isVolume}) && ( $tagname eq "span" ) && ( $attr->{class} eq "serie" ) ) { + $self->{isSerie} = 1; + } elsif ( ( $self->{isSynopsis} ) && ( $tagname eq "br" ) && ( $self->{startSynopsis} ) ) { # This is a stop! for br ;-) and complementary of the p in the end section # should be ( ( $tagname eq "p" ) || ( $tagname eq "br" ) ) $self->{isSynopsis} = 0; $self->{startSynopsis} = 0; - $self->{parsingEnded} = 1; + $self->{parsingEnded} = 1; } } } else { - if ( $tagname eq "title") - { - $self->{isIssue} = 1; - $self->{isTitle} = 1; - } - - if ( ( $self->{isCover} == 0 ) && ( $tagname eq "a" ) && ( $attr->{href} =~ m/Couvertures\/.*\.[jJ][pP][gG]/ ) ) - { - $self->{curInfo}->{image} = 'http://www.bedetheque.com/' . $attr->{href}; + if ( ( $self->{isCover} == 0 ) && ( $tagname eq "a" ) && ( $attr->{href} =~ m/Couvertures\/.*\.[jJ][pP][gG]/ ) ) { + $self->{curInfo}->{image} = $attr->{href}; $self->{isCover} = 1; } - elsif ( ( $tagname eq "div") && ( $attr->{class} eq "titre" ) ) { - $self->{isVolume} = 1; - } - elsif ( ( $tagname eq "ul") && ( $attr->{class} eq "infos" ) ) { - $self->{isResultsTable} = 1; + elsif ( $tagname eq "label" ) { + $self->{isLabel} = 1; } - elsif ( ( $self->{isResultsTable} ) && ( $tagname eq "label" ) ) { - $self->{current_field} = ''; - $self->{openlabel} = 1; + elsif ( ( $tagname eq "ul" ) && ( $attr->{class} eq "tabs-album" ) && ( ! $self->{doneSerie} ) ) { + $self->{isTabs} = 1; } - elsif ( ( $tagname eq "div" ) && ( $attr->{class} eq "title" ) && ( !defined( $self->{curInfo}->{title} ) || ( $self->{curInfo}->{title} =~ /^$/ ) ) ) { + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "name" ) && ( ! $self->{doneTitle} ) ) { $self->{isTitle} = 1; } - elsif ( ( $tagname eq "span" ) && ( $attr->{class} eq "type" ) ) { + elsif ( ( $tagname eq "span" ) && ( $attr->{class} eq "titre-rubrique" ) && ( ! $self->{doneSerie} ) && ( $self->{isTabs} ) ) { $self->{isSerie} = 1; } - elsif ( $tagname eq "em" ) { + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "author" ) && ( ! $self->{doneWriter} ) ) { + $self->{isWriter} = 1; + } + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "illustrator" ) && ( ! $self->{doneIllustrator} ) ) { + $self->{isIllustrator} = 1; + } + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "illustrator" ) && ( ! $self->{doneColourist} ) && ( $self->{doneIllustrator} ) ) { + $self->{isColourist} = 1; + } + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "publisher" ) && ( ! $self->{donePublisher} ) ) { + $self->{isPublisher} = 1; + } + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "isbn" ) && ( ! $self->{doneISBN} ) ) { + $self->{isISBN} = 1; + } + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "numberOfPages" ) && ( ! $self->{doneNumberboards} ) ) { + $self->{isNumberboards} = 1; + } + elsif ( ( $tagname eq "span" ) && ( $attr->{itemprop} eq "description" ) && ( ! $self->{doneSynopsis} ) ) { $self->{isSynopsis} = 1; } - elsif ( ( $tagname eq "a" ) && ( $attr->{class} eq "titre eo" ) ) { - if ( $attr->{title} =~ m/.+\s-(\d+)-\s.+/ ) { - $self->{curInfo}->{volume} = $1; - } + elsif ( ( $tagname eq "ul" ) && ( $attr->{class} eq "liste-albums" ) ) { + $self->{doneColourist} = 1; # To avoid getting mess with illustrator } +# elsif ( ( $tagname eq "a" ) && ( $attr->{class} eq "titre eo" ) ) { +# if ( $attr->{title} =~ m/.+\s-(\d+)-\s.+/ ) { +# $self->{curInfo}->{volume} = $1; +# } +# } } } @@ -260,6 +308,17 @@ use GCPlugins::GCcomics::GCcomicsCommon; $self->{itemsList}[ $self->{itemIdx} ]->{series} = $origtext; $self->{isSerie} = 0; } + elsif ( $self->{isTitle} == 1) + { + $self->{itemsList}[ $self->{itemIdx} ]->{title} = $origtext; + $self->{isTitle} = 0; + } + elsif ( $self->{isNumber} == 1) + { + $self->{itemsList}[ $self->{itemIdx} ]->{volume} = $origtext; + $self->{itemsList}[ $self->{itemIdx} ]->{volume} =~ s/#//; + $self->{isNumber} = 0; + } else { if ($self->{isCollection} == 1) @@ -296,8 +355,8 @@ use GCPlugins::GCcomics::GCcomicsCommon; "Scénario :" => 'writer', "Dessin :" => 'illustrator', "Couleurs :" => 'colourist', - "Dépot légal :" => 'publishdate', - "Achevé impr. :" => 'printdate ', + "Dépot légal :" => 'publishdate', + "Achevé impr. :" => 'printdate ', "Estimation :" => 'cost', "Editeur :" => 'publisher', "Collection : " => 'collection', @@ -317,27 +376,86 @@ use GCPlugins::GCcomics::GCcomicsCommon; $self->{current_field} = ""; } } - elsif ( $self->{isVolume} ) - { - $self->{curInfo}->{volume} = $origtext; - $self->{isVolume} = 0 ; - } - - if ( $self->{isTitle} ) - { + elsif ( $self->{isTitle} ) { $self->{curInfo}->{title} = $origtext; + $self->{isTitle} = 0 ; + $self->{doneTitle} = 1 ; } elsif ( $self->{isSerie} ) { $self->{curInfo}->{series} = $origtext; $self->{curInfo}->{series} =~s/^\s+//; + $self->{isSerie} = 0 ; + $self->{doneSerie} = 1 ; + $self->{isTabs} = 0 ; + } + elsif ( $self->{isWriter} ) { + $self->{curInfo}->{writer} = $origtext; + $self->{isWriter} = 0 ; + $self->{doneWriter} = 1 ; + } + elsif ( $self->{isIllustrator} ) { + $self->{curInfo}->{illustrator} = $origtext; + $self->{isIllustrator} = 0 ; + $self->{doneIllustrator} = 1 ; + } + elsif ( $self->{isColourist} ) { + $self->{curInfo}->{colourist} = $origtext; + $self->{isColourist} = 0 ; + $self->{doneColourist} = 1 ; + } + elsif ( $self->{isPublisher} ) { + $self->{curInfo}->{publisher} = $origtext; + $self->{isPublisher} = 0 ; + $self->{donePublisher} = 1 ; } - elsif ( ( $self->{isSynopsis} ) && ( ( $origtext =~ /Résumé de l'album :/ ) || ( $origtext =~ /Résumé de la série :/ ) ) ) { - $self->{startSynopsis} = 1; + elsif ( $self->{isISBN} ) { + $self->{curInfo}->{isbn} = $origtext; + $self->{isISBN} = 0 ; + $self->{doneISBN} = 1 ; } - elsif ( ( $self->{isSynopsis} ) && ( $self->{startSynopsis} ) ) { - $self->{curInfo}->{synopsis} .= " ".$origtext; + elsif ( $self->{isNumberboards} ) { + $self->{curInfo}->{numberboards} = $origtext; + $self->{isNumberboards} = 0 ; + $self->{doneNumberboards} = 1 ; + } + elsif ( $self->{isVolume} ) { + $self->{curInfo}->{volume} = $origtext; + $self->{isVolume} = 0 ; + $self->{doneVolume} = 1 ; + } + elsif ( ( $self->{isLabel} ) && ( $origtext =~ m/Dépot légal/ ) && ( ! $self->{donePublishdate} ) ) { + $self->{isPublishdate} = 1 ; + $self->{isLabel} = 0 ; + } + elsif ( $self->{isPublishdate} ) { + $self->{curInfo}->{publishdate} = $origtext; + $self->{isPublishdate} = 0 ; + $self->{donePublishdate} = 1 ; + } + elsif ( ( $self->{isLabel} ) && ( $origtext =~ m/Estimation/ ) && ( ! $self->{doneCost} ) ) { + $self->{isCost} = 1 ; + $self->{isLabel} = 0 ; + } + elsif ( $self->{isCost} ) { + $self->{curInfo}->{cost} = $origtext; + $self->{isCost} = 0 ; + $self->{doneCost} = 1 ; + } + elsif ( ( $self->{isLabel} ) && ( $origtext =~ m/Format/ ) && ( ! $self->{doneFormat} ) ) { + $self->{isFormat} = 1 ; + $self->{isLabel} = 0 ; + } + elsif ( $self->{isFormat} ) { + $self->{curInfo}->{format} = $origtext; + $self->{isFormat} = 0 ; + $self->{doneFormat} = 1 ; + } + elsif ( $self->{isSynopsis} ) { + $self->{curInfo}->{synopsis} = $origtext; $self->{curInfo}->{synopsis} =~ s/^(\s)*//; $self->{curInfo}->{synopsis} =~ s/(\s)*$//; + $self->{isSynopsis} = 0 ; + $self->{doneSynopsis} = 1 ; } } } @@ -359,9 +477,9 @@ use GCPlugins::GCcomics::GCcomicsCommon; $self->{isCollection} = 0; } } else { - if ( ( $self->{inTable} ) && ( $tagname eq "a" ) ) { + if ( ( $self->{inTable} ) && ( $tagname eq "span" ) ) { $self->{isTitle} = 0; - } elsif ( ( $self->{inTable} ) && ( $tagname eq "td" ) ) { + } elsif ( ( $self->{inTable} ) && ( $tagname eq "li" ) ) { $self->{isVolume} = 0; } } @@ -373,18 +491,20 @@ use GCPlugins::GCcomics::GCcomicsCommon; $self->{isIssue} = 0; $self->{isResultsTable} = 0; } - elsif ( ( $self->{isResultsTable} ) && ( $tagname eq "label" ) ) { + elsif ( $tagname eq "label" ) { $self->{openlabel} = 0; + $self->{isLabel} = 0; } - elsif ( ( $self->{isTitle} ) && ( ( $tagname eq "div" ) || ( $tagname eq "h1" ) ) ) { - $self->{isTitle} = 0; - } - elsif ( ( $self->{isSerie} ) && ( $tagname eq "a" ) ) { - $self->{isSerie} = 0; - } - elsif ( ( $self->{isSynopsis} ) && ( $tagname eq "em" ) && ( !$self->{startSynopsis} ) ) { - $self->{isSynopsis} = 0; - $self->{startSynopsis} = 0; + elsif ( $tagname eq "span" ) { + $self->{isColourist} = 0; + $self->{isIllustrator} = 0; + $self->{isISBN} = 0; + $self->{isNumberboards} = 0; + $self->{isPublisher} = 0; + $self->{isSerie} = 0; + $self->{isSynopsis} = 0; + $self->{isTitle} = 0; + $self->{isWriter} = 0; } elsif ( ( $self->{isSynopsis} ) && ( ( $tagname eq "p" ) || ( $tagname eq "br" ) ) && ( $self->{startSynopsis} ) ) { $self->{isSynopsis} = 0; @@ -395,4 +515,4 @@ use GCPlugins::GCcomics::GCcomicsCommon; } } -1;
\ No newline at end of file +1; |