brightcove-api 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -24,6 +24,11 @@ Ruby gem for interacting with the Brightcove media API. http://docs.brightcove.c
24
24
  => {"items"=>[{"longDescription"=>nil, "name"=>"Wild Slopes '06", "lastModifiedDate"=>"1171324523307", "thumbnailURL"=>"http://brightcove.vo.llnwd.net/d2/unsecured/media/270881183/270881183_502534829_94499905676eb7cd04a558da2adcf6a34f437b88.jpg?pubId=270881183", "tags"=>["adventure", "snowboarding"], "playsTrailingWeek"=>35, "shortDescription"=>"A ski and snowboard movie that challenges the hype and dares you to see what freeskiing and snowboarding have become. Documenting the very best of this year's riding and culture.", "playsTotal"=>4458, "adKeys"=>nil, "id"=>496518766, "length"=>51251, "videoStillURL"=>"http://brightcove.vo.llnwd.net/d2/unsecured/media/270881183/270881183_502534838_f80fe64f052328cd3b2e158d7234003a23091845.jpg?pubId=270881183", "publishedDate"=>"1171324434811", "creationDate"=>"1171267200000", "linkText"=>nil, "economics"=>"FREE", "referenceId"=>"title010", "linkURL"=>nil}, {"longDescription"=>nil, "name"=>"Jellyfish", "lastModifiedDate"=>"1245181300374", "thumbnailURL"=>"http://brightcove.vo.llnwd.net/d7/unsecured/media/270881183/270881183_26530711001_jellyFish.jpg?pubId=270881183", "tags"=>["sea", "custom skins"], "playsTrailingWeek"=>46, "shortDescription"=>"Jellyfish", "playsTotal"=>4081, "adKeys"=>nil, "id"=>26512561001, "length"=>28400, "videoStillURL"=>"http://brightcove.vo.llnwd.net/d7/unsecured/media/270881183/270881183_26519430001_vs-270881183-vid26513829001-img0000.jpg?pubId=270881183", "publishedDate"=>"1245172164326", "creationDate"=>"1245172164326", "linkText"=>nil, "economics"=>"AD_SUPPORTED", "referenceId"=>nil, "linkURL"=>nil}, {"longDescription"=>"Long Description", "name"=>"Demo Title 2", "lastModifiedDate"=>"1263581295791", "thumbnailURL"=>"http://brightcove.vo.llnwd.net/d2/unsecured/media/270881183/270881183_275925069_d1f97c7f07f2a3f4de7b38eda3761f16f39d2a99.jpg?pubId=270881183", "tags"=>[], "playsTrailingWeek"=>1, "shortDescription"=>"Short Description", "playsTotal"=>3876, "adKeys"=>nil, "id"=>276024035, "length"=>418742, "videoStillURL"=>"http://brightcove.vo.llnwd.net/d2/unsecured/media/270881183/270881183_275943599_b7e2ca63c0311fa3f0b027304b41d252f12d2d66.jpg?pubId=270881183", "publishedDate"=>"1161296014264", "creationDate"=>"1161241200000", "linkText"=>"Related Link", "economics"=>"FREE", "referenceId"=>nil, "linkURL"=>"http://www.brightcove.com"}, {"longDescription"=>nil, "name"=>"Dolphins", "lastModifiedDate"=>"1263581295790", "thumbnailURL"=>"http://brightcove.vo.llnwd.net/d7/unsecured/media/270881183/270881183_26531197001_dolphins.jpg?pubId=270881183", "tags"=>["sea", "custom skins"], "playsTrailingWeek"=>30, "shortDescription"=>"Dolphins", "playsTotal"=>3870, "adKeys"=>nil, "id"=>26511963001, "length"=>12800, "videoStillURL"=>"http://brightcove.vo.llnwd.net/d7/unsecured/media/270881183/270881183_26519372001_vs-270881183-vid26510372001-img0000.jpg?pubId=270881183", "publishedDate"=>"1245171732987", "creationDate"=>"1245171732987", "linkText"=>nil, "economics"=>"AD_SUPPORTED", "referenceId"=>nil, "linkURL"=>nil}, {"longDescription"=>nil, "name"=>"Welcome to Brightcove 3", "lastModifiedDate"=>"1225134261511", "thumbnailURL"=>"http://brightcove.vo.llnwd.net/d6/unsecured/media/270881183/270881183_1858983740_brightcove3-thumb.jpg?pubId=270881183", "tags"=>[], "playsTrailingWeek"=>0, "shortDescription"=>"Tareef Kawaf, Brightcove's SVP of Engineering, welcomes you to Brightcove 3.", "playsTotal"=>3349, "adKeys"=>nil, "id"=>1858922805, "length"=>53820, "videoStillURL"=>"http://brightcove.vo.llnwd.net/d6/unsecured/media/270881183/270881183_1858994782_vid-StudioDashboards.jpg?pubId=270881183", "publishedDate"=>"1225134261508", "creationDate"=>"1224096089173", "linkText"=>nil, "economics"=>"AD_SUPPORTED", "referenceId"=>nil, "linkURL"=>nil}], "page_number"=>0, "page_size"=>5, "total_count"=>-1}
