line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::NicoVideo; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
44587
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
85
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
70
|
|
5
|
2
|
|
|
2
|
|
11
|
use vars qw($VERSION); |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
127
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.28'; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
11
|
use base qw(Class::Accessor::Fast); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
2709
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
12776
|
use Carp qw(croak); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
165
|
|
11
|
2
|
|
|
2
|
|
13116
|
use LWP::UserAgent; |
|
2
|
|
|
|
|
204065
|
|
|
2
|
|
|
|
|
74
|
|
12
|
2
|
|
|
2
|
|
1683
|
use Net::NicoVideo::UserAgent; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
83
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
20
|
use vars qw($DELAY_DEFAULT $MSG_LOGIN_FAILED); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
8354
|
|
15
|
|
|
|
|
|
|
$DELAY_DEFAULT = 1; |
16
|
|
|
|
|
|
|
$MSG_LOGIN_FAILED = "Cannot login because specified account information may be invalid"; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw( |
19
|
|
|
|
|
|
|
user_agent |
20
|
|
|
|
|
|
|
email |
21
|
|
|
|
|
|
|
password |
22
|
|
|
|
|
|
|
delay |
23
|
|
|
|
|
|
|
)); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub get_user_agent { |
26
|
1
|
|
|
1
|
1
|
9221
|
my $self = shift; |
27
|
1
|
50
|
|
|
|
7
|
$self->user_agent(LWP::UserAgent->new) |
28
|
|
|
|
|
|
|
unless( $self->user_agent ); |
29
|
1
|
|
|
|
|
248
|
Net::NicoVideo::UserAgent->new($self->user_agent); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub get_email { |
33
|
2
|
|
|
2
|
1
|
704
|
my $self = shift; |
34
|
2
|
50
|
|
|
|
8
|
return defined $self->email ? $self->email : $ENV{NET_NICOVIDEO_EMAIL}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub get_password { |
38
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; |
39
|
2
|
50
|
|
|
|
8
|
return defined $self->password ? $self->password : $ENV{NET_NICOVIDEO_PASSWORD}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub get_delay { |
43
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
44
|
0
|
0
|
|
|
|
|
if( defined $self->delay ){ |
|
|
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
|
|
|
|
|
|
|
sub through_login { |
54
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
55
|
0
|
|
|
|
|
|
my $ua = shift; |
56
|
0
|
|
|
|
|
|
my $res = $ua->request_login($self->get_email, $self->get_password); |
57
|
0
|
0
|
|
|
|
|
croak "Request 'request_login' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
if( $res->is_error ); |
59
|
0
|
|
|
|
|
|
$ua->login( $res ); # this returns $ua |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub download { |
63
|
0
|
|
|
0
|
1
|
|
my ($self, $video_id, @args) = @_; |
64
|
0
|
|
|
|
|
|
$self->fetch_watch($video_id); |
65
|
0
|
0
|
|
|
|
|
my $delay = defined($self->delay) ? $self->delay : $DELAY_DEFAULT; |
66
|
0
|
0
|
|
|
|
|
sleep $delay if( $delay ); |
67
|
0
|
|
|
|
|
|
$self->fetch_video($self->fetch_flv($video_id), @args); |
68
|
0
|
|
|
|
|
|
return $self; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#----------------------------------------------------------- |
72
|
|
|
|
|
|
|
# fetch |
73
|
|
|
|
|
|
|
# |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub fetch_thumbinfo { |
76
|
0
|
|
|
0
|
1
|
|
my ($self, $video_id) = @_; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my $res = $self->get_user_agent->request_thumbinfo($video_id); |
79
|
0
|
0
|
|
|
|
|
croak "Request 'request_thumbinfo' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
if( $res->is_error ); |
81
|
0
|
|
|
|
|
|
my $parsed_content = $res->parsed_content; |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
croak "Invalid content as @{[ ref($parsed_content) ]}" |
|
0
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
if( $parsed_content->is_error ); |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
return $parsed_content; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub fetch_flv { |
90
|
0
|
|
|
0
|
1
|
|
my ($self, $video_id) = @_; |
91
|
0
|
|
|
|
|
|
my $ua = $self->get_user_agent; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# workaround |
94
|
0
|
0
|
0
|
|
|
|
if( $video_id and $video_id =~ /^so\d+$/ ){ |
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
|
0
|
|
|
|
|
croak "Request 'request_flv' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
if( $res->is_error ); |
102
|
|
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
|
unless( $res->is_authflagged ){ |
104
|
|
|
|
|
|
|
# try again |
105
|
0
|
|
|
|
|
|
$res = $self->through_login($ua)->request_flv($video_id); |
106
|
0
|
0
|
|
|
|
|
croak "Request 'request_flv' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
if( $res->is_error ); |
108
|
0
|
0
|
|
|
|
|
croak $MSG_LOGIN_FAILED |
109
|
|
|
|
|
|
|
unless( $res->is_authflagged ); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
my $parsed_content = $res->parsed_content; |
113
|
0
|
0
|
|
|
|
|
croak "Invalid content as @{[ ref($parsed_content) ]}" |
|
0
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
if( $parsed_content->is_error ); |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
return $parsed_content; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub fetch_watch { |
120
|
0
|
|
|
0
|
1
|
|
my ($self, $video_id) = @_; |
121
|
0
|
|
|
|
|
|
my $ua = $self->get_user_agent; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
my $res = $ua->request_watch($video_id); |
124
|
0
|
0
|
|
|
|
|
croak "Request 'request_watch' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
if( $res->is_error ); |
126
|
|
|
|
|
|
|
|
127
|
0
|
0
|
|
|
|
|
unless( $res->is_authflagged ){ |
128
|
|
|
|
|
|
|
# try again |
129
|
0
|
|
|
|
|
|
$res = $self->through_login($ua)->request_watch($video_id); |
130
|
0
|
0
|
|
|
|
|
croak "Request 'request_watch' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
if( $res->is_error ); |
132
|
0
|
0
|
|
|
|
|
croak $MSG_LOGIN_FAILED |
133
|
|
|
|
|
|
|
unless( $res->is_authflagged ); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
my $parsed_content = $res->parsed_content; |
137
|
0
|
0
|
|
|
|
|
croak "Invalid content as @{[ ref($parsed_content) ]}" |
|
0
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
if( $parsed_content->is_error ); |
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
return $parsed_content; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub fetch_video { |
144
|
|
|
|
|
|
|
# $something accepts flv, url ( via flv->url ) or video_id |
145
|
0
|
|
|
0
|
1
|
|
my ($self, $something, @args) = @_; |
146
|
0
|
0
|
0
|
|
|
|
if( $something and ! ref($something) and $something !~ m{^https?://} ){ |
|
|
|
0
|
|
|
|
|
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
|
0
|
|
|
|
|
croak "Request 'fetch_video' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
if( $res->is_error ); |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
my $parsed_content = $res->parsed_content; |
155
|
0
|
0
|
|
|
|
|
croak "Invalid content as @{[ ref($parsed_content) ]}" |
|
0
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
if( $parsed_content->is_error ); |
157
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
return $parsed_content; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub fetch_thread { |
162
|
|
|
|
|
|
|
# $something accepts flv, or video_id |
163
|
0
|
|
|
0
|
1
|
|
my ($self, $something, $opts) = @_; |
164
|
0
|
0
|
0
|
|
|
|
if( $something and ! ref($something) ){ |
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
|
0
|
|
|
|
|
croak "Request 'fetch_thread' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
if( $res->is_error ); |
171
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
my $parsed_content = $res->parsed_content; |
173
|
0
|
0
|
|
|
|
|
croak "Invalid content as @{[ ref($parsed_content) ]}" |
|
0
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
if( $parsed_content->is_error ); |
175
|
|
|
|
|
|
|
|
176
|
0
|
|
|
|
|
|
return $parsed_content; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
#----------------------------------------------------------- |
180
|
|
|
|
|
|
|
# Tag RSS |
181
|
|
|
|
|
|
|
# |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub fetch_tag_rss { |
184
|
0
|
|
|
0
|
1
|
|
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
|
0
|
|
|
|
|
croak "Request 'request_tag_rss' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
if( $res->is_error ); |
190
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
my $parsed_content = $res->parsed_content; |
192
|
0
|
0
|
|
|
|
|
croak "Invalid content as @{[ ref($parsed_content) ]}" |
|
0
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
if( $parsed_content->is_error ); |
194
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
return $parsed_content; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub fetch_tag_rss_by_recent_post { # shortcut |
199
|
0
|
|
|
0
|
1
|
|
my ($self, $keyword, $page) = @_; |
200
|
0
|
|
0
|
|
|
|
$page ||= 1; |
201
|
0
|
|
|
|
|
|
$self->fetch_tag_rss($keyword, {'sort' => 'f', page => $page}); |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
#----------------------------------------------------------- |
205
|
|
|
|
|
|
|
# Mylist RSS |
206
|
|
|
|
|
|
|
# |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub fetch_mylist_rss { |
209
|
0
|
|
|
0
|
1
|
|
my ($self, $mylist) = @_; |
210
|
0
|
|
|
|
|
|
my $ua = $self->get_user_agent; |
211
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
|
my $res = $ua->request_mylist_rss($mylist); |
213
|
0
|
0
|
0
|
|
|
|
croak "Request 'request_mylist_rss' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
if( $res->is_error and $res->code ne '403' ); |
215
|
0
|
|
|
|
|
|
my $parsed_content = $res->parsed_content; |
216
|
|
|
|
|
|
|
|
217
|
0
|
0
|
0
|
|
|
|
if( ( ! $res->is_authflagged or $parsed_content->is_closed ) |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
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
|
0
|
0
|
|
|
|
croak "Request 'request_mylist_rss' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
if( $res->is_error and $res->code ne '403' ); |
225
|
0
|
0
|
|
|
|
|
croak $MSG_LOGIN_FAILED |
226
|
|
|
|
|
|
|
unless( $res->is_authflagged ); |
227
|
0
|
|
|
|
|
|
$parsed_content = $res->parsed_content; |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
0
|
0
|
|
|
|
|
croak "Invalid content as @{[ ref($parsed_content) ]}" |
|
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
|
|
|
|
|
|
|
sub fetch_mylist_page { |
242
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
243
|
0
|
|
|
|
|
|
my $ua = $self->get_user_agent; |
244
|
|
|
|
|
|
|
|
245
|
0
|
|
|
|
|
|
my $res = $ua->request_mylist_page; |
246
|
0
|
0
|
|
|
|
|
croak "Request 'request_mylist_page' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
if( $res->is_error ); |
248
|
|
|
|
|
|
|
|
249
|
0
|
0
|
|
|
|
|
unless( $res->is_authflagged ){ |
250
|
|
|
|
|
|
|
# try again |
251
|
0
|
|
|
|
|
|
$res = $self->through_login($ua)->request_mylist_page; |
252
|
0
|
0
|
|
|
|
|
croak $MSG_LOGIN_FAILED |
253
|
|
|
|
|
|
|
unless( $res->is_authflagged ); |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
0
|
|
|
|
|
|
my $parsed_content = $res->parsed_content; |
257
|
0
|
0
|
|
|
|
|
croak "Invalid content as @{[ ref($parsed_content) ]}" |
|
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
|
|
|
|
|
|
|
sub fetch_mylist_item { |
265
|
0
|
|
|
0
|
1
|
|
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
|
0
|
|
|
|
|
croak "Request 'request_mylist_item' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
if( $res->is_error ); |
271
|
|
|
|
|
|
|
|
272
|
0
|
0
|
|
|
|
|
unless( $res->is_authflagged ){ |
273
|
|
|
|
|
|
|
# try again |
274
|
0
|
|
|
|
|
|
$res = $self->through_login($ua)->request_mylist_item($video_id); |
275
|
0
|
0
|
|
|
|
|
croak "Request 'request_mylist_item' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
if( $res->is_error ); |
277
|
0
|
0
|
|
|
|
|
croak $MSG_LOGIN_FAILED |
278
|
|
|
|
|
|
|
unless( $res->is_authflagged ); |
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
|
281
|
0
|
|
|
|
|
|
my $parsed_content = $res->parsed_content; |
282
|
0
|
0
|
|
|
|
|
croak "Invalid content as @{[ ref($parsed_content) ]}" |
|
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
|
|
|
|
|
|
|
sub list_mylistgroup { |
294
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
295
|
0
|
|
|
|
|
|
my $ua = $self->get_user_agent; |
296
|
|
|
|
|
|
|
|
297
|
0
|
|
|
|
|
|
my $res = $ua->request_mylistgroup_list; |
298
|
0
|
0
|
|
|
|
|
croak "Request 'request_mylistgroup_list' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
if( $res->is_error ); |
300
|
|
|
|
|
|
|
|
301
|
0
|
|
|
|
|
|
my $parsed_content = $res->parsed_content; |
302
|
|
|
|
|
|
|
|
303
|
0
|
0
|
|
|
|
|
unless( $parsed_content->is_success ){ |
304
|
0
|
0
|
|
|
|
|
if( $parsed_content->is_error_noauth ){ |
305
|
|
|
|
|
|
|
# try again |
306
|
0
|
|
|
|
|
|
$res = $self->through_login($ua)->request_mylistgroup_list; |
307
|
0
|
0
|
|
|
|
|
croak "Request 'request_mylistgroup_list' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
if( $res->is_error ); |
309
|
0
|
|
|
|
|
|
$parsed_content = $res->parsed_content; |
310
|
0
|
0
|
|
|
|
|
unless( $parsed_content->is_success ){ |
311
|
0
|
0
|
|
|
|
|
croak $MSG_LOGIN_FAILED if( $parsed_content->is_error_noauth ); |
312
|
0
|
|
|
|
|
|
croak "Invalid content as @{[ ref($parsed_content) ]}"; |
|
0
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
} |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
0
|
|
|
|
|
|
return $parsed_content; |
318
|
|
|
|
|
|
|
} |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
# NicoAPI.MylistGroup #get |
321
|
|
|
|
|
|
|
sub get_mylistgroup { |
322
|
0
|
|
|
0
|
1
|
|
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
|
0
|
|
|
|
|
croak "Request 'request_mylistgroup_get' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
if( $res->is_error ); |
328
|
|
|
|
|
|
|
|
329
|
0
|
|
|
|
|
|
my $parsed_content = $res->parsed_content; |
330
|
|
|
|
|
|
|
|
331
|
0
|
0
|
|
|
|
|
unless( $parsed_content->is_success ){ |
332
|
0
|
0
|
|
|
|
|
if( $parsed_content->is_error_noauth ){ |
333
|
|
|
|
|
|
|
# try again |
334
|
0
|
|
|
|
|
|
$res = $self->through_login($ua)->request_mylistgroup_get($group_id); |
335
|
0
|
0
|
|
|
|
|
croak "Request 'request_mylistgroup_get' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
if( $res->is_error ); |
337
|
0
|
|
|
|
|
|
$parsed_content = $res->parsed_content; |
338
|
0
|
0
|
|
|
|
|
unless( $parsed_content->is_success ){ |
339
|
0
|
0
|
|
|
|
|
croak $MSG_LOGIN_FAILED if( $parsed_content->is_error_noauth ); |
340
|
0
|
|
|
|
|
|
croak "Invalid content as @{[ ref($parsed_content) ]}"; |
|
0
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
} |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
|
345
|
0
|
|
|
|
|
|
return $parsed_content; |
346
|
|
|
|
|
|
|
} |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
# NicoAPI.MylistGroup #add |
349
|
|
|
|
|
|
|
sub add_mylistgroup { |
350
|
0
|
|
|
0
|
1
|
|
my ($self, $mylist, $token) = @_; |
351
|
0
|
|
|
|
|
|
my $ua = $self->get_user_agent; |
352
|
0
|
0
|
|
|
|
|
$token = $self->fetch_mylist_page->token |
353
|
|
|
|
|
|
|
unless( $token ); |
354
|
0
|
|
|
|
|
|
my $res = $ua->request_mylistgroup_add($mylist, $token); |
355
|
0
|
0
|
|
|
|
|
croak "Request 'request_mylistgroup_add' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
if( $res->is_error ); |
357
|
0
|
|
|
|
|
|
return $res->parsed_content; |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
# NicoAPI.MylistGroup #update |
361
|
|
|
|
|
|
|
sub update_mylistgroup { |
362
|
0
|
|
|
0
|
1
|
|
my ($self, $mylist, $token) = @_; |
363
|
0
|
|
|
|
|
|
my $ua = $self->get_user_agent; |
364
|
0
|
0
|
|
|
|
|
$token = $self->fetch_mylist_page->token |
365
|
|
|
|
|
|
|
unless( $token ); |
366
|
0
|
|
|
|
|
|
my $res = $ua->request_mylistgroup_update($mylist, $token); |
367
|
0
|
0
|
|
|
|
|
croak "Request 'request_mylistgroup_update' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
if( $res->is_error ); |
369
|
0
|
|
|
|
|
|
return $res->parsed_content; |
370
|
|
|
|
|
|
|
} |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
# NicoAPI.MylistGroup #remove |
373
|
|
|
|
|
|
|
sub remove_mylistgroup { |
374
|
0
|
|
|
0
|
1
|
|
my ($self, $mylist, $token) = @_; |
375
|
0
|
|
|
|
|
|
my $ua = $self->get_user_agent; |
376
|
0
|
0
|
|
|
|
|
$token = $self->fetch_mylist_page->token |
377
|
|
|
|
|
|
|
unless( $token ); |
378
|
0
|
|
|
|
|
|
my $res = $ua->request_mylistgroup_delete($mylist, $token); |
379
|
0
|
0
|
|
|
|
|
croak "Request 'request_mylistgroup_delete' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
if( $res->is_error ); |
381
|
0
|
|
|
|
|
|
return $res->parsed_content; |
382
|
|
|
|
|
|
|
} |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
*delete_mylistgroup = *remove_mylistgroup; |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
#----------------------------------------------------------- |
387
|
|
|
|
|
|
|
# NicoAPI.Mylist |
388
|
|
|
|
|
|
|
# |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
# NicoAPI.Mylist #list |
391
|
|
|
|
|
|
|
sub list_mylist { |
392
|
0
|
|
|
0
|
1
|
|
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
|
0
|
|
|
|
|
croak "Request 'request_mylist_list' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
if( $res->is_error ); |
398
|
0
|
|
|
|
|
|
my $parsed_content = $res->parsed_content; |
399
|
|
|
|
|
|
|
|
400
|
0
|
0
|
|
|
|
|
unless( $parsed_content->is_success ){ |
401
|
0
|
0
|
|
|
|
|
if( $parsed_content->is_error_noauth ){ |
402
|
|
|
|
|
|
|
# try again |
403
|
0
|
|
|
|
|
|
$res = $self->through_login($ua)->request_mylist_list($group); |
404
|
0
|
0
|
|
|
|
|
croak "Request 'request_mylist_list' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
if( $res->is_error ); |
406
|
0
|
|
|
|
|
|
$parsed_content = $res->parsed_content; |
407
|
|
|
|
|
|
|
|
408
|
0
|
0
|
|
|
|
|
unless( $parsed_content->is_success ){ |
409
|
0
|
0
|
|
|
|
|
croak $MSG_LOGIN_FAILED if( $parsed_content->is_error_noauth ); |
410
|
0
|
|
|
|
|
|
croak "Invalid content as @{[ ref($parsed_content) ]}"; |
|
0
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
} |
412
|
|
|
|
|
|
|
} |
413
|
|
|
|
|
|
|
} |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
# it returns Net::NicoVideo::Content::NicoAPI::MylistItem |
416
|
0
|
|
|
|
|
|
return $parsed_content; |
417
|
|
|
|
|
|
|
} |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
# NicoAPI.Mylist #add |
420
|
|
|
|
|
|
|
sub add_mylist { |
421
|
0
|
|
|
0
|
1
|
|
my ($self, $group, $item, $token) = @_; |
422
|
0
|
|
|
|
|
|
my $ua = $self->get_user_agent; |
423
|
0
|
0
|
|
|
|
|
$token = $self->fetch_mylist_page->token |
424
|
|
|
|
|
|
|
unless( $token ); |
425
|
0
|
|
|
|
|
|
my $res = $ua->request_mylist_add($group, $item, $token); |
426
|
0
|
0
|
|
|
|
|
croak "Request 'request_mylist_add' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
if( $res->is_error ); |
428
|
0
|
|
|
|
|
|
return $res->parsed_content; |
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
# NicoAPI.Mylist #update |
432
|
|
|
|
|
|
|
sub update_mylist { |
433
|
0
|
|
|
0
|
1
|
|
my ($self, $group, $item, $token) = @_; |
434
|
0
|
|
|
|
|
|
my $ua = $self->get_user_agent; |
435
|
0
|
0
|
|
|
|
|
$token = $self->fetch_mylist_page->token |
436
|
|
|
|
|
|
|
unless( $token ); |
437
|
0
|
|
|
|
|
|
my $res = $ua->request_mylist_update($group, $item, $token); |
438
|
0
|
0
|
|
|
|
|
croak "Request 'request_mylist_update' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
if( $res->is_error ); |
440
|
0
|
|
|
|
|
|
return $res->parsed_content; |
441
|
|
|
|
|
|
|
} |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
# NicoAPI.Mylist #remove |
444
|
|
|
|
|
|
|
sub remove_mylist { |
445
|
0
|
|
|
0
|
1
|
|
my ($self, $group, $item, $token) = @_; |
446
|
0
|
|
|
|
|
|
my $ua = $self->get_user_agent; |
447
|
0
|
0
|
|
|
|
|
$token = $self->fetch_mylist_page->token |
448
|
|
|
|
|
|
|
unless( $token ); |
449
|
0
|
|
|
|
|
|
my $res = $ua->request_mylist_remove($group, $item, $token); |
450
|
0
|
0
|
|
|
|
|
croak "Request 'request_mylist_remove' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
if( $res->is_error ); |
452
|
0
|
|
|
|
|
|
return $res->parsed_content; |
453
|
|
|
|
|
|
|
} |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
*delete_mylist = *remove_mylist; |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
# NicoAPI.Mylist #move |
458
|
|
|
|
|
|
|
sub move_mylist { |
459
|
0
|
|
|
0
|
1
|
|
my ($self, $group, $target, $item, $token) = @_; |
460
|
0
|
|
|
|
|
|
my $ua = $self->get_user_agent; |
461
|
0
|
0
|
|
|
|
|
$token = $self->fetch_mylist_page->token |
462
|
|
|
|
|
|
|
unless( $token ); |
463
|
0
|
|
|
|
|
|
my $res = $ua->request_mylist_move($group, $target, $item, $token); |
464
|
0
|
0
|
|
|
|
|
croak "Request 'request_mylist_move' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
if( $res->is_error ); |
466
|
0
|
|
|
|
|
|
return $res->parsed_content; |
467
|
|
|
|
|
|
|
} |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
# NicoAPI.Mylist #copy |
470
|
|
|
|
|
|
|
sub copy_mylist { |
471
|
0
|
|
|
0
|
1
|
|
my ($self, $group, $target, $item, $token) = @_; |
472
|
0
|
|
|
|
|
|
my $ua = $self->get_user_agent; |
473
|
0
|
0
|
|
|
|
|
$token = $self->fetch_mylist_page->token |
474
|
|
|
|
|
|
|
unless( $token ); |
475
|
0
|
|
|
|
|
|
my $res = $ua->request_mylist_copy($group, $target, $item, $token); |
476
|
0
|
0
|
|
|
|
|
croak "Request 'request_mylist_copy' is error: @{[ $res->status_line ]}" |
|
0
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
if( $res->is_error ); |
478
|
0
|
|
|
|
|
|
return $res->parsed_content; |
479
|
|
|
|
|
|
|
} |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
1; |
482
|
|
|
|
|
|
|
__END__ |