line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::NicoVideo::Request; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
25052
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
116
|
|
4
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
102
|
|
5
|
3
|
|
|
3
|
|
173
|
use vars qw($VERSION); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
175
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.27'; |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
24
|
use base qw(HTTP::Request); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
1311
|
|
9
|
3
|
|
|
3
|
|
33040
|
use HTTP::Request::Common; |
|
3
|
|
|
|
|
2497
|
|
|
3
|
|
|
|
|
230
|
|
10
|
3
|
|
|
3
|
|
18
|
use Carp qw/croak/; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
164
|
|
11
|
3
|
|
|
3
|
|
145
|
use URI::Escape; |
|
3
|
|
|
|
|
30
|
|
|
3
|
|
|
|
|
11001
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub get { |
14
|
2
|
|
|
2
|
0
|
11565
|
my $class = shift; |
15
|
2
|
|
|
|
|
12
|
return GET @_; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub login { |
19
|
4
|
|
|
4
|
0
|
7876
|
my ($class, $email, $password) = @_; |
20
|
4
|
100
|
66
|
|
|
383
|
croak "missing mandatory parameter" |
21
|
|
|
|
|
|
|
if( ! defined $email or ! defined $password ); |
22
|
2
|
|
|
|
|
3
|
my $url = 'https://secure.nicovideo.jp/secure/login?site=niconico'; |
23
|
2
|
|
|
|
|
12
|
return POST $url, [ |
24
|
|
|
|
|
|
|
next_url => '', |
25
|
|
|
|
|
|
|
mail => $email, |
26
|
|
|
|
|
|
|
password => $password, |
27
|
|
|
|
|
|
|
]; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub thumbinfo { |
31
|
3
|
|
|
3
|
0
|
2057
|
my ($class, $video_id) = @_; |
32
|
3
|
100
|
|
|
|
231
|
croak "missing mandatory parameter" |
33
|
|
|
|
|
|
|
if( ! defined $video_id ); |
34
|
2
|
|
|
|
|
6
|
my $url = 'http://ext.nicovideo.jp/api/getthumbinfo/'.$video_id; |
35
|
2
|
|
|
|
|
9
|
return GET $url; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub flv { |
39
|
5
|
|
|
5
|
0
|
15241
|
my ($class, $video_id) = @_; |
40
|
5
|
100
|
|
|
|
305
|
croak "missing mandatory parameter" |
41
|
|
|
|
|
|
|
if( ! defined $video_id); |
42
|
4
|
|
|
|
|
9
|
my $url = 'http://flapi.nicovideo.jp/api/getflv/'.$video_id; |
43
|
4
|
100
|
|
|
|
20
|
my $params = $video_id =~ /^nm/ ? ['as3' => 1] : []; |
44
|
4
|
|
|
|
|
15
|
return POST $url, $params; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub watch { |
48
|
3
|
|
|
3
|
0
|
5267
|
my ($class, $video_id) = @_; |
49
|
3
|
100
|
|
|
|
194
|
croak "missing mandatory parameter" |
50
|
|
|
|
|
|
|
if( ! defined $video_id); |
51
|
2
|
|
|
|
|
6
|
my $url = 'http://www.nicovideo.jp/watch/'.$video_id; |
52
|
2
|
|
|
|
|
8
|
return GET $url; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub thread { |
56
|
6
|
|
|
6
|
0
|
9668
|
my ($class, $ms, $thread_id, $opts) = @_; |
57
|
6
|
100
|
66
|
|
|
397
|
croak "missing mandatory parameter" |
58
|
|
|
|
|
|
|
if( ! defined $ms or ! defined $thread_id ); |
59
|
4
|
|
50
|
|
|
12
|
$opts ||= {}; |
60
|
4
|
100
|
100
|
|
|
44
|
return POST $ms, |
61
|
|
|
|
|
|
|
Content => sprintf '', |
62
|
|
|
|
|
|
|
$thread_id, ($opts->{'chats'} || 250), ($opts->{'fork'} ? ' fork="1"' : ''); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub tag_rss { |
66
|
3
|
|
|
3
|
0
|
5480
|
my ($class, $keyword, $params) = @_; |
67
|
3
|
100
|
|
|
|
193
|
croak "missing mandatory parameter" |
68
|
|
|
|
|
|
|
if( ! defined $keyword ); |
69
|
2
|
|
50
|
|
|
6
|
$params ||= {}; |
70
|
2
|
|
|
|
|
6
|
$params->{rss} = '2.0'; |
71
|
2
|
|
|
|
|
3
|
my @q = (); |
72
|
2
|
|
|
|
|
3
|
for my $k ( sort keys %{$params} ){ |
|
2
|
|
|
|
|
15
|
|
73
|
4
|
|
|
|
|
352
|
my $v = $params->{$k}; |
74
|
4
|
50
|
|
|
|
11
|
$v = '' unless( defined $v ); |
75
|
4
|
|
|
|
|
19
|
push @q, sprintf('%s=%s', uri_escape_utf8($k), uri_escape_utf8($v)); |
76
|
|
|
|
|
|
|
} |
77
|
2
|
|
|
|
|
50
|
my $url = sprintf 'http://www.nicovideo.jp/tag/%s', uri_escape_utf8($keyword); |
78
|
2
|
50
|
|
|
|
165
|
$url = sprintf('%s?%s', $url, join('&', @q)) if( @q ); |
79
|
2
|
|
|
|
|
8
|
return GET $url; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub mylist_rss { |
83
|
3
|
|
|
3
|
0
|
2604
|
my ($class, $mylist_id) = @_; |
84
|
3
|
100
|
|
|
|
156
|
croak "missing mandatory parameter" |
85
|
|
|
|
|
|
|
if( ! defined $mylist_id ); |
86
|
2
|
|
|
|
|
6
|
my $url = 'http://www.nicovideo.jp/mylist/'.$mylist_id.'?rss=2.0'; |
87
|
2
|
|
|
|
|
8
|
return GET $url; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub mylist_page { |
91
|
2
|
|
|
2
|
0
|
1575
|
my ($class) = @_; |
92
|
2
|
|
|
|
|
8
|
return GET 'http://www.nicovideo.jp/my/mylist'; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub mylist_item { |
96
|
3
|
|
|
3
|
0
|
3391
|
my ($class, $video_id) = @_; |
97
|
3
|
100
|
|
|
|
162
|
croak "missing mandatory parameter" |
98
|
|
|
|
|
|
|
if( ! defined $video_id ); |
99
|
2
|
|
|
|
|
5
|
my $url = 'http://www.nicovideo.jp/mylist_add/video/'.$video_id; |
100
|
2
|
|
|
|
|
7
|
return GET $url; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub mylistgroup_list { |
104
|
2
|
|
|
2
|
0
|
3212
|
my ($class) = @_; |
105
|
2
|
|
|
|
|
7
|
return POST 'http://www.nicovideo.jp/api/mylistgroup/list'; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub mylistgroup_get { |
109
|
3
|
|
|
3
|
0
|
8595
|
my ($class, $mylist_id) = @_; |
110
|
3
|
100
|
|
|
|
218
|
croak "missing mandatory parameter" |
111
|
|
|
|
|
|
|
if( ! defined $mylist_id ); |
112
|
2
|
|
|
|
|
5
|
my $params = [ group_id => $mylist_id ]; |
113
|
2
|
|
|
|
|
8
|
return POST 'http://www.nicovideo.jp/api/mylistgroup/get', $params; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub mylistgroup_add { |
117
|
2
|
|
|
2
|
0
|
3643
|
my ($class, $params, $token) = @_; |
118
|
2
|
|
50
|
|
|
8
|
$params ||= {}; |
119
|
2
|
|
|
|
|
16
|
return POST 'http://www.nicovideo.jp/api/mylistgroup/add', [ |
120
|
|
|
|
|
|
|
token => $token, |
121
|
|
|
|
|
|
|
name => $params->{name}, |
122
|
|
|
|
|
|
|
description => $params->{description}, |
123
|
|
|
|
|
|
|
public => $params->{public}, |
124
|
|
|
|
|
|
|
default_sort=> $params->{default_sort}, |
125
|
|
|
|
|
|
|
icon_id => $params->{icon_id}, |
126
|
|
|
|
|
|
|
]; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub mylistgroup_update { |
130
|
2
|
|
|
2
|
0
|
6189
|
my ($class, $params, $token) = @_; |
131
|
2
|
|
50
|
|
|
8
|
$params ||= {}; |
132
|
2
|
|
|
|
|
19
|
return POST 'http://www.nicovideo.jp/api/mylistgroup/update', [ |
133
|
|
|
|
|
|
|
token => $token, |
134
|
|
|
|
|
|
|
group_id => $params->{group_id}, |
135
|
|
|
|
|
|
|
name => $params->{name}, |
136
|
|
|
|
|
|
|
description => $params->{description}, |
137
|
|
|
|
|
|
|
public => $params->{public}, |
138
|
|
|
|
|
|
|
default_sort=> $params->{default_sort}, |
139
|
|
|
|
|
|
|
icon_id => $params->{icon_id}, |
140
|
|
|
|
|
|
|
]; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub mylistgroup_delete { |
144
|
2
|
|
|
2
|
0
|
6126
|
my ($class, $params, $token) = @_; |
145
|
2
|
|
50
|
|
|
12
|
$params ||= {}; |
146
|
2
|
|
|
|
|
13
|
return POST 'http://www.nicovideo.jp/api/mylistgroup/delete', [ |
147
|
|
|
|
|
|
|
token => $token, |
148
|
|
|
|
|
|
|
group_id => $params->{group_id}, |
149
|
|
|
|
|
|
|
]; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub mylist_list { |
153
|
3
|
|
|
3
|
0
|
14561
|
my ($class, $group_id) = @_; |
154
|
3
|
100
|
|
|
|
229
|
croak "missing mandatory parameter" |
155
|
|
|
|
|
|
|
if( ! defined $group_id ); |
156
|
2
|
|
|
|
|
5
|
my $params = [ group_id => $group_id ]; |
157
|
2
|
|
|
|
|
9
|
return POST 'http://www.nicovideo.jp/api/mylist/list', $params; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub mylist_add { |
161
|
2
|
|
|
2
|
0
|
3459
|
my ($class, $params, $token) = @_; |
162
|
2
|
|
50
|
|
|
8
|
$params ||= {}; |
163
|
2
|
|
|
|
|
17
|
return POST 'http://www.nicovideo.jp/api/mylist/add', [ |
164
|
|
|
|
|
|
|
token => $token, |
165
|
|
|
|
|
|
|
group_id => $params->{group_id}, |
166
|
|
|
|
|
|
|
item_type => $params->{item_type}, |
167
|
|
|
|
|
|
|
item_id => $params->{item_id}, |
168
|
|
|
|
|
|
|
description => $params->{description}, |
169
|
|
|
|
|
|
|
]; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub mylist_update { |
173
|
2
|
|
|
2
|
0
|
6341
|
my ($class, $params, $token) = @_; |
174
|
2
|
|
50
|
|
|
8
|
$params ||= {}; |
175
|
2
|
|
|
|
|
15
|
return POST 'http://www.nicovideo.jp/api/mylist/update', [ |
176
|
|
|
|
|
|
|
token => $token, |
177
|
|
|
|
|
|
|
group_id => $params->{group_id}, |
178
|
|
|
|
|
|
|
item_type => $params->{item_type}, |
179
|
|
|
|
|
|
|
item_id => $params->{item_id}, |
180
|
|
|
|
|
|
|
description => $params->{description}, |
181
|
|
|
|
|
|
|
]; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub mylist_delete { |
185
|
2
|
|
|
2
|
0
|
6113
|
my ($class, $params, $token) = @_; |
186
|
2
|
|
50
|
|
|
8
|
$params ||= {}; |
187
|
2
|
|
|
|
|
9
|
my @args = $class->make_id_list($params->{item_type}, $params->{item_id}); |
188
|
2
|
|
|
|
|
7
|
push @args, ( |
189
|
|
|
|
|
|
|
token => $token, |
190
|
|
|
|
|
|
|
group_id => $params->{group_id}, |
191
|
|
|
|
|
|
|
); |
192
|
2
|
|
|
|
|
8
|
return POST 'http://www.nicovideo.jp/api/mylist/delete', \@args; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub mylist_move { |
196
|
2
|
|
|
2
|
0
|
8362
|
my ($class, $params, $token) = @_; |
197
|
2
|
|
50
|
|
|
13
|
$params ||= {}; |
198
|
2
|
|
|
|
|
13
|
my @args = $class->make_id_list($params->{item_type}, $params->{item_id}); |
199
|
2
|
|
|
|
|
12
|
push @args, ( |
200
|
|
|
|
|
|
|
token => $token, |
201
|
|
|
|
|
|
|
group_id => $params->{group_id}, |
202
|
|
|
|
|
|
|
target_group_id => $params->{target_group_id}, |
203
|
|
|
|
|
|
|
); |
204
|
2
|
|
|
|
|
18
|
return POST 'http://www.nicovideo.jp/api/mylist/move', \@args; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub mylist_copy { |
208
|
2
|
|
|
2
|
0
|
10337
|
my ($class, $params, $token) = @_; |
209
|
2
|
|
50
|
|
|
10
|
$params ||= {}; |
210
|
2
|
|
|
|
|
12
|
my @args = $class->make_id_list($params->{item_type}, $params->{item_id}); |
211
|
2
|
|
|
|
|
11
|
push @args, ( |
212
|
|
|
|
|
|
|
token => $token, |
213
|
|
|
|
|
|
|
group_id => $params->{group_id}, |
214
|
|
|
|
|
|
|
target_group_id => $params->{target_group_id}, |
215
|
|
|
|
|
|
|
); |
216
|
2
|
|
|
|
|
13
|
return POST 'http://www.nicovideo.jp/api/mylist/copy', \@args; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub make_id_list { |
220
|
12
|
|
|
12
|
0
|
8316
|
my ($class, $item_type, $item_id) = @_; |
221
|
12
|
100
|
66
|
|
|
1098
|
croak "missing mandatory parameter" |
222
|
|
|
|
|
|
|
if( ! defined $item_type or ! defined $item_id ); |
223
|
10
|
|
|
|
|
40
|
my @id_list = ('id_list['.$item_type.'][]' => $item_id); |
224
|
10
|
100
|
|
|
|
46
|
return wantarray ? @id_list : \@id_list; |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
1; |
228
|
|
|
|
|
|
|
__END__ |