EZTV.pm

filter: Statementstmt 85.0% 17 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod n/a totaltotal 84.6% 22 / 26 CC 1 SCAR 1.8
CC
1
Cov
85%
__ANON__
2.0
_build_shows
1.2
BEGIN
1.0
CRAP 1.2
« EZTV/Show.pm ↑ Summary
1 package WWW::EZTV;
2 {
3 2 $WWW::EZTV::VERSION = '0.05';
4 }
5 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 with 'WWW::EZTV::UA';
7 2 ▶use WWW::EZTV::Show;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: EZTV scrapper
10  
11 2 ▶has url => ( is => 'ro', lazy => 1, default => sub { Mojo::URL->new('http://eztv.it/') } );
Subroutine __ANON__: called CC=1 SCAR=0.0
12 2 ▶has url_shows => ( is => 'ro', lazy => 1, default => sub { shift->url->clone->path('/showlist/') } );
Subroutine __ANON__: called CC=1 SCAR=0.0
13  
14 2 has shows =>
15 is => 'ro',
16 lazy => 1,
17 builder => '_build_shows',
18 handles => {
19 find_show => 'first',
20 has_shows => 'size',
21 };
22  
23 sub _build_shows {
24 2 ▶ my $self = shift;
Subroutine _build_shows: called CC=1 SCAR=2.0
25  
26 $self->get_response( $self->url_shows )->dom->find('table.forum_header_border tr[name="hover"]')->map(sub {
27 0 ▶ my $tr = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 0 my $link = $tr->at('td:nth-child(1) a');
29 0 WWW::EZTV::Show->new(
30 title => $link->all_text,
31 url => $self->url->clone->path($link->attr('href')),
32 status => lc($tr->at('td:nth-child(2)')->all_text),
33 rating => $tr->at('td:nth-child(3)')->all_text
34 );
35 2 });
36 }
37  
38 2 1;
39  
40  
41  
42  
43  
44  
45  
46  
47 __END__
48 =pod
49  
50 =encoding UTF-8
51  
52 =head1 NAME
53  
54 WWW::EZTV - EZTV scrapper
55  
56 =head1 VERSION
57  
58 version 0.05
59  
60 =head1 SYNOPSIS
61  
62 use WWW::EZTV;
63 use v5.10;
64  
65 my $eztv = WWW::EZTV->new;
66  
67 # Find one show
68 my $show = $eztv->find_show(sub{ $_->name =~ /Walking dead/i });
69  
70 # Find one episode
71 my $episode = $show->find_episode(sub{
72 $_->season == 3 &&
73 $_->number == 8 &&
74 $_->quality eq 'standard'
75 });
76  
77 # Get first torrent url for this episode
78 say $episode->find_link(sub{ $_->type eq 'torrent' })->url;
79  
80 =head1 ATTRIBUTES
81  
82 =head2 url
83  
84 EZTV URL.
85  
86 =head2 url_shows
87  
88 EZTV shows URL.
89  
90 =head2 shows
91  
92 L<Mojo::Collection> of L<WWW::EZTV::Show> objects.
93  
94 =head2 has_shows
95  
96 How many shows exists.
97  
98 =head1 METHODS
99  
100 =head2 find_show
101  
102 Find first L<WWW::EZTV::Show> object matching the given criteria.
103 This method accept an anon function.
104  
105 =head1 BUGS
106  
107 This is an early release, so probable there are plenty of bugs around.
108 If you found one, please report it on RT or at the github repo:
109  
110 L<https://github.com/diegok/www-eztv>
111  
112 Pull requests are also very welcomed, but please include tests demostrating
113 what you've fixed.
114  
115 =head1 AUTHOR
116  
117 Diego Kuperman <diego@freekeylabs.com>
118  
119 =head1 COPYRIGHT AND LICENSE
120  
121 This software is copyright (c) 2012 by Diego Kuperman.
122  
123 This is free software; you can redistribute it and/or modify it under
124 the same terms as the Perl 5 programming language system itself.
125  
126 =cut
127  
« EZTV/Show.pm ↑ Summary