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