Retrive episode links by type and some more docs
[cascardo/www-eztv.git] / lib / WWW / EZTV / Link.pm
index 065544b..12b1a81 100644 (file)
@@ -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;