Retrive episode links by type and some more docs
[cascardo/www-eztv.git] / lib / WWW / EZTV / Link.pm
1 package WWW::EZTV::Link;
2 use Moose;
3 with 'WWW::EZTV::UA';
4
5 # ABSTRACT: Episode link
6
7 =attr url
8
9 Link address
10
11 =cut
12 has url => is => 'ro', isa => 'Str', required => 1;
13
14
15 =attr type
16
17 Link type. It can be:
18
19  - magnet
20  - torrent
21  - torrent-redirect (URL that do html/js redirect to a torrent file)
22  - direct
23
24 =cut
25 has type => is => 'ro', lazy => 1, builder => '_guess_type';
26
27 sub _guess_type {
28     my $self = shift;
29
30     if ( $self->url =~ /magnet:/ ) {
31         return 'magnet';
32     }
33     elsif ( $self->url =~ /\.torrent$/ ) {
34         return 'torrent';
35     }
36     elsif ( $self->url =~ /bt-chat.com/ ) {
37         return 'torrent-redirect';
38     }
39
40     return 'direct';
41 }
42 1;