| 1 | package WWW::TVMaze; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 2 | ▶ | use 5.006; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 2 | ▶ | use Mouse; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 2 | ▶ | use LWP::UserAgent; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 2 | ▶ | use JSON::XS; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 2 | ▶ | use DateTime; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 2 | ▶ | use Params::Validate qw(:all); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | WWW::TVMaze - Interface to TVMaze API | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | =head1 VERSION | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | Version 0.05 | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 2 | our $VERSION = '0.05'; | |||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 2 | has '_endpoint' => ( | |||||||||||||||||||
| 25 | isa => 'Str', | ||||||||||||||||||||
| 26 | is =>'ro', | ||||||||||||||||||||
| 27 | default => 'http://api.tvmaze.com' | ||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 2 | has 'error' => ( | |||||||||||||||||||
| 31 | isa => 'Maybe[Str]', | ||||||||||||||||||||
| 32 | is => 'rw', | ||||||||||||||||||||
| 33 | default => undef, | ||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 2 | has 'http_status' => ( | |||||||||||||||||||
| 37 | isa => 'Maybe[Str]', | ||||||||||||||||||||
| 38 | is =>'rw', | ||||||||||||||||||||
| 39 | default => undef, | ||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | =head1 SYNOPSIS | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | This module allows you to user TVMaze API (L<http://www.tvmaze.com/api>) | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | use WWW::TVMaze; | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | my $tv_maze = WWW::TVMaze->new(); | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | my $shows = $tv_maze->show_search('Arrow'); | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | =head1 METHODS | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | =head2 shows | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | my $show = $tv_maze->shows($id); | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | Returns a show by its ID | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | =head2 show_search | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | my $shows = $tv_maze->show_search($search_keyword); | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | Returns a list of shows that match your search keyword | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | =head2 show_single_search | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | my $show = $tv_maze->show_single_search($search_keyword); | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | Returns a single show that match your search keyword | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | =head2 show_lookup | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | my $show = $tv_maze->show_lookup( $id, $id_type ); # $id_type can be 'tvrage' or 'thetvdb' or 'imdb' | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | Returns a show by its TVRage ID or by its THETVDB ID | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | =head2 show_seasons | ||||||||||||||||||||
| 83 | my $seasons = $tv_maze->show_seasons($show_id); | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | Returns all seasons of a show. Each season contains the number; the name (available for shows that give a title to each season, episode order (the total amount of episodes that will be released in the season); premiere and end date; network or web channel that specific season premiered on; and its image and summary. | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | =head2 show_episode_list | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | my $ep_list = $tv_maze->show_episode_list($show_id, $include_specials); # $include_specials can be 0 or 1 and is optional; | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | Returns a complete list of episodes for a given show. by defauls specials are not included | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | =head2 show_cast | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | my $cast = $tv_maze->show_cast($show_id); | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | Returns a list of main cast for a given show | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | =head2 show_akas | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | my $akas = $tv_maze->show_akas($show_id); | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | Returns a list of AKA's for a show | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | =head2 show_index | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | my $index = $tv_maze->show_index($page); ## $page is optional, pagination starts on page 0 | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | Returns all TV Maze shows , 250 results per page | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | =head2 episode_by_number | ||||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | my $ep = $tv_maze->episode_by_number($show_id, $season, $ep_number); | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | Returns a show episode | ||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | =head2 episodes_by_date | ||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | my $eps = $tv_maze->episodes_by_date($show_id, $date); | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | Returns a list of episodes for a given show aired on a given date | ||||||||||||||||||||
| 122 | |||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | =head2 schedule | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | my $schedule = $tv_maze->schedule($country_code, $date); # $country_code is an ISO 3166-1 code of the country, $date an ISO 8601 formatted date, both parameters are optional, defaults to 'US' and current day | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | Returns a complete list of episodes for the date and country provided | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | =head2 full_schedule | ||||||||||||||||||||
| 132 | |||||||||||||||||||||
| 133 | my $schedule = $tv_maze->full_schedule(); | ||||||||||||||||||||
| 134 | |||||||||||||||||||||
| 135 | Returns a list of all future episodes known to TVmaze | ||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | =head2 people_search | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | my $people = $tv_maze->people_search($search_keyword); | ||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | Returns a list of persons that match your search keyword | ||||||||||||||||||||
| 143 | |||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | =head2 people | ||||||||||||||||||||
| 146 | |||||||||||||||||||||
| 147 | my $people = $tv_maze->people($id); | ||||||||||||||||||||
| 148 | |||||||||||||||||||||
| 149 | Returns a person by its ID | ||||||||||||||||||||
| 150 | |||||||||||||||||||||
| 151 | |||||||||||||||||||||
| 152 | =head2 person_cast_credits | ||||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | my $person_credits = $tv_maze->person_cast_credits($person_id, $emded_show); # $embed_show is optional, can be 1 or 0; | ||||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | Returns alll show-level cast credits for a person | ||||||||||||||||||||
| 157 | |||||||||||||||||||||
| 158 | =head2 person_crew_credits | ||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | my $person_credits = $tv_maze->person_crew_credits($person_id, $emded_show); # $embed_show is optional, can be 1 or 0; | ||||||||||||||||||||
| 161 | |||||||||||||||||||||
| 162 | Returns alll show-level crew credits for a person | ||||||||||||||||||||
| 163 | |||||||||||||||||||||
| 164 | =head2 updates | ||||||||||||||||||||
| 165 | |||||||||||||||||||||
| 166 | my $updates = $tv_maze->updates(); | ||||||||||||||||||||
| 167 | |||||||||||||||||||||
| 168 | Returns a list of all the shows in the database with a timestamp of when they were last updated | ||||||||||||||||||||
| 169 | |||||||||||||||||||||
| 170 | |||||||||||||||||||||
| 171 | =head2 error | ||||||||||||||||||||
| 172 | |||||||||||||||||||||
| 173 | my $error = $tv_maze->error(); | ||||||||||||||||||||
| 174 | |||||||||||||||||||||
| 175 | Returns the last error | ||||||||||||||||||||
| 176 | |||||||||||||||||||||
| 177 | =head2 http_status | ||||||||||||||||||||
| 178 | |||||||||||||||||||||
| 179 | my $http_status = $tv_maze->http_status(); | ||||||||||||||||||||
| 180 | |||||||||||||||||||||
| 181 | Returns the last HTTP status received | ||||||||||||||||||||
| 182 | =cut | ||||||||||||||||||||
| 183 | |||||||||||||||||||||
| 184 | |||||||||||||||||||||
| 185 | sub shows { | ||||||||||||||||||||
| 186 | 0 | ▶ | my ($self, $id) = @_; | ||||||||||||||||||
|
Subroutine
shows: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 187 | 0 | shift @_; | |||||||||||||||||||
| 188 | 0 | validate_pos(@_, { type => SCALAR } ); | |||||||||||||||||||
| 189 | |||||||||||||||||||||
| 190 | 0 | return $self->_request('shows/' . $id); | |||||||||||||||||||
| 191 | } | ||||||||||||||||||||
| 192 | |||||||||||||||||||||
| 193 | sub show_search { | ||||||||||||||||||||
| 194 | 0 | ▶ | my ($self, $search) = @_; | ||||||||||||||||||
|
Subroutine
show_search: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 195 | 0 | shift @_; | |||||||||||||||||||
| 196 | 0 | validate_pos(@_ , { type => SCALAR } ); | |||||||||||||||||||
| 197 | 0 | return $self->_request('search/shows?q=' . $search); | |||||||||||||||||||
| 198 | } | ||||||||||||||||||||
| 199 | |||||||||||||||||||||
| 200 | |||||||||||||||||||||
| 201 | sub show_single_search { | ||||||||||||||||||||
| 202 | 0 | ▶ | my ($self, $search) = @_; | ||||||||||||||||||
|
Subroutine
show_single_search: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 203 | 0 | shift @_; | |||||||||||||||||||
| 204 | 0 | validate_pos(@_ , { type => SCALAR } ); | |||||||||||||||||||
| 205 | 0 | return $self->_request('singlesearch/shows?q=' . $search); | |||||||||||||||||||
| 206 | } | ||||||||||||||||||||
| 207 | |||||||||||||||||||||
| 208 | |||||||||||||||||||||
| 209 | sub show_lookup { | ||||||||||||||||||||
| 210 | 0 | ▶ | my ($self, $id, $id_type) = @_; | ||||||||||||||||||
|
Subroutine
show_lookup: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 211 | 0 | shift @_; | |||||||||||||||||||
| 212 | 0 | validate_pos (@_ , { type => SCALAR }, { type => SCALAR, regex => qr/^tvrage$|^thetvdb$|^imdb$/ } ); | |||||||||||||||||||
| 213 | 0 | return $self->_request('lookup/shows?' . $id_type .'=' . $id); | |||||||||||||||||||
| 214 | } | ||||||||||||||||||||
| 215 | |||||||||||||||||||||
| 216 | |||||||||||||||||||||
| 217 | |||||||||||||||||||||
| 218 | sub people_search { | ||||||||||||||||||||
| 219 | 0 | ▶ | my ($self, $search) = @_; | ||||||||||||||||||
|
Subroutine
people_search: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 220 | 0 | shift @_; | |||||||||||||||||||
| 221 | 0 | validate_pos(@_ , { type => SCALAR } ); | |||||||||||||||||||
| 222 | 0 | return $self->_request('search/people?q=' . $search); | |||||||||||||||||||
| 223 | } | ||||||||||||||||||||
| 224 | |||||||||||||||||||||
| 225 | |||||||||||||||||||||
| 226 | |||||||||||||||||||||
| 227 | sub schedule { | ||||||||||||||||||||
| 228 | 0 | ▶ | my ($self, $country_code, $date) = @_; | ||||||||||||||||||
|
Subroutine
schedule: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 229 | 0 | shift @_; | |||||||||||||||||||
| 230 | 0 | validate_pos(@_ , { type => SCALAR, optional => 1 , regex => qr/^\w{2}$/}, { type => SCALAR , optional => 1 , regex => qw/\d{4}-\d{2}-\d{2}$/ } ); | |||||||||||||||||||
| 231 | 0 | ▶ | $country_code ||= 'US'; | ||||||||||||||||||
|
Condition0%0/2
$country_code ||= "US"
MC/DC0%0/1
$country_code ||= "US"
$country_code
Truth table0%0/2
A
A= $country_code
| |||||||||||||||||||||
| 232 | 0 | ▶ | $date ||= DateTime->now->ymd('-'); | ||||||||||||||||||
|
Condition0%0/3
$date ||= "DateTime"->now->ymd("-")
MC/DC0%0/2
$date ||= "DateTime"->now->ymd("-")
$date
"DateTime"->now->ymd("-")
Truth table0%0/3
A ||= B
A= $dateB= "DateTime"->now->ymd("-")
| |||||||||||||||||||||
| 233 | 0 | return $self->_request('schedule?country=' . $country_code . '&date=' .$date); | |||||||||||||||||||
| 234 | } | ||||||||||||||||||||
| 235 | |||||||||||||||||||||
| 236 | |||||||||||||||||||||
| 237 | sub full_schedule { | ||||||||||||||||||||
| 238 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
full_schedule: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 239 | 0 | return $self->_request('schedule/full'); | |||||||||||||||||||
| 240 | } | ||||||||||||||||||||
| 241 | |||||||||||||||||||||
| 242 | |||||||||||||||||||||
| 243 | sub show_seasons { | ||||||||||||||||||||
| 244 | 0 | ▶ | my ($self, $tvmaze_id) = @_; | ||||||||||||||||||
|
Subroutine
show_seasons: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 245 | 0 | shift @_; | |||||||||||||||||||
| 246 | 0 | validate_pos(@_, { type => SCALAR }); | |||||||||||||||||||
| 247 | 0 | return $self->_request('shows/' . $tvmaze_id .'/seasons'); | |||||||||||||||||||
| 248 | } | ||||||||||||||||||||
| 249 | |||||||||||||||||||||
| 250 | sub show_episode_list { | ||||||||||||||||||||
| 251 | 0 | ▶ | my ($self, $tvmaze_id, $specials) = @_; | ||||||||||||||||||
|
Subroutine
show_episode_list: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 252 | 0 | shift @_; | |||||||||||||||||||
| 253 | 0 | validate_pos(@_, { type => SCALAR }, { type => BOOLEAN , optional => 1 } ); | |||||||||||||||||||
| 254 | 0 | ▶ | $specials ||= 0; | ||||||||||||||||||
|
Condition0%0/2
$specials ||= 0
MC/DC0%0/1
$specials ||= 0
$specials
Truth table0%0/2
A
A= $specials
| |||||||||||||||||||||
| 255 | 0 | return $self->_request('shows/' . $tvmaze_id .'/episodes?specials=' . $specials); | |||||||||||||||||||
| 256 | } | ||||||||||||||||||||
| 257 | |||||||||||||||||||||
| 258 | |||||||||||||||||||||
| 259 | sub episode_by_number { | ||||||||||||||||||||
| 260 | 0 | ▶ | my ($self, $tvmaze_id, $season, $number) = @_; | ||||||||||||||||||
|
Subroutine
episode_by_number: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 261 | 0 | shift @_; | |||||||||||||||||||
| 262 | 0 | validate_pos(@_, { type => SCALAR }, { type => SCALAR , optional => 1, regex => qr/^\d+$/ }, { type => SCALAR , optional => 1, regex => qr/^\d+$/ } ); | |||||||||||||||||||
| 263 | 0 | $season |= 1; | |||||||||||||||||||
| 264 | 0 | $number |= 1; | |||||||||||||||||||
| 265 | 0 | return $self->_request('shows/' . $tvmaze_id . '/episodebynumber?season=' . $season .'&number=' . $number); | |||||||||||||||||||
| 266 | } | ||||||||||||||||||||
| 267 | |||||||||||||||||||||
| 268 | |||||||||||||||||||||
| 269 | sub episodes_by_date { | ||||||||||||||||||||
| 270 | 0 | ▶ | my ($self, $tvmaze_id, $date) = @_; | ||||||||||||||||||
|
Subroutine
episodes_by_date: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 271 | |||||||||||||||||||||
| 272 | 0 | ▶ | if ($date !~/^\d{4}-\d{2}-\d{2}$/) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 273 | 0 | $self->error('invalid date'); | |||||||||||||||||||
| 274 | 0 | return undef; | |||||||||||||||||||
| 275 | } | ||||||||||||||||||||
| 276 | 0 | return $self->_request('shows/' . $tvmaze_id .'/episodesbydate?date=' . $date); | |||||||||||||||||||
| 277 | } | ||||||||||||||||||||
| 278 | |||||||||||||||||||||
| 279 | |||||||||||||||||||||
| 280 | |||||||||||||||||||||
| 281 | |||||||||||||||||||||
| 282 | sub show_cast { | ||||||||||||||||||||
| 283 | 0 | ▶ | my ($self, $tvmaze_id) = @_; | ||||||||||||||||||
|
Subroutine
show_cast: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 284 | 0 | return $self->_request('shows/' . $tvmaze_id .'/cast'); | |||||||||||||||||||
| 285 | } | ||||||||||||||||||||
| 286 | |||||||||||||||||||||
| 287 | |||||||||||||||||||||
| 288 | sub show_akas { | ||||||||||||||||||||
| 289 | 0 | ▶ | my ($self, $tvmaze_id) = @_; | ||||||||||||||||||
|
Subroutine
show_akas: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 290 | 0 | return $self->_request('shows/' . $tvmaze_id .'/akas'); | |||||||||||||||||||
| 291 | } | ||||||||||||||||||||
| 292 | |||||||||||||||||||||
| 293 | |||||||||||||||||||||
| 294 | |||||||||||||||||||||
| 295 | |||||||||||||||||||||
| 296 | sub show_index { | ||||||||||||||||||||
| 297 | 0 | ▶ | my ($self, $page) = @_; | ||||||||||||||||||
|
Subroutine
show_index: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 298 | 0 | ▶ | $page ||= 0; | ||||||||||||||||||
|
Condition0%0/2
$page ||= 0
MC/DC0%0/1
$page ||= 0
$page
Truth table0%0/2
A
A= $page
| |||||||||||||||||||||
| 299 | 0 | return $self->_request('shows?page=' . $page); | |||||||||||||||||||
| 300 | } | ||||||||||||||||||||
| 301 | |||||||||||||||||||||
| 302 | |||||||||||||||||||||
| 303 | |||||||||||||||||||||
| 304 | sub people { | ||||||||||||||||||||
| 305 | 0 | ▶ | my ($self, $tvmaze_id) = @_; | ||||||||||||||||||
|
Subroutine
people: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 306 | 0 | return $self->_request('people/' . $tvmaze_id); | |||||||||||||||||||
| 307 | } | ||||||||||||||||||||
| 308 | |||||||||||||||||||||
| 309 | |||||||||||||||||||||
| 310 | |||||||||||||||||||||
| 311 | sub person_cast_credits { | ||||||||||||||||||||
| 312 | 0 | ▶ | my ($self, $tvmaze_id, $embed) = @_; | ||||||||||||||||||
|
Subroutine
person_cast_credits: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 313 | 0 | ▶ | return $self->_request('people/' . $tvmaze_id .'/castcredits' . ( $embed ? '?embed=show' : '' )); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 314 | } | ||||||||||||||||||||
| 315 | |||||||||||||||||||||
| 316 | |||||||||||||||||||||
| 317 | sub person_crew_credits { | ||||||||||||||||||||
| 318 | 0 | ▶ | my ($self, $tvmaze_id, $embed) = @_; | ||||||||||||||||||
|
Subroutine
person_crew_credits: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 319 | 0 | ▶ | return $self->_request('people/' . $tvmaze_id .'/crewcredits' . ( $embed ? '?embed=show' : '' )); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 320 | } | ||||||||||||||||||||
| 321 | |||||||||||||||||||||
| 322 | |||||||||||||||||||||
| 323 | |||||||||||||||||||||
| 324 | sub updates { | ||||||||||||||||||||
| 325 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
updates: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 326 | 0 | return $self->_request('updates/shows'); | |||||||||||||||||||
| 327 | } | ||||||||||||||||||||
| 328 | |||||||||||||||||||||
| 329 | |||||||||||||||||||||
| 330 | |||||||||||||||||||||
| 331 | |||||||||||||||||||||
| 332 | |||||||||||||||||||||
| 333 | sub _request { | ||||||||||||||||||||
| 334 | 0 | ▶ | my ($self, $uri) = @_; | ||||||||||||||||||
|
Subroutine
_request: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 335 | |||||||||||||||||||||
| 336 | 0 | my $ua = LWP::UserAgent->new(); | |||||||||||||||||||
| 337 | 0 | my $url = $self->_endpoint .'/' . $uri; | |||||||||||||||||||
| 338 | 0 | my $response = $ua->get($url); | |||||||||||||||||||
| 339 | |||||||||||||||||||||
| 340 | 0 | $self->http_status($response->code); | |||||||||||||||||||
| 341 | |||||||||||||||||||||
| 342 | 0 | ▶ | if (!$response->is_success) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 343 | 0 | $self->error('request error'); | |||||||||||||||||||
| 344 | 0 | return {}; | |||||||||||||||||||
| 345 | } | ||||||||||||||||||||
| 346 | |||||||||||||||||||||
| 347 | 0 | my $data = {}; | |||||||||||||||||||
| 348 | 0 | eval { | |||||||||||||||||||
| 349 | 0 | $data = decode_json($response->decoded_content); | |||||||||||||||||||
| 350 | }; | ||||||||||||||||||||
| 351 | 0 | ▶ | if ($@) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 352 | 0 | $self->error('problem decoding json'); | |||||||||||||||||||
| 353 | 0 | return undef; | |||||||||||||||||||
| 354 | } | ||||||||||||||||||||
| 355 | 0 | return $data; | |||||||||||||||||||
| 356 | } | ||||||||||||||||||||
| 357 | |||||||||||||||||||||
| 358 | |||||||||||||||||||||
| 359 | |||||||||||||||||||||
| 360 | |||||||||||||||||||||
| 361 | |||||||||||||||||||||
| 362 | |||||||||||||||||||||
| 363 | |||||||||||||||||||||
| 364 | =head1 AUTHOR | ||||||||||||||||||||
| 365 | |||||||||||||||||||||
| 366 | Bruno Martins, C<< <bscmartins at gmail.com> >> | ||||||||||||||||||||
| 367 | |||||||||||||||||||||
| 368 | =head1 BUGS | ||||||||||||||||||||
| 369 | |||||||||||||||||||||
| 370 | Please report any bugs or feature requests at L<https://github.com/bmartins/WWW-TVMaze> | ||||||||||||||||||||
| 371 | |||||||||||||||||||||
| 372 | |||||||||||||||||||||
| 373 | |||||||||||||||||||||
| 374 | |||||||||||||||||||||
| 375 | =head1 SUPPORT | ||||||||||||||||||||
| 376 | |||||||||||||||||||||
| 377 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||
| 378 | |||||||||||||||||||||
| 379 | perldoc WWW::TVMaze | ||||||||||||||||||||
| 380 | |||||||||||||||||||||
| 381 | |||||||||||||||||||||
| 382 | |||||||||||||||||||||
| 383 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||
| 384 | |||||||||||||||||||||
| 385 | Copyright 2015 Bruno Martins. | ||||||||||||||||||||
| 386 | |||||||||||||||||||||
| 387 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||
| 388 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||
| 389 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||
| 390 | |||||||||||||||||||||
| 391 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||
| 392 | |||||||||||||||||||||
| 393 | |||||||||||||||||||||
| 394 | =cut | ||||||||||||||||||||
| 395 | |||||||||||||||||||||
| 396 | 2 | 1; # End of WWW::TVMaze | |||||||||||||||||||