Rarbg-torrentapi

Perl Module to interact with https://torrentapi.org
git clone https://git.e1e0.net/Rarbg-torrentapi.git
Log | Files | Refs | README | LICENSE

commit ecc57376ff27aa66556d994ed898aec150628fc4
parent 2fc4ec956fabcac1faa49457ea32aa5dd006cfad
Author: Paco Esteban <paco@onna.be>
Date:   Thu, 21 Nov 2019 20:36:42 +0100

fix: title can be null too.

Diffstat:
Mlib/Rarbg/torrentapi/Res.pm | 13++++++++-----
Mt/res.t | 21+++++++++++++++++++++
2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/lib/Rarbg/torrentapi/Res.pm b/lib/Rarbg/torrentapi/Res.pm @@ -2,14 +2,19 @@ package Rarbg::torrentapi::Res; use strict; use 5.008_005; -our $VERSION = 'v0.1.1'; +our $VERSION = 'v0.2.0'; use Moose; -has [qw( category download info_page pubdate title)] => ( +has [qw( category download info_page pubdate )] => ( is => 'ro', isa => 'Str' ); +has title => ( + is => 'ro', + isa => 'Maybe[Str]' +); + has [qw( seeders leechers ranked size)] => ( is => 'ro', isa => 'Int' @@ -17,9 +22,7 @@ has [qw( seeders leechers ranked size)] => ( has episode_info => ( is => 'ro', - # sometimes we get undef, that breaks validation ... - # isa => 'HashRef', - # default => sub { {} } + isa => 'Maybe[HashRef]' ); no Moose; diff --git a/t/res.t b/t/res.t @@ -46,4 +46,25 @@ is( isa_ok( $res->episode_info, 'HASH' ); is( $res->episode_info->{imdb}, 'tt2930604', 'Episode info hash test' ); +# sometimes episode_info and title can be null +$res_msg = <<RES; + { + "title": null, + "category": "TV HD Episodes", + "download": "magnet-link-here", + "seeders": 10, + "leechers": 0, + "size": 1061306416, + "pubdate": "2015-07-31 14:01:18 +0000", + "episode_info": null, + "ranked": 0, + "info_page": "https://torrentapi.org/redirect_to_info.php?token=tok&p=foo" + } +RES +$res_res = decode_json($res_msg); +$res = Rarbg::torrentapi::Res->new($res_res); + +is( $res->title, undef, 'Title info undef' ); +is( $res->episode_info, undef, 'Episode info undef' ); + done_testing;