dmcloud 1.2 → 1.4

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGJiOWVmMGRkMDMwMDIxYWQ5ZjA5NDQwN2E4NTM5YTFjOGRiM2IyYw==
4
+ OTU5NTY4ZTZlNDMwMDNhODc4NGQyMmNhYzZhMWJhYjJjYTliZWZiOA==
5
5
  data.tar.gz: !binary |-
6
- NTQzMzhmYjlmZmM4MTJlNzAxZDliODVmMmEzNzYyZDljY2ZhMDdjMA==
6
+ NzViZjAyYWE4ODEyNWUyYmEyMWIxNDYwNTZlMmM5MjQ4MjVlMTU5Yg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MGY4ZjU4Y2ZjODVhMDZhODgxYzQzZmIyNTdkYmVjN2UwYzg2MmU0OWNjNGYy
10
- ZDcxMmE4NzZmODJkYjdjYTc0MWMxYjg4NjI5ZDRlYjA0NzNhNGU4MWQ2ZDBl
11
- OGUzYWUxNjFkYWI3YWZhZGM2NDJkMzIwMTBjNzNjMjMxNDdiYzY=
9
+ NjgxMjI3ODczMjc2YmNjZTUzMDVlNGM0MmU0YjI5OGRkM2U3ZjlkNmZmOWQ2
10
+ OGJiOTVmMmU5ZjE5MDg0OTM2ZTk5ZDllMzExNTUxZDIxOThkYTYwYTA5NGI2
11
+ MmQ3YTE5M2RlMzBhN2IwZjhjOTdiZGVmMGQ0YWVmOGI3ZWQwYTk=
12
12
  data.tar.gz: !binary |-
13
- MWI3ODk4YmNlMWIxZjJmNDRkZDRlZDFmYzc2Mjg1NGVlN2Q3ZThmNzEwMWZj
14
- NmM0MjZjYzFmN2MwMzE0YTVjNmExMmIyYmYyMWNhZGFiODg4YmQwMzM1YTg1
15
- ZGI2YWJlOTYyYzcyN2Q0ODQzZGZmZGRhYTZhNDAzODZlYWVjMDc=
13
+ Yzk4Y2I3NmZiN2U0YTBjZjVhMmQwYzdmZTJkMWNiYTk1Y2U0YTBiMWRiNWZl
14
+ Y2VmNjE0ODlhMjdmNjg1MDRhMDAyNTNkNGE3ZGYxMzU0NWJiZDI0YTU1MGU3
15
+ MzdkZjQ5MjYwNTQwODdiMjk3MGUwMzAyMzlmNzhkZDQzM2UxNDQ=
data/dmcloud.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "dmcloud"
8
- s.version = "1.2"
8
+ s.version = "1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ritik Malhotra", "Tanooj Luthra"]
12
- s.date = "2013-06-15"
12
+ s.date = "2013-06-27"
13
13
  s.description = "This gem will simplify usage of DailyMotion Cloud API. Originally authored by Jeremy Mortelette, modified by us to fix the bugs."
14
14
  s.email = ["ritikmalhotra@gmail.com"]
