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