line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::NicoVideo::Content; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1429
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
72
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
60
|
|
5
|
2
|
|
|
2
|
|
11
|
use vars qw($VERSION); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
1147
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.28'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
1
|
|
|
1
|
0
|
2
|
my $class = shift; |
10
|
1
|
|
33
|
|
|
7
|
$class = ref $class || $class; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
|
|
2
|
my $contents = shift; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
4
|
my $self = { |
15
|
|
|
|
|
|
|
_decoded_content => undef, |
16
|
|
|
|
|
|
|
_status => undef, |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
5
|
bless $self, $class; |
20
|
|
|
|
|
|
|
|
21
|
1
|
50
|
|
|
|
15
|
$self->load($contents) if( defined $contents ); |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
10
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _decoded_content { |
27
|
2
|
|
|
2
|
|
9367
|
my $self = shift; |
28
|
2
|
100
|
|
|
|
28
|
return @_ ? $self->{_decoded_content} = shift : $self->{_decoded_content}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _status { |
32
|
1
|
|
|
1
|
|
4
|
my $self = shift; |
33
|
1
|
50
|
|
|
|
9
|
return @_ ? $self->{_status} = shift : $self->{_status}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub set_status_success { |
37
|
1
|
|
|
1
|
0
|
11
|
$_[0]->_status(1); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub set_status_error { |
41
|
0
|
|
|
0
|
0
|
0
|
$_[0]->_status(0); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub load { |
45
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
46
|
1
|
|
|
|
|
1
|
my $contents = shift; |
47
|
|
|
|
|
|
|
|
48
|
1
|
50
|
|
|
|
4
|
unless( ref($contents) ){ |
49
|
0
|
|
|
|
|
0
|
$self->_decoded_content( $contents ); |
50
|
|
|
|
|
|
|
}else{ |
51
|
1
|
50
|
|
|
|
11
|
if( $contents->isa('HTTP::Response') ){ |
52
|
1
|
|
|
|
|
9
|
$self->_decoded_content( $contents->decoded_content ); |
53
|
|
|
|
|
|
|
}else{ |
54
|
0
|
|
|
|
|
0
|
$self->_decoded_content( $$contents ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
6
|
return $self; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub members { # interface |
62
|
0
|
|
|
0
|
0
|
|
(); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub parse { # interface |
66
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
67
|
0
|
0
|
|
|
|
|
$self->load($_[0]) if( defined $_[0] ); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# here! parse contents and set _status to success or error |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return $self; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub is_success { |
75
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
76
|
0
|
0
|
|
|
|
|
unless( defined $self->_status ){ |
77
|
0
|
|
|
|
|
|
die "content is not parsed as @{[ ref($self) ]} yet"; |
|
0
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
} |
79
|
0
|
0
|
|
|
|
|
return $self->_status ? 1 : 0; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub is_error { |
83
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
84
|
0
|
0
|
|
|
|
|
unless( defined $self->_status ){ |
85
|
0
|
|
|
|
|
|
die "content is not parsed as @{[ ref($self) ]} yet"; |
|
0
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} |
87
|
0
|
0
|
|
|
|
|
return $self->_status ? 0 : 1; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
__END__ |