NicoVideo/UserAgent.pm

filter: Statementstmt 27.9% 33 / 118 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 33 MC/DCmcdc 0.0% 0 / 22 Subroutinesub 25.7% 9 / 35 Podpod 0.0% 0 / 27 totaltotal 16.3% 42 / 257 CC 23 SCAR 23.5
CC
23
Cov
19%
request_mylist_move_multi
30.0
request_mylist_copy_multi
30.0
request_video
12.0
CRAP 10.4
« NicoVideo/Content/Flv.pm ↑ Summary NicoVideo/Content/MylistPage.pm »
1 package Net::NicoVideo::UserAgent;
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 # NOTE: Never inherit with classes that have "get()" or "set()",
9 # because these interfere with _component which is decorated with Net::NicoVideo::Decorator
10 2 ▶use base qw(Net::NicoVideo::Decorator);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use HTTP::Cookies;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use HTTP::Request::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Net::NicoVideo::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Net::NicoVideo::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 our $MOD_MYLISTGROUP = 'Net::NicoVideo::Content::NicoAPI::MylistGroup';
18 2 our $MOD_FLV = 'Net::NicoVideo::Content::Flv';
19  
20 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
21 1 my ($class, $component, @opts) = @_;
22  
23 # component accepts LWP::UserAgent
24 1 $class->SUPER::new($component, @opts);
25 }
26  
27 0 ▶sub login {
Subroutine login: not called CC=1 SCAR=6.9
Pod undocumented
28 0 my ($self, $res) = @_;
29  
30 0 my $cookie_jar = HTTP::Cookies->new;
31 0 $cookie_jar->extract_cookies($res);
32 0 $self->cookie_jar($cookie_jar);
33  
34 0 return $self;
35 }
36  
37 0 ▶sub request_login {
Subroutine request_login: not called CC=1 SCAR=6.9
Pod undocumented
38 0 my ($self, $email, $password) = @_;
39 0 Net::NicoVideo::Response->new(
40 $self->request(Net::NicoVideo::Request->login($email,$password)));
41 }
42  
43 0 ▶sub request_get {
Subroutine request_get: not called CC=1 SCAR=6.9
Pod undocumented
44 0 my ($self, $url, @args) = @_;
45 0 Net::NicoVideo::Response->new(
46 $self->request(Net::NicoVideo::Request->get($url), @args));
47 }
48  
49 #-----------------------------------------------------------
50 # fetch
51 #
52  
53 0 ▶sub request_thumbinfo {
Subroutine request_thumbinfo: not called CC=1 SCAR=6.9
Pod undocumented
54 0 my ($self, $video_id) = @_;
55 0 require Net::NicoVideo::Response::ThumbInfo;
56 0 Net::NicoVideo::Response::ThumbInfo->new(
57 $self->request(Net::NicoVideo::Request->thumbinfo($video_id)));
58 }
59  
60 0 ▶sub request_flv {
Subroutine request_flv: not called CC=1 SCAR=6.9
Pod undocumented
61 0 my ($self, $video_id) = @_;
62 0 require Net::NicoVideo::Response::Flv;
63 0 Net::NicoVideo::Response::Flv->new(
64 $self->request(Net::NicoVideo::Request->flv($video_id)));
65 }
66  
67 0 ▶sub request_watch {
Subroutine request_watch: not called CC=1 SCAR=6.9
Pod undocumented
68 0 my ($self, $video_id) = @_;
69 0 require Net::NicoVideo::Response::Watch;
70 0 Net::NicoVideo::Response::Watch->new(
71 $self->request(Net::NicoVideo::Request->watch($video_id)));
72 }
73  
74 0 ▶sub request_video {
Subroutine request_video: not called CC=3 SCAR=24.8
Pod undocumented
75 0 my ($self, $flv, @args) = @_;
76 0 ▶ my $url = (ref($flv) and $flv->isa($MOD_FLV)) ? $flv->url : $flv;
Branch: 1 branch
BranchTrueFalseTotal
ref $flv && $flv->isa($Net::NicoVideo::UserAgent::MOD_FLV) ? : 0 0 0
Condition0%0/3
ref $flv and $flv->isa($Net::NicoVideo::UserAgent::MOD_FLV)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $flv and $flv->isa($Net::NicoVideo::UserAgent::MOD_FLV)
ref $flv $flv->isa($Net::NicoVideo::UserAgent::MOD_FLV)
Truth table0%0/3
A and B
A= ref $flvB= $flv->isa($Net::NicoVideo::UserAgent::MOD_FLV)
ABresult
0X0
100
111
77 0 require Net::NicoVideo::Response::Video;
78 0 Net::NicoVideo::Response::Video->new(
79 $self->request(Net::NicoVideo::Request->get($url), @args));
80 }
81  
82 0 ▶sub request_thread {
Subroutine request_thread: not called CC=1 SCAR=6.9
Pod undocumented
83 0 my ($self, $flv, $opts) = @_;
84 0 require Net::NicoVideo::Response::Thread;
85 0 Net::NicoVideo::Response::Thread->new(
86 $self->request(Net::NicoVideo::Request->thread($flv->ms,$flv->thread_id,$opts)));
87 }
88  
89 #-----------------------------------------------------------
90 # Tag RSS
91 #
92  
93 0 ▶sub request_tag_rss {
Subroutine request_tag_rss: not called CC=1 SCAR=6.9
Pod undocumented
94 0 my ($self, $keyword, $params) = @_;
95 0 require Net::NicoVideo::Response::TagRSS;
96 0 Net::NicoVideo::Response::TagRSS->new(
97 $self->request(Net::NicoVideo::Request->tag_rss($keyword,$params)));
98 }
99  
100 #-----------------------------------------------------------
101 # Mylist RSS
102 #
103  
104 0 ▶sub request_mylist_rss {
Subroutine request_mylist_rss: not called CC=1 SCAR=6.9
Pod undocumented
105 0 my ($self, $mylist_id) = @_;
106 0 require Net::NicoVideo::Response::MylistRSS;
107 0 Net::NicoVideo::Response::MylistRSS->new(
108 $self->request(Net::NicoVideo::Request->mylist_rss($mylist_id)));
109 }
110  
111 #-----------------------------------------------------------
112 # Mylist Base
113 #
114  
115 # taking NicoAPI.token
116 0 ▶sub request_mylist_page {
Subroutine request_mylist_page: not called CC=1 SCAR=6.9
Pod undocumented
117 0 my $self = shift;
118 0 require Net::NicoVideo::Response::MylistPage;
119 0 Net::NicoVideo::Response::MylistPage->new(
120 $self->request(Net::NicoVideo::Request->mylist_page));
121 }
122  
123 # taking NicoAPI.token to update Mylist, item_type and item_id for video_id
124 0 ▶sub request_mylist_item {
Subroutine request_mylist_item: not called CC=1 SCAR=6.9
Pod undocumented
125 0 my ($self, $video_id) = @_;
126 0 require Net::NicoVideo::Response::MylistItem;
127 0 Net::NicoVideo::Response::MylistItem->new(
128 $self->request(Net::NicoVideo::Request->mylist_item($video_id)));
129 }
130  
131 #-----------------------------------------------------------
132 # NicoAPI.MylistGroup
133 #
134  
135 # NicoAPI.MylistGroup #list
136 0 ▶sub request_mylistgroup_list {
Subroutine request_mylistgroup_list: not called CC=1 SCAR=6.9
Pod undocumented
137 0 my ($self) = @_;
138 0 require Net::NicoVideo::Response::NicoAPI;
139 0 Net::NicoVideo::Response::NicoAPI->new(
140 $self->request(Net::NicoVideo::Request->mylistgroup_list));
141 }
142  
143 # NicoAPI.MylistGroup #get
144 0 ▶sub request_mylistgroup_get {
Subroutine request_mylistgroup_get: not called CC=3 SCAR=24.8
Pod undocumented
145 0 my ($self, $group) = @_; # mylistgroup or group_id
146 0 ▶ $group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP));
Branch: 1 branch
BranchTrueFalseTotal
if ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP) 0 0 0
Condition0%0/3
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ref $group $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
Truth table0%0/3
A and B
A= ref $groupB= $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ABresult
0X0
100
111
147 0 require Net::NicoVideo::Response::NicoAPI;
148 0 Net::NicoVideo::Response::NicoAPI->new(
149 $self->request(Net::NicoVideo::Request->mylistgroup_get($group)));
150 }
151  
152 # NicoAPI.MylistGroup #add
153 0 ▶sub request_mylistgroup_add {
Subroutine request_mylistgroup_add: not called CC=1 SCAR=6.9
Pod undocumented
154 0 my ($self, $group, $token) = @_; # mylistgroup
155 0 require Net::NicoVideo::Response::NicoAPI;
156 0 Net::NicoVideo::Response::NicoAPI->new(
157 $self->request(Net::NicoVideo::Request->mylistgroup_add({
158 name => $group->name,
159 description => $group->description,
160 public => $group->public,
161 default_sort => $group->default_sort,
162 icon_id => $group->icon_id,
163 }, $token )));
164 }
165  
166 # NicoAPI.MylistGroup #update
167 0 ▶sub request_mylistgroup_update {
Subroutine request_mylistgroup_update: not called CC=1 SCAR=6.9
Pod undocumented
168 0 my ($self, $group, $token) = @_; # mylistgroup
169 0 require Net::NicoVideo::Response::NicoAPI;
170 0 Net::NicoVideo::Response::NicoAPI->new(
171 $self->request(Net::NicoVideo::Request->mylistgroup_update({
172 group_id => $group->id,
173 name => $group->name,
174 description => $group->description,
175 public => $group->public,
176 default_sort => $group->default_sort,
177 icon_id => $group->icon_id,
178 }, $token )));
179 }
180  
181 # NicoAPI.MylistGroup #remove
182 0 ▶sub request_mylistgroup_remove {
Subroutine request_mylistgroup_remove: not called CC=3 SCAR=24.8
Pod undocumented
183 0 my ($self, $group, $token) = @_; # mylistgroup or group_id
184 0 ▶ $group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP));
Branch: 1 branch
BranchTrueFalseTotal
if ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP) 0 0 0
Condition0%0/3
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ref $group $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
Truth table0%0/3
A and B
A= ref $groupB= $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ABresult
0X0
100
111
185 0 require Net::NicoVideo::Response::NicoAPI;
186 0 Net::NicoVideo::Response::NicoAPI->new(
187 $self->request(Net::NicoVideo::Request->mylistgroup_delete({
188 group_id => $group,
189 }, $token )));
190 }
191  
192 2 *request_mylistgroup_delete = *request_mylistgroup_remove;
193  
194 #-----------------------------------------------------------
195 # NicoAPI.Mylist
196 #
197  
198 # NicoAPI.Mylist #list
199 0 ▶sub request_mylist_list {
Subroutine request_mylist_list: not called CC=3 SCAR=24.8
Pod undocumented
200 0 my ($self, $group) = @_; # mylistgroup or group_id
201 0 ▶ $group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP));
Branch: 1 branch
BranchTrueFalseTotal
if ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP) 0 0 0
Condition0%0/3
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ref $group $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
Truth table0%0/3
A and B
A= ref $groupB= $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ABresult
0X0
100
111
202 0 require Net::NicoVideo::Response::NicoAPI;
203 0 Net::NicoVideo::Response::NicoAPI->new(
204 $self->request(Net::NicoVideo::Request->mylist_list($group)));
205 }
206  
207 # NicoAPI.Mylist #add
208 0 ▶sub request_mylist_add {
Subroutine request_mylist_add: not called CC=3 SCAR=24.8
Pod undocumented
209 0 my ($self, $group, $item, $token) = @_; # mylistgroup or group_id
210 0 ▶ $group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP));
Branch: 1 branch
BranchTrueFalseTotal
if ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP) 0 0 0
Condition0%0/3
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ref $group $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
Truth table0%0/3
A and B
A= ref $groupB= $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ABresult
0X0
100
111
211 0 require Net::NicoVideo::Response::NicoAPI;
212 0 Net::NicoVideo::Response::NicoAPI->new(
213 $self->request(Net::NicoVideo::Request->mylist_add({
214 group_id => $group,
215 item_type => $item->item_type,
216 item_id => $item->item_id,
217 description => $item->description,
218 }, $token )));
219 }
220  
221 # NicoAPI.Mylist #update
222 0 ▶sub request_mylist_update {
Subroutine request_mylist_update: not called CC=3 SCAR=24.8
Pod undocumented
223 0 my ($self, $group, $item, $token) = @_; # mylistgroup or group_id
224 0 ▶ $group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP));
Branch: 1 branch
BranchTrueFalseTotal
if ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP) 0 0 0
Condition0%0/3
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ref $group $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
Truth table0%0/3
A and B
A= ref $groupB= $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ABresult
0X0
100
111
225 0 require Net::NicoVideo::Response::NicoAPI;
226 0 Net::NicoVideo::Response::NicoAPI->new(
227 $self->request(Net::NicoVideo::Request->mylist_update({
228 group_id => $group,
229 item_type => $item->item_type,
230 item_id => $item->item_id,
231 description => $item->description,
232 }, $token )));
233 }
234  
235 # NicoAPI.Mylist #remove
236 0 ▶sub request_mylist_remove {
Subroutine request_mylist_remove: not called CC=1 SCAR=6.9
Pod undocumented
237 0 my $self = shift;
238 0 $self->request_mylist_remove_multi(@_);
239 }
240  
241 2 *request_mylist_delete = *request_mylist_remove;
242  
243 # NicoAPI.Mylist #removeMulti
244 0 ▶sub request_mylist_remove_multi {
Subroutine request_mylist_remove_multi: not called CC=3 SCAR=24.8
Pod undocumented
245 0 my ($self, $group, $item, $token) = @_; # mylistgroup or group_id
246 0 ▶ $group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP));
Branch: 1 branch
BranchTrueFalseTotal
if ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP) 0 0 0
Condition0%0/3
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ref $group $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
Truth table0%0/3
A and B
A= ref $groupB= $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ABresult
0X0
100
111
247 0 require Net::NicoVideo::Response::NicoAPI;
248 0 Net::NicoVideo::Response::NicoAPI->new(
249 $self->request(Net::NicoVideo::Request->mylist_delete({
250 group_id => $group,
251 item_type => $item->item_type,
252 item_id => $item->item_id,
253 }, $token )));
254 }
255  
256 2 *request_mylist_delete_multi = *request_mylist_remove_multi;
257  
258 # NicoAPI.Mylist #move
259 0 ▶sub request_mylist_move {
Subroutine request_mylist_move: not called CC=1 SCAR=6.9
Pod undocumented
260 0 my $self = shift;
261 0 $self->request_mylist_move_multi(@_);
262 }
263  
264 # NicoAPI.Mylist #moveMulti
265 0 ▶sub request_mylist_move_multi {
Subroutine request_mylist_move_multi: not called CC=5 SCAR=34.0
Pod undocumented
266 0 my ($self, $group, $target, $item, $token) = @_; # mylistgroup or group_id
267 0 ▶ $group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP));
Branch: 1 branch
BranchTrueFalseTotal
if ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP) 0 0 0
Condition0%0/3
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ref $group $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
Truth table0%0/3
A and B
A= ref $groupB= $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ABresult
0X0
100
111
268 0 ▶ $target = $target->id if( ref($target) and $target->isa($MOD_MYLISTGROUP));
Branch: 1 branch
BranchTrueFalseTotal
if ref $target and $target->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP) 0 0 0
Condition0%0/3
ref $target and $target->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $target and $target->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ref $target $target->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
Truth table0%0/3
A and B
A= ref $targetB= $target->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ABresult
0X0
100
111
269 0 require Net::NicoVideo::Response::NicoAPI;
270 0 Net::NicoVideo::Response::NicoAPI->new(
271 $self->request(Net::NicoVideo::Request->mylist_move({
272 group_id => $group,
273 target_group_id => $target,
274 item_type => $item->item_type,
275 item_id => $item->item_id,
276 }, $token )));
277 }
278  
279 # NicoAPI.Mylist #copy
280 0 ▶sub request_mylist_copy {
Subroutine request_mylist_copy: not called CC=1 SCAR=6.9
Pod undocumented
281 0 shift->request_mylist_copy_multi(@_);
282 }
283  
284 # NicoAPI.Mylist #copyMulti
285 0 ▶sub request_mylist_copy_multi {
Subroutine request_mylist_copy_multi: not called CC=5 SCAR=34.0
Pod undocumented
286 0 my ($self, $group, $target, $item, $token) = @_; # mylistgroup or group_id
287 0 ▶ $group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP));
Branch: 1 branch
BranchTrueFalseTotal
if ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP) 0 0 0
Condition0%0/3
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $group and $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ref $group $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
Truth table0%0/3
A and B
A= ref $groupB= $group->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ABresult
0X0
100
111
288 0 ▶ $target = $target->id if( ref($target) and $target->isa($MOD_MYLISTGROUP));
Branch: 1 branch
BranchTrueFalseTotal
if ref $target and $target->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP) 0 0 0
Condition0%0/3
ref $target and $target->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
!ll&&!rl&&r
000
MC/DC0%0/2
ref $target and $target->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ref $target $target->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
Truth table0%0/3
A and B
A= ref $targetB= $target->isa($Net::NicoVideo::UserAgent::MOD_MYLISTGROUP)
ABresult
0X0
100
111
289 0 require Net::NicoVideo::Response::NicoAPI;
290 0 Net::NicoVideo::Response::NicoAPI->new(
291 $self->request(Net::NicoVideo::Request->mylist_copy({
292 group_id => $group,
293 target_group_id => $target,
294 item_type => $item->item_type,
295 item_id => $item->item_id,
296 }, $token )));
297 }
298  
299 2 1;
300 __END__
« NicoVideo/Content/Flv.pm ↑ Summary NicoVideo/Content/MylistPage.pm »