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