X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fwww-eztv.git;a=blobdiff_plain;f=lib%2FWWW%2FEZTV%2FLink.pm;h=12b1a815aa7010974a56f2b34d631fbd61325105;hp=065544b60880d043b78073b5043fd4ca6779253b;hb=17802f254b869064461d14e6a2fb015b59246a46;hpb=e3142e3a240afca9f0ac4cf9d4a7c4eb45c701e2 diff --git a/lib/WWW/EZTV/Link.pm b/lib/WWW/EZTV/Link.pm index 065544b..12b1a81 100644 --- a/lib/WWW/EZTV/Link.pm +++ b/lib/WWW/EZTV/Link.pm @@ -2,8 +2,41 @@ package WWW::EZTV::Link; use Moose; with 'WWW::EZTV::UA'; -# ABSTRACT: EZTV episode link +# ABSTRACT: Episode link +=attr url + +Link address + +=cut has url => is => 'ro', isa => 'Str', required => 1; + +=attr type + +Link type. It can be: + + - magnet + - torrent + - torrent-redirect (URL that do html/js redirect to a torrent file) + - direct + +=cut +has type => is => 'ro', lazy => 1, builder => '_guess_type'; + +sub _guess_type { + my $self = shift; + + if ( $self->url =~ /magnet:/ ) { + return 'magnet'; + } + elsif ( $self->url =~ /\.torrent$/ ) { + return 'torrent'; + } + elsif ( $self->url =~ /bt-chat.com/ ) { + return 'torrent-redirect'; + } + + return 'direct'; +} 1;