| 1 | =head1 NAME | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | WWW::TV::Episode - Parse TV.com for TV Episode information. | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | use WWW::TV::Episode qw(); | ||||||||||||||||||||||||||||
| 8 | my $episode = WWW::TV::Series->new(id => '475567'); | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | # with optional paramers | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | print $episode->summary; | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | The L<WWW::TV::Episode> module parses TV.com episode information using | ||||||||||||||||||||||||||||
| 17 | L<LWP::UserAgent>. Unfortunately I can't see a way to search for an episode | ||||||||||||||||||||||||||||
| 18 | by name, so I haven't implemented it. It is probably possible to do so if you | ||||||||||||||||||||||||||||
| 19 | populate a series object and grep $series->episodes for the episode name you | ||||||||||||||||||||||||||||
| 20 | are searching for. | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =head1 METHODS | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =cut | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | package WWW::TV::Episode; | ||||||||||||||||||||||||||||
| 27 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 2 | our $VERSION = '0.14'; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 2 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 2 | ▶ | use LWP::UserAgent qw(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =head2 new | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | The new() method is the constructor. It takes the id of the show | ||||||||||||||||||||||||||||
| 38 | assuming you have previously looked that up. | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | # default usage | ||||||||||||||||||||||||||||
| 41 | my $episode = WWW::TV::Episode->new(id => 924072); | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | # change user-agent from the default of "libwww-perl/#.##" | ||||||||||||||||||||||||||||
| 44 | my $episode = WWW::TV::Episode->new(id => 924072, agent => 'WWW::TV'); | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | It also (optionally) takes the name of the episode. This is not used | ||||||||||||||||||||||||||||
| 47 | in any way to search for the episode, but is used as initial data | ||||||||||||||||||||||||||||
| 48 | population for that field so that the html isn't parsed if you only | ||||||||||||||||||||||||||||
| 49 | want an object with the name. This is used by the L<WWW::TV::Series> | ||||||||||||||||||||||||||||
| 50 | object to populate a big array of episodes that have names without | ||||||||||||||||||||||||||||
| 51 | needing to fetch any pages. | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | # pre-populate episode name | ||||||||||||||||||||||||||||
| 54 | my $episode = WWW::TV::Episode->new(id => 924072, name => 'Run!'); | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =cut | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=23.7
Pod
documented
| |||||||||||||||||||||||||||||
| 59 | 2 | ▶ | my $class = ref $_[0] ? ref(shift) : shift; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 2 | my %data; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 2 | ▶ | if (@_ == 1) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 64 | 0 | $data{id} = shift; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | elsif (scalar(@_) % 2 == 0) { | ||||||||||||||||||||||||||||
| 67 | 2 | %data = @_; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 2 | ▶ | croak 'No id given to constructor' unless exists $data{id}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 2 | ▶ | croak "Invalid id: $data{id}" unless ($data{id} =~ /^\d+$/ && $data{id}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$data{"id"} =~ /^\d+$/ and $data{"id"}
MC/DC0%0/2
$data{"id"} =~ /^\d+$/ and $data{"id"}
$data{"id"} =~ /^\d+$/
$data{"id"}
Truth table33%1/3
A and B
A= $data{"id"} =~ /^\d+$/B= $data{"id"}
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | return bless { | ||||||||||||||||||||||||||||
| 74 | id => $data{id}, | ||||||||||||||||||||||||||||
| 75 | name => $data{name}, | ||||||||||||||||||||||||||||
| 76 | _agent => $data{agent}, | ||||||||||||||||||||||||||||
| 77 | _site => $data{site}, | ||||||||||||||||||||||||||||
| 78 | filled => { | ||||||||||||||||||||||||||||
| 79 | id => 1, | ||||||||||||||||||||||||||||
| 80 | $data{name} | ||||||||||||||||||||||||||||
| 81 | 2 | ▶ | ? (name => 1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | : (), | ||||||||||||||||||||||||||||
| 83 | }, | ||||||||||||||||||||||||||||
| 84 | }, $class; | ||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =head2 id | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | The ID of this episode, according to TV.com | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =cut | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 2 | ▶ | sub id { | ||||||||||||||||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 94 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 2 | return $self->{id}; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =head2 name | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | Returns a string containing the name of the episode. | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =cut | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 2 | ▶ | sub name { | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 106 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 2 | ▶ | unless (exists $self->{filled}->{name}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 1 | $self->{filled}->{name} = 1; | |||||||||||||||||||||||||||
| 110 | 1 | ($self->{name}) = $self->_html =~ m{ | |||||||||||||||||||||||||||
| 111 | <h2\sclass="module_title">(.*)</h2>\n | ||||||||||||||||||||||||||||
| 112 | \s*<ul\sclass="ep_stats"> | ||||||||||||||||||||||||||||
| 113 | }x; | ||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 2 | return $self->{name}; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =head2 summary | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | Returns a string containing basic information about this series. | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | =cut | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 2 | ▶ | sub summary { | ||||||||||||||||||||||||||
|
Subroutine
summary: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 126 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 2 | ▶ | unless (exists $self->{filled}->{summary}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 1 | $self->{filled}->{summary} = 1; | |||||||||||||||||||||||||||
| 130 | 1 | ($self->{summary}) = $self->_html =~ m{ | |||||||||||||||||||||||||||
| 131 | <p\sclass="deck">(.*?)</p> | ||||||||||||||||||||||||||||
| 132 | }smx; | ||||||||||||||||||||||||||||
| 133 | 1 | $self->{summary} =~ s/<br ?\/?>/\n/g; | |||||||||||||||||||||||||||
| 134 | 1 | $self->{summary} =~ s/<a href="[^"]+">.*?<\/a>//g; | |||||||||||||||||||||||||||
| 135 | 1 | $self->{summary} =~ s/^\s*//; | |||||||||||||||||||||||||||
| 136 | 1 | $self->{summary} =~ s/\s*$//; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 2 | return $self->{summary}; | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | =head2 season_number | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | Returns the season number that this episode appeared in. | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | =cut | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 1 | ▶ | sub season_number { | ||||||||||||||||||||||||||
|
Subroutine
season_number: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 149 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 1 | ▶ | unless (exists $self->{filled}->{season_number}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 1 | $self->_fill_vitals; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 1 | return $self->{season_number}; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | =head2 episode_number | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | Returns the overall number of this episode. Note, this is not | ||||||||||||||||||||||||||||
| 161 | necessarily the production order of the episodes, but is the order | ||||||||||||||||||||||||||||
| 162 | in which they aired. | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | =cut | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 1 | ▶ | sub episode_number { | ||||||||||||||||||||||||||
|
Subroutine
episode_number: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 167 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 1 | ▶ | unless (exists $self->{filled}->{episode_number}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | 0 | $self->_fill_vitals; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 1 | return $self->{episode_number}; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | =head2 format_details ($format_str) | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | Returns episode details using a special format string, similar to printf: | ||||||||||||||||||||||||||||
| 179 | %I - series ID | ||||||||||||||||||||||||||||
| 180 | %N - series name | ||||||||||||||||||||||||||||
| 181 | %s - season number | ||||||||||||||||||||||||||||
| 182 | %S - season number (0-padded to two digits, if required) | ||||||||||||||||||||||||||||
| 183 | %i - episode ID | ||||||||||||||||||||||||||||
| 184 | %e - episode number | ||||||||||||||||||||||||||||
| 185 | %E - episode number (0-padded to two digits, if required) | ||||||||||||||||||||||||||||
| 186 | %n - episode name | ||||||||||||||||||||||||||||
| 187 | %d - date episode first aired | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | The default format is: | ||||||||||||||||||||||||||||
| 190 | %N.s%Se%E - %n (eg: "Heroes.s1e02 - Don't Look Back") | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | =cut | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 2 | ▶ | sub format_details { | ||||||||||||||||||||||||||
|
Subroutine
format_details: called CC=3 SCAR=13.8
Pod
documented
| |||||||||||||||||||||||||||||
| 195 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 2 | ▶ | my $format_str = shift || '%N.s%Se%E - %n'; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || '%N.s%Se%E - %n'
MC/DC0%0/1
shift() || '%N.s%Se%E - %n'
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | # format subs .. expecting $_[0] is $self | ||||||||||||||||||||||||||||
| 200 | my %formats = ( | ||||||||||||||||||||||||||||
| 201 | 1 | ▶ | 'I' => sub { $_[0]->series_id }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 202 | 1 | ▶ | 'N' => sub { $_[0]->series->name }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 203 | 0 | ▶ | 's' => sub { $_[0]->season_number }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 204 | 0 | ▶ | 'S' => sub { sprintf('%02d', $_[0]->season_number) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 205 | 0 | ▶ | 'i' => sub { $_[0]->id }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 206 | 0 | ▶ | 'e' => sub { $_[0]->episode_number }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 207 | 0 | ▶ | 'E' => sub { sprintf('%02d', $_[0]->episode_number) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 208 | 0 | ▶ | 'n' => sub { $_[0]->name }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 209 | 0 | ▶ | 'd' => sub { $_[0]->first_aired }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 210 | 2 | ); | |||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | # substitution | ||||||||||||||||||||||||||||
| 213 | 2 | $format_str =~ | |||||||||||||||||||||||||||
| 214 | s/ | ||||||||||||||||||||||||||||
| 215 | # look for single character format specifier | ||||||||||||||||||||||||||||
| 216 | %([a-zA-Z]) | ||||||||||||||||||||||||||||
| 217 | / | ||||||||||||||||||||||||||||
| 218 | # use format sub if found, otherwise leave as-is | ||||||||||||||||||||||||||||
| 219 | 2 | ▶ | $formats{$1} ? $formats{$1}->($self) : "\%$1" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | /sgex; | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 1 | return $format_str; | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | =head2 first_aired | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | Returns a string of the date this episode first aired in ISO 8601 (yyyy-mm-dd) format. | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | =cut | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 1 | ▶ | sub first_aired { | ||||||||||||||||||||||||||
|
Subroutine
first_aired: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 233 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 1 | ▶ | unless (exists $self->{filled}->{first_aired}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 236 | 0 | $self->_fill_vitals; | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 1 | return $self->{first_aired}; | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | =head2 stars | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | Returns a list of the stars that appeared in this episode. | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | # in scalar context, returns a comma-delimited string | ||||||||||||||||||||||||||||
| 247 | my $stars = $episode->stars; | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | # in array context, returns an array | ||||||||||||||||||||||||||||
| 250 | my @stars = $episode->stars; | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | =cut | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 1 | ▶ | sub stars { | ||||||||||||||||||||||||||
|
Subroutine
stars: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 255 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 1 | ▶ | unless (exists $self->{filled}->{stars}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 258 | 1 | my ($stars) = $self->_html =~ m{ | |||||||||||||||||||||||||||
| 259 | <dl\s*>\s* | ||||||||||||||||||||||||||||
| 260 | <dt>Stars?:</dt>\s* | ||||||||||||||||||||||||||||
| 261 | (<dd>.*?</dd>)\s* | ||||||||||||||||||||||||||||
| 262 | </dl> | ||||||||||||||||||||||||||||
| 263 | }x; | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 1 | $self->{stars} = $self->_parse_people($stars); | |||||||||||||||||||||||||||
| 266 | 1 | $self->{filled}->{stars} = 1; | |||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 1 | return $self->{stars}; | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | =head2 guest_stars | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | Returns a list of the guest stars that appeared in this episode. | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | # in scalar context, returns a comma-delimited string | ||||||||||||||||||||||||||||
| 277 | my $guest_stars = $episode->guest_stars; | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | # in array context, returns an array | ||||||||||||||||||||||||||||
| 280 | my @guest_stars = $episode->guest_stars; | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | =cut | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 1 | ▶ | sub guest_stars { | ||||||||||||||||||||||||||
|
Subroutine
guest_stars: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 285 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 1 | ▶ | unless (exists $self->{filled}->{guest_stars}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 288 | 1 | my ($stars) = $self->_html =~ m{ | |||||||||||||||||||||||||||
| 289 | <dl\s*(?:class="last")?\s*>\s* | ||||||||||||||||||||||||||||
| 290 | <dt>Guest\sStars?:</dt>\s* | ||||||||||||||||||||||||||||
| 291 | (<dd>.*?</dd>)\s* | ||||||||||||||||||||||||||||
| 292 | </dl> | ||||||||||||||||||||||||||||
| 293 | }x; | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | 1 | $self->{guest_stars} = $self->_parse_people($stars); | |||||||||||||||||||||||||||
| 296 | 1 | $self->{filled}->{guest_stars} = 1; | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | 1 | return $self->{guest_stars}; | |||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | =head2 recurring_roles | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | Returns a list of the people who have recurring roles | ||||||||||||||||||||||||||||
| 305 | that appeared in this episode | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | # in scalar context, returns a comma-delimited string | ||||||||||||||||||||||||||||
| 308 | my $recurring_roless = $episode->recurring_roless; | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | # in array context, returns an array | ||||||||||||||||||||||||||||
| 311 | my @recurring_roless = $episode->recurring_roless; | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | =cut | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 1 | ▶ | sub recurring_roles { | ||||||||||||||||||||||||||
|
Subroutine
recurring_roles: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 316 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 1 | ▶ | unless (exists $self->{filled}->{recurring_roles}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | 1 | my ($stars) = $self->_html =~ m{ | |||||||||||||||||||||||||||
| 320 | <dl\s*>\s* | ||||||||||||||||||||||||||||
| 321 | <dt>Recurring\sRoles?:</dt>\s* | ||||||||||||||||||||||||||||
| 322 | (<dd>.*?</dd>)\s* | ||||||||||||||||||||||||||||
| 323 | </dl> | ||||||||||||||||||||||||||||
| 324 | }x; | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 1 | $self->{recurring_roles} = $self->_parse_people($stars); | |||||||||||||||||||||||||||
| 327 | 1 | $self->{filled}->{recurring_roles} = 1; | |||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | 1 | return $self->{recurring_roles}; | |||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 5 | ▶ | sub _parse_people { | ||||||||||||||||||||||||||
|
Subroutine
_parse_people: called CC=4 SCAR=23.2
| |||||||||||||||||||||||||||||
| 334 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 335 | 5 | ▶ | my $stars = shift or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 0 | my @stars; | |||||||||||||||||||||||||||
| 338 | 0 | for my $star (split /<\/dd>/, $stars) { | |||||||||||||||||||||||||||
| 339 | 0 | ▶ | next unless $star =~ m{<a href="[^"]+">(.*?)</a>}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 340 | 0 | push @stars, $1; | |||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | 0 | return join(', ', @stars); | |||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | =head2 writers | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | Returns a list of the people that wrote this episode. | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | # in scalar context, returns a comma-delimited string | ||||||||||||||||||||||||||||
| 351 | my $writers = $episode->writers; | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | # in array context, returns an array | ||||||||||||||||||||||||||||
| 354 | my @writers = $episode->writers; | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | =cut | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 1 | ▶ | sub writers { | ||||||||||||||||||||||||||
|
Subroutine
writers: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 359 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | 1 | ▶ | unless (exists $self->{filled}->{writers}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 362 | 1 | my ($writers) = $self->_html =~ m{ | |||||||||||||||||||||||||||
| 363 | <dl\s*>\s* | ||||||||||||||||||||||||||||
| 364 | <dt>Writers?:</dt>\s* | ||||||||||||||||||||||||||||
| 365 | (<dd>.*?</dd>)\s* | ||||||||||||||||||||||||||||
| 366 | </dl> | ||||||||||||||||||||||||||||
| 367 | }x; | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | 1 | $self->{writers} = $self->_parse_people($writers); | |||||||||||||||||||||||||||
| 370 | 1 | $self->{filled}->{writers} = 1; | |||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | 1 | return $self->{writers}; | |||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | =head2 directors | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | Returns a list of the people that directed this episode. | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | # in scalar context, returns a comma-delimited string | ||||||||||||||||||||||||||||
| 381 | my $directors = $episode->directors; | ||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | # in array context, returns an array | ||||||||||||||||||||||||||||
| 384 | my @directors = $episode->directors; | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | =cut | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | 1 | ▶ | sub directors { | ||||||||||||||||||||||||||
|
Subroutine
directors: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 389 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | 1 | ▶ | unless (exists $self->{filled}->{directors}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 392 | 1 | my ($directors) = $self->_html =~ m{ | |||||||||||||||||||||||||||
| 393 | <dl\s*>\s* | ||||||||||||||||||||||||||||
| 394 | <dt>Directors?:</dt>\s* | ||||||||||||||||||||||||||||
| 395 | (<dd>.*?</dd>)\s* | ||||||||||||||||||||||||||||
| 396 | </dl> | ||||||||||||||||||||||||||||
| 397 | }x; | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | 1 | $self->{directors} = $self->_parse_people($directors); | |||||||||||||||||||||||||||
| 400 | 1 | $self->{filled}->{directors} = 1; | |||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | 1 | return $self->{directors}; | |||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | =head2 agent ($value) | ||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | Returns the current user agent setting, and sets to $value if provided. | ||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | =cut | ||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | 6 | ▶ | sub agent { | ||||||||||||||||||||||||||
|
Subroutine
agent: called CC=5 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||
| 413 | 6 | my $self = shift; # may be called as $self or $class | |||||||||||||||||||||||||||
| 414 | 6 | my $value = shift; | |||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | 6 | ▶ | if (ref $self) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 417 | 6 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 418 | 2 | $self->{_agent} = $value; | |||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||
| 420 | 6 | ▶ | return ($self->{_agent} || LWP::UserAgent::_agent); | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'_agent'} || LWP::UserAgent::_agent()
MC/DC0%0/2
$self->{'_agent'} || LWP::UserAgent::_agent()
$self->{'_agent'}
LWP::UserAgent::_agent()
Truth table66%2/3
A || B
A= $self->{'_agent'}B= LWP::UserAgent::_agent()
| |||||||||||||||||||||||||||||
| 421 | } else { | ||||||||||||||||||||||||||||
| 422 | 0 | ▶ | return ($value || LWP::UserAgent::_agent); | ||||||||||||||||||||||||||
|
Condition0%0/3
$value || LWP::UserAgent::_agent()
MC/DC0%0/2
$value || LWP::UserAgent::_agent()
$value
LWP::UserAgent::_agent()
Truth table0%0/3
A || B
A= $valueB= LWP::UserAgent::_agent()
| |||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | =head2 site ($value) | ||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | Returns the current mirror site setting, and sets to $value if provided. | ||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | Default site is "www"; other options include: us, uk, au | ||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | =cut | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | 8 | ▶ | sub site { | ||||||||||||||||||||||||||
|
Subroutine
site: called CC=6 SCAR=18.5
Pod
documented
| |||||||||||||||||||||||||||||
| 435 | 8 | my $self = shift; # may be called as $self or $class | |||||||||||||||||||||||||||
| 436 | 8 | my $value = shift; | |||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | 8 | ▶ | if (ref $self) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 439 | 8 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 440 | 3 | ▶ | if ($value =~ /^(au|uk|us|www|)$/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 441 | 2 | $self->{_site} = $value; | |||||||||||||||||||||||||||
| 442 | } else { | ||||||||||||||||||||||||||||
| 443 | 1 | warn "Ignoring unknown site value: [$value]\n"; | |||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||
| 446 | 8 | ▶ | return ($self->{_site} || 'www'); | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'_site'} || 'www'
MC/DC100%1/1
$self->{'_site'} || 'www'
$self->{'_site'}
Truth table100%2/2
A
A= $self->{'_site'}
| |||||||||||||||||||||||||||||
| 447 | } else { | ||||||||||||||||||||||||||||
| 448 | 0 | ▶ | return ($value || 'www'); | ||||||||||||||||||||||||||
|
Condition0%0/2
$value || 'www'
MC/DC0%0/1
$value || 'www'
$value
Truth table0%0/2
A
A= $value
| |||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | =head2 url | ||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||
| 454 | Returns the url that was used to create this object. | ||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | =cut | ||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | 1 | ▶ | sub url { | ||||||||||||||||||||||||||
|
Subroutine
url: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 459 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | 1 | return sprintf('http://%s.tv.com/episode/%d/summary.html', $self->site, $self->id); | |||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | =head2 season | ||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | Returns an array of other episodes for the same season of this series. | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | =cut | ||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | 0 | ▶ | sub season { | ||||||||||||||||||||||||||
|
Subroutine
season: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 471 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 472 | 0 | my @episodes = $self->series->episodes( season => $self->season_number ); | |||||||||||||||||||||||||||
| 473 | 0 | ▶ | return wantarray ? @episodes : \@episodes; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | =head2 series_id | ||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | Returns the series ID for this episode. | ||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | =cut | ||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||
| 482 | 2 | ▶ | sub series_id { | ||||||||||||||||||||||||||
|
Subroutine
series_id: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 483 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | 2 | ▶ | unless (exists $self->{filled}->{series_id}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 486 | 1 | my ($id) = $self->_html =~ m{<a href=".*/show/(\d+)/cast\.html">}; | |||||||||||||||||||||||||||
| 487 | 1 | $self->{series_id} = $id; | |||||||||||||||||||||||||||
| 488 | 1 | $self->{filled}->{series_id} = 1; | |||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | 2 | return $self->{series_id}; | |||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | =head2 series | ||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | Returns an L<WWW::TV::Series> object which is the complete series | ||||||||||||||||||||||||||||
| 497 | that this episode is a part of. | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | =cut | ||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | 1 | ▶ | sub series { | ||||||||||||||||||||||||||
|
Subroutine
series: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||
| 502 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | 1 | ▶ | unless (exists $self->{filled}->{series}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 505 | 1 | ▶ | if ($self->series_id) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 506 | 0 | require WWW::TV::Series; | |||||||||||||||||||||||||||
| 507 | 0 | $self->{series} = WWW::TV::Series->new(id => $self->series_id); | |||||||||||||||||||||||||||
| 508 | 0 | $self->{filled}->{series} = 1; | |||||||||||||||||||||||||||
| 509 | } else { | ||||||||||||||||||||||||||||
| 510 | 1 | croak "Can't find series_id for this episode"; | |||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | 0 | return $self->{series}; | |||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | 1 | ▶ | sub _fill_vitals { | ||||||||||||||||||||||||||
|
Subroutine
_fill_vitals: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 518 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | ($self->{season_number}, $self->{episode_number}, $self->{first_aired}) | ||||||||||||||||||||||||||||
| 521 | 1 | = $self->_html | |||||||||||||||||||||||||||
| 522 | =~ m{ | ||||||||||||||||||||||||||||
| 523 | <ul\sclass="ep_stats"> | ||||||||||||||||||||||||||||
| 524 | <li>.*?</li> | ||||||||||||||||||||||||||||
| 525 | <li><span>Season:</span>\s*(.*?)\s*</li> | ||||||||||||||||||||||||||||
| 526 | <li><span>Episode:</span>\s*(.*?)\s*</li> | ||||||||||||||||||||||||||||
| 527 | (?:<li><span>First\sAired:</span>\s*(?:\w*?\s*)?(\d+/\d+/\d+|n/a)\s*</li>)? | ||||||||||||||||||||||||||||
| 528 | (?:<li><span>Prod\sCode:</span>\s*.*\s*</li>)? | ||||||||||||||||||||||||||||
| 529 | </ul> | ||||||||||||||||||||||||||||
| 530 | }sx; | ||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||
| 532 | 1 | $self->{filled}->{$_} = 1 for qw(episode_number season_number first_aired); | |||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||
| 534 | 1 | return $self->_parse_first_aired; | |||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | 1 | ▶ | sub _parse_first_aired { | ||||||||||||||||||||||||||
|
Subroutine
_parse_first_aired: called CC=3 SCAR=13.5
| |||||||||||||||||||||||||||||
| 538 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | 1 | ▶ | if (not defined $self->{first_aired}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 541 | 1 | $self->{first_aired} = 'n/a'; | |||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | 1 | ▶ | return if $self->{first_aired} eq 'n/a'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | 0 | my ($month, $day, $year) = split('/', $self->{first_aired}); | |||||||||||||||||||||||||||
| 547 | 0 | $self->{first_aired} = sprintf('%04d-%02d-%02d', $year, $month, $day); | |||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | 0 | return 1; | |||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | 9 | ▶ | sub _html { | ||||||||||||||||||||||||||
|
Subroutine
_html: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 553 | 9 | my $self = shift; | |||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||
| 555 | 9 | ▶ | unless ($self->{filled}->{html}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 556 | 1 | my $ua = LWP::UserAgent->new( agent => $self->agent ); | |||||||||||||||||||||||||||
| 557 | 1 | my $rc = $ua->get($self->url); | |||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | 1 | ▶ | croak sprintf('Unable to fetch page for series %s', $self->id) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 560 | unless $rc->is_success; | ||||||||||||||||||||||||||||
| 561 | $self->{html} = | ||||||||||||||||||||||||||||
| 562 | join( | ||||||||||||||||||||||||||||
| 563 | "\n", | ||||||||||||||||||||||||||||
| 564 | 1 | map { s/^\s*//; s/\s*$//; $_ } | |||||||||||||||||||||||||||
| 565 | split /\n/, $rc->content | ||||||||||||||||||||||||||||
| 566 | ); | ||||||||||||||||||||||||||||
| 567 | 1 | $self->{filled}->{html} = 1; | |||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||
| 570 | 9 | return $self->{html}; | |||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | 2 | 1; | |||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | __END__ | ||||||||||||||||||||||||||||