viddler 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +2 -0
- data/.gitignore +4 -0
- data/.rvmrc +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +24 -0
- data/History.txt +9 -0
- data/README.txt +9 -4
- data/Rakefile +77 -3
- data/VERSION +1 -0
- data/lib/viddler.rb +2 -5
- data/lib/viddler/api_spec.rb +3 -3
- data/lib/viddler/base.rb +117 -62
- data/lib/viddler/comment.rb +4 -2
- data/lib/viddler/multipart_params.rb +11 -6
- data/lib/viddler/request.rb +33 -32
- data/lib/viddler/version.rb +1 -1
- data/lib/viddler/video.rb +69 -30
- data/test/fixtures/embed_code.txt +8 -0
- data/test/test_helper.rb +6 -1
- data/test/test_viddler.rb +79 -33
- data/test/video.rb +83 -0
- data/{log/debug.log → tmp/.gitignore} +0 -0
- data/viddler.gemspec +98 -0
- metadata +95 -34
- data/Manifest.txt +0 -35
- data/config/hoe.rb +0 -70
- data/config/requirements.rb +0 -15
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -74
- data/setup.rb +0 -1585
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/website/index.html +0 -93
- data/website/index.txt +0 -39
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.html.erb +0 -48
data/.bundle/config
ADDED
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm gemset use viddler_dev
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
viddler (0.3.4)
|
5
|
+
activesupport (>= 3.0.0.rc)
|
6
|
+
mime-types
|
7
|
+
rest-client
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (3.0.0.rc)
|
13
|
+
mime-types (1.16)
|
14
|
+
rest-client (1.6.0)
|
15
|
+
mime-types (>= 1.16)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
activesupport (>= 3.0.0.rc)
|
22
|
+
mime-types
|
23
|
+
rest-client
|
24
|
+
viddler!
|
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
= Viddler.rb
|
2
2
|
|
3
3
|
* Rubyforge profile: http://viddler.rubyforge.com
|
4
|
-
* Source code
|
4
|
+
* Source code: http://github.com/iSabanin/viddler
|
5
|
+
* Tracker: http://ilya_sabanin.lighthouseapp.com/projects/10110-viddler-rb/overview
|
5
6
|
|
6
7
|
== DESCRIPTION:
|
7
8
|
|
@@ -25,11 +26,11 @@ Currently implemented API methods:
|
|
25
26
|
* viddler.videos.getByUser
|
26
27
|
* viddler.videos.getByTag
|
27
28
|
* viddler.videos.getFeatured
|
28
|
-
|
29
|
+
|
29
30
|
== NOT YET IMPLEMENTED:
|
30
31
|
|
31
32
|
* Wrapper for video permissions.
|
32
|
-
|
33
|
+
|
33
34
|
== REQUIREMENTS:
|
34
35
|
|
35
36
|
* active_support[http://rubyforge.org/projects/activesupport/]
|
@@ -38,12 +39,16 @@ Currently implemented API methods:
|
|
38
39
|
|
39
40
|
== INSTALL:
|
40
41
|
|
41
|
-
*
|
42
|
+
* gem install viddler
|
42
43
|
|
43
44
|
== CONTACT:
|
44
45
|
|
45
46
|
* ilya dot sabanin at gmail.com
|
46
47
|
|
48
|
+
== CONTRIBUTORS:
|
49
|
+
|
50
|
+
* Kyle Slattery
|
51
|
+
|
47
52
|
== LICENSE:
|
48
53
|
|
49
54
|
(The MIT License)
|
data/Rakefile
CHANGED
@@ -1,4 +1,78 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
3
|
|
4
|
-
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "viddler"
|
8
|
+
gem.summary = 'Ruby wrapper around Viddler.com API.'
|
9
|
+
gem.email = 'ilya.sabanin@gmail.com'
|
10
|
+
gem.homepage = "http://viddler.rubyforge.org"
|
11
|
+
gem.authors = ["Ilya Sabanin"]
|
12
|
+
|
13
|
+
gem.add_dependency("activesupport", ">= 3.0.0.rc")
|
14
|
+
gem.add_dependency("rest-client")
|
15
|
+
gem.add_dependency("mime-types")
|
16
|
+
|
17
|
+
gem.description = \
|
18
|
+
%{Ruby wrapper around Viddler.com[http://www.viddler.com] API.
|
19
|
+
|
20
|
+
== FEATURES:
|
21
|
+
|
22
|
+
Currently implemented API methods:
|
23
|
+
|
24
|
+
* viddler.videos.getRecordToken
|
25
|
+
* viddler.users.register
|
26
|
+
* viddler.users.auth
|
27
|
+
* viddler.users.getProfile
|
28
|
+
* viddler.users.setProfile
|
29
|
+
* viddler.users.setOptions
|
30
|
+
* viddler.videos.upload
|
31
|
+
* viddler.videos.getStatus
|
32
|
+
* viddler.videos.getDetails
|
33
|
+
* viddler.videos.getDetailsByUrl
|
34
|
+
* viddler.videos.setDetails
|
35
|
+
* viddler.videos.getByUser
|
36
|
+
* viddler.videos.getByTag
|
37
|
+
* viddler.videos.getFeatured
|
38
|
+
}
|
39
|
+
|
40
|
+
end
|
41
|
+
Jeweler::GemcutterTasks.new
|
42
|
+
rescue LoadError
|
43
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
44
|
+
end
|
45
|
+
|
46
|
+
require 'rake/testtask'
|
47
|
+
Rake::TestTask.new(:test) do |test|
|
48
|
+
test.libs << 'lib' << 'test'
|
49
|
+
test.pattern = 'test/**/test_*.rb'
|
50
|
+
test.verbose = true
|
51
|
+
end
|
52
|
+
|
53
|
+
begin
|
54
|
+
require 'rcov/rcovtask'
|
55
|
+
Rcov::RcovTask.new do |test|
|
56
|
+
test.libs << 'test'
|
57
|
+
test.pattern = 'test/**/test_*.rb'
|
58
|
+
test.verbose = true
|
59
|
+
end
|
60
|
+
rescue LoadError
|
61
|
+
task :rcov do
|
62
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
task :test => :check_dependencies
|
67
|
+
|
68
|
+
task :default => :test
|
69
|
+
|
70
|
+
require 'rake/rdoctask'
|
71
|
+
Rake::RDocTask.new do |rdoc|
|
72
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
73
|
+
|
74
|
+
rdoc.rdoc_dir = 'rdoc'
|
75
|
+
rdoc.title = "test2 #{version}"
|
76
|
+
rdoc.rdoc_files.include('README*')
|
77
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
78
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.3.0
|
data/lib/viddler.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
|
-
|
2
|
-
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
require 'active_support'
|
1
|
+
require 'active_support/core_ext/object'
|
6
2
|
require 'ostruct'
|
7
3
|
|
8
4
|
require 'ext/open_struct'
|
9
5
|
require 'ext/hash'
|
10
6
|
require 'ext/array'
|
7
|
+
|
11
8
|
require 'viddler/api_spec'
|
12
9
|
require 'viddler/base'
|
13
10
|
require 'viddler/multipart_params'
|
data/lib/viddler/api_spec.rb
CHANGED
@@ -57,7 +57,7 @@ module Viddler #:nodoc:
|
|
57
57
|
}
|
58
58
|
|
59
59
|
VIDEOS_SETDETAILS_ATTRS = {
|
60
|
-
:optional =>
|
60
|
+
:optional => [
|
61
61
|
:title,
|
62
62
|
:description,
|
63
63
|
:tags,
|
@@ -70,7 +70,7 @@ module Viddler #:nodoc:
|
|
70
70
|
:tagging_perm,
|
71
71
|
:download_perm,
|
72
72
|
:download_users
|
73
|
-
|
73
|
+
]
|
74
74
|
}
|
75
75
|
|
76
76
|
def self.check_attributes(viddler_method, attributes)
|
@@ -91,4 +91,4 @@ module Viddler #:nodoc:
|
|
91
91
|
|
92
92
|
end
|
93
93
|
|
94
|
-
end
|
94
|
+
end
|
data/lib/viddler/base.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Viddler
|
2
|
-
|
2
|
+
|
3
3
|
# Generic Viddler exception class.
|
4
4
|
class ViddlerError < StandardError #:nodoc:
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
# Raised when username and password has not been set.
|
8
8
|
class AuthenticationRequiredError < ViddlerError #:nodoc:
|
9
9
|
def message
|
@@ -17,9 +17,9 @@ module Viddler
|
|
17
17
|
'This method is not yet implemented.'
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
# A class that can be instantiated for access to a Viddler API.
|
22
|
-
#
|
22
|
+
#
|
23
23
|
# Examples:
|
24
24
|
#
|
25
25
|
# @viddler = Viddler::Base.new(API_KEY, USERNAME, PASSWORD)
|
@@ -29,6 +29,8 @@ module Viddler
|
|
29
29
|
# @viddler = Viddler::Base.new(YOUR_API_KEY)
|
30
30
|
#
|
31
31
|
class Base
|
32
|
+
attr_accessor :session_id, :username, :password
|
33
|
+
|
32
34
|
# Creates new viddler instance.
|
33
35
|
#
|
34
36
|
# Example:
|
@@ -39,7 +41,7 @@ module Viddler
|
|
39
41
|
@api_key, @username, @password = api_key, username, password
|
40
42
|
@session_id = nil
|
41
43
|
end
|
42
|
-
|
44
|
+
|
43
45
|
# Implements <tt>viddler.users.auth[http://wiki.developers.viddler.com/index.php/Viddler.users.auth]</tt>.
|
44
46
|
#
|
45
47
|
# 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.
|
@@ -60,11 +62,11 @@ module Viddler
|
|
60
62
|
end
|
61
63
|
@session_id = request.response['auth']['sessionid']
|
62
64
|
end
|
63
|
-
|
65
|
+
|
64
66
|
def authenticated?
|
65
67
|
@session_id ? true : false
|
66
68
|
end
|
67
|
-
|
69
|
+
|
68
70
|
# Implements <tt>viddler.videos.getRecordToken[http://wiki.developers.viddler.com/index.php/Viddler.videos.getRecordToken]</tt>.
|
69
71
|
#
|
70
72
|
# Example:
|
@@ -75,7 +77,7 @@ module Viddler
|
|
75
77
|
#
|
76
78
|
def get_record_token
|
77
79
|
authenticate unless authenticated?
|
78
|
-
|
80
|
+
|
79
81
|
request = Viddler::Request.new(:get, 'videos.getRecordToken')
|
80
82
|
request.run do |p|
|
81
83
|
p.api_key = @api_key
|
@@ -83,7 +85,7 @@ module Viddler
|
|
83
85
|
end
|
84
86
|
request.response['record_token']
|
85
87
|
end
|
86
|
-
|
88
|
+
|
87
89
|
# 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
90
|
#
|
89
91
|
# <tt>new_attributes</tt> hash should contain next required keys:
|
@@ -108,7 +110,7 @@ module Viddler
|
|
108
110
|
#
|
109
111
|
def register_user(new_attributes={})
|
110
112
|
Viddler::ApiSpec.check_attributes('users.register', new_attributes)
|
111
|
-
|
113
|
+
|
112
114
|
request = Viddler::Request.new(:get, 'users.register')
|
113
115
|
request.run do |p|
|
114
116
|
p.api_key = @api_key
|
@@ -118,44 +120,33 @@ module Viddler
|
|
118
120
|
end
|
119
121
|
request.response['user']['username']
|
120
122
|
end
|
121
|
-
|
122
|
-
# Implements <tt>viddler.videos.
|
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.
|
123
|
+
|
124
|
+
# Implements <tt>viddler.videos.delete[http://wiki.developers.viddler.com/index.php/Viddler.videos.delete]</tt>. Requires authentication.
|
130
125
|
#
|
131
126
|
# Example:
|
132
127
|
#
|
133
|
-
# @viddler.
|
128
|
+
# @viddler.delete_video(video_id)
|
134
129
|
#
|
135
|
-
# Returns
|
130
|
+
# Returns true for success or false for failure
|
136
131
|
#
|
137
|
-
def
|
132
|
+
def delete_video(video_id)
|
138
133
|
authenticate unless authenticated?
|
139
|
-
Viddler::
|
140
|
-
|
141
|
-
request = Viddler::Request.new(:post, 'videos.upload')
|
134
|
+
request = Viddler::Request.new(:post, 'videos.delete')
|
142
135
|
request.run do |p|
|
143
|
-
p.api_key
|
144
|
-
p.sessionid
|
145
|
-
|
146
|
-
p.send("#{param}=", value)
|
147
|
-
end
|
136
|
+
p.api_key = @api_key
|
137
|
+
p.sessionid = @session_id
|
138
|
+
p.video_id = video_id
|
148
139
|
end
|
149
|
-
|
140
|
+
request.response.key? 'success'
|
150
141
|
end
|
151
|
-
|
142
|
+
|
152
143
|
# Implements <tt>viddler.users.getProfile[http://wiki.developers.viddler.com/index.php/Viddler.users.getProfile]</tt>.
|
153
144
|
#
|
154
145
|
# Example:
|
155
146
|
#
|
156
147
|
# @viddler.find_profile(viddler_username)
|
157
148
|
#
|
158
|
-
# Returns Viddler::User instance.
|
149
|
+
# Returns Viddler::User instance.
|
159
150
|
#
|
160
151
|
def find_profile(viddler_name)
|
161
152
|
request = Viddler::Request.new(:get, 'users.getProfile')
|
@@ -165,7 +156,7 @@ module Viddler
|
|
165
156
|
end
|
166
157
|
Viddler::User.new request.response['user']
|
167
158
|
end
|
168
|
-
|
159
|
+
|
169
160
|
# Implements <tt>viddler.users.setProfile[http://wiki.developers.viddler.com/index.php/Viddler.users.setProfile]</tt>. Requires authentication.
|
170
161
|
#
|
171
162
|
# <tt>new_attributes</tt> hash could contain next optional keys:
|
@@ -181,12 +172,12 @@ module Viddler
|
|
181
172
|
#
|
182
173
|
# @viddler.update_profile(:first_name => 'Vasya', :last_name => 'Pupkin')
|
183
174
|
#
|
184
|
-
# Returns Viddler::User instance.
|
175
|
+
# Returns Viddler::User instance.
|
185
176
|
#
|
186
177
|
def update_profile(new_attributes={})
|
187
178
|
authenticate unless authenticated?
|
188
179
|
Viddler::ApiSpec.check_attributes('users.setProfile', new_attributes)
|
189
|
-
|
180
|
+
|
190
181
|
request = Viddler::Request.new(:post, 'users.setProfile')
|
191
182
|
request.run do |p|
|
192
183
|
p.api_key = @api_key
|
@@ -197,7 +188,7 @@ module Viddler
|
|
197
188
|
end
|
198
189
|
Viddler::User.new request.response['user']
|
199
190
|
end
|
200
|
-
|
191
|
+
|
201
192
|
# 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>
|
202
193
|
#
|
203
194
|
# <tt>new_attributes</tt> hash could contain next optional keys:
|
@@ -221,7 +212,7 @@ module Viddler
|
|
221
212
|
def update_account(new_attributes={})
|
222
213
|
authenticate unless authenticated?
|
223
214
|
Viddler::ApiSpec.check_attributes('users.setOptions', new_attributes)
|
224
|
-
|
215
|
+
|
225
216
|
request = Viddler::Request.new(:get, 'users.setOptions')
|
226
217
|
request.run do |p|
|
227
218
|
p.api_key = @api_key
|
@@ -232,7 +223,7 @@ module Viddler
|
|
232
223
|
end
|
233
224
|
request.response['updated'].to_i
|
234
225
|
end
|
235
|
-
|
226
|
+
|
236
227
|
# Implements <tt>viddler.videos.getStatus[http://wiki.developers.viddler.com/index.php/Viddler.vidoes.getStatus]</tt>.
|
237
228
|
#
|
238
229
|
# Example:
|
@@ -247,9 +238,9 @@ module Viddler
|
|
247
238
|
p.api_key = @api_key
|
248
239
|
p.video_id = video_id
|
249
240
|
end
|
250
|
-
OpenStruct.new request.response['video_status']
|
241
|
+
OpenStruct.new request.response['video_status']
|
251
242
|
end
|
252
|
-
|
243
|
+
|
253
244
|
# Implements <tt>viddler.videos.getDetails[http://wiki.developers.viddler.com/index.php/Viddler.videos.getDetails]</tt>. Authentication is optional.
|
254
245
|
#
|
255
246
|
# Example:
|
@@ -261,7 +252,7 @@ module Viddler
|
|
261
252
|
def find_video_by_id(video_id)
|
262
253
|
# Authentication is optional for this request
|
263
254
|
authenticate if could_authenticate? and !authenticated?
|
264
|
-
|
255
|
+
|
265
256
|
request = Viddler::Request.new(:get, 'videos.getDetails')
|
266
257
|
request.run do |p|
|
267
258
|
p.api_key = @api_key
|
@@ -270,7 +261,7 @@ module Viddler
|
|
270
261
|
end
|
271
262
|
Viddler::Video.new(request.response['video'])
|
272
263
|
end
|
273
|
-
|
264
|
+
|
274
265
|
# Implements <tt>viddler.videos.getDetailsByUrl[http://wiki.developers.viddler.com/index.php/Viddler.videos.getDetailsByUrl]</tt>. Authentication is optional.
|
275
266
|
#
|
276
267
|
# Example:
|
@@ -282,16 +273,16 @@ module Viddler
|
|
282
273
|
def find_video_by_url(video_url)
|
283
274
|
# Authentication is optional for this request
|
284
275
|
authenticate if could_authenticate? and !authenticated?
|
285
|
-
|
276
|
+
|
286
277
|
request = Viddler::Request.new(:get, 'videos.getDetailsByUrl')
|
287
278
|
request.run do |p|
|
288
279
|
p.sessionid = @session_id if authenticated?
|
289
280
|
p.api_key = @api_key
|
290
|
-
p.url = video_url
|
281
|
+
p.url = video_url
|
291
282
|
end
|
292
283
|
Viddler::Video.new(request.response['video'])
|
293
284
|
end
|
294
|
-
|
285
|
+
|
295
286
|
# Implements <tt>viddler.videos.setDetails[http://wiki.developers.viddler.com/index.php/Viddler.videos.setDetails]</tt>. Requires authentication.
|
296
287
|
#
|
297
288
|
# <tt>new_attributes</tt> hash could contain next optional keys:
|
@@ -319,7 +310,7 @@ module Viddler
|
|
319
310
|
def update_video(video_id, new_attributes={})
|
320
311
|
authenticate unless authenticated?
|
321
312
|
Viddler::ApiSpec.check_attributes('videos.setDetails', new_attributes)
|
322
|
-
|
313
|
+
|
323
314
|
request = Viddler::Request.new(:get, 'videos.setDetails')
|
324
315
|
request.run do |p|
|
325
316
|
p.api_key = @api_key
|
@@ -331,7 +322,59 @@ module Viddler
|
|
331
322
|
end
|
332
323
|
Viddler::Video.new(request.response['video'])
|
333
324
|
end
|
334
|
-
|
325
|
+
|
326
|
+
def set_permalink(video_id, url)
|
327
|
+
authenticate unless authenticated?
|
328
|
+
|
329
|
+
request = Viddler::Request.new(:post, 'videos.setPermalink')
|
330
|
+
request.run do |p|
|
331
|
+
p.api_key = @api_key
|
332
|
+
p.sessionid = @session_id
|
333
|
+
p.video_id = video_id
|
334
|
+
p.permalink = url
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
# Implements <tt>viddler.videos.upload[http://wiki.developers.viddler.com/index.php/Viddler.videos.upload]</tt>. Requires authentication.
|
339
|
+
#
|
340
|
+
# <tt>new_attributes</tt> hash should contain all required keys:
|
341
|
+
# * <tt>title:</tt> The video title;
|
342
|
+
# * <tt>description:</tt> The video description;
|
343
|
+
# * <tt>tags:</tt> The video tags;
|
344
|
+
# * <tt>file:</tt> The video file;
|
345
|
+
# * <tt>make_public:</tt> Use "1" for true and "0" for false to choose whether or not the video goes public when uploaded.
|
346
|
+
#
|
347
|
+
# Example:
|
348
|
+
#
|
349
|
+
# @viddler.upload_video(:title => 'Great Title', :file => File.open('/movies/movie.mov'), ...)
|
350
|
+
#
|
351
|
+
# Returns Viddler::Video instance.
|
352
|
+
#
|
353
|
+
def upload_video(new_attributes={})
|
354
|
+
authenticate unless authenticated?
|
355
|
+
Viddler::ApiSpec.check_attributes('videos.upload', new_attributes)
|
356
|
+
|
357
|
+
# Get an upload endpoint
|
358
|
+
# request = Viddler::Request.new(:post, 'viddler.videos.prepareUpload')
|
359
|
+
# request.run do |p|
|
360
|
+
# p.api_key = @api_key
|
361
|
+
# p.sessionid = @session_id
|
362
|
+
# end
|
363
|
+
# endpoint = request.response['upload']['endpoint']
|
364
|
+
|
365
|
+
# Upload to endpoint url
|
366
|
+
request = Viddler::Request.new(:post, 'videos.upload')
|
367
|
+
# request.url = endpoint
|
368
|
+
request.run do |p|
|
369
|
+
p.api_key = @api_key
|
370
|
+
p.sessionid = @session_id
|
371
|
+
for param, value in new_attributes
|
372
|
+
p.send("#{param}=", value)
|
373
|
+
end
|
374
|
+
end
|
375
|
+
Viddler::Video.new(request.response['video'])
|
376
|
+
end
|
377
|
+
|
335
378
|
# Implements <tt>viddler.videos.getByUser[http://wiki.developers.viddler.com/index.php/Viddler.videos.getByUser]</tt>. Authentication is optional.
|
336
379
|
#
|
337
380
|
# Options hash could contain next values:
|
@@ -346,20 +389,20 @@ module Viddler
|
|
346
389
|
#
|
347
390
|
def find_all_videos_by_user(username, options={})
|
348
391
|
authenticate if could_authenticate? and !authenticated?
|
349
|
-
|
392
|
+
|
350
393
|
options.assert_valid_keys(:page, :per_page)
|
351
|
-
|
394
|
+
|
352
395
|
request = Viddler::Request.new(:get, 'videos.getByUser')
|
353
396
|
request.run do |p|
|
354
397
|
p.api_key = @api_key
|
355
|
-
p.sessionid = @session_id
|
398
|
+
p.sessionid = @session_id
|
356
399
|
p.user = username
|
357
400
|
p.page = options[:page] || 1
|
358
|
-
p.per_page = options[:per_page] || 20
|
401
|
+
p.per_page = options[:per_page] || 20
|
359
402
|
end
|
360
|
-
parse_videos_list(request.response['video_list'])
|
403
|
+
parse_videos_list(request.response['video_list'])
|
361
404
|
end
|
362
|
-
|
405
|
+
|
363
406
|
# Implements <tt>viddler.videos.getByTag[http://wiki.developers.viddler.com/index.php/Viddler.videos.getByTag]</tt>.
|
364
407
|
#
|
365
408
|
# Options hash could contain next values:
|
@@ -374,7 +417,7 @@ module Viddler
|
|
374
417
|
#
|
375
418
|
def find_all_videos_by_tag(tag_name, options={})
|
376
419
|
options.assert_valid_keys(:page, :per_page)
|
377
|
-
|
420
|
+
|
378
421
|
request = Viddler::Request.new(:get, 'videos.getByTag')
|
379
422
|
request.run do |p|
|
380
423
|
p.api_key = @api_key
|
@@ -384,7 +427,7 @@ module Viddler
|
|
384
427
|
end
|
385
428
|
parse_videos_list(request.response['video_list'])
|
386
429
|
end
|
387
|
-
|
430
|
+
|
388
431
|
# Implements <tt>viddler.videos.getFeatured[http://wiki.developers.viddler.com/index.php/Viddler.videos.getFeatured]</tt>.
|
389
432
|
#
|
390
433
|
# Example:
|
@@ -393,25 +436,37 @@ module Viddler
|
|
393
436
|
#
|
394
437
|
# Returns array of Viddler::Video instances.
|
395
438
|
#
|
396
|
-
def find_all_featured_videos
|
439
|
+
def find_all_featured_videos
|
397
440
|
request = Viddler::Request.new(:get, 'videos.getFeatured')
|
398
441
|
request.run do |p|
|
399
442
|
p.api_key = @api_key
|
400
443
|
end
|
401
444
|
parse_videos_list(request.response['video_list'])
|
402
445
|
end
|
403
|
-
|
446
|
+
|
447
|
+
def delete_comment(id)
|
448
|
+
authenticate unless authenticated?
|
449
|
+
request = Viddler::Request.new(:post, 'videos.comments.remove')
|
450
|
+
request.run do |p|
|
451
|
+
p.api_key = @api_key
|
452
|
+
p.sessionid = @session_id
|
453
|
+
p.comment_id = id
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
404
457
|
private
|
405
|
-
|
458
|
+
|
406
459
|
def could_authenticate?
|
407
460
|
@username and @password
|
408
461
|
end
|
409
|
-
|
462
|
+
|
410
463
|
def parse_videos_list(video_list)
|
411
|
-
video_list['video'].collect do |attr|
|
464
|
+
Array.wrap(video_list['video']).collect do |attr|
|
412
465
|
next unless attr.is_a?(Hash)
|
413
466
|
Viddler::Video.new(attr)
|
414
467
|
end
|
468
|
+
|
415
469
|
end
|
416
470
|
end
|
417
|
-
|
471
|
+
|
472
|
+
end
|