NicoVideo.pm

filter: Statementstmt 13.8% 38 / 274 Branchbran 1.9% 3 / 154 Conditioncond 0.0% 0 / 29 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 31.4% 11 / 35 Podpod 100% 27 / 27 totaltotal 14.7% 79 / 535 CC 88 SCAR 36.6
CC
88
Cov
9%
fetch_mylist_rss
132.0
fetch_flv
72.0
list_mylistgroup
56.0
CRAP 38.8
« NicoVideo/Content/MylistItem.pm ↑ Summary NicoVideo/Content/ThumbInfo.pm »
1 package Net::NicoVideo;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 $VERSION = '0.28';
7  
8 2 ▶use base qw(Class::Accessor::Fast);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Net::NicoVideo::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use vars qw($DELAY_DEFAULT $MSG_LOGIN_FAILED);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 $DELAY_DEFAULT = 1;
16 2 $MSG_LOGIN_FAILED = "Cannot login because specified account information may be invalid";
17  
18 2 __PACKAGE__->mk_accessors(qw(
19 user_agent
20 email
21 password
22 delay
23 ));
24  
25 1 ▶sub get_user_agent {
Subroutine get_user_agent: called CC=2 SCAR=7.1
Pod documented
26 1 my $self = shift;
27 1 ▶ $self->user_agent(LWP::UserAgent->new)
Branch: 1 branch
BranchTrueFalseTotal
unless $self->user_agent 1 0 1
28 unless( $self->user_agent );
29 1 Net::NicoVideo::UserAgent->new($self->user_agent);
30 }
31  
32 2 ▶sub get_email {
Subroutine get_email: called CC=2 SCAR=7.2
Pod documented
33 2 my $self = shift;
34 2 ▶ return defined $self->email ? $self->email : $ENV{NET_NICOVIDEO_EMAIL};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->email ? : 0 2 2
35 }
36  
37 2 ▶sub get_password {
Subroutine get_password: called CC=2 SCAR=7.2
Pod documented
38 2 my $self = shift;
39 2 ▶ return defined $self->password ? $self->password : $ENV{NET_NICOVIDEO_PASSWORD};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->password ? : 0 2 2
40 }
41  
42 0 ▶sub get_delay {
Subroutine get_delay: not called CC=3 SCAR=24.8
Pod documented
43 0 my $self = shift;
44 0 ▶ if( defined $self->delay ){
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->delay) { } 0 0 0
elsif ($ENV{'NET_NICOVIDEO_DELAY'}) { } 0 0 0
45 0 return $self->delay;
46 }elsif( $ENV{NET_NICOVIDEO_DELAY} ){
47 0 return $ENV{NET_NICOVIDEO_DELAY};
48 }else{
49 0 return $DELAY_DEFAULT;
50 }
51 }
52  
53 0 ▶sub through_login {
Subroutine through_login: not called CC=2 SCAR=17.9
Pod documented
54 0 my $self = shift;
55 0 my $ua = shift;
56 0 my $res = $ua->request_login($self->get_email, $self->get_password);
57 0 ▶ croak "Request 'request_login' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
58 if( $res->is_error );
59 0 $ua->login( $res ); # this returns $ua
60 }
61  
62 0 ▶sub download {
Subroutine download: not called CC=3 SCAR=24.8
Pod documented
63 0 my ($self, $video_id, @args) = @_;
64 0 $self->fetch_watch($video_id);
65 0 ▶ my $delay = defined($self->delay) ? $self->delay : $DELAY_DEFAULT;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->delay ? : 0 0 0
66 0 ▶ sleep $delay if( $delay );
Branch: 1 branch
BranchTrueFalseTotal
if $delay 0 0 0
67 0 $self->fetch_video($self->fetch_flv($video_id), @args);
68 0 return $self;
69 }
70  
71 #-----------------------------------------------------------
72 # fetch
73 #
74  
75 0 ▶sub fetch_thumbinfo {
Subroutine fetch_thumbinfo: not called CC=3 SCAR=24.8
Pod documented
76 0 my ($self, $video_id) = @_;
77  
78 0 my $res = $self->get_user_agent->request_thumbinfo($video_id);
79 0 ▶ croak "Request 'request_thumbinfo' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
80 if( $res->is_error );
81 0 my $parsed_content = $res->parsed_content;
82  
83 0 ▶ croak "Invalid content as @{[ ref($parsed_content) ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $parsed_content->is_error 0 0 0
84 if( $parsed_content->is_error );
85  
86 0 return $parsed_content;
87 }
88  
89 0 ▶sub fetch_flv {
Subroutine fetch_flv: not called CC=8 SCAR=42.8
Pod documented
90 0 my ($self, $video_id) = @_;
91 0 my $ua = $self->get_user_agent;
92
93 # workaround
94 0 ▶ if( $video_id and $video_id =~ /^so\d+$/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($video_id and $video_id =~ /^so\d+$/) 0 0 0
Condition0%0/3
$video_id and $video_id =~ /^so\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$video_id and $video_id =~ /^so\d+$/
$video_id $video_id =~ /^so\d+$/
Truth table0%0/3
A and B
A= $video_idB= $video_id =~ /^so\d+$/
ABresult
0X0
100
111
95 0 my $item = $self->fetch_mylist_item($video_id);
96 0 $video_id = $item->item_id;
97 }
98  
99 0 my $res = $ua->request_flv($video_id);
100 0 ▶ croak "Request 'request_flv' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
101 if( $res->is_error );
102  
103 0 ▶ unless( $res->is_authflagged ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($res->is_authflagged) 0 0 0
104 # try again
105 0 $res = $self->through_login($ua)->request_flv($video_id);
106 0 ▶ croak "Request 'request_flv' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
107 if( $res->is_error );
108 0 ▶ croak $MSG_LOGIN_FAILED
Branch: 1 branch
BranchTrueFalseTotal
unless $res->is_authflagged 0 0 0
109 unless( $res->is_authflagged );
110 }
111  
112 0 my $parsed_content = $res->parsed_content;
113 0 ▶ croak "Invalid content as @{[ ref($parsed_content) ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $parsed_content->is_error 0 0 0
114 if( $parsed_content->is_error );
115  
116 0 return $parsed_content;
117 }
118  
119 0 ▶sub fetch_watch {
Subroutine fetch_watch: not called CC=6 SCAR=37.4
Pod documented
120 0 my ($self, $video_id) = @_;
121 0 my $ua = $self->get_user_agent;
122  
123 0 my $res = $ua->request_watch($video_id);
124 0 ▶ croak "Request 'request_watch' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
125 if( $res->is_error );
126  
127 0 ▶ unless( $res->is_authflagged ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($res->is_authflagged) 0 0 0
128 # try again
129 0 $res = $self->through_login($ua)->request_watch($video_id);
130 0 ▶ croak "Request 'request_watch' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
131 if( $res->is_error );
132 0 ▶ croak $MSG_LOGIN_FAILED
Branch: 1 branch
BranchTrueFalseTotal
unless $res->is_authflagged 0 0 0
133 unless( $res->is_authflagged );
134 }
135  
136 0 my $parsed_content = $res->parsed_content;
137 0 ▶ croak "Invalid content as @{[ ref($parsed_content) ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $parsed_content->is_error 0 0 0
138 if( $parsed_content->is_error );
139  
140 0 return $parsed_content;
141 }
142  
143 0 ▶sub fetch_video {
Subroutine fetch_video: not called CC=6 SCAR=37.4
Pod documented
144 # $something accepts flv, url ( via flv->url ) or video_id
145 0 my ($self, $something, @args) = @_;
146 0 ▶ if( $something and ! ref($something) and $something !~ m{^https?://} ){
Branch: 1 branch
BranchTrueFalseTotal
if ($something and not ref $something and not $something =~ m[^https?://]) 0 0 0
Condition0%0/6
$something and not ref $something and not $something =~ m[^https?://]
!ll&&!rl&&r
000
$something and not ref $something
!ll&&!rl&&r
000
MC/DC0%0/3
$something and not ref $something and not $something =~ m[^https?://]
$something not ref $something not $something =~ m[^https?://]
Truth table0%0/4
A and not(B) and not(C)
A= $somethingB= not ref $somethingC= not $something =~ m[^https?://]
ABCresult
0XX0
10X0
1100
1111
147 # it is a video_id
148 0 $something = $self->fetch_flv($something);
149 }
150 0 my $res = $self->get_user_agent->request_video($something, @args);
151 0 ▶ croak "Request 'fetch_video' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
152 if( $res->is_error );
153  
154 0 my $parsed_content = $res->parsed_content;
155 0 ▶ croak "Invalid content as @{[ ref($parsed_content) ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $parsed_content->is_error 0 0 0
156 if( $parsed_content->is_error );
157  
158 0 return $parsed_content;
159 }
160  
161 0 ▶sub fetch_thread {
Subroutine fetch_thread: not called CC=5 SCAR=34.0
Pod documented
162 # $something accepts flv, or video_id
163 0 my ($self, $something, $opts) = @_;
164 0 ▶ if( $something and ! ref($something) ){
Branch: 1 branch
BranchTrueFalseTotal
if ($something and not ref $something) 0 0 0
Condition0%0/3
$something and not ref $something
!ll&&!rl&&r
000
MC/DC0%0/2
$something and not ref $something
$something not ref $something
Truth table0%0/3
A and not(B)
A= $somethingB= not ref $something
ABresult
0X0
100
111
165 # it is a video_id
166 0 $something = $self->fetch_flv($something);
167 }
168 0 my $res = $self->get_user_agent->request_thread($something, $opts);
169 0 ▶ croak "Request 'fetch_thread' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
170 if( $res->is_error );
171  
172 0 my $parsed_content = $res->parsed_content;
173 0 ▶ croak "Invalid content as @{[ ref($parsed_content) ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $parsed_content->is_error 0 0 0
174 if( $parsed_content->is_error );
175  
176 0 return $parsed_content;
177 }
178  
179 #-----------------------------------------------------------
180 # Tag RSS
181 #
182  
183 0 ▶sub fetch_tag_rss {
Subroutine fetch_tag_rss: not called CC=3 SCAR=24.8
Pod documented
184 0 my ($self, $keyword, $params) = @_;
185 0 my $ua = $self->get_user_agent;
186  
187 0 my $res = $ua->request_tag_rss($keyword, $params);
188 0 ▶ croak "Request 'request_tag_rss' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
189 if( $res->is_error );
190  
191 0 my $parsed_content = $res->parsed_content;
192 0 ▶ croak "Invalid content as @{[ ref($parsed_content) ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $parsed_content->is_error 0 0 0
193 if( $parsed_content->is_error );
194  
195 0 return $parsed_content;
196 }
197  
198 0 ▶sub fetch_tag_rss_by_recent_post { # shortcut
Subroutine fetch_tag_rss_by_recent_post: not called CC=2 SCAR=17.9
Pod documented
199 0 my ($self, $keyword, $page) = @_;
200 0 ▶ $page ||= 1;
Condition0%0/2
$page ||= 1
l!l
00
MC/DC0%0/1
$page ||= 1
$page
Truth table0%0/2
A
A= $page
Aresult
11
00
201 0 $self->fetch_tag_rss($keyword, {'sort' => 'f', page => $page});
202 }
203  
204 #-----------------------------------------------------------
205 # Mylist RSS
206 #
207  
208 0 ▶sub fetch_mylist_rss {
Subroutine fetch_mylist_rss: not called CC=11 SCAR=48.8
Pod documented
209 0 my ($self, $mylist) = @_;
210 0 my $ua = $self->get_user_agent;
211  
212 0 my $res = $ua->request_mylist_rss($mylist);
213 0 ▶ croak "Request 'request_mylist_rss' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error and $res->code ne 403 0 0 0
Condition0%0/3
$res->is_error and $res->code ne 403
!ll&&!rl&&r
000
MC/DC0%0/2
$res->is_error and $res->code ne 403
$res->is_error $res->code ne 403
Truth table0%0/3
A and B
A= $res->is_errorB= $res->code ne 403
ABresult
0X0
100
111
214 if( $res->is_error and $res->code ne '403' );
215 0 my $parsed_content = $res->parsed_content;
216
217 0 ▶ if( ( ! $res->is_authflagged or $parsed_content->is_closed )
Branch: 1 branch
BranchTrueFalseTotal
if (!$res->is_authflagged || $parsed_content->is_closed and defined $self->get_email and defined $self->get_password) 0 0 0
Condition0%0/9
!$res->is_authflagged || $parsed_content->is_closed and defined $self->get_email and defined $self->get_password
!ll&&!rl&&r
000
!$res->is_authflagged || $parsed_content->is_closed and defined $self->get_email
!ll&&!rl&&r
000
not $res->is_authflagged or $parsed_content->is_closed
l!l&&r!l&&!r
000
MC/DC0%0/4
!$res->is_authflagged || $parsed_content->is_closed and defined $self->get_email and defined $self->get_password
not $res->is_authflagged $parsed_content->is_closed defined $self->get_email defined $self->get_password
Truth table0%0/7
not(A) or B and C and D
A= not $res->is_authflaggedB= $parsed_content->is_closedC= defined $self->get_emailD= defined $self->get_password
ABCDresult
00XX0
1X0X0
010X0
1X100
01100
1X111
01111
218 and defined $self->get_email
219 and defined $self->get_password
220 ){
221 # try again
222 0 $res = $self->through_login($ua)->request_mylist_rss($mylist);
223 0 ▶ croak "Request 'request_mylist_rss' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error and $res->code ne 403 0 0 0
Condition0%0/3
$res->is_error and $res->code ne 403
!ll&&!rl&&r
000
MC/DC0%0/2
$res->is_error and $res->code ne 403
$res->is_error $res->code ne 403
Truth table0%0/3
A and B
A= $res->is_errorB= $res->code ne 403
ABresult
0X0
100
111
224 if( $res->is_error and $res->code ne '403' );
225 0 ▶ croak $MSG_LOGIN_FAILED
Branch: 1 branch
BranchTrueFalseTotal
unless $res->is_authflagged 0 0 0
226 unless( $res->is_authflagged );
227 0 $parsed_content = $res->parsed_content;
228 }
229  
230 0 ▶ croak "Invalid content as @{[ ref($parsed_content) ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_content_error 0 0 0
231 if( $res->is_content_error );
232  
233 0 return $parsed_content;
234 }
235  
236 #-----------------------------------------------------------
237 # Mylist Base
238 #
239  
240 # taking NicoAPI.token
241 0 ▶sub fetch_mylist_page {
Subroutine fetch_mylist_page: not called CC=5 SCAR=34.0
Pod documented
242 0 my ($self) = @_;
243 0 my $ua = $self->get_user_agent;
244  
245 0 my $res = $ua->request_mylist_page;
246 0 ▶ croak "Request 'request_mylist_page' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
247 if( $res->is_error );
248  
249 0 ▶ unless( $res->is_authflagged ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($res->is_authflagged) 0 0 0
250 # try again
251 0 $res = $self->through_login($ua)->request_mylist_page;
252 0 ▶ croak $MSG_LOGIN_FAILED
Branch: 1 branch
BranchTrueFalseTotal
unless $res->is_authflagged 0 0 0
253 unless( $res->is_authflagged );
254 }
255  
256 0 my $parsed_content = $res->parsed_content;
257 0 ▶ croak "Invalid content as @{[ ref($parsed_content) ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $parsed_content->is_error 0 0 0
258 if( $parsed_content->is_error );
259  
260 0 return $parsed_content;
261 }
262  
263 # taking NicoAPI.token to update Mylist, item_type and item_id for video_id
264 0 ▶sub fetch_mylist_item {
Subroutine fetch_mylist_item: not called CC=6 SCAR=37.4
Pod documented
265 0 my ($self, $video_id) = @_;
266 0 my $ua = $self->get_user_agent;
267  
268 0 my $res = $ua->request_mylist_item($video_id);
269 0 ▶ croak "Request 'request_mylist_item' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
270 if( $res->is_error );
271  
272 0 ▶ unless( $res->is_authflagged ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($res->is_authflagged) 0 0 0
273 # try again
274 0 $res = $self->through_login($ua)->request_mylist_item($video_id);
275 0 ▶ croak "Request 'request_mylist_item' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
276 if( $res->is_error );
277 0 ▶ croak $MSG_LOGIN_FAILED
Branch: 1 branch
BranchTrueFalseTotal
unless $res->is_authflagged 0 0 0
278 unless( $res->is_authflagged );
279 }
280  
281 0 my $parsed_content = $res->parsed_content;
282 0 ▶ croak "Invalid content as @{[ ref($parsed_content) ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $parsed_content->is_error 0 0 0
283 if( $parsed_content->is_error );
284  
285 0 return $parsed_content;
286 }
287  
288 #-----------------------------------------------------------
289 # NicoAPI.MylistGroup
290 #
291  
292 # NicoAPI.MylistGroup #list
293 0 ▶sub list_mylistgroup {
Subroutine list_mylistgroup: not called CC=7 SCAR=40.3
Pod documented
294 0 my ($self) = @_;
295 0 my $ua = $self->get_user_agent;
296
297 0 my $res = $ua->request_mylistgroup_list;
298 0 ▶ croak "Request 'request_mylistgroup_list' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
299 if( $res->is_error );
300  
301 0 my $parsed_content = $res->parsed_content;
302  
303 0 ▶ unless( $parsed_content->is_success ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($parsed_content->is_success) 0 0 0
304 0 ▶ if( $parsed_content->is_error_noauth ){
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed_content->is_error_noauth) 0 0 0
305 # try again
306 0 $res = $self->through_login($ua)->request_mylistgroup_list;
307 0 ▶ croak "Request 'request_mylistgroup_list' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
308 if( $res->is_error );
309 0 $parsed_content = $res->parsed_content;
310 0 ▶ unless( $parsed_content->is_success ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($parsed_content->is_success) 0 0 0
311 0 ▶ croak $MSG_LOGIN_FAILED if( $parsed_content->is_error_noauth );
Branch: 1 branch
BranchTrueFalseTotal
if $parsed_content->is_error_noauth 0 0 0
312 0 croak "Invalid content as @{[ ref($parsed_content) ]}";
313 }
314 }
315 }
316  
317 0 return $parsed_content;
318 }
319  
320 # NicoAPI.MylistGroup #get
321 0 ▶sub get_mylistgroup {
Subroutine get_mylistgroup: not called CC=7 SCAR=40.3
Pod documented
322 0 my ($self, $group_id) = @_;
323 0 my $ua = $self->get_user_agent;
324  
325 0 my $res = $ua->request_mylistgroup_get($group_id);
326 0 ▶ croak "Request 'request_mylistgroup_get' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
327 if( $res->is_error );
328  
329 0 my $parsed_content = $res->parsed_content;
330
331 0 ▶ unless( $parsed_content->is_success ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($parsed_content->is_success) 0 0 0
332 0 ▶ if( $parsed_content->is_error_noauth ){
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed_content->is_error_noauth) 0 0 0
333 # try again
334 0 $res = $self->through_login($ua)->request_mylistgroup_get($group_id);
335 0 ▶ croak "Request 'request_mylistgroup_get' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
336 if( $res->is_error );
337 0 $parsed_content = $res->parsed_content;
338 0 ▶ unless( $parsed_content->is_success ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($parsed_content->is_success) 0 0 0
339 0 ▶ croak $MSG_LOGIN_FAILED if( $parsed_content->is_error_noauth );
Branch: 1 branch
BranchTrueFalseTotal
if $parsed_content->is_error_noauth 0 0 0
340 0 croak "Invalid content as @{[ ref($parsed_content) ]}";
341 }
342 }
343 }
344  
345 0 return $parsed_content;
346 }
347  
348 # NicoAPI.MylistGroup #add
349 0 ▶sub add_mylistgroup {
Subroutine add_mylistgroup: not called CC=3 SCAR=24.8
Pod documented
350 0 my ($self, $mylist, $token) = @_;
351 0 my $ua = $self->get_user_agent;
352 0 ▶ $token = $self->fetch_mylist_page->token
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
353 unless( $token );
354 0 my $res = $ua->request_mylistgroup_add($mylist, $token);
355 0 ▶ croak "Request 'request_mylistgroup_add' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
356 if( $res->is_error );
357 0 return $res->parsed_content;
358 }
359  
360 # NicoAPI.MylistGroup #update
361 0 ▶sub update_mylistgroup {
Subroutine update_mylistgroup: not called CC=3 SCAR=24.8
Pod documented
362 0 my ($self, $mylist, $token) = @_;
363 0 my $ua = $self->get_user_agent;
364 0 ▶ $token = $self->fetch_mylist_page->token
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
365 unless( $token );
366 0 my $res = $ua->request_mylistgroup_update($mylist, $token);
367 0 ▶ croak "Request 'request_mylistgroup_update' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
368 if( $res->is_error );
369 0 return $res->parsed_content;
370 }
371  
372 # NicoAPI.MylistGroup #remove
373 0 ▶sub remove_mylistgroup {
Subroutine remove_mylistgroup: not called CC=3 SCAR=24.8
Pod documented
374 0 my ($self, $mylist, $token) = @_;
375 0 my $ua = $self->get_user_agent;
376 0 ▶ $token = $self->fetch_mylist_page->token
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
377 unless( $token );
378 0 my $res = $ua->request_mylistgroup_delete($mylist, $token);
379 0 ▶ croak "Request 'request_mylistgroup_delete' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
380 if( $res->is_error );
381 0 return $res->parsed_content;
382 }
383  
384 2 *delete_mylistgroup = *remove_mylistgroup;
385  
386 #-----------------------------------------------------------
387 # NicoAPI.Mylist
388 #
389  
390 # NicoAPI.Mylist #list
391 0 ▶sub list_mylist {
Subroutine list_mylist: not called CC=7 SCAR=40.3
Pod documented
392 0 my ($self, $group) = @_; # mylistgroup or group_id
393 0 my $ua = $self->get_user_agent;
394  
395 0 my $res = $ua->request_mylist_list($group);
396 0 ▶ croak "Request 'request_mylist_list' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
397 if( $res->is_error );
398 0 my $parsed_content = $res->parsed_content;
399
400 0 ▶ unless( $parsed_content->is_success ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($parsed_content->is_success) 0 0 0
401 0 ▶ if( $parsed_content->is_error_noauth ){
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed_content->is_error_noauth) 0 0 0
402 # try again
403 0 $res = $self->through_login($ua)->request_mylist_list($group);
404 0 ▶ croak "Request 'request_mylist_list' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
405 if( $res->is_error );
406 0 $parsed_content = $res->parsed_content;
407
408 0 ▶ unless( $parsed_content->is_success ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($parsed_content->is_success) 0 0 0
409 0 ▶ croak $MSG_LOGIN_FAILED if( $parsed_content->is_error_noauth );
Branch: 1 branch
BranchTrueFalseTotal
if $parsed_content->is_error_noauth 0 0 0
410 0 croak "Invalid content as @{[ ref($parsed_content) ]}";
411 }
412 }
413 }
414  
415 # it returns Net::NicoVideo::Content::NicoAPI::MylistItem
416 0 return $parsed_content;
417 }
418  
419 # NicoAPI.Mylist #add
420 0 ▶sub add_mylist {
Subroutine add_mylist: not called CC=3 SCAR=24.8
Pod documented
421 0 my ($self, $group, $item, $token) = @_;
422 0 my $ua = $self->get_user_agent;
423 0 ▶ $token = $self->fetch_mylist_page->token
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
424 unless( $token );
425 0 my $res = $ua->request_mylist_add($group, $item, $token);
426 0 ▶ croak "Request 'request_mylist_add' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
427 if( $res->is_error );
428 0 return $res->parsed_content;
429 }
430  
431 # NicoAPI.Mylist #update
432 0 ▶sub update_mylist {
Subroutine update_mylist: not called CC=3 SCAR=24.8
Pod documented
433 0 my ($self, $group, $item, $token) = @_;
434 0 my $ua = $self->get_user_agent;
435 0 ▶ $token = $self->fetch_mylist_page->token
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
436 unless( $token );
437 0 my $res = $ua->request_mylist_update($group, $item, $token);
438 0 ▶ croak "Request 'request_mylist_update' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
439 if( $res->is_error );
440 0 return $res->parsed_content;
441 }
442  
443 # NicoAPI.Mylist #remove
444 0 ▶sub remove_mylist {
Subroutine remove_mylist: not called CC=3 SCAR=24.8
Pod documented
445 0 my ($self, $group, $item, $token) = @_;
446 0 my $ua = $self->get_user_agent;
447 0 ▶ $token = $self->fetch_mylist_page->token
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
448 unless( $token );
449 0 my $res = $ua->request_mylist_remove($group, $item, $token);
450 0 ▶ croak "Request 'request_mylist_remove' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
451 if( $res->is_error );
452 0 return $res->parsed_content;
453 }
454  
455 2 *delete_mylist = *remove_mylist;
456  
457 # NicoAPI.Mylist #move
458 0 ▶sub move_mylist {
Subroutine move_mylist: not called CC=3 SCAR=24.8
Pod documented
459 0 my ($self, $group, $target, $item, $token) = @_;
460 0 my $ua = $self->get_user_agent;
461 0 ▶ $token = $self->fetch_mylist_page->token
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
462 unless( $token );
463 0 my $res = $ua->request_mylist_move($group, $target, $item, $token);
464 0 ▶ croak "Request 'request_mylist_move' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
465 if( $res->is_error );
466 0 return $res->parsed_content;
467 }
468  
469 # NicoAPI.Mylist #copy
470 0 ▶sub copy_mylist {
Subroutine copy_mylist: not called CC=3 SCAR=24.8
Pod documented
471 0 my ($self, $group, $target, $item, $token) = @_;
472 0 my $ua = $self->get_user_agent;
473 0 ▶ $token = $self->fetch_mylist_page->token
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
474 unless( $token );
475 0 my $res = $ua->request_mylist_copy($group, $target, $item, $token);
476 0 ▶ croak "Request 'request_mylist_copy' is error: @{[ $res->status_line ]}"
Branch: 1 branch
BranchTrueFalseTotal
if $res->is_error 0 0 0
477 if( $res->is_error );
478 0 return $res->parsed_content;
479 }
480  
481 2 1;
482 __END__
« NicoVideo/Content/MylistItem.pm ↑ Summary NicoVideo/Content/ThumbInfo.pm »