1 package WWW::EZTV::Show;
7 use WWW::EZTV::Episode;
9 # ABSTRACT: Show object
11 has title => is => 'ro', isa => 'Str', required => 1;
12 has name => is => 'ro', lazy => 1, default => \&_name;
13 has year => is => 'ro', lazy => 1, default => \&_year;
14 has url => is => 'ro', isa => 'Mojo::URL', required => 1;
15 has status => is => 'ro', isa => 'Str', required => 1;
16 has rating => is => 'ro', isa => 'Num', default => sub {0};
20 builder => '_build_episodes',
22 find_episode => 'first',
23 has_episodes => 'size',
28 $self->get_response($self->url)->dom->find('table.header_noborder tr[name="hover"]')->map(sub{
30 my $link = $tr->at('td:nth-child(2) a');
32 WWW::EZTV::Episode->new(
33 title => $link->attr('alt'),
34 url => $self->url->clone->path($link->attr('href')),
35 links => $tr->find('td:nth-child(3) a')->map(sub{
36 WWW::EZTV::Link->new( url => $_[0]->attr('href')
37 || $_[0]->attr('data-url')
38 || $_[0]->attr('data-bx-magnet') )
40 released => $tr->at('td:nth-child(4)')->all_text,
48 my $name = $self->title;
50 # Chasers War on Everything, The
51 if ( $name =~ /^(.+),\s*([^,]+)$/ ) { $name = "$2 $1" }
53 # Remove year: Castle (2009)
54 $name =~ s/\s* \(\d{4}\) \s*/ /x;
56 # Trim and cleanup spaces
57 $self->_cleanup_str($name);
62 if ( $self->title =~ /\((\d{4})\)/ ) {
69 $str =~ s/^\s+|\s+$//g;
96 Collection of episodes fetched for this show.
102 How many episodes has this show.
108 Find first L<WWW::EZTV::Episode> object matching the given criteria.
109 This method accept an anon function.