Subject: | Episodeof doesnt work |
Hi,
I started to work with TV Series, and I found out, episodeof() is not working, so I did quick
and dirty patch - in attachment.
code:
sub episodeof {
my CLASS_NAME $self = shift;
my $forced = shift || 0;
return if !$self->kind or $self->kind ne "episode";
if($forced) {
my($episodeof, $title, $year, $episode, $season, $id);
my($parser) = $self->_parser(FORCED);
while(my $tag = $parser->get_tag('span')) {
($episode, $season) = ($1, $2) if $tag->[1]->{class} && $tag->[1]->{class}
eq 'tv-series-smaller' && $parser->get_text('span') =~ m/\(#(\d+)\.(\d+)\)/;
}
#start again
$parser = $self->_parser(FORCED);
while($parser->get_tag('h2')) {
my $tag = $parser->get_tag('a');
if($tag->[1]->{href} =~ /title\/tt(\d+)\//) {
$id = $1;
$title = $parser->get_trimmed_text;
}
}
#start again
$parser = $self->_parser(FORCED);
while($parser->get_tag(MAIN_TAG)) {
last if $parser->get_text =~ /^Original Air Date/i;
}
$parser->get_tag();
($year) = ($1) if $parser->get_text =~ /(\d{4})/;
push @{ $self->{_episodeof} }, {title => $title, year => $year, id => $id, season =>
$season, episode => $episode};
}
return $self->{_episodeof};
}
Subject: | patch.diff |
661,663c661,663
< while(my $tag = $parser->get_tag('span')) {
< ($episode, $season) = ($1, $2) if $tag->[1]->{class} && $tag->[1]->{class} eq 'tv-series-smaller' && $parser->get_text('span') =~ m/\(#(\d+)\.(\d+)\)/;
< }
---
> while($parser->get_tag(MAIN_TAG)) {
> last if $parser->get_text =~ /^TV Series/i;
> }
665,672c665,668
< #start again
< $parser = $self->_parser(FORCED);
< while($parser->get_tag('h2')) {
< my $tag = $parser->get_tag('a');
< if($tag->[1]->{href} =~ /title\/tt(\d+)\//) {
< $id = $1;
< $title = $parser->get_trimmed_text;
< }
---
> while(my $tag = $parser->get_tag('a')) {
> ($title, $year) = ($1, $2) if $parser->get_text =~ m!(.*?)\s+\(([\d\?]{4}).*?\)!;
> last unless $tag->[1]{href} =~ /title/i;
> ($id) = $tag->[1]{href} =~ /(\d+)/;
680,681c676,678
< $parser->get_tag();
< ($year) = ($1) if $parser->get_text =~ /(\d{4})/;
---
>
> $parser->get_token;
> ($season, $episode) = $parser->get_text =~ /\(Season\s+(\d+),\s+Episode\s+(\d+)/;