summaryrefslogtreecommitdiff
path: root/lib/gcstar/GCPlugins/GCTVseries
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gcstar/GCPlugins/GCTVseries')
-rw-r--r--lib/gcstar/GCPlugins/GCTVseries/GCTVseriesCommon.pm53
-rw-r--r--lib/gcstar/GCPlugins/GCTVseries/GCThemoviedb.pm340
-rw-r--r--lib/gcstar/GCPlugins/GCTVseries/GCTvdb.pm466
-rw-r--r--lib/gcstar/GCPlugins/GCTVseries/GCTvdbES.pm61
-rw-r--r--lib/gcstar/GCPlugins/GCTVseries/GCTvdbFR.pm61
-rw-r--r--lib/gcstar/GCPlugins/GCTVseries/GCTvdbIT.pm60
6 files changed, 1041 insertions, 0 deletions
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 =~ /^<!DOCTYPE html/;
+ my $xml;
+ my $xs = XML::Simple->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 =~ /^<!DOCTYPE html/;
+ my $xml;
+ my $xs = XML::Simple->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;