25
25
  >> response = brightcove.post('delete_video', {:video_id => '595153263001'})
26
26
  => {"result"=>{}, "id"=>nil, "error"=>nil}
27
+
28
+ If you want to perform a file upload, for example, to create a video, you can use the __post_file()__ method.
29
+
30
+ >> response = brightcove.post_file('create_video', '/path/to/video.mov', :video => {:shortDescription => 'Short Description', :name => 'Video name'})
31
+ => {"result"=>653155417001, "error=>nil, "id"=>nil}
27
32
 
28
33
  == Note on Patches/Pull Requests
29
34
 
data/Rakefile CHANGED
@@ -13,6 +13,7 @@ begin
13
13
  gem.add_dependency('httparty', '0.5.2')
14
14
  gem.add_dependency('fakeweb', '1.2.8')
15
15
  gem.add_dependency('json', '1.2.4')
16
+ gem.add_dependency('rest-client', '1.6.1')
16
17
  end
17
18
  Jeweler::GemcutterTasks.new
18
19
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.0.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{brightcove-api}
8
- s.version = "1.0.2"
8
+ s.version = "1.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Czarnecki"]
12
- s.date = %q{2010-09-25}
12
+ s.date = %q{2010-10-29}
13
13
  s.description = %q{Ruby gem for interacting with the Brightcove media API. http://docs.brightcove.com/en/media/}
14
14
  s.email = %q{dczarnecki@agoragames.com}
15
15
  s.extra_rdoc_files = [
@@ -25,8 +25,10 @@ Gem::Specification.new do |s|
25
25
  "VERSION",
26
26
  "brightcove-api.gemspec",
27
27
  "lib/brightcove-api.rb",
28
+ "test/fakeweb/create_video_response.json",
28
29
  "test/fakeweb/delete_video_response.json",
29
30
  "test/fakeweb/find_all_videos_response.json",
31
+ "test/fakeweb/movie.mov",
30
32
  "test/helper.rb",
31
33
  "test/test_brightcove-api.rb"
32
34
  ]
@@ -48,15 +50,18 @@ Gem::Specification.new do |s|
48
50
  s.add_runtime_dependency(%q<httparty>, ["= 0.5.2"])
49
51
  s.add_runtime_dependency(%q<fakeweb>, ["= 1.2.8"])
50
52
  s.add_runtime_dependency(%q<json>, ["= 1.2.4"])
53
+ s.add_runtime_dependency(%q<rest-client>, ["= 1.6.1"])
51
54
  else
52
55
  s.add_dependency(%q<httparty>, ["= 0.5.2"])
53
56
  s.add_dependency(%q<fakeweb>, ["= 1.2.8"])
54
57
  s.add_dependency(%q<json>, ["= 1.2.4"])
58
+ s.add_dependency(%q<rest-client>, ["= 1.6.1"])
55
59
  end
56
60
  else
57
61
  s.add_dependency(%q<httparty>, ["= 0.5.2"])
58
62
  s.add_dependency(%q<fakeweb>, ["= 1.2.8"])
59
63
  s.add_dependency(%q<json>, ["= 1.2.4"])
64
+ s.add_dependency(%q<rest-client>, ["= 1.6.1"])
60
65
  end
61
66
  end
62
67
 
@@ -1,11 +1,12 @@
1
1
  require 'httparty'
2
2
  require 'json'
3
+ require 'rest-client'
3
4
 
4
5
  module Brightcove
5
6
  class API
6
7
  include HTTParty
7
8
 
8
- VERSION = '1.0.2'.freeze
9
+ VERSION = '1.0.3'.freeze
9
10
 
10
11
  DEFAULT_HEADERS = {
11
12
  'User-Agent' => "brightcove-api gem #{VERSION}"
@@ -58,8 +59,23 @@ module Brightcove
58
59
  body = {}
59
60
  body.merge!({:method => api_method})
60
61
  body.merge!({:params => parameters})
61
-
62
+
62
63
  self.class.post(@write_api_url, {:body => {:json => JSON.generate(body)}})
63
64
  end
65
+
66
+ def post_file(api_method, file, parameters = {})
67
+ parameters.merge!({"token" => @token})
68
+
69
+ body = {}
70
+ body.merge!({:method => api_method})
71
+ body.merge!({:params => parameters})
72
+
73
+ response = RestClient.post(@write_api_url, {
74
+ :json => body.to_json,
75
+ :file => File.new(file, 'rb')
76
+ }, :content_type => :json, :accept => :json, :multipart => true)
77
+
78
+ JSON.parse(response)
79
+ end
64
80
  end
65
81
  end
@@ -0,0 +1 @@
1
+ {"result": 653155417001, "error": null, "id": null}
File without changes
@@ -12,7 +12,7 @@ class TestBrightcoveApi < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  def test_api_version
15
- assert_equal '1.0.2', Brightcove::API::VERSION
15
+ assert_equal '1.0.3', Brightcove::API::VERSION
16
16
  end
17
17
 
18
18
  def test_can_set_read_api_url
@@ -73,4 +73,20 @@ class TestBrightcoveApi < Test::Unit::TestCase
73
73
  assert brightcove_response.has_key?('result')
74
74
  assert_equal brightcove_response['error'], 'nil'
75
75
  end
76
+
77
+ def test_create_video_using_post_file
78
+ FakeWeb.register_uri(:post,
79
+ 'http://api.brightcove.com/services/post',
80
+ :body => File.join(File.dirname(__FILE__), 'fakeweb', 'create_video_response.json'),
81
+ :content_type => "application/json")
82
+
83
+ brightcove = Brightcove::API.new('0Z2dtxTdJAxtbZ-d0U7Bhio2V1Rhr5Iafl5FFtDPY8E.')
84
+ brightcove_response = brightcove.post_file('delete_video',
85
+ File.join(File.dirname(__FILE__), 'fakeweb', 'movie.mov'),
86
+ :video => {:shortDescription => "Short Description", :name => "Video"})
87
+
88
+ assert brightcove_response.has_key?('result')
89
+ assert_equal '653155417001', brightcove_response['result'].to_s
90
+ assert_equal brightcove_response['error'], nil
91
+ end
76
92
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brightcove-api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 2
10
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Czarnecki
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-25 00:00:00 -04:00
18
+ date: 2010-10-29 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -66,6 +66,22 @@ dependencies:
66
66
  version: 1.2.4
67
67
  type: :runtime
68
68
  version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: rest-client
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - "="
76
+ - !ruby/object:Gem::Version
77
+ hash: 13
78
+ segments:
79
+ - 1
80
+ - 6
81
+ - 1
82
+ version: 1.6.1
83
+ type: :runtime
84
+ version_requirements: *id004
69
85
  description: Ruby gem for interacting with the Brightcove media API. http://docs.brightcove.com/en/media/
70
86
  email: dczarnecki@agoragames.com
71
87
  executables: []
@@ -84,8 +100,10 @@ files:
84
100
  - VERSION
85
101
  - brightcove-api.gemspec
86
102
  - lib/brightcove-api.rb
103
+ - test/fakeweb/create_video_response.json
87
104
  - test/fakeweb/delete_video_response.json
88
105
  - test/fakeweb/find_all_videos_response.json
106
+ - test/fakeweb/movie.mov
89
107
  - test/helper.rb
90
108
  - test/test_brightcove-api.rb
91
109
  has_rdoc: true