mcfearsome-viddler 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,459 @@
1
+ module Viddler
2
+
3
+ # Generic Viddler exception class.
4
+ class ViddlerError < StandardError #:nodoc:
5
+ end
6
+
7
+ # Raised when username and password has not been set.
8
+ class AuthenticationRequiredError < ViddlerError #:nodoc:
9
+ def message
10
+ 'Method that you re trying to execute requires username and password.'
11
+ end
12
+ end
13
+
14
+ # Raised when calling not yet implemented API methods.
15
+ class NotImplementedError < ViddlerError #:nodoc:
16
+ def message
17
+ 'This method is not yet implemented.'
18
+ end
19
+ end
20
+
21
+ # A class that can be instantiated for access to a Viddler API.
22
+ #
23
+ # Examples:
24
+ #
25
+ # @viddler = Viddler::Base.new(API_KEY, USERNAME, PASSWORD)
26
+ #
27
+ # Username and password are optional, some API methods doesn't require them:
28
+ #
29
+ # @viddler = Viddler::Base.new(YOUR_API_KEY)
30
+ #
31
+ class Base
32
+ # Creates new viddler instance.
33
+ #
34
+ # Example:
35
+ #
36
+ # @viddler = Viddler::Base.new(api_key, username, password)
37
+ #
38
+ def initialize(api_key, username=nil, password=nil)
39
+ @api_key, @username, @password = api_key, username, password
40
+ @session_id = nil
41
+ end
42
+
43
+ # Implements <tt>viddler.users.auth[http://wiki.developers.viddler.com/index.php/Viddler.users.auth]</tt>.
44
+ #
45
+ # It's not necessary for you to call this method manually before each method that requires authentication. Viddler.rb will do that for you automatically. You can use this method for checking credentials and for trying if connection to Viddler works.
46
+ #
47
+ # Example:
48
+ #
49
+ # @viddler.authenticate
50
+ #
51
+ # Returns a string with session id.
52
+ #
53
+ def authenticate
54
+ raise AuthenticationRequiredError unless could_authenticate?
55
+ request = Viddler::Request.new(:get, 'users.auth')
56
+ request.run do |p|
57
+ p.api_key = @api_key
58
+ p.user = @username
59
+ p.password = @password
60
+ end
61
+ @session_id = request.response['auth']['sessionid']
62
+ end
63
+
64
+ def authenticated?
65
+ @session_id ? true : false
66
+ end
67
+
68
+ # Implements <tt>viddler.videos.getRecordToken[http://wiki.developers.viddler.com/index.php/Viddler.videos.getRecordToken]</tt>.
69
+ #
70
+ # Example:
71
+ #
72
+ # @viddler.get_record_token
73
+ #
74
+ # Returns a string with record token.
75
+ #
76
+ def get_record_token
77
+ authenticate unless authenticated?
78
+
79
+ request = Viddler::Request.new(:get, 'videos.getRecordToken')
80
+ request.run do |p|
81
+ p.api_key = @api_key
82
+ p.sessionid = @session_id
83
+ end
84
+ request.response['record_token']
85
+ end
86
+
87
+ # Implements <tt>viddler.users.register[http://wiki.developers.viddler.com/index.php/Viddler.users.register]</tt>. <b>Restricted to Viddler qualified API keys only.</b>
88
+ #
89
+ # <tt>new_attributes</tt> hash should contain next required keys:
90
+ # * <tt>user:</tt> The chosen Viddler user name;
91
+ # * <tt>email:</tt> The email address of the user;
92
+ # * <tt>fname:</tt> The user's first name;
93
+ # * <tt>lname:</tt> The user's last name;
94
+ # * <tt>password:</tt> The user's password with Viddler;
95
+ # * <tt>question:</tt> The text of the user's secret question;
96
+ # * <tt>answer:</tt> The text of the answer to the secret question;
97
+ # * <tt>lang:</tt> The language of the user for the account (e.g. EN)
98
+ # * <tt>termsaccepted:</tt> "1" indicates the user has accepted Viddler's terms and conditions.
99
+ #
100
+ # and could contain next optional keys:
101
+ # * <tt>company:</tt> The user's company affiliation.
102
+ #
103
+ # Example:
104
+ #
105
+ # @viddler.register_user(:user => 'login', :email => 'mail@example.com', ...)
106
+ #
107
+ # Returns new user's username string.
108
+ #
109
+ def register_user(new_attributes={})
110
+ Viddler::ApiSpec.check_attributes('users.register', new_attributes)
111
+
112
+ request = Viddler::Request.new(:get, 'users.register')
113
+ request.run do |p|
114
+ p.api_key = @api_key
115
+ for param, value in new_attributes
116
+ p.send("#{param}=", value)
117
+ end
118
+ end
119
+ request.response['user']['username']
120
+ end
121
+
122
+ # Implements <tt>viddler.videos.upload[http://wiki.developers.viddler.com/index.php/Viddler.videos.upload]</tt>. Requires authentication.
123
+ #
124
+ # <tt>new_attributes</tt> hash should contain next required keys:
125
+ # * <tt>title:</tt> The video title;
126
+ # * <tt>description:</tt> The video description;
127
+ # * <tt>tags:</tt> The video tags;
128
+ # * <tt>file:</tt> The video file;
129
+ # * <tt>make_public:</tt> Use "1" for true and "0" for false to choose whether or not the video goes public when uploaded.
130
+ #
131
+ # Example:
132
+ #
133
+ # @viddler.upload_video(:title => 'Great Title', :file => File.open('/movies/movie.mov'), ...)
134
+ #
135
+ # Returns Viddler::Video instance.
136
+ #
137
+ def upload_video(new_attributes={})
138
+ authenticate unless authenticated?
139
+ Viddler::ApiSpec.check_attributes('videos.upload', new_attributes)
140
+
141
+ # Get an upload endpoint
142
+ request = Viddler::Request.new(:post, 'viddler.videos.prepareUpload')
143
+ request.run do |p|
144
+ p.api_key = @api_key
145
+ p.sessionid = @session_id
146
+ end
147
+ endpoint = request.response['upload']['endpoint']
148
+
149
+ # Upload to endpoint url
150
+ request = Viddler::Request.new(:post, 'videos.upload')
151
+ request.url = endpoint
152
+ request.run do |p|
153
+ p.api_key = @api_key
154
+ p.sessionid = @session_id
155
+ for param, value in new_attributes
156
+ p.send("#{param}=", value)
157
+ end
158
+ end
159
+ Viddler::Video.new(request.response['video'])
160
+ end
161
+
162
+ # Implements <tt>viddler.users.getProfile[http://wiki.developers.viddler.com/index.php/Viddler.users.getProfile]</tt>.
163
+ #
164
+ # Example:
165
+ #
166
+ # @viddler.find_profile(viddler_username)
167
+ #
168
+ # Returns Viddler::User instance.
169
+ #
170
+ def find_profile(viddler_name)
171
+ request = Viddler::Request.new(:get, 'users.getProfile')
172
+ request.run do |p|
173
+ p.api_key = @api_key
174
+ p.user = viddler_name
175
+ end
176
+ Viddler::User.new request.response['user']
177
+ end
178
+
179
+ # Implements <tt>viddler.users.setProfile[http://wiki.developers.viddler.com/index.php/Viddler.users.setProfile]</tt>. Requires authentication.
180
+ #
181
+ # <tt>new_attributes</tt> hash could contain next optional keys:
182
+ # * <tt>first_name</tt>
183
+ # * <tt>last_name</tt>
184
+ # * <tt>about_me</tt>
185
+ # * <tt>birthdate:</tt> Birthdate in yyyy-mm-dd format;
186
+ # * <tt>gender:</tt> Either m or y.
187
+ # * <tt>company</tt>
188
+ # * <tt>city</tt>
189
+ #
190
+ # Example:
191
+ #
192
+ # @viddler.update_profile(:first_name => 'Vasya', :last_name => 'Pupkin')
193
+ #
194
+ # Returns Viddler::User instance.
195
+ #
196
+ def update_profile(new_attributes={})
197
+ authenticate unless authenticated?
198
+ Viddler::ApiSpec.check_attributes('users.setProfile', new_attributes)
199
+
200
+ request = Viddler::Request.new(:post, 'users.setProfile')
201
+ request.run do |p|
202
+ p.api_key = @api_key
203
+ p.sessionid = @session_id
204
+ for param, value in new_attributes
205
+ p.send("#{param}=", value)
206
+ end
207
+ end
208
+ Viddler::User.new request.response['user']
209
+ end
210
+
211
+ # Implements <tt>viddler.users.setOptions[http://wiki.developers.viddler.com/index.php/Viddler.users.setOptions]</tt>. Requires authentication. <b>Restricted to Viddler partners only.</b>
212
+ #
213
+ # <tt>new_attributes</tt> hash could contain next optional keys:
214
+ # * <tt>show_account:</tt> "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
215
+ # * <tt>tagging_enabled:</tt> "1", "0" - Enable/disable tagging on all your videos
216
+ # * <tt>commenting_enabled:</tt> "1", "0" - Enable/disable commenting on all your videos
217
+ # * <tt>show_related_videos:</tt> "1", "0" - Show/hide related videos on all your videos
218
+ # * <tt>embedding_enabled:</tt> "1", "0" - Enable/disable embedding of off all your videos
219
+ # * <tt>clicking_through_enabled:</tt> "1", "0" - Enable/disable redirect to viddler site while clicking on embedded player
220
+ # * <tt>email_this_enabled:</tt> "1", "0" - Enable/disable email this option on all your videos
221
+ # * <tt>trackbacks_enabled:</tt> "1", "0" - Enable/disable trackbacks on all your videos
222
+ # * <tt>favourites_enabled:</tt> "1", "0" - Enable/disable favourites on all your videos
223
+ # * <tt>custom_logo_enabled:</tt> "1", "0" - Enable/disable custom logo on all your videos. Note that logo itself must be send to viddler manually.
224
+ #
225
+ # Example:
226
+ #
227
+ # @viddler.update_account(:show_account => '0')
228
+ #
229
+ # Returns number of updated parameters.
230
+ #
231
+ def update_account(new_attributes={})
232
+ authenticate unless authenticated?
233
+ Viddler::ApiSpec.check_attributes('users.setOptions', new_attributes)
234
+
235
+ request = Viddler::Request.new(:get, 'users.setOptions')
236
+ request.run do |p|
237
+ p.api_key = @api_key
238
+ p.sessionid = @session_id
239
+ for param, value in new_attributes
240
+ p.send("#{param}=", value)
241
+ end
242
+ end
243
+ request.response['updated'].to_i
244
+ end
245
+
246
+ # Implements <tt>viddler.videos.getStatus[http://wiki.developers.viddler.com/index.php/Viddler.vidoes.getStatus]</tt>.
247
+ #
248
+ # Example:
249
+ #
250
+ # @viddler.get_video_status(video_id)
251
+ #
252
+ # This methods returns OpenStruct instance with Viddler's status information on a given video. We don't control what Viddler returns and it's all basically technical internal information of Viddler. Use this on your own risk.
253
+ #
254
+ def get_video_status(video_id)
255
+ request = Viddler::Request.new(:get, 'videos.getStatus')
256
+ request.run do |p|
257
+ p.api_key = @api_key
258
+ p.video_id = video_id
259
+ end
260
+ OpenStruct.new request.response['video_status']
261
+ end
262
+
263
+ # Implements <tt>viddler.videos.getDetails[http://wiki.developers.viddler.com/index.php/Viddler.videos.getDetails]</tt>. Authentication is optional.
264
+ #
265
+ # Example:
266
+ #
267
+ # @viddler.find_video_by_id(video_id)
268
+ #
269
+ # Returns Viddler::Video instance.
270
+ #
271
+ def find_video_by_id(video_id)
272
+ # Authentication is optional for this request
273
+ authenticate if could_authenticate? and !authenticated?
274
+
275
+ request = Viddler::Request.new(:get, 'videos.getDetails')
276
+ request.run do |p|
277
+ p.api_key = @api_key
278
+ p.video_id = video_id
279
+ p.sessionid = @session_id if authenticated?
280
+ end
281
+ Viddler::Video.new(request.response['video'])
282
+ end
283
+
284
+ # Implements <tt>viddler.videos.getDetailsByUrl[http://wiki.developers.viddler.com/index.php/Viddler.videos.getDetailsByUrl]</tt>. Authentication is optional.
285
+ #
286
+ # Example:
287
+ #
288
+ # @viddler.find_video_by_url('http://www.viddler.com/explore/username/videos/video_num/')
289
+ #
290
+ # Returns Viddler::Video instance.
291
+ #
292
+ def find_video_by_url(video_url)
293
+ # Authentication is optional for this request
294
+ authenticate if could_authenticate? and !authenticated?
295
+
296
+ request = Viddler::Request.new(:get, 'videos.getDetailsByUrl')
297
+ request.run do |p|
298
+ p.sessionid = @session_id if authenticated?
299
+ p.api_key = @api_key
300
+ p.url = video_url
301
+ end
302
+ Viddler::Video.new(request.response['video'])
303
+ end
304
+
305
+ # Implements <tt>viddler.videos.setDetails[http://wiki.developers.viddler.com/index.php/Viddler.videos.setDetails]</tt>. Requires authentication.
306
+ #
307
+ # <tt>new_attributes</tt> hash could contain next optional keys:
308
+ # * <tt>title:</tt> Video title - 500 characters max
309
+ # * <tt>description:</tt> Video description
310
+ # * <tt>tags:</tt> 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 format tagname[timestamp_in_ms] as tagname. For example - using tag1,tag2,tag3[2500] will set 2 global and 1 timed tag at 2.5s
311
+ # * <tt>view_perm:</tt> View permission. Can be set to public, shared_all, shared or private
312
+ # * <tt>view_users:</tt> 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.
313
+ # * <tt>view_use_secret:</tt> 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.
314
+ # * <tt>embed_perm:</tt> Embedding permission. Supported permission levels are the same as for view_perm. This and all permissions below cannot be less restrictive than view_perm. You cannot set it to public if view_perm is for example shared.
315
+ # * <tt>embed_users:</tt> Same as view_users. If view_perm is shared, this list cannot contain more users than view_users. Invalid usernames will be removed.
316
+ # * <tt>commenting_perm:</tt> Commenting permission. Description is the same as for embed_perm
317
+ # * <tt>commenting_users:</tt> Same as embed_users.
318
+ # * <tt>tagging_perm:</tt> Tagging permission. Description is the same as for embed_perm
319
+ # * <tt>tagging_users:</tt> Same as embed_users.
320
+ # * <tt>download_perm:</tt> Download permission. Description is the same as for embed_perm
321
+ # * <tt>download_users:</tt> Same as embed_users.
322
+ #
323
+ # Example:
324
+ #
325
+ # @viddler.update_video(video_id, :title => 'Brand new title')
326
+ #
327
+ # Returns Viddler::Video instance.
328
+ #
329
+ def update_video(video_id, new_attributes={})
330
+ authenticate unless authenticated?
331
+ Viddler::ApiSpec.check_attributes('videos.setDetails', new_attributes)
332
+
333
+ request = Viddler::Request.new(:get, 'videos.setDetails')
334
+ request.run do |p|
335
+ p.api_key = @api_key
336
+ p.sessionid = @session_id
337
+ p.video_id = video_id
338
+ for param, value in new_attributes
339
+ p.send("#{param}=", value)
340
+ end
341
+ end
342
+ Viddler::Video.new(request.response['video'])
343
+ end
344
+
345
+ def set_permalink(video_id, url)
346
+ authenticate unless authenticated?
347
+
348
+ request = Viddler::Request.new(:post, 'videos.setPermalink')
349
+ request.run do |p|
350
+ p.api_key = @api_key
351
+ p.sessionid = @session_id
352
+ p.video_id = video_id
353
+ p.permalink = url
354
+ end
355
+ end
356
+
357
+ # Implements <tt>viddler.videos.getByUser[http://wiki.developers.viddler.com/index.php/Viddler.videos.getByUser]</tt>. Authentication is optional.
358
+ #
359
+ # Options hash could contain next values:
360
+ # * <tt>page</tt>: The "page number" of results to retrieve (e.g. 1, 2, 3);
361
+ # * <tt>per_page</tt>: The number of results to retrieve per page (maximum 100). If not specified, the default value equals 20.
362
+ #
363
+ # Example:
364
+ #
365
+ # @viddler.find_all_videos_by_user(username, :page => 2)
366
+ #
367
+ # Returns array of Viddler::Video instances.
368
+ #
369
+ def find_all_videos_by_user(username, options={})
370
+ authenticate if could_authenticate? and !authenticated?
371
+
372
+ options.assert_valid_keys(:page, :per_page)
373
+
374
+ request = Viddler::Request.new(:get, 'videos.getByUser')
375
+ request.run do |p|
376
+ p.api_key = @api_key
377
+ p.sessionid = @session_id if authenticated?
378
+ p.user = username
379
+ p.page = options[:page] || 1
380
+ p.per_page = options[:per_page] || 20
381
+ end
382
+ parse_videos_list(request.response['video_list'])
383
+ end
384
+
385
+ # Implements <tt>viddler.videos.getByTag[http://wiki.developers.viddler.com/index.php/Viddler.videos.getByTag]</tt>.
386
+ #
387
+ # Options hash could contain next values:
388
+ # * <tt>page</tt>: The "page number" of results to retrieve (e.g. 1, 2, 3);
389
+ # * <tt>per_page</tt>: The number of results to retrieve per page (maximum 100). If not specified, the default value equals 20.
390
+ #
391
+ # Example:
392
+ #
393
+ # @viddler.find_all_videos_by_tag('super tag', :per_page => 5)
394
+ #
395
+ # Returns array of Viddler::Video instances.
396
+ #
397
+ def find_all_videos_by_tag(tag_name, options={})
398
+ options.assert_valid_keys(:page, :per_page)
399
+
400
+ request = Viddler::Request.new(:get, 'videos.getByTag')
401
+ request.run do |p|
402
+ p.api_key = @api_key
403
+ p.tag = tag_name
404
+ p.page = options[:page] || 1
405
+ p.per_page = options[:per_page] || 20
406
+ end
407
+ parse_videos_list(request.response['video_list'])
408
+ end
409
+
410
+ # Implements <tt>viddler.videos.getFeatured[http://wiki.developers.viddler.com/index.php/Viddler.videos.getFeatured]</tt>.
411
+ #
412
+ # Example:
413
+ #
414
+ # @viddler.find_all_featured_videos
415
+ #
416
+ # Returns array of Viddler::Video instances.
417
+ #
418
+ def find_all_featured_videos
419
+ request = Viddler::Request.new(:get, 'videos.getFeatured')
420
+ request.run do |p|
421
+ p.api_key = @api_key
422
+ end
423
+ parse_videos_list(request.response['video_list'])
424
+ end
425
+
426
+ def delete_video(id)
427
+ authenticate unless authenticated?
428
+ request = Viddler::Request.new(:post, 'videos.delete')
429
+ request.run do |p|
430
+ p.api_key = @api_key
431
+ p.sessionid = @session_id
432
+ p.video_id = id
433
+ end
434
+ end
435
+
436
+ def delete_comment(id)
437
+ authenticate unless authenticated?
438
+ request = Viddler::Request.new(:post, 'videos.comments.remove')
439
+ request.run do |p|
440
+ p.api_key = @api_key
441
+ p.sessionid = @session_id
442
+ p.comment_id = id
443
+ end
444
+ end
445
+
446
+ private
447
+
448
+ def could_authenticate?
449
+ @username and @password
450
+ end
451
+
452
+ def parse_videos_list(video_list)
453
+ video_list['video'].collect do |attr|
454
+ next unless attr.is_a?(Hash)
455
+ Viddler::Video.new(attr)
456
+ end
457
+ end
458
+ end
459
+ end
@@ -0,0 +1,24 @@
1
+ module Viddler
2
+ # This class wraps Viddler's comment's information.
3
+ class Comment
4
+
5
+ attr_accessor :id, :author, :text, :time, :timepoint
6
+
7
+ def initialize(attributes={}) #:nodoc:
8
+ a = attributes
9
+ @id = a['id']
10
+ @author = a['author']
11
+ @text = a['text']
12
+ @time = Time.at(fix_unix_time(a['time']))
13
+ @timepoint = a['add_timepoint'].to_i / 1000
14
+ end
15
+
16
+ private
17
+
18
+ # For unknown reason Viddler API returns wrong unix time with 3 superfluous zeros at the end.
19
+ def fix_unix_time(viddler_time) #:nodoc:
20
+ viddler_time.to_i / 1000
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,127 @@
1
+ module Viddler
2
+
3
+ # Raised when response from Viddler contains absolutely no data
4
+ class EmptyResponseError < ViddlerError #:nodoc:
5
+ end
6
+
7
+ # Raised when response from Viddler contains an error
8
+ class ResponseError < ViddlerError #:nodoc:
9
+ def initialize(message)
10
+ super message
11
+ end
12
+ end
13
+
14
+ # Class used to send requests over http to Viddler API.
15
+ class Request #:nodoc:
16
+
17
+ API_URL = 'http://api.viddler.com/rest/v1/'
18
+
19
+ attr_accessor :url, :http_method, :response
20
+ attr_reader :params
21
+
22
+ def initialize(http_method, method) #:nodoc:
23
+ @http_method = http_method.to_s
24
+ @url = API_URL
25
+ self.params = {:method => viddlerize(method)}
26
+ end
27
+
28
+ # Use this method to setup your request's payload and headers.
29
+ #
30
+ # Example:
31
+ #
32
+ # request.set :headers do |h|
33
+ # h.content_type = 'application/ufo'
34
+ # end
35
+ #
36
+ # request.set :params do |p|
37
+ # p.sessionid = '12323'
38
+ # p.api_key = '13123
39
+ # end
40
+ #
41
+ def set(container, &declarations)
42
+ struct = OpenStruct.new
43
+ declarations.call(struct)
44
+ send("#{container}=", struct.table)
45
+ end
46
+
47
+ # Send http request to Viddler API.
48
+ def run(&block)
49
+ if block_given?
50
+ set(:params, &block)
51
+ end
52
+
53
+ c = Curl::Easy.new(url)
54
+ c.headers['Accept'] = 'application/xml'
55
+
56
+ if post? or multipart?
57
+ c.multipart_form_post = true if multipart?
58
+ c.http_post(*build_params)
59
+ else
60
+ c.url = url_with_params
61
+ c.perform
62
+ end
63
+
64
+ self.response = parse_response(c.body_str)
65
+ end
66
+
67
+ private
68
+
69
+ def build_params
70
+ f = []
71
+ t = []
72
+ params.each do |key, value|
73
+ if value.is_a? File
74
+ f << Curl::PostField.file(key.to_s, value.path, File.basename(value.path))
75
+ else
76
+ t << Curl::PostField.content(key.to_s, value.to_s)
77
+ end
78
+ end
79
+ t + f
80
+ end
81
+
82
+ def parse_response(raw_response)
83
+ raise EmptyResponseError if raw_response.blank?
84
+ response_hash = Hash.from_xml(raw_response)
85
+ if response_error = response_hash['error']
86
+ raise ResponseError.new(viddler_error_message(response_error))
87
+ end
88
+ response_hash
89
+ end
90
+
91
+ def url_with_params
92
+ self.url + '?' + params.to_query
93
+ end
94
+
95
+ def viddlerize(name)
96
+ if name.include?('viddler.')
97
+ name
98
+ else
99
+ 'viddler.' + name
100
+ end
101
+ end
102
+
103
+ def params=(hash) #:nodoc:
104
+ @params ||= Hash.new
105
+ @params.update(hash)
106
+ end
107
+
108
+ def multipart? #:nodoc:
109
+ if params.find{|k,v| v.is_a?(File)} then true else false end
110
+ end
111
+
112
+ def post? #:nodoc:
113
+ http_method == 'post'
114
+ end
115
+
116
+ def viddler_error_message(response_error)
117
+ description = response_error['description'] || ''
118
+ details = response_error['details'] || ''
119
+ code = response_error['code'] || ''
120
+
121
+ details = ": #{details};" unless details.empty?
122
+ code = " [code: #{code}]" unless code.empty?
123
+ %Q[#{description}#{details}#{code}]
124
+ end
125
+
126
+ end
127
+ end
@@ -0,0 +1,39 @@
1
+ module Viddler
2
+ # This class wraps Viddler's user's information.
3
+ class User
4
+
5
+ attr_accessor :username,
6
+ :first_name,
7
+ :last_name,
8
+ :about_me,
9
+ :avatar,
10
+ :age,
11
+ :video_upload_count,
12
+ :video_watch_count,
13
+ :homepage,
14
+ :gender,
15
+ :company,
16
+ :city,
17
+ :friend_count,
18
+ :favourite_video_count
19
+
20
+ def initialize(attributes={}) #:nodoc:
21
+ a = attributes
22
+ @username = a['username']
23
+ @first_name = a['first_name']
24
+ @last_name = a['last_name']
25
+ @about_me = a['about_me']
26
+ @avatar = a['avatar']
27
+ @age = a['age'].to_i
28
+ @homepage = a['homepage']
29
+ @gender = a['gender']
30
+ @company = a['company']
31
+ @city = a['city']
32
+ @video_upload_count = a['video_upload_count'].to_i
33
+ @video_watch_count = a['video_watch_count'].to_i
34
+ @friend_count = a['friend_count'].to_i
35
+ @favourite_video_count = a['favourite_video_count'].to_i
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,9 @@
1
+ module Viddler #:nodoc:
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 2
5
+ TINY = 5
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end