line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::NicoVideo::UserAgent; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
99
|
|
4
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
81
|
|
5
|
2
|
|
|
2
|
|
11
|
use vars qw($VERSION); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
125
|
|
6
|
|
|
|
|
|
|
$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
|
|
|
2
|
|
12
|
use base qw(Net::NicoVideo::Decorator); |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
1129
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
2726
|
use HTTP::Cookies; |
|
2
|
|
|
|
|
27265
|
|
|
2
|
|
|
|
|
69
|
|
13
|
2
|
|
|
2
|
|
7075
|
use HTTP::Request::Common; |
|
2
|
|
|
|
|
7370
|
|
|
2
|
|
|
|
|
206
|
|
14
|
2
|
|
|
2
|
|
1885
|
use Net::NicoVideo::Request; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
79
|
|
15
|
2
|
|
|
2
|
|
1462
|
use Net::NicoVideo::Response; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
5108
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $MOD_MYLISTGROUP = 'Net::NicoVideo::Content::NicoAPI::MylistGroup'; |
18
|
|
|
|
|
|
|
our $MOD_FLV = 'Net::NicoVideo::Content::Flv'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
1
|
|
|
1
|
0
|
13
|
my ($class, $component, @opts) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# component accepts LWP::UserAgent |
24
|
1
|
|
|
|
|
13
|
$class->SUPER::new($component, @opts); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub login { |
28
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub request_login { |
38
|
0
|
|
|
0
|
0
|
|
my ($self, $email, $password) = @_; |
39
|
0
|
|
|
|
|
|
Net::NicoVideo::Response->new( |
40
|
|
|
|
|
|
|
$self->request(Net::NicoVideo::Request->login($email,$password))); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub request_get { |
44
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub request_thumbinfo { |
54
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub request_flv { |
61
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub request_watch { |
68
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub request_video { |
75
|
0
|
|
|
0
|
0
|
|
my ($self, $flv, @args) = @_; |
76
|
0
|
0
|
0
|
|
|
|
my $url = (ref($flv) and $flv->isa($MOD_FLV)) ? $flv->url : $flv; |
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
|
|
|
|
|
|
|
sub request_thread { |
83
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub request_tag_rss { |
94
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub request_mylist_rss { |
105
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub request_mylist_page { |
117
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub request_mylist_item { |
125
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub request_mylistgroup_list { |
137
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub request_mylistgroup_get { |
145
|
0
|
|
|
0
|
0
|
|
my ($self, $group) = @_; # mylistgroup or group_id |
146
|
0
|
0
|
0
|
|
|
|
$group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP)); |
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
|
|
|
|
|
|
|
sub request_mylistgroup_add { |
154
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub request_mylistgroup_update { |
168
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub request_mylistgroup_remove { |
183
|
0
|
|
|
0
|
0
|
|
my ($self, $group, $token) = @_; # mylistgroup or group_id |
184
|
0
|
0
|
0
|
|
|
|
$group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP)); |
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
|
|
|
|
|
|
|
*request_mylistgroup_delete = *request_mylistgroup_remove; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
#----------------------------------------------------------- |
195
|
|
|
|
|
|
|
# NicoAPI.Mylist |
196
|
|
|
|
|
|
|
# |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# NicoAPI.Mylist #list |
199
|
|
|
|
|
|
|
sub request_mylist_list { |
200
|
0
|
|
|
0
|
0
|
|
my ($self, $group) = @_; # mylistgroup or group_id |
201
|
0
|
0
|
0
|
|
|
|
$group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP)); |
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
|
|
|
|
|
|
|
sub request_mylist_add { |
209
|
0
|
|
|
0
|
0
|
|
my ($self, $group, $item, $token) = @_; # mylistgroup or group_id |
210
|
0
|
0
|
0
|
|
|
|
$group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP)); |
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
|
|
|
|
|
|
|
sub request_mylist_update { |
223
|
0
|
|
|
0
|
0
|
|
my ($self, $group, $item, $token) = @_; # mylistgroup or group_id |
224
|
0
|
0
|
0
|
|
|
|
$group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP)); |
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
|
|
|
|
|
|
|
sub request_mylist_remove { |
237
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
238
|
0
|
|
|
|
|
|
$self->request_mylist_remove_multi(@_); |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
*request_mylist_delete = *request_mylist_remove; |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
# NicoAPI.Mylist #removeMulti |
244
|
|
|
|
|
|
|
sub request_mylist_remove_multi { |
245
|
0
|
|
|
0
|
0
|
|
my ($self, $group, $item, $token) = @_; # mylistgroup or group_id |
246
|
0
|
0
|
0
|
|
|
|
$group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP)); |
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
|
|
|
|
|
|
|
*request_mylist_delete_multi = *request_mylist_remove_multi; |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
# NicoAPI.Mylist #move |
259
|
|
|
|
|
|
|
sub request_mylist_move { |
260
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
261
|
0
|
|
|
|
|
|
$self->request_mylist_move_multi(@_); |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
# NicoAPI.Mylist #moveMulti |
265
|
|
|
|
|
|
|
sub request_mylist_move_multi { |
266
|
0
|
|
|
0
|
0
|
|
my ($self, $group, $target, $item, $token) = @_; # mylistgroup or group_id |
267
|
0
|
0
|
0
|
|
|
|
$group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP)); |
268
|
0
|
0
|
0
|
|
|
|
$target = $target->id if( ref($target) and $target->isa($MOD_MYLISTGROUP)); |
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
|
|
|
|
|
|
|
sub request_mylist_copy { |
281
|
0
|
|
|
0
|
0
|
|
shift->request_mylist_copy_multi(@_); |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
# NicoAPI.Mylist #copyMulti |
285
|
|
|
|
|
|
|
sub request_mylist_copy_multi { |
286
|
0
|
|
|
0
|
0
|
|
my ($self, $group, $target, $item, $token) = @_; # mylistgroup or group_id |
287
|
0
|
0
|
0
|
|
|
|
$group = $group->id if( ref($group) and $group->isa($MOD_MYLISTGROUP)); |
288
|
0
|
0
|
0
|
|
|
|
$target = $target->id if( ref($target) and $target->isa($MOD_MYLISTGROUP)); |
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
|
|
|
|
|
|
|
1; |
300
|
|
|
|
|
|
|
__END__ |