From: diegok Date: Sat, 18 Apr 2015 16:25:43 +0000 (+0200) Subject: Updated domain and fixed DOM parsing X-Git-Tag: v0.06~1 X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fwww-eztv.git;a=commitdiff_plain;h=0c136ed3095264fd92280b8ce840fcbc719be34a Updated domain and fixed DOM parsing --- diff --git a/Changes b/Changes index 68d3ec0..4cd86cd 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,10 @@ {{$NEXT}} + - Changed host to eztv.ch + - Updated DOM parsing expresions + +0.05 2013-12-29 13:14:23 Europe/Madrid + - Force upgrade of Mojolicious to 4.X (no auto version from UA) - Small error and tests refactor diff --git a/lib/WWW/EZTV.pm b/lib/WWW/EZTV.pm index f45c083..5953bbb 100644 --- a/lib/WWW/EZTV.pm +++ b/lib/WWW/EZTV.pm @@ -5,10 +5,10 @@ use WWW::EZTV::Show; # ABSTRACT: EZTV scrapper -has url => ( is => 'ro', lazy => 1, default => sub { Mojo::URL->new('http://eztv.it/') } ); +has url => ( is => 'ro', lazy => 1, default => sub { Mojo::URL->new('https://eztv.ch/') } ); has url_shows => ( is => 'ro', lazy => 1, default => sub { shift->url->clone->path('/showlist/') } ); -has shows => +has shows => is => 'ro', lazy => 1, builder => '_build_shows', @@ -20,14 +20,14 @@ has shows => sub _build_shows { my $self = shift; - $self->get_response( $self->url_shows )->dom->find('table.forum_header_border tr[name="hover"]')->map(sub { + $self->get_response( $self->url_shows )->dom->find('table.header_brd tr[name="hover"]')->map(sub { my $tr = shift; - my $link = $tr->at('td:nth-child(1) a'); + my $link = $tr->at('td:nth-child(2) a'); WWW::EZTV::Show->new( title => $link->all_text, url => $self->url->clone->path($link->attr('href')), - status => lc($tr->at('td:nth-child(2)')->all_text), - rating => $tr->at('td:nth-child(3)')->all_text + status => lc($tr->at('td:nth-child(3)')->all_text), + rating => $tr->at('td:nth-child(4)')->text + 0 ); }); } diff --git a/lib/WWW/EZTV/Episode.pm b/lib/WWW/EZTV/Episode.pm index fa2da23..db8cfb7 100644 --- a/lib/WWW/EZTV/Episode.pm +++ b/lib/WWW/EZTV/Episode.pm @@ -50,19 +50,19 @@ sub _parse { ((?\d+p)\s+)? (?.*?) ) - (?: + (?: \s+ - \((? - \d+ + \((? + \d+ [^\)]+ - )\) + )\) )? \s*$/xi; return { name => $+{name} || $title, chapter => $+{chapter}, - number => $+{number} +0, + number => ($+{number}||0) +0, season => ($+{season}||0) +0, total => ($+{total}||0) +0, version => $+{version} || '', diff --git a/lib/WWW/EZTV/Show.pm b/lib/WWW/EZTV/Show.pm index f9c994e..3114724 100644 --- a/lib/WWW/EZTV/Show.pm +++ b/lib/WWW/EZTV/Show.pm @@ -1,5 +1,6 @@ package WWW::EZTV::Show; use Moose; +use v5.10; with 'WWW::EZTV::UA'; use WWW::EZTV::Link; use WWW::EZTV::Episode; @@ -11,8 +12,8 @@ has name => is => 'ro', lazy => 1, default => \&_name; has year => is => 'ro', lazy => 1, default => \&_year; has url => is => 'ro', isa => 'Mojo::URL', required => 1; has status => is => 'ro', isa => 'Str', required => 1; -has rating => is => 'ro', isa => 'Int', default => sub {0}; -has episodes => +has rating => is => 'ro', isa => 'Num', default => sub {0}; +has episodes => is => 'ro', lazy => 1, builder => '_build_episodes', @@ -23,15 +24,17 @@ has episodes => sub _build_episodes { my $self = shift; - $self->get_response($self->url)->dom->find('table.forum_header_noborder tr[name="hover"]')->map(sub{ + $self->get_response($self->url)->dom->find('table.header_noborder tr[name="hover"]')->map(sub{ my $tr = shift; - my $a = $tr->at('td:nth-child(2) a'); + my $link = $tr->at('td:nth-child(2) a'); WWW::EZTV::Episode->new( - title => $a->attr('title'), - url => $self->url->clone->path($a->attr('href')), + title => $link->attr('alt'), + url => $self->url->clone->path($link->attr('href')), links => $tr->find('td:nth-child(3) a')->map(sub{ - WWW::EZTV::Link->new( url => shift->attr('href') ) + WWW::EZTV::Link->new( url => $_[0]->attr('href') + || $_[0]->attr('data-url') + || $_[0]->attr('data-bx-magnet') ) }), released => $tr->at('td:nth-child(4)')->all_text, show => $self