line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Viddler; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
20881
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
900
|
use HTTP::Request::Common; |
|
1
|
|
|
|
|
30098
|
|
|
1
|
|
|
|
|
84
|
|
7
|
1
|
|
|
1
|
|
206790
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
102629
|
|
|
1
|
|
|
|
|
37
|
|
8
|
1
|
|
|
1
|
|
1033
|
use LWP::Simple; |
|
1
|
|
|
|
|
73686
|
|
|
1
|
|
|
|
|
11
|
|
9
|
1
|
|
|
1
|
|
1065
|
use XML::Simple; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
WebService::Viddler - An encapsulation of the Viddler video platform in Perl |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 0.10 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = "0.10"; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
### To Do |
24
|
|
|
|
|
|
|
# |
25
|
|
|
|
|
|
|
# Complete support of all API methods |
26
|
|
|
|
|
|
|
# Process/Return Viddler error codes for all method calls |
27
|
|
|
|
|
|
|
# Document common error codes and method specific error codes |
28
|
|
|
|
|
|
|
# Validation/Error Handling of parameters/results |
29
|
|
|
|
|
|
|
# Add SSL option for methods such as users_auth |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
#### |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use WebService::Viddler; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $videos = new WebService::Viddler( apiKey => $apiKey, |
38
|
|
|
|
|
|
|
username => $username, |
39
|
|
|
|
|
|
|
password => $passwd, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
print "API Version: " .$videos->api_getInfo(). "\n"; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$video->videos_upload( $title, $tags, $description, $make_public, $file, $bitrate ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$video->videos_getDetails( $video_id, $add_embed_code, $include_comments ); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This is an object-oriented library which focuses on providing Perl specific methods for accessing the Viddler video service via their API, as documented at: http://developers.viddler.com/documentation/api/ |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This library currently only supports version 1 of the Viddler API |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Along with method specific error codes, all methods may return one of the following error codes upon failure. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Error Codes: |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1 An internal error has occurred |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
2 Bad argument format |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
3 Unknown argument specified |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
4 Missing required argument for this method |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
5 No method specified |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
6 Unknown method specified |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
7 API key missing |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
8 Invalid or unknown API key specified |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
9 Invalid or expired sessionid |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
10 Used HTTP method is not allowed for this API method. Try using HTTP POST instead of HTTP GET. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
11 Method call not allowed. Your API key security level restricts calling this method. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
12 API key disabled |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 Methods |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head3 new |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $video = Viddler->new( apikey => $key, username => $username, password => $passwd ); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Instantiates an object which established the basic connection to the API, including requesting and setting a session id. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# The constructor of an object is called new() by convention. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub new { |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my ( $class, %args ) = @_; |
97
|
|
|
|
|
|
|
my $new = bless { |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
_apiURL => 'http://api.viddler.com/rest/v1/', |
100
|
|
|
|
|
|
|
_sessionID => undef, |
101
|
|
|
|
|
|
|
_record_token => undef, |
102
|
|
|
|
|
|
|
%args |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
}, $class; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Get a sessionid |
107
|
|
|
|
|
|
|
my $result = $new->users_auth; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
if ( $result ne "1" ) { |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
warn "Viddler Error: " . $result; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
return $new; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head3 users_auth |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Gets and sets a sessionid for an authenticated Viddler account. Returned sessionid is valid for 5 minutes (may change in the future). Every method request which contains valid sessionid, renews its validity time. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
$video->users_auth; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
No required parameters, we use the username and password defined at object's creation |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Additional options parameters include: |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
* get_record_token: If set to "1" response will also include recordToken |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Returns 1 ( true ) if successful and a Viddler error code if unsuccessful |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Additional Error Codes: |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
101 Username not found. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
102 This account has been suspended. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
103 Password incorrect for this username. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub users_auth { |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
my ( $self, $get_record_token ) = @_; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
if ( ( !defined $get_record_token ) || ( $get_record_token ne "1" ) ) { |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
$get_record_token = ""; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
154
|
|
|
|
|
|
|
my $content = |
155
|
|
|
|
|
|
|
get $self->{_apiURL} |
156
|
|
|
|
|
|
|
. "?method=viddler.users.auth&api_key=" |
157
|
|
|
|
|
|
|
. $self->{apiKey} |
158
|
|
|
|
|
|
|
. "&user=" |
159
|
|
|
|
|
|
|
. $self->{username} |
160
|
|
|
|
|
|
|
. "&password=" |
161
|
|
|
|
|
|
|
. $self->{password} |
162
|
|
|
|
|
|
|
. "&get_record_token=" |
163
|
|
|
|
|
|
|
. $get_record_token; |
164
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
if ( defined $results->{'code'} ) { |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
return $results->{'code'}; |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
else { |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$self->{_sessionID} = $results->{'sessionid'}; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
if ( defined $results->{'get_record_token'} ) { |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
$self->{_recordToken} = $results->{'record_token'}; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
if ( defined( $self->{_sessionID} ) ) { |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
return 1; |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head3 users_register |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Creates a Viddler account. Note: This method is restricted to only qualified API keys. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
$video->users_register( $user, $email, $fname, $lname, $password, $question, $answer, $lang, $termsaccepted, $company ); |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Requires the following parameters: |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
* user: The chosen Viddler user name |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
* email: The email address of the user |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
* fname: The user's first name |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
* lname: The user's last name |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
* password: The user's password with Viddler |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
* question: The text of the user's secret question |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
* answer: The text of the answer to the secret question |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
* lang: The language of the user for the account |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
* termsaccepted: "1" indicates the user has accepted Viddler's terms and conditions |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
Additional options parameters include: |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
* company: The user's company affiliation |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Returns the created username as a string, if successful. Returns an error code if unsuccessful. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Additional Error Codes: |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
104 Terms of Service not accepted by user. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
105 Username already in use. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
106 Email address already in use. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=cut |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub users_register( $$$$$$$$$ ) { |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
my ( |
236
|
|
|
|
|
|
|
$self, $user, $email, $fname, |
237
|
|
|
|
|
|
|
$lname, $password, $question, $answer, |
238
|
|
|
|
|
|
|
$lang, $termsaccepted, $company |
239
|
|
|
|
|
|
|
) = @_; |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
if ( !defined $company ) { |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
$company = ""; |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
my $content = |
250
|
|
|
|
|
|
|
get $self->{_apiURL} |
251
|
|
|
|
|
|
|
. "?method=viddler.users.register&api_key=" |
252
|
|
|
|
|
|
|
. $self->{apiKey} |
253
|
|
|
|
|
|
|
. "&user=" |
254
|
|
|
|
|
|
|
. $user |
255
|
|
|
|
|
|
|
. "&email=" |
256
|
|
|
|
|
|
|
. $email |
257
|
|
|
|
|
|
|
. "&fname=" |
258
|
|
|
|
|
|
|
. $fname |
259
|
|
|
|
|
|
|
. "&lname=" |
260
|
|
|
|
|
|
|
. $lname |
261
|
|
|
|
|
|
|
. "&password=" |
262
|
|
|
|
|
|
|
. $password |
263
|
|
|
|
|
|
|
. "&question=" |
264
|
|
|
|
|
|
|
. $question |
265
|
|
|
|
|
|
|
. "&answer=" |
266
|
|
|
|
|
|
|
. $answer |
267
|
|
|
|
|
|
|
. "&lang=" |
268
|
|
|
|
|
|
|
. $lang |
269
|
|
|
|
|
|
|
. "&termsaccepted=" |
270
|
|
|
|
|
|
|
. $termsaccepted |
271
|
|
|
|
|
|
|
. "&company=" |
272
|
|
|
|
|
|
|
. $company; |
273
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
if ( defined $results->{'code'} ) { |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
return $results->{'code'}; |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
else { |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
return $results->{'username'}; |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
} |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=head3 users_getProfile |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
Retrieves the public parts of a user profile. |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
$video->users_getProfile( $user ); |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
Requires the following parameters: |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
* user: The chosen Viddler user name |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
Additional options parameters include: |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
None |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
Returns a hash of an array of user's public profile information |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=cut |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
sub users_getProfile( $ ) { |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
my ( $self, $user ) = @_; |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
311
|
|
|
|
|
|
|
my $content = |
312
|
|
|
|
|
|
|
get $self->{_apiURL} |
313
|
|
|
|
|
|
|
. "?method=viddler.users.getProfile&api_key=" |
314
|
|
|
|
|
|
|
. $self->{apiKey} |
315
|
|
|
|
|
|
|
. "&user=" |
316
|
|
|
|
|
|
|
. $user; |
317
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
318
|
|
|
|
|
|
|
return $results; |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
} |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=head3 users_setProfile |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
Updates authenticated user profile data |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
$video->users_setProfile( $first_name, $last_name, $about_me, $birthday, $gender, $company, $city ); |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
Requires the following parameters: |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
None |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
Additional options parameters include: |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
* first_name: User's first name. 20 characters max |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
* last_name: User's last name. 20 characters max |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
* about_me: About the user. No length limitation |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
* birthdate: User's birthday in yyyy-mm-dd format |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
* gender: User's gender, either "m" for male or "f" for female |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
* company: User's company. 100 characters max |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
* city: User's city. 250 characters max. Currently this is the only address field supported by Viddler, so you may provide more information than just city. |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
Note: Arguments not sent, won't update the profile. To remove any information from profile just send empty parameter value. |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
Returns a hash of an array of user's public profile information, including updated information |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
=cut |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
sub users_setProfile { |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
my ( $self, $first_name, $last_name, $about_me, $birthday, $gender, |
357
|
|
|
|
|
|
|
$company, $city ) |
358
|
|
|
|
|
|
|
= @_; |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
361
|
|
|
|
|
|
|
my $ua = new LWP::UserAgent; |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
my $content = |
364
|
|
|
|
|
|
|
"method=viddler.users.setProfile" |
365
|
|
|
|
|
|
|
. "&api_key=" |
366
|
|
|
|
|
|
|
. $self->{apiKey} |
367
|
|
|
|
|
|
|
. "&sessionid=" |
368
|
|
|
|
|
|
|
. $self->{_sessionID}; |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
if ( defined $first_name ) { |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
$content .= "&first_name=" . $first_name; |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
if ( defined $last_name ) { |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
$content .= "&last_name=" . $last_name; |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
} |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
if ( defined $about_me ) { |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
$content .= "&about_me=" . $about_me; |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
} |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
if ( defined $birthday ) { |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
$content .= "&birthday=" . $birthday; |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
} |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
if ( defined $gender ) { |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
$content .= "&gender=" . $gender; |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
} |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
if ( defined $company ) { |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
$content .= "&company=" . $company; |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
} |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
if ( defined $city ) { |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
$content .= "&city=" . $city; |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
} |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
my $request = POST $self->{_apiURL}, |
413
|
|
|
|
|
|
|
Content_Type => 'application/x-www-form-urlencoded', |
414
|
|
|
|
|
|
|
Content => $content; |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
my $results = $xml->XMLin( $ua->request($request)->content ); |
417
|
|
|
|
|
|
|
return $results; |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
} |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
=head3 users_search |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
Search Viddler people (or Viddler users). This method can also be used to search through people that are active and also a Viddler user's friends. |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
$video->users_search( $type, $query, $page, $per_page ); |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
Requires the following parameters: |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
* type: The type of search (e.g. "everybody", "friends", "active" |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
* query: What to search for (e.g. "New York City", "Paul Weinstein", or "Photographers") |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
Additional options parameters include: |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
* page: The "page number" of results to retrieve (e.g. 1, 2, 3) |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
* per_page: The number of results to retrieve per page (maximum 100). If not specified, the default value equals 20 |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
Returns a hash of an array of search results |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
=cut |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
sub users_search( $$ ) { |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
my ( $self, $type, $query, $page, $per_page ) = @_; |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
if ( !defined $page ) { |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
$page = ""; |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
} |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
if ( !defined $per_page ) { |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
$per_page = ""; |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
} |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
460
|
|
|
|
|
|
|
my $content = |
461
|
|
|
|
|
|
|
get $self->{_apiURL} |
462
|
|
|
|
|
|
|
. "?method=viddler.users.search&api_key=" |
463
|
|
|
|
|
|
|
. $self->{apiKey} |
464
|
|
|
|
|
|
|
. "&sessionid=" |
465
|
|
|
|
|
|
|
. $self->{_sessionID} |
466
|
|
|
|
|
|
|
. "&type=" |
467
|
|
|
|
|
|
|
. $type |
468
|
|
|
|
|
|
|
. "&query=" |
469
|
|
|
|
|
|
|
. $query |
470
|
|
|
|
|
|
|
. "&page=" |
471
|
|
|
|
|
|
|
. $page |
472
|
|
|
|
|
|
|
. "&per_page=" |
473
|
|
|
|
|
|
|
. $per_page; |
474
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
475
|
|
|
|
|
|
|
return $results; |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
} |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
=head3 users_setOptions |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
Sets user account options. Currently only partners options are supported. More of them later! |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
$video->users_setOptions( $show_account, $tagging_enabled, $commenting_enabled, $show_related_videos, $embedding_enabled, $clicking_through_enabled, $email_this_enabled, $trackbacks_enabled, $favourites_enabled, $custom_logo_enabled ); |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
Requires the following parameters: |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
None |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
Additional options parameters include: |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
* show_account: "1", "0" - Show/hide your account in Viddler. If you set it to "0" both your account and your videos won't be visible on viddler.com site |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
* tagging_enabled: "1", "0" - Enable/disable tagging on all your videos |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
* commenting_enabled: "1", "0" - Enable/disable commenting on all your videos |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
* show_related_videos: "1", "0" - Show/hide related videos on all your videos |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
* embedding_enabled: "1", "0" - Enable/disable embedding of off all your videos |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
* clicking_through_enabled: "1", "0" - Enable/disable redirect to Viddler while clicking on embedded player |
502
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
* email_this_enabled: "1", "0" - Enable/disable email this option on all your videos |
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
* trackbacks_enabled: "1", "0" - Enable/disable trackbacks on all your videos |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
* favourites_enabled: "1", "0" - Enable/disable favorites on all your videos |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
* custom_logo_enabled: "1", "0" - Enable/disable custom logo on all your videos. Note: that logo itself must be send to viddler manually. |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
Returns an integer representing the number of options actually updated |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
=cut |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
sub users_setOptions { |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
my ( |
518
|
|
|
|
|
|
|
$self, $show_account, |
519
|
|
|
|
|
|
|
$tagging_enabled, $commenting_enabled, |
520
|
|
|
|
|
|
|
$show_related_videos, $embedding_enabled, |
521
|
|
|
|
|
|
|
$clicking_through_enabled, $email_this_enabled, |
522
|
|
|
|
|
|
|
$trackbacks_enabled, $favourites_enabled, |
523
|
|
|
|
|
|
|
$custom_logo_enabled |
524
|
|
|
|
|
|
|
) = @_; |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
if ( !defined $show_account ) { |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
$show_account = ""; |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
} |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
if ( !defined $tagging_enabled ) { |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
$tagging_enabled = ""; |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
} |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
if ( !defined $commenting_enabled ) { |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
$commenting_enabled = ""; |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
} |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
if ( !defined $show_related_videos ) { |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
$show_related_videos = ""; |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
} |
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
if ( !defined $embedding_enabled ) { |
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
$embedding_enabled = ""; |
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
} |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
if ( !defined $clicking_through_enabled ) { |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
$clicking_through_enabled = ""; |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
} |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
if ( !defined $email_this_enabled ) { |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
$email_this_enabled = ""; |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
} |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
if ( !defined $trackbacks_enabled ) { |
571
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
$trackbacks_enabled = ""; |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
} |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
if ( !defined $favourites_enabled ) { |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
$favourites_enabled = ""; |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
} |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
if ( !defined $custom_logo_enabled ) { |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
$custom_logo_enabled = ""; |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
} |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
my $content = |
589
|
|
|
|
|
|
|
get $self->{_apiURL} |
590
|
|
|
|
|
|
|
. "?method=viddler.users.setOptions&api_key=" |
591
|
|
|
|
|
|
|
. $self->{apiKey} |
592
|
|
|
|
|
|
|
. "&sessionid=" |
593
|
|
|
|
|
|
|
. $self->{_sessionID} |
594
|
|
|
|
|
|
|
. "&show_account=" |
595
|
|
|
|
|
|
|
. $show_account |
596
|
|
|
|
|
|
|
. "&tagging_enabled=" |
597
|
|
|
|
|
|
|
. $tagging_enabled |
598
|
|
|
|
|
|
|
. "&commenting_enabled" |
599
|
|
|
|
|
|
|
. $commenting_enabled |
600
|
|
|
|
|
|
|
. "&show_related_videos=" |
601
|
|
|
|
|
|
|
. $show_related_videos |
602
|
|
|
|
|
|
|
. "&embedding_enabled=" |
603
|
|
|
|
|
|
|
. $embedding_enabled |
604
|
|
|
|
|
|
|
. "&clicking_ithrough_enabled=" |
605
|
|
|
|
|
|
|
. $clicking_through_enabled |
606
|
|
|
|
|
|
|
. "&email_this_enabled=" |
607
|
|
|
|
|
|
|
. $email_this_enabled |
608
|
|
|
|
|
|
|
. "&trackbacks_enabled=" |
609
|
|
|
|
|
|
|
. $trackbacks_enabled |
610
|
|
|
|
|
|
|
. "&favourites_enabled=" |
611
|
|
|
|
|
|
|
. $favourites_enabled |
612
|
|
|
|
|
|
|
. "&custom_logo_enabled=" |
613
|
|
|
|
|
|
|
. $custom_logo_enabled; |
614
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
615
|
|
|
|
|
|
|
return $results->{'updated'}; |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
} |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
=head3 api_getInfo |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
Gets and returns the current version of the Viddler API. |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
$video->api_getInfo; |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
Returns current API version as a string |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
=cut |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
sub api_getInfo { |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
my ($self) = @_; |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
634
|
|
|
|
|
|
|
my $content = |
635
|
|
|
|
|
|
|
get $self->{_apiURL} |
636
|
|
|
|
|
|
|
. "?method=viddler.api.getInfo&api_key=" |
637
|
|
|
|
|
|
|
. $self->{apiKey}; |
638
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
639
|
|
|
|
|
|
|
return $results->{'version'}; |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
} |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
=head3 videos_getRecordToken |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
Generate token for embedded recorder |
646
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
$video->videos_getRecordToken; |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
Returns a record token as a string |
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
=cut |
652
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
sub videos_getRecordToken { |
654
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
my ($self) = @_; |
656
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
658
|
|
|
|
|
|
|
my $content = |
659
|
|
|
|
|
|
|
get $self->{_apiURL} |
660
|
|
|
|
|
|
|
. "?method=viddler.videos.getRecordToken&api_key=" |
661
|
|
|
|
|
|
|
. $self->{apiKey} |
662
|
|
|
|
|
|
|
. "&sessionid=" |
663
|
|
|
|
|
|
|
. $self->{_sessionID}; |
664
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
665
|
|
|
|
|
|
|
return $results->{'record_token'}; |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
} |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
=head3 videos_prepareUpload |
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
There are two possible solutions for video upload via API call. First one is regular viddler.videos.upload API call. When upload call to this method is received it scans the request and proxies it to best possible upload server. Everything is done in the background and doesn't require any additional client side interaction. Disadvantage of this solution is that the upload will go through multiple servers before reaching its final location. This may cause some slowness in certain situations (API nodes overload etc). |
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
To prevent this you may use second (preferred) solution. Call viddler.videos.prepareUpload method which will assign the best possible upload node for you. After reading the response use "endpoint" tag value as new API endpoint for viddler.videos.upload method call instead of standard http://api.viddler.com/rest/v1/ endpoint. |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
This method is available since API version 1.3.0. |
676
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
$video->videos_prepareUpload; |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
Returns a endpoint as a string for videos_upload method |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
=cut |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
sub videos_prepareUpload { |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
my ($self) = @_; |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
688
|
|
|
|
|
|
|
my $content = |
689
|
|
|
|
|
|
|
get $self->{_apiURL} |
690
|
|
|
|
|
|
|
. "?method=viddler.videos.prepareUpload&api_key=" |
691
|
|
|
|
|
|
|
. $self->{apiKey} |
692
|
|
|
|
|
|
|
. "&sessionid=" |
693
|
|
|
|
|
|
|
. $self->{_sessionID}; |
694
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
695
|
|
|
|
|
|
|
return $results->{'endpoint'}; |
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
} |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
=head3 videos_upload |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
Uploads a video to a user's account on Viddler site. |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
Make sure "file" part is sent as the last part of a request. Your upload request will be validated before actual file will be read. |
704
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
For better videos uploads performance consider using viddler.videos.prepareUpload method which will assign new, one time use API endpoint for video upload call. |
706
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
$video->videos_upload( $title, $tags, $description, $make_public, $file, $bitrate ); |
708
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
Requires the following parameters: |
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
* title: The video's title |
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
* tags: Tags for the video. Separate each tag with a space. To join two words together in one tag, use double quotes. |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
* description: The video description. |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
* make_public: Use "1" for true and "0" for false to choose whether or not the video goes public when uploaded. |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
* file: The video file. |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
Additional options parameters include: |
722
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
* bitrate: (in kilobits per second) The bitrate to encode the current video at, rather than the account default. E.g. 400, 700, or 1500. Note: This option is not available for all accounts. |
724
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
Returns a hash of an array of the successfully uploaded video's details |
726
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
=cut |
728
|
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
sub videos_upload( $$$$$ ) { |
730
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
my ( $self, $title, $tags, $description, $make_public, $file, $bitrate ) = |
732
|
|
|
|
|
|
|
@_; |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
735
|
|
|
|
|
|
|
my $ua = new LWP::UserAgent; |
736
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
my $request = POST $self->{_apiURL}, |
738
|
|
|
|
|
|
|
Content_Type => 'multipart/form-data', |
739
|
|
|
|
|
|
|
Content => [ |
740
|
|
|
|
|
|
|
method => 'viddler.videos.upload', |
741
|
|
|
|
|
|
|
api_key => $self->{apiKey}, |
742
|
|
|
|
|
|
|
sessionid => $self->{_sessionID}, |
743
|
|
|
|
|
|
|
title => $title, |
744
|
|
|
|
|
|
|
tags => $tags, |
745
|
|
|
|
|
|
|
description => $description, |
746
|
|
|
|
|
|
|
make_public => $make_public, |
747
|
|
|
|
|
|
|
file => [$file], |
748
|
|
|
|
|
|
|
bitrate => $bitrate |
749
|
|
|
|
|
|
|
]; |
750
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
my $results = $xml->XMLin( $ua->request($request)->content ); |
752
|
|
|
|
|
|
|
return $results; |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
} |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
=head3 videos_getStatus |
757
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
Returns the status of a video uploaded through the API |
759
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
$video->videos_getStatus( $video_id ); |
761
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
Requires the following parameters: |
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
* video_id: The ID of the video to get information for. The video ID is a value that's returned by videos_upload. |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
Additional options parameters include: |
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
None |
769
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
Returns a status code as a string |
771
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
Status Codes: |
773
|
|
|
|
|
|
|
|
774
|
|
|
|
|
|
|
1 Video waiting for encode |
775
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
2 Video encoding |
777
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
3 Video did not encoded (encoding error) |
779
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
4 Video ready |
781
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
5 Video deleted |
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
=cut |
785
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
sub videos_getStatus( $ ) { |
787
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
my ( $self, $video_id ) = @_; |
789
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
791
|
|
|
|
|
|
|
my $content = |
792
|
|
|
|
|
|
|
get $self->{_apiURL} |
793
|
|
|
|
|
|
|
. "?method=viddler.videos.getStatus&api_key=" |
794
|
|
|
|
|
|
|
. $self->{apiKey} |
795
|
|
|
|
|
|
|
. "&sessionid=" |
796
|
|
|
|
|
|
|
. $self->{_sessionID} |
797
|
|
|
|
|
|
|
. "&video_id=" |
798
|
|
|
|
|
|
|
. $video_id; |
799
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
800
|
|
|
|
|
|
|
return $results->{'statuscode'}; |
801
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
} |
803
|
|
|
|
|
|
|
|
804
|
|
|
|
|
|
|
=head3 videos_getDetails |
805
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
Displays the details for a video |
807
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
$video->videos_getDetails( $video_id, $add_embed_code, $include_comments ); |
809
|
|
|
|
|
|
|
|
810
|
|
|
|
|
|
|
Requires the following parameters: |
811
|
|
|
|
|
|
|
|
812
|
|
|
|
|
|
|
* video_id: The ID of the video to get information for. The video ID is a value that's returned by videos_upload. |
813
|
|
|
|
|
|
|
|
814
|
|
|
|
|
|
|
Additional options parameters include: |
815
|
|
|
|
|
|
|
|
816
|
|
|
|
|
|
|
* add_embed_code: Include video embed code in response ("1" or "0", default is "0") |
817
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
* include_comments: Include comments in response ("1" or "0", default: "1") |
819
|
|
|
|
|
|
|
|
820
|
|
|
|
|
|
|
Returns a hash of an array of the video's details if successful, a Viddler error code if unsuccessful |
821
|
|
|
|
|
|
|
|
822
|
|
|
|
|
|
|
Notes: |
823
|
|
|
|
|
|
|
|
824
|
|
|
|
|
|
|
* All possible permission levels in result set are: public, shared_all, shared and private |
825
|
|
|
|
|
|
|
|
826
|
|
|
|
|
|
|
* Only /video/permissions/view node may contain secreturl node |
827
|
|
|
|
|
|
|
|
828
|
|
|
|
|
|
|
* Only shared permission level may contain user and list subnodes |
829
|
|
|
|
|
|
|
|
830
|
|
|
|
|
|
|
Additional Error Codes: |
831
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
100 Video could not be found |
833
|
|
|
|
|
|
|
|
834
|
|
|
|
|
|
|
=cut |
835
|
|
|
|
|
|
|
|
836
|
|
|
|
|
|
|
sub videos_getDetails( $ ) { |
837
|
|
|
|
|
|
|
|
838
|
|
|
|
|
|
|
my ( $self, $video_id, $add_embed_code, $include_comments ) = @_; |
839
|
|
|
|
|
|
|
|
840
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
841
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
if ( !defined $add_embed_code ) { |
843
|
|
|
|
|
|
|
|
844
|
|
|
|
|
|
|
$add_embed_code = "0"; |
845
|
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
} |
847
|
|
|
|
|
|
|
|
848
|
|
|
|
|
|
|
if ( !defined $include_comments ) { |
849
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
$include_comments = "1"; |
851
|
|
|
|
|
|
|
|
852
|
|
|
|
|
|
|
} |
853
|
|
|
|
|
|
|
|
854
|
|
|
|
|
|
|
my $content = |
855
|
|
|
|
|
|
|
get $self->{_apiURL} |
856
|
|
|
|
|
|
|
. "?method=viddler.videos.getDetails&api_key=" |
857
|
|
|
|
|
|
|
. $self->{apiKey} |
858
|
|
|
|
|
|
|
. "&sessionid=" |
859
|
|
|
|
|
|
|
. $self->{_sessionID} |
860
|
|
|
|
|
|
|
. "&video_id=" |
861
|
|
|
|
|
|
|
. $video_id |
862
|
|
|
|
|
|
|
. "&add_embed_code=" |
863
|
|
|
|
|
|
|
. $add_embed_code |
864
|
|
|
|
|
|
|
. "&include_comments=" |
865
|
|
|
|
|
|
|
. $include_comments; |
866
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
867
|
|
|
|
|
|
|
|
868
|
|
|
|
|
|
|
if ( defined $results->{'code'} ) { |
869
|
|
|
|
|
|
|
|
870
|
|
|
|
|
|
|
return $results->{'code'}; |
871
|
|
|
|
|
|
|
|
872
|
|
|
|
|
|
|
} |
873
|
|
|
|
|
|
|
else { |
874
|
|
|
|
|
|
|
|
875
|
|
|
|
|
|
|
return $results; |
876
|
|
|
|
|
|
|
|
877
|
|
|
|
|
|
|
} |
878
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
} |
880
|
|
|
|
|
|
|
|
881
|
|
|
|
|
|
|
=head3 videos_getDetailsByUrl |
882
|
|
|
|
|
|
|
|
883
|
|
|
|
|
|
|
Displays the details for a video |
884
|
|
|
|
|
|
|
|
885
|
|
|
|
|
|
|
$video->videos_getByDetailsByUrl( $video_url ); |
886
|
|
|
|
|
|
|
|
887
|
|
|
|
|
|
|
Requires the following parameters: |
888
|
|
|
|
|
|
|
|
889
|
|
|
|
|
|
|
* video_url: The complete Viddler video URL |
890
|
|
|
|
|
|
|
|
891
|
|
|
|
|
|
|
Additional options parameters include: |
892
|
|
|
|
|
|
|
|
893
|
|
|
|
|
|
|
None |
894
|
|
|
|
|
|
|
|
895
|
|
|
|
|
|
|
Returns a hash of an array of the video's details |
896
|
|
|
|
|
|
|
|
897
|
|
|
|
|
|
|
Additional Error Codes: |
898
|
|
|
|
|
|
|
|
899
|
|
|
|
|
|
|
2 Bad argument format |
900
|
|
|
|
|
|
|
|
901
|
|
|
|
|
|
|
100 Video could not be found |
902
|
|
|
|
|
|
|
|
903
|
|
|
|
|
|
|
=cut |
904
|
|
|
|
|
|
|
|
905
|
|
|
|
|
|
|
sub videos_getDetailsByUrl( $ ) { |
906
|
|
|
|
|
|
|
|
907
|
|
|
|
|
|
|
my ( $self, $video_url ) = @_; |
908
|
|
|
|
|
|
|
|
909
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
910
|
|
|
|
|
|
|
my $content = |
911
|
|
|
|
|
|
|
get $self->{_apiURL} |
912
|
|
|
|
|
|
|
. "?method=viddler.videos.getDetailsByUrl&api_key=" |
913
|
|
|
|
|
|
|
. $self->{apiKey} |
914
|
|
|
|
|
|
|
. "&sessionid=" |
915
|
|
|
|
|
|
|
. $self->{_sessionID} . "&url=" |
916
|
|
|
|
|
|
|
. $video_url; |
917
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
918
|
|
|
|
|
|
|
|
919
|
|
|
|
|
|
|
if ( defined $results->{'code'} ) { |
920
|
|
|
|
|
|
|
|
921
|
|
|
|
|
|
|
return $results->{'code'}; |
922
|
|
|
|
|
|
|
|
923
|
|
|
|
|
|
|
} |
924
|
|
|
|
|
|
|
else { |
925
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
return $results; |
927
|
|
|
|
|
|
|
|
928
|
|
|
|
|
|
|
} |
929
|
|
|
|
|
|
|
|
930
|
|
|
|
|
|
|
} |
931
|
|
|
|
|
|
|
|
932
|
|
|
|
|
|
|
=head3 videos_setDetails |
933
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
Updated video details |
935
|
|
|
|
|
|
|
|
936
|
|
|
|
|
|
|
$video->videos_setByDetails( $video_id, $title, $description, $tags, $view_perm, $view_users, $view_use_secret, $embed_perm, $embed_users, $commenting_users, $tagging_perm, $tagging_users, $download_perm, $download_users ); |
937
|
|
|
|
|
|
|
|
938
|
|
|
|
|
|
|
Requires the following parameters: |
939
|
|
|
|
|
|
|
|
940
|
|
|
|
|
|
|
* video_id: The ID of the video which you want to update |
941
|
|
|
|
|
|
|
|
942
|
|
|
|
|
|
|
Additional options parameters include: |
943
|
|
|
|
|
|
|
|
944
|
|
|
|
|
|
|
* title: Video title - 500 characters max |
945
|
|
|
|
|
|
|
|
946
|
|
|
|
|
|
|
* description: Video description |
947
|
|
|
|
|
|
|
|
948
|
|
|
|
|
|
|
* tags: List of tags to be set on video. Setting tags will update current tags set (both timed and global video tags). To set timed tag use formattagname[timestamp_in_ms] as tagname. For example - usingtag1,tag2,tag3[2500] will set 2 global and 1 timed tag at 2.5s |
949
|
|
|
|
|
|
|
|
950
|
|
|
|
|
|
|
* view_perm: View permission. Can be set to public, shared_all, shared or private |
951
|
|
|
|
|
|
|
|
952
|
|
|
|
|
|
|
* view_users: List of users which may view this video if view_perm is set to shared. Only your viddler friends are allowed here. If you provide multiple usernames - non valid viddler friends usernames will be ignored. |
953
|
|
|
|
|
|
|
|
954
|
|
|
|
|
|
|
* view_use_secret: If view_perm is set to non public value, you may activate secreturl for your video. If you want to enable or regenerate secreturl pass "1" as parameter value. If you want to disable secreturl pass "0" as parameter value. |
955
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
* embed_perm: Embedding permission. Supported permission levels are the same as forview_perm. This and all permissions below cannot be less restrictive thanview_perm. You cannot set it to public if view_perm is for example shared. |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
* embed_users: Same as view_users. If view_perm is shared, this list cannot contain more users than view_users. Invalid usernames will be removed. |
959
|
|
|
|
|
|
|
|
960
|
|
|
|
|
|
|
* commenting_perm: Commenting permission. Description is the same as for embed_perm |
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
* commenting_users: Same as embed_users. |
963
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
* tagging_perm: Tagging permission. Description is the same as for embed_perm |
965
|
|
|
|
|
|
|
|
966
|
|
|
|
|
|
|
* tagging_users: Same as embed_users. |
967
|
|
|
|
|
|
|
|
968
|
|
|
|
|
|
|
* download_perm: Download permission. Description is the same as for embed_perm |
969
|
|
|
|
|
|
|
|
970
|
|
|
|
|
|
|
* download_users: Same as embed_users. |
971
|
|
|
|
|
|
|
|
972
|
|
|
|
|
|
|
Note: Invalid arguments will be ignored. All lists are comma or space separated. |
973
|
|
|
|
|
|
|
|
974
|
|
|
|
|
|
|
Returns a hash of an array of the video's details, including updated details, if successful. Returns a Viddler error code if unsuccessful. |
975
|
|
|
|
|
|
|
|
976
|
|
|
|
|
|
|
Additional Error Codes: |
977
|
|
|
|
|
|
|
|
978
|
|
|
|
|
|
|
100 Video could not be found |
979
|
|
|
|
|
|
|
|
980
|
|
|
|
|
|
|
107 Wrong privileges |
981
|
|
|
|
|
|
|
|
982
|
|
|
|
|
|
|
=cut |
983
|
|
|
|
|
|
|
|
984
|
|
|
|
|
|
|
sub videos_setDetails( $ ) { |
985
|
|
|
|
|
|
|
|
986
|
|
|
|
|
|
|
my ( |
987
|
|
|
|
|
|
|
$self, $video_id, $title, |
988
|
|
|
|
|
|
|
$description, $tags, $view_perm, |
989
|
|
|
|
|
|
|
$view_users, $view_use_secret, $embed_perm, |
990
|
|
|
|
|
|
|
$embed_users, $commenting_perm, $commenting_users, |
991
|
|
|
|
|
|
|
$tagging_perm, $tagging_users, $download_perm, |
992
|
|
|
|
|
|
|
$download_users |
993
|
|
|
|
|
|
|
) = @_; |
994
|
|
|
|
|
|
|
|
995
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
996
|
|
|
|
|
|
|
my $ua = new LWP::UserAgent; |
997
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
my $content = |
999
|
|
|
|
|
|
|
"method=viddler.users.setDetails" |
1000
|
|
|
|
|
|
|
. "&api_key=" |
1001
|
|
|
|
|
|
|
. $self->{apiKey} |
1002
|
|
|
|
|
|
|
. "&sessionid=" |
1003
|
|
|
|
|
|
|
. $self->{_sessionID} |
1004
|
|
|
|
|
|
|
. "&video_id=" |
1005
|
|
|
|
|
|
|
. $video_id; |
1006
|
|
|
|
|
|
|
|
1007
|
|
|
|
|
|
|
if ( defined $title ) { |
1008
|
|
|
|
|
|
|
|
1009
|
|
|
|
|
|
|
$content .= "&title=" . $title; |
1010
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
} |
1012
|
|
|
|
|
|
|
|
1013
|
|
|
|
|
|
|
if ( defined $description ) { |
1014
|
|
|
|
|
|
|
|
1015
|
|
|
|
|
|
|
$content .= "&description=" . $description; |
1016
|
|
|
|
|
|
|
|
1017
|
|
|
|
|
|
|
} |
1018
|
|
|
|
|
|
|
|
1019
|
|
|
|
|
|
|
if ( defined $tags ) { |
1020
|
|
|
|
|
|
|
|
1021
|
|
|
|
|
|
|
$content .= "&tags=" . $tags; |
1022
|
|
|
|
|
|
|
|
1023
|
|
|
|
|
|
|
} |
1024
|
|
|
|
|
|
|
|
1025
|
|
|
|
|
|
|
if ( defined $view_perm ) { |
1026
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
$content .= "&view_perm=" . $view_perm; |
1028
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
} |
1030
|
|
|
|
|
|
|
|
1031
|
|
|
|
|
|
|
if ( defined $view_users ) { |
1032
|
|
|
|
|
|
|
|
1033
|
|
|
|
|
|
|
$content .= "&view_users=" . $view_users; |
1034
|
|
|
|
|
|
|
|
1035
|
|
|
|
|
|
|
} |
1036
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
if ( defined $view_use_secret ) { |
1038
|
|
|
|
|
|
|
|
1039
|
|
|
|
|
|
|
$content .= "&view_use_secret=" . $view_use_secret; |
1040
|
|
|
|
|
|
|
|
1041
|
|
|
|
|
|
|
} |
1042
|
|
|
|
|
|
|
|
1043
|
|
|
|
|
|
|
if ( defined $embed_perm ) { |
1044
|
|
|
|
|
|
|
|
1045
|
|
|
|
|
|
|
$content .= "&embed_perm=" . $embed_perm; |
1046
|
|
|
|
|
|
|
|
1047
|
|
|
|
|
|
|
} |
1048
|
|
|
|
|
|
|
|
1049
|
|
|
|
|
|
|
if ( defined $embed_users ) { |
1050
|
|
|
|
|
|
|
|
1051
|
|
|
|
|
|
|
$content .= "&embed_users=" . $embed_users; |
1052
|
|
|
|
|
|
|
|
1053
|
|
|
|
|
|
|
} |
1054
|
|
|
|
|
|
|
|
1055
|
|
|
|
|
|
|
if ( defined $commenting_perm ) { |
1056
|
|
|
|
|
|
|
|
1057
|
|
|
|
|
|
|
$content .= "&commenting_perm=" . $commenting_perm; |
1058
|
|
|
|
|
|
|
|
1059
|
|
|
|
|
|
|
} |
1060
|
|
|
|
|
|
|
|
1061
|
|
|
|
|
|
|
if ( defined $commenting_users ) { |
1062
|
|
|
|
|
|
|
|
1063
|
|
|
|
|
|
|
$content .= "&commenting_users=" . $commenting_users; |
1064
|
|
|
|
|
|
|
|
1065
|
|
|
|
|
|
|
} |
1066
|
|
|
|
|
|
|
|
1067
|
|
|
|
|
|
|
if ( defined $tagging_perm ) { |
1068
|
|
|
|
|
|
|
|
1069
|
|
|
|
|
|
|
$content .= "&tagging_perm=" . $tagging_perm; |
1070
|
|
|
|
|
|
|
|
1071
|
|
|
|
|
|
|
} |
1072
|
|
|
|
|
|
|
|
1073
|
|
|
|
|
|
|
if ( defined $tagging_users ) { |
1074
|
|
|
|
|
|
|
|
1075
|
|
|
|
|
|
|
$content .= "&tagging_users=" . $tagging_users; |
1076
|
|
|
|
|
|
|
|
1077
|
|
|
|
|
|
|
} |
1078
|
|
|
|
|
|
|
|
1079
|
|
|
|
|
|
|
if ( defined $download_perm ) { |
1080
|
|
|
|
|
|
|
|
1081
|
|
|
|
|
|
|
$content .= "&download_perm=" . $download_perm; |
1082
|
|
|
|
|
|
|
|
1083
|
|
|
|
|
|
|
} |
1084
|
|
|
|
|
|
|
|
1085
|
|
|
|
|
|
|
if ( defined $download_users ) { |
1086
|
|
|
|
|
|
|
|
1087
|
|
|
|
|
|
|
$content .= "&download_users=" . $download_users; |
1088
|
|
|
|
|
|
|
|
1089
|
|
|
|
|
|
|
} |
1090
|
|
|
|
|
|
|
|
1091
|
|
|
|
|
|
|
my $request = POST $self->{_apiURL}, |
1092
|
|
|
|
|
|
|
Content_Type => 'application/x-www-form-urlencoded', |
1093
|
|
|
|
|
|
|
Content => $content; |
1094
|
|
|
|
|
|
|
|
1095
|
|
|
|
|
|
|
my $results = $xml->XMLin( $ua->request($request)->content ); |
1096
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
if ( defined $results->{'code'} ) { |
1098
|
|
|
|
|
|
|
|
1099
|
|
|
|
|
|
|
return $results->{'code'}; |
1100
|
|
|
|
|
|
|
|
1101
|
|
|
|
|
|
|
} |
1102
|
|
|
|
|
|
|
else { |
1103
|
|
|
|
|
|
|
|
1104
|
|
|
|
|
|
|
return $results; |
1105
|
|
|
|
|
|
|
|
1106
|
|
|
|
|
|
|
} |
1107
|
|
|
|
|
|
|
|
1108
|
|
|
|
|
|
|
} |
1109
|
|
|
|
|
|
|
|
1110
|
|
|
|
|
|
|
=head3 videos_setPermalink |
1111
|
|
|
|
|
|
|
|
1112
|
|
|
|
|
|
|
Set permalink on videos you own. Permalink is used by our flash player. When a user clicks on a video while it is played, he will be redirected to permalink url defined on a video. |
1113
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
$video->videos_setPermalink( $video_id, $permalink ); |
1115
|
|
|
|
|
|
|
|
1116
|
|
|
|
|
|
|
Requires the following parameters: |
1117
|
|
|
|
|
|
|
|
1118
|
|
|
|
|
|
|
* video_id: The ID of the video to get information for. This is the ID that's returned by videos_upload. |
1119
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
* permalink: URL address to your page - max 250 characters long. |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
Additional options parameters include: |
1123
|
|
|
|
|
|
|
|
1124
|
|
|
|
|
|
|
None |
1125
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
Note: To reset a permalink back to its Viddler.com default - simply supply an empty permalink argument. |
1127
|
|
|
|
|
|
|
|
1128
|
|
|
|
|
|
|
Returns 0 ( false ) if unsuccessful and 1 ( true ) if successful |
1129
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
=cut |
1131
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
sub videos_setPermalink( $$ ) { |
1133
|
|
|
|
|
|
|
|
1134
|
|
|
|
|
|
|
my ( $self, $video_id, $permalink ) = @_; |
1135
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
1137
|
|
|
|
|
|
|
my $content = |
1138
|
|
|
|
|
|
|
get $self->{_apiURL} |
1139
|
|
|
|
|
|
|
. "?method=viddler.videos.setPermalink&api_key=" |
1140
|
|
|
|
|
|
|
. $self->{apiKey} |
1141
|
|
|
|
|
|
|
. "&sessionid=" |
1142
|
|
|
|
|
|
|
. $self->{_sessionID} |
1143
|
|
|
|
|
|
|
. "&video_id=" |
1144
|
|
|
|
|
|
|
. $video_id |
1145
|
|
|
|
|
|
|
. "&permalink=" |
1146
|
|
|
|
|
|
|
. $permalink; |
1147
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
1148
|
|
|
|
|
|
|
|
1149
|
|
|
|
|
|
|
if ( defined( $results->{'success'} ) ) { |
1150
|
|
|
|
|
|
|
|
1151
|
|
|
|
|
|
|
return 1; |
1152
|
|
|
|
|
|
|
|
1153
|
|
|
|
|
|
|
} |
1154
|
|
|
|
|
|
|
else { |
1155
|
|
|
|
|
|
|
|
1156
|
|
|
|
|
|
|
return 0; |
1157
|
|
|
|
|
|
|
|
1158
|
|
|
|
|
|
|
} |
1159
|
|
|
|
|
|
|
|
1160
|
|
|
|
|
|
|
} |
1161
|
|
|
|
|
|
|
|
1162
|
|
|
|
|
|
|
=head3 videos_setThumbnail |
1163
|
|
|
|
|
|
|
|
1164
|
|
|
|
|
|
|
Choose a thumbnail based on a moment in time in a video. This feature will select the nearest keyframe to the point given and create a new thumbnail. |
1165
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
Due to the caching methods of Viddler's service, it will take a few minutes for the new thumbnail to propagate to our entire network. |
1167
|
|
|
|
|
|
|
|
1168
|
|
|
|
|
|
|
$video->videos_setThumbnail( $video_id, $timepoint, $file ); |
1169
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
Requires the following parameters: |
1171
|
|
|
|
|
|
|
|
1172
|
|
|
|
|
|
|
* video_id: The ID of the video which you want to update |
1173
|
|
|
|
|
|
|
|
1174
|
|
|
|
|
|
|
* timepoint: Time in seconds from 0 to video length (int). |
1175
|
|
|
|
|
|
|
|
1176
|
|
|
|
|
|
|
* file: An image file to use as the static thumbnail. JPG, GIF, PNG supported. |
1177
|
|
|
|
|
|
|
|
1178
|
|
|
|
|
|
|
Additional options parameters include: |
1179
|
|
|
|
|
|
|
|
1180
|
|
|
|
|
|
|
None |
1181
|
|
|
|
|
|
|
|
1182
|
|
|
|
|
|
|
Notes: |
1183
|
|
|
|
|
|
|
|
1184
|
|
|
|
|
|
|
* Invalid arguments will be ignored |
1185
|
|
|
|
|
|
|
|
1186
|
|
|
|
|
|
|
* Time point must be in seconds and be a valid integer. |
1187
|
|
|
|
|
|
|
|
1188
|
|
|
|
|
|
|
* To improve thumbnail generation increase the number of keyframes in the video uploaded. |
1189
|
|
|
|
|
|
|
|
1190
|
|
|
|
|
|
|
* Due to caching, a new thumbnail make take a few minutes to propagate throughout the network. |
1191
|
|
|
|
|
|
|
|
1192
|
|
|
|
|
|
|
* If both timepoint and file are sent, timepoint is ignored. |
1193
|
|
|
|
|
|
|
|
1194
|
|
|
|
|
|
|
* Image files should be the same dimensions as the video. Larger image files will be automatically scaled down. |
1195
|
|
|
|
|
|
|
|
1196
|
|
|
|
|
|
|
* Max thumbnail size is 400 KB. Anything larger results in Error 200. |
1197
|
|
|
|
|
|
|
|
1198
|
|
|
|
|
|
|
Returns a hash of an array of URL's for accessing various thumbanil image sizes |
1199
|
|
|
|
|
|
|
|
1200
|
|
|
|
|
|
|
=cut |
1201
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
sub videos_setThumbnail( $$ ) { |
1203
|
|
|
|
|
|
|
|
1204
|
|
|
|
|
|
|
my ( $self, $video_id, $timepoint, $file ) = @_; |
1205
|
|
|
|
|
|
|
|
1206
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
1207
|
|
|
|
|
|
|
my $ua = new LWP::UserAgent; |
1208
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
my $request = POST $self->{_apiURL}, |
1210
|
|
|
|
|
|
|
Content_Type => 'multipart/form-data', |
1211
|
|
|
|
|
|
|
Content => [ |
1212
|
|
|
|
|
|
|
method => 'viddler.videos.setThumbnail', |
1213
|
|
|
|
|
|
|
api_key => $self->{apiKey}, |
1214
|
|
|
|
|
|
|
sessionid => $self->{_sessionID}, |
1215
|
|
|
|
|
|
|
video_id => $video_id, |
1216
|
|
|
|
|
|
|
timepoint => $timepoint, |
1217
|
|
|
|
|
|
|
file => [$file] |
1218
|
|
|
|
|
|
|
]; |
1219
|
|
|
|
|
|
|
|
1220
|
|
|
|
|
|
|
my $results = $xml->XMLin( $ua->request($request)->content ); |
1221
|
|
|
|
|
|
|
return $results; |
1222
|
|
|
|
|
|
|
|
1223
|
|
|
|
|
|
|
} |
1224
|
|
|
|
|
|
|
|
1225
|
|
|
|
|
|
|
=head3 videos_search |
1226
|
|
|
|
|
|
|
|
1227
|
|
|
|
|
|
|
Gets and returns results of a search of Viddler videos and people. |
1228
|
|
|
|
|
|
|
|
1229
|
|
|
|
|
|
|
$video->videos_search( $type, $query, $page, $per_page ); |
1230
|
|
|
|
|
|
|
|
1231
|
|
|
|
|
|
|
Requires the following parameters: |
1232
|
|
|
|
|
|
|
|
1233
|
|
|
|
|
|
|
* type: The type of search (e.g. "myvideos", "friendsvideos", "allvideos", "relevant", "recent", "popular", "timedtags", "globaltags". (The "timedtags" and "globetags" sorting argument should be used in conjunction with an actual tag being given for the query argument.)) |
1234
|
|
|
|
|
|
|
|
1235
|
|
|
|
|
|
|
* query: What to search for (e.g. "iPhone", "Pennsylvania", or "Windows XP") |
1236
|
|
|
|
|
|
|
|
1237
|
|
|
|
|
|
|
Additional options parameters include: |
1238
|
|
|
|
|
|
|
|
1239
|
|
|
|
|
|
|
* page: The "page number" of results to retrieve (e.g. 1, 2, 3). |
1240
|
|
|
|
|
|
|
|
1241
|
|
|
|
|
|
|
* per_page: The number of results to retrieve per page (maximum 100). If not specified, the default value equals 20. |
1242
|
|
|
|
|
|
|
|
1243
|
|
|
|
|
|
|
Returns a hash of an array of search results |
1244
|
|
|
|
|
|
|
|
1245
|
|
|
|
|
|
|
=cut |
1246
|
|
|
|
|
|
|
|
1247
|
|
|
|
|
|
|
sub videos_search( $$ ) { |
1248
|
|
|
|
|
|
|
|
1249
|
|
|
|
|
|
|
my ( $self, $type, $query, $page, $per_page ) = @_; |
1250
|
|
|
|
|
|
|
|
1251
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
1252
|
|
|
|
|
|
|
|
1253
|
|
|
|
|
|
|
if ( !defined $page ) { |
1254
|
|
|
|
|
|
|
|
1255
|
|
|
|
|
|
|
$page = ""; |
1256
|
|
|
|
|
|
|
|
1257
|
|
|
|
|
|
|
} |
1258
|
|
|
|
|
|
|
|
1259
|
|
|
|
|
|
|
if ( !defined $per_page ) { |
1260
|
|
|
|
|
|
|
|
1261
|
|
|
|
|
|
|
$per_page = ""; |
1262
|
|
|
|
|
|
|
|
1263
|
|
|
|
|
|
|
} |
1264
|
|
|
|
|
|
|
|
1265
|
|
|
|
|
|
|
my $content = |
1266
|
|
|
|
|
|
|
get $self->{_apiURL} |
1267
|
|
|
|
|
|
|
. "?method=viddler.videos.search&api_key=" |
1268
|
|
|
|
|
|
|
. $self->{apiKey} |
1269
|
|
|
|
|
|
|
. "&type=" |
1270
|
|
|
|
|
|
|
. $type |
1271
|
|
|
|
|
|
|
. "&query=" |
1272
|
|
|
|
|
|
|
. $query |
1273
|
|
|
|
|
|
|
. "&page=" |
1274
|
|
|
|
|
|
|
. $page |
1275
|
|
|
|
|
|
|
. "&per_age=" |
1276
|
|
|
|
|
|
|
. $per_page |
1277
|
|
|
|
|
|
|
. "&sessionid=" |
1278
|
|
|
|
|
|
|
. $self->{_sessionID}; |
1279
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
1280
|
|
|
|
|
|
|
return $results; |
1281
|
|
|
|
|
|
|
|
1282
|
|
|
|
|
|
|
} |
1283
|
|
|
|
|
|
|
|
1284
|
|
|
|
|
|
|
=head3 videos_getByUser |
1285
|
|
|
|
|
|
|
|
1286
|
|
|
|
|
|
|
Gets and returns a lists of all videos that were uploaded by the specified user. |
1287
|
|
|
|
|
|
|
|
1288
|
|
|
|
|
|
|
$video->videos_getByUser( $user, page, $per_page, $tags, $sort ); |
1289
|
|
|
|
|
|
|
|
1290
|
|
|
|
|
|
|
Requires the following parameters: |
1291
|
|
|
|
|
|
|
|
1292
|
|
|
|
|
|
|
* user: The chosen Viddler user name. You can provide multiple coma separated Viddler usernames |
1293
|
|
|
|
|
|
|
|
1294
|
|
|
|
|
|
|
Additional options parameters include: |
1295
|
|
|
|
|
|
|
|
1296
|
|
|
|
|
|
|
* page: The of results to retrieve (e.g. 1, 2, 3). |
1297
|
|
|
|
|
|
|
|
1298
|
|
|
|
|
|
|
* per_page: The number of results to retrieve per page (maximum 100). If not specified, the default value equals 20. |
1299
|
|
|
|
|
|
|
|
1300
|
|
|
|
|
|
|
* tags: The tags you would like to filter your query by. |
1301
|
|
|
|
|
|
|
|
1302
|
|
|
|
|
|
|
* sort: How you would like to sort your query (views-asc,views-desc,uploaded-asc,uploaded-desc) |
1303
|
|
|
|
|
|
|
|
1304
|
|
|
|
|
|
|
Returns a hash of an array of search results |
1305
|
|
|
|
|
|
|
|
1306
|
|
|
|
|
|
|
=cut |
1307
|
|
|
|
|
|
|
|
1308
|
|
|
|
|
|
|
sub videos_getByUser( $ ) { |
1309
|
|
|
|
|
|
|
|
1310
|
|
|
|
|
|
|
my ( $self, $user, $page, $per_page, $tags, $sort ) = @_; |
1311
|
|
|
|
|
|
|
|
1312
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
1313
|
|
|
|
|
|
|
|
1314
|
|
|
|
|
|
|
if ( !defined $page ) { |
1315
|
|
|
|
|
|
|
|
1316
|
|
|
|
|
|
|
$page = ""; |
1317
|
|
|
|
|
|
|
|
1318
|
|
|
|
|
|
|
} |
1319
|
|
|
|
|
|
|
|
1320
|
|
|
|
|
|
|
if ( !defined $per_page ) { |
1321
|
|
|
|
|
|
|
|
1322
|
|
|
|
|
|
|
$per_page = ""; |
1323
|
|
|
|
|
|
|
|
1324
|
|
|
|
|
|
|
} |
1325
|
|
|
|
|
|
|
|
1326
|
|
|
|
|
|
|
if ( !defined $tags ) { |
1327
|
|
|
|
|
|
|
|
1328
|
|
|
|
|
|
|
$tags = ""; |
1329
|
|
|
|
|
|
|
|
1330
|
|
|
|
|
|
|
} |
1331
|
|
|
|
|
|
|
|
1332
|
|
|
|
|
|
|
if ( !defined $sort ) { |
1333
|
|
|
|
|
|
|
|
1334
|
|
|
|
|
|
|
$sort = ""; |
1335
|
|
|
|
|
|
|
|
1336
|
|
|
|
|
|
|
} |
1337
|
|
|
|
|
|
|
|
1338
|
|
|
|
|
|
|
my $content = |
1339
|
|
|
|
|
|
|
get $self->{_apiURL} |
1340
|
|
|
|
|
|
|
. "?method=viddler.videos.getByUser&api_key=" |
1341
|
|
|
|
|
|
|
. $self->{apiKey} |
1342
|
|
|
|
|
|
|
. "&sessionid=" |
1343
|
|
|
|
|
|
|
. $self->{_sessionID} |
1344
|
|
|
|
|
|
|
. "&user=" |
1345
|
|
|
|
|
|
|
. $user |
1346
|
|
|
|
|
|
|
. "&page=" |
1347
|
|
|
|
|
|
|
. $page |
1348
|
|
|
|
|
|
|
. "&per_age=" |
1349
|
|
|
|
|
|
|
. $per_page |
1350
|
|
|
|
|
|
|
. "&tags=" |
1351
|
|
|
|
|
|
|
. $tags |
1352
|
|
|
|
|
|
|
. "&sort=" |
1353
|
|
|
|
|
|
|
. $sort; |
1354
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
1355
|
|
|
|
|
|
|
return $results; |
1356
|
|
|
|
|
|
|
|
1357
|
|
|
|
|
|
|
} |
1358
|
|
|
|
|
|
|
|
1359
|
|
|
|
|
|
|
=head3 videos_getByTag |
1360
|
|
|
|
|
|
|
|
1361
|
|
|
|
|
|
|
Lists all videos that have the specified tag. |
1362
|
|
|
|
|
|
|
|
1363
|
|
|
|
|
|
|
$video->videos_getByTag( $tag, $page, $per_page, $sort ); |
1364
|
|
|
|
|
|
|
|
1365
|
|
|
|
|
|
|
Requires the following parameters: |
1366
|
|
|
|
|
|
|
|
1367
|
|
|
|
|
|
|
* tag The tag to search for |
1368
|
|
|
|
|
|
|
|
1369
|
|
|
|
|
|
|
Additional options parameters include: |
1370
|
|
|
|
|
|
|
|
1371
|
|
|
|
|
|
|
* page: The "page number" of results to retrieve (e.g. 1, 2, 3). |
1372
|
|
|
|
|
|
|
|
1373
|
|
|
|
|
|
|
* per_page: The number of results to retrieve per page (maximum 100). If not specified, the default value equals 20. |
1374
|
|
|
|
|
|
|
|
1375
|
|
|
|
|
|
|
* sort: How you would like to sort your query (views-asc,views-desc,uploaded-asc,uploaded-desc) |
1376
|
|
|
|
|
|
|
|
1377
|
|
|
|
|
|
|
Returns a hash of an array of details for videos with a matching tag |
1378
|
|
|
|
|
|
|
|
1379
|
|
|
|
|
|
|
=cut |
1380
|
|
|
|
|
|
|
|
1381
|
|
|
|
|
|
|
sub videos_getByTag( $ ) { |
1382
|
|
|
|
|
|
|
|
1383
|
|
|
|
|
|
|
my ( $self, $tag, $page, $per_page, $sort ) = @_; |
1384
|
|
|
|
|
|
|
|
1385
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
1386
|
|
|
|
|
|
|
|
1387
|
|
|
|
|
|
|
if ( !defined $page ) { |
1388
|
|
|
|
|
|
|
|
1389
|
|
|
|
|
|
|
$page = ""; |
1390
|
|
|
|
|
|
|
|
1391
|
|
|
|
|
|
|
} |
1392
|
|
|
|
|
|
|
|
1393
|
|
|
|
|
|
|
if ( !defined $per_page ) { |
1394
|
|
|
|
|
|
|
|
1395
|
|
|
|
|
|
|
$per_page = ""; |
1396
|
|
|
|
|
|
|
|
1397
|
|
|
|
|
|
|
} |
1398
|
|
|
|
|
|
|
|
1399
|
|
|
|
|
|
|
if ( !defined $sort ) { |
1400
|
|
|
|
|
|
|
|
1401
|
|
|
|
|
|
|
$sort = ""; |
1402
|
|
|
|
|
|
|
|
1403
|
|
|
|
|
|
|
} |
1404
|
|
|
|
|
|
|
|
1405
|
|
|
|
|
|
|
my $content = |
1406
|
|
|
|
|
|
|
get $self->{_apiURL} |
1407
|
|
|
|
|
|
|
. "?method=viddler.videos.getByTag&api_key=" |
1408
|
|
|
|
|
|
|
. $self->{apiKey} . "&tag=" |
1409
|
|
|
|
|
|
|
. $tag |
1410
|
|
|
|
|
|
|
. "&page=" |
1411
|
|
|
|
|
|
|
. $page |
1412
|
|
|
|
|
|
|
. "&per_page=" |
1413
|
|
|
|
|
|
|
. $per_page |
1414
|
|
|
|
|
|
|
. "&sort=" |
1415
|
|
|
|
|
|
|
. $sort; |
1416
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
1417
|
|
|
|
|
|
|
return $results; |
1418
|
|
|
|
|
|
|
|
1419
|
|
|
|
|
|
|
} |
1420
|
|
|
|
|
|
|
|
1421
|
|
|
|
|
|
|
=head3 videos_getFeatured |
1422
|
|
|
|
|
|
|
|
1423
|
|
|
|
|
|
|
Lists currently featured videos |
1424
|
|
|
|
|
|
|
|
1425
|
|
|
|
|
|
|
$video->videos_getFeatured; |
1426
|
|
|
|
|
|
|
|
1427
|
|
|
|
|
|
|
Returns a hash of an array of details for videos featured by Viddler |
1428
|
|
|
|
|
|
|
|
1429
|
|
|
|
|
|
|
=cut |
1430
|
|
|
|
|
|
|
|
1431
|
|
|
|
|
|
|
sub videos_getFeatured( ) { |
1432
|
|
|
|
|
|
|
|
1433
|
|
|
|
|
|
|
my ($self) = @_; |
1434
|
|
|
|
|
|
|
|
1435
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
1436
|
|
|
|
|
|
|
my $content = |
1437
|
|
|
|
|
|
|
get $self->{_apiURL} |
1438
|
|
|
|
|
|
|
. "?method=viddler.videos.getFeatured&api_key=" |
1439
|
|
|
|
|
|
|
. $self->{apiKey}; |
1440
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
1441
|
|
|
|
|
|
|
return $results; |
1442
|
|
|
|
|
|
|
|
1443
|
|
|
|
|
|
|
} |
1444
|
|
|
|
|
|
|
|
1445
|
|
|
|
|
|
|
=head3 videos_delete |
1446
|
|
|
|
|
|
|
|
1447
|
|
|
|
|
|
|
Deletes a video associated with a users account. |
1448
|
|
|
|
|
|
|
|
1449
|
|
|
|
|
|
|
$video->videos_delete( $video_id ); |
1450
|
|
|
|
|
|
|
|
1451
|
|
|
|
|
|
|
Requires the following parameters: |
1452
|
|
|
|
|
|
|
|
1453
|
|
|
|
|
|
|
* video_id: The ID of the video to get information for. This is the ID that's returned by videos_upload. |
1454
|
|
|
|
|
|
|
|
1455
|
|
|
|
|
|
|
Additional options parameters include: |
1456
|
|
|
|
|
|
|
|
1457
|
|
|
|
|
|
|
None |
1458
|
|
|
|
|
|
|
|
1459
|
|
|
|
|
|
|
Returns 0 ( false ) if unsuccessful and 1 ( true ) if successful |
1460
|
|
|
|
|
|
|
|
1461
|
|
|
|
|
|
|
=cut |
1462
|
|
|
|
|
|
|
|
1463
|
|
|
|
|
|
|
sub videos_delete( $ ) { |
1464
|
|
|
|
|
|
|
|
1465
|
|
|
|
|
|
|
my ( $self, $video_id ) = @_; |
1466
|
|
|
|
|
|
|
|
1467
|
|
|
|
|
|
|
my $xml = new XML::Simple; |
1468
|
|
|
|
|
|
|
my $content = |
1469
|
|
|
|
|
|
|
get $self->{_apiURL} |
1470
|
|
|
|
|
|
|
. "?method=viddler.videos.delete&api_key=" |
1471
|
|
|
|
|
|
|
. $self->{apiKey} |
1472
|
|
|
|
|
|
|
. "&sessionid=" |
1473
|
|
|
|
|
|
|
. $self->{_sessionID} |
1474
|
|
|
|
|
|
|
. "&video_id=" |
1475
|
|
|
|
|
|
|
. $video_id; |
1476
|
|
|
|
|
|
|
my $results = $xml->XMLin($content); |
1477
|
|
|
|
|
|
|
|
1478
|
|
|
|
|
|
|
if ( defined( $results->{'success'} ) ) { |
1479
|
|
|
|
|
|
|
|
1480
|
|
|
|
|
|
|
return 1; |
1481
|
|
|
|
|
|
|
|
1482
|
|
|
|
|
|
|
} |
1483
|
|
|
|
|
|
|
else { |
1484
|
|
|
|
|
|
|
|
1485
|
|
|
|
|
|
|
return 0; |
1486
|
|
|
|
|
|
|
|
1487
|
|
|
|
|
|
|
} |
1488
|
|
|
|
|
|
|
|
1489
|
|
|
|
|
|
|
} |
1490
|
|
|
|
|
|
|
|
1491
|
|
|
|
|
|
|
=head1 AUTHOR |
1492
|
|
|
|
|
|
|
|
1493
|
|
|
|
|
|
|
Paul Weinstein, C<< >> |
1494
|
|
|
|
|
|
|
|
1495
|
|
|
|
|
|
|
=head1 BUGS |
1496
|
|
|
|
|
|
|
|
1497
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
1498
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
1499
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
1500
|
|
|
|
|
|
|
|
1501
|
|
|
|
|
|
|
=head1 SUPPORT |
1502
|
|
|
|
|
|
|
|
1503
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
1504
|
|
|
|
|
|
|
|
1505
|
|
|
|
|
|
|
perldoc WebService::Viddler |
1506
|
|
|
|
|
|
|
|
1507
|
|
|
|
|
|
|
|
1508
|
|
|
|
|
|
|
You can also look for information at: |
1509
|
|
|
|
|
|
|
|
1510
|
|
|
|
|
|
|
=over 4 |
1511
|
|
|
|
|
|
|
|
1512
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
1513
|
|
|
|
|
|
|
|
1514
|
|
|
|
|
|
|
L |
1515
|
|
|
|
|
|
|
|
1516
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
1517
|
|
|
|
|
|
|
|
1518
|
|
|
|
|
|
|
L |
1519
|
|
|
|
|
|
|
|
1520
|
|
|
|
|
|
|
=item * CPAN Ratings |
1521
|
|
|
|
|
|
|
|
1522
|
|
|
|
|
|
|
L |
1523
|
|
|
|
|
|
|
|
1524
|
|
|
|
|
|
|
=item * Search CPAN |
1525
|
|
|
|
|
|
|
|
1526
|
|
|
|
|
|
|
L |
1527
|
|
|
|
|
|
|
|
1528
|
|
|
|
|
|
|
=back |
1529
|
|
|
|
|
|
|
|
1530
|
|
|
|
|
|
|
|
1531
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
1532
|
|
|
|
|
|
|
|
1533
|
|
|
|
|
|
|
|
1534
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
1535
|
|
|
|
|
|
|
|
1536
|
|
|
|
|
|
|
Copyright 2010 Paul Weinstein. |
1537
|
|
|
|
|
|
|
|
1538
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
1539
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
1540
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
1541
|
|
|
|
|
|
|
|
1542
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
1543
|
|
|
|
|
|
|
|
1544
|
|
|
|
|
|
|
|
1545
|
|
|
|
|
|
|
=cut |
1546
|
|
|
|
|
|
|
|
1547
|
|
|
|
|
|
|
1; # End of WebService::Viddler |
1548
|
|
|
|
|
|
|
__END__ |