1 package WWW::EZTV::Show;
5 use WWW::EZTV::Episode;
7 # ABSTRACT: Show object
9 has title => is => 'ro', isa => 'Str', required => 1;
10 has name => is => 'ro', lazy => 1, default => \&_name;
11 has year => is => 'ro', lazy => 1, default => \&_year;
12 has url => is => 'ro', isa => 'Mojo::URL', required => 1;
13 has status => is => 'ro', isa => 'Str', required => 1;
14 has rating => is => 'ro', isa => 'Int', default => sub {0};
18 builder => '_build_episodes',
20 find_episode => 'first',
21 has_episodes => 'size',
26 $self->get_response($self->url)->dom->find('table.forum_header_noborder tr[name="hover"]')->map(sub{
28 my $a = $tr->at('td:nth-child(2) a');
30 WWW::EZTV::Episode->new(
31 title => $a->attrs('title'),
32 url => $self->url->clone->path($a->attrs('href')),
33 links => $tr->find('td:nth-child(3) a')->map(sub{
34 WWW::EZTV::Link->new( url => shift->attrs('href') )
36 released => $tr->at('td:nth-child(4)')->all_text,
44 my $name = $self->title;
46 # Chasers War on Everything, The
47 if ( $name =~ /^(.+),\s*([^,]+)$/ ) { $name = "$2 $1" }
49 # Remove year: Castle (2009)
50 $name =~ s/\s* \(\d{4}\) \s*/ /x;
52 # Trim and cleanup spaces
53 $self->_cleanup_str($name);
58 if ( $self->title =~ /\((\d{4})\)/ ) {
65 $str =~ s/^\s+|\s+$//g;
92 Collection of episodes fetched for this show.
98 How many episodes has this show.
104 Find first L<WWW::EZTV::Episode> object matching the given criteria.
105 This method accept an anon function.