15
15
  s.extra_rdoc_files = [
@@ -17,7 +17,7 @@ module DmCloud
17
17
  request.rehash
18
18
  end
19
19
 
20
- def self.info(media_id, assets_names = ['source'], fields = {})
20
+ def self.info(media_id, assets_names = ['source'], fields = {}, authToken = false)
21
21
  raise StandardError, "missing :media_id in params" unless media_id
22
22
  request = Hash.new
23
23
 
@@ -28,10 +28,12 @@ module DmCloud
28
28
  request[:fields] = []
29
29
  fields[:meta] = ['title'] unless fields[:meta]
30
30
  fields[:meta].each { |value| request[:fields] << "meta.#{value.to_s}" }
31
- request[:fields] += ['id', 'created', 'embed_url', 'frame_ratio']
32
-
31
+ if not authToken
32
+ request[:fields] += ['id', 'created', 'embed_url', 'frame_ratio']
33
+ end
33
34
  # the worldwide statistics on the number of views
34
35
  # request['fields'] << 'stats.global.last_week' if fields[:stats][:global]
36
+ # request['fields'] << 'assets.all.progress'
35
37
 
36
38
  # TODO: handle statistics request per country
37
39
  # fields[:stats].each { |key| request << "meta.#{key.to_s}" } if fields[:meta].present?
@@ -110,6 +112,7 @@ module DmCloud
110
112
  request[:fields] << "assets.#{name}.created"
111
113
  request[:fields] << "assets.#{name}.file_extension"
112
114
  request[:fields] << "assets.#{name}.file_size"
115
+ request[:fields] << "assets.#{name}.progress"
113
116
  end
114
117
  request
115
118
  end
@@ -49,16 +49,20 @@ module DmCloud
49
49
  # fields (Array) – (required) the list of fields to retrieve.
50
50
  # Returns:
51
51
  # a multi-level structure containing about the media related to the requested fields.
52
- def self.info(media_id, assets_names = ['source'], fields = {})
52
+ def self.info(media_id, assets_names = ['source'], authToken = false, fields = {})
53
53
  raise StandardError, "missing :media_id in params" unless media_id
54
54
  call_type = "media.info"
55
55
 
56
56
  params = {
57
57
  :call => call_type,
58
- args: DmCloud::Builder::Media.info(media_id, assets_names, fields)
58
+ args: DmCloud::Builder::Media.info(media_id, assets_names, fields, authToken)
59
59
  }
60
60
 
61
- DmCloud.config[:auto_call] == true ? DmCloud::Request.execute(call_type, params) : {call: call_type, params: params}
61
+ if authToken
62
+ return DmCloud::Signing.identify(params)
63
+ else
64
+ DmCloud.config[:auto_call] == true ? DmCloud::Request.execute(call_type, params) : {call: call_type, params: params}
65
+ end
62
66
  end
63
67
 
64
68
  # Returns a paginated list of media info structures.
@@ -11,7 +11,6 @@ module DmCloud
11
11
  def self.execute(call, params = {})
12
12
  url = define(call)
13
13
  params['auth'] = DmCloud::Signing.identify(params)
14
-
15
14
  result = send_request(params)
16
15
  parse_response(result)
17
16
  end
@@ -25,7 +24,10 @@ module DmCloud
25
24
  request.content_type = 'application/json'
26
25
  request.body = params.to_json
27
26
 
28
- # puts 'request (YAML format ): ' + request.to_yaml + "\n" + '-' * 80
27
+ #puts "Request body in send_request:"
28
+ #puts request.body
29
+
30
+ #puts 'request (YAML format ): ' + request.to_yaml + "\n" + '-' * 80
29
31
 
30
32
  http.request(request).body
31
33
  end
@@ -1,4 +1,5 @@
1
1
  require 'rubygems'
2
+ require 'digest'
2
3
 
3
4
  module DmCloud
4
5
  class Signing
@@ -12,12 +13,13 @@ module DmCloud
12
13
  user_id = DmCloud.config[:user_key]
13
14
  api_key = DmCloud.config[:secret_key]
14
15
 
16
+ #puts request
15
17
  normalized_request = normalize(request).to_s
16
- # puts 'identify:: normalized_values : ' + normalized_request + "\n" + '-' * 80
18
+ #puts 'identify:: normalized_values : ' + normalized_request + "\n" + '-' * 80
17
19
 
18
20
  params = user_id + normalized_request + api_key
19
21
 
20
- # puts 'identify:: Values before MD5 encrypt : ' + params + "\n" + '-' * 80
22
+ #puts 'identify:: Values before MD5 encrypt : ' + params + "\n" + '-' * 80
21
23
 
22
24
  checksum = Digest::MD5.hexdigest(params)
23
25
  auth_token = user_id + ':' + checksum
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dmcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: '1.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ritik Malhotra
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-15 00:00:00.000000000 Z
12
+ date: 2013-06-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec