dm_cloud 0.1.0 → 0.1.1
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.
- data/VERSION +1 -1
- data/dm_cloud.gemspec +78 -0
- data/lib/dm_cloud/builder/media.rb +11 -11
- data/lib/dm_cloud/media.rb +2 -7
- data/lib/dm_cloud/signing.rb +2 -2
- data/lib/dm_cloud/streaming.rb +10 -9
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/dm_cloud.gemspec
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "dm_cloud"
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jeremy Mortelette"]
|
12
|
+
s.date = "2012-11-26"
|
13
|
+
s.description = "This gem will simplify usage of DailyMotion Cloud API, it represent api in ruby style, with automated handler for search and upload files"
|
14
|
+
s.email = ["mortelette.jeremy@gmail.com"]
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"Gemfile",
|
22
|
+
"LICENSE.txt",
|
23
|
+
"README.md",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"dm_cloud.gemspec",
|
27
|
+
"lib/dm_cloud.rb",
|
28
|
+
"lib/dm_cloud/builder/media.rb",
|
29
|
+
"lib/dm_cloud/media.rb",
|
30
|
+
"lib/dm_cloud/request.rb",
|
31
|
+
"lib/dm_cloud/signing.rb",
|
32
|
+
"lib/dm_cloud/streaming.rb",
|
33
|
+
"lib/dm_cloud/version.rb",
|
34
|
+
"spec/dm_cloud/media_spec.rb",
|
35
|
+
"spec/dm_cloud/signing_spec.rb",
|
36
|
+
"spec/dm_cloud/streaming_spec.rb",
|
37
|
+
"spec/dm_cloud_spec.rb",
|
38
|
+
"spec/spec_helper.rb",
|
39
|
+
"spec/vcr_cassettes/dm_cloud/dm_cloud_streaming.yml",
|
40
|
+
"spec/vcr_cassettes/dm_cloud_media.yml"
|
41
|
+
]
|
42
|
+
s.homepage = ""
|
43
|
+
s.require_paths = ["lib"]
|
44
|
+
s.rubygems_version = "1.8.24"
|
45
|
+
s.summary = "Simplify DailyMotion Cloud API usage"
|
46
|
+
s.test_files = ["spec/dm_cloud/media_spec.rb", "spec/dm_cloud/signing_spec.rb", "spec/dm_cloud/streaming_spec.rb", "spec/dm_cloud_spec.rb", "spec/spec_helper.rb", "spec/vcr_cassettes/dm_cloud/dm_cloud_streaming.yml", "spec/vcr_cassettes/dm_cloud_media.yml"]
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
s.specification_version = 3
|
50
|
+
|
51
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
53
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
54
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
55
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
56
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
57
|
+
s.add_development_dependency(%q<vcr>, [">= 0"])
|
58
|
+
s.add_development_dependency(%q<webmock>, [">= 0"])
|
59
|
+
else
|
60
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
61
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
62
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
63
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
64
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
65
|
+
s.add_dependency(%q<vcr>, [">= 0"])
|
66
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
67
|
+
end
|
68
|
+
else
|
69
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
70
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
71
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
72
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
73
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
74
|
+
s.add_dependency(%q<vcr>, [">= 0"])
|
75
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
@@ -45,14 +45,15 @@ module DmCloud
|
|
45
45
|
fields[:assets].each { |value| request << "assets.#{name}.#{value.to_s}" }
|
46
46
|
end
|
47
47
|
end
|
48
|
-
puts "request fields = #{request.to_yaml}"
|
49
48
|
request
|
50
49
|
end
|
51
50
|
|
52
|
-
def self.list(fields = {})
|
51
|
+
def self.list(page = 1, per_page = 10, fields = {})
|
53
52
|
# raise StandardError, "missing :media_id in params" unless media_id
|
54
53
|
request = Hash.new
|
55
54
|
|
55
|
+
request[:page] = page
|
56
|
+
request[:per_page] = per_page
|
56
57
|
request[:fields] = []
|
57
58
|
# requested media meta datas
|
58
59
|
fields[:meta] = ['title'] unless fields[:meta]
|
@@ -68,16 +69,16 @@ module DmCloud
|
|
68
69
|
# request['stats'][COUNTRY_CODE][TIME_INTERVAL] : the statistics on the number of views in a specific country (eg: stats.fr.total, stats.us.last_week, etc...)
|
69
70
|
# request['extended_stats'][COUNTRY_CODE][TIME_INTERVAL]
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
72
|
+
assets_names = ['source'] if assets_names.nil?
|
73
|
+
if not fields[:assets]
|
74
|
+
request = all_assets_fields(request, assets_names)
|
75
|
+
else
|
76
|
+
assets_names.each do |name|
|
77
|
+
fields[:assets].each { |value| request[:fields] << "assets.#{name}.#{value.to_s}" }
|
78
78
|
end
|
79
|
+
end
|
79
80
|
|
80
|
-
|
81
|
+
request
|
81
82
|
end
|
82
83
|
|
83
84
|
|
@@ -111,7 +112,6 @@ module DmCloud
|
|
111
112
|
end
|
112
113
|
request
|
113
114
|
end
|
114
|
-
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
data/lib/dm_cloud/media.rb
CHANGED
@@ -71,17 +71,12 @@ module DmCloud
|
|
71
71
|
# per_page (Integer) – (optional) the number of objet per page, default: 10
|
72
72
|
# Returns:
|
73
73
|
# an object with information for the pagination and the result of the query.
|
74
|
-
def self.list(
|
74
|
+
def self.list(page = 1, per_page = 10, fields = {})
|
75
75
|
call_type = "media.list"
|
76
76
|
|
77
|
-
page = options[:page] ? options[:page] : 1
|
78
|
-
per_page = options[:per_page] ? options[:per_page] : 10
|
79
|
-
|
80
77
|
params = {
|
81
78
|
:call => call_type,
|
82
|
-
args: DmCloud::Builder::Media.list(
|
83
|
-
:page => page,
|
84
|
-
:per_page => per_page
|
79
|
+
args: DmCloud::Builder::Media.list( page, per_page, fields)
|
85
80
|
}
|
86
81
|
DmCloud.config[:auto_call] == true ? DmCloud::Request.execute(call_type, params) : {call: call_type, params: params}
|
87
82
|
end
|
data/lib/dm_cloud/signing.rb
CHANGED
@@ -40,7 +40,7 @@ module DmCloud
|
|
40
40
|
# To generate this component the parameters are serialized using x-www-form-urlencoded, compressed with gzip and encoded in base64.
|
41
41
|
# Result :
|
42
42
|
# return a string which contain the signed url like
|
43
|
-
# <
|
43
|
+
# <expires>-<sec>-<nonce>-<md5sum>[-<pub-sec-data>]
|
44
44
|
def self.sign(stream, security_datas = nil)
|
45
45
|
raise StandardError, "missing :stream in params" unless stream
|
46
46
|
sec_level = security(DmCloud.config[:security_level])
|
@@ -50,7 +50,7 @@ module DmCloud
|
|
50
50
|
:sec_level => sec_level,
|
51
51
|
:url_no_query => stream,
|
52
52
|
:expires => 1.hours.from_now.to_i,
|
53
|
-
:nonce => SecureRandom.hex(16)[0,
|
53
|
+
:nonce => SecureRandom.hex(16)[0,16],
|
54
54
|
:secret => DmCloud.config[:secret_key]
|
55
55
|
}
|
56
56
|
base.merge!(:sec_data => sec_data, :pub_sec_data => sec_data) unless sec_data.nil?
|
data/lib/dm_cloud/streaming.rb
CHANGED
@@ -8,9 +8,9 @@ require 'digest/md5'
|
|
8
8
|
module DmCloud
|
9
9
|
class Streaming
|
10
10
|
# Default URL to get embed content ou direct url
|
11
|
-
DIRECT_STREAM =
|
12
|
-
EMBED_STREAM =
|
13
|
-
EMBED_IFRAME = '<iframe width=[WIDTH] height=[HEIGHT] frameborder="0" scrolling="no" src="[EMBED_URL]"></iframe>'
|
11
|
+
DIRECT_STREAM = "[PROTOCOL]://cdn.dmcloud.net/route/[USER_ID]/[MEDIA_ID]/[ASSET_NAME].[ASSET_EXTENSION]"
|
12
|
+
EMBED_STREAM = "[PROTOCOL]://api.dmcloud.net/embed/[USER_ID]/[MEDIA_ID]"
|
13
|
+
EMBED_IFRAME = '<iframe width="[WIDTH]" height="[HEIGHT]" frameborder="0" scrolling="no" src="[EMBED_URL]"></iframe>'
|
14
14
|
|
15
15
|
# Get embeded player
|
16
16
|
# Params :
|
@@ -26,21 +26,22 @@ module DmCloud
|
|
26
26
|
raise StandardError, "missing :media_id in params" unless media_id
|
27
27
|
|
28
28
|
skin_id = options[:skin_id] ? options[:skin_id] : 'modern1'
|
29
|
-
width = options[:width] ? options[:width] : '848'
|
30
|
-
height = options[:height] ? options[:height] : '480'
|
29
|
+
width = options[:width] ? options[:width].to_s : '848'
|
30
|
+
height = options[:height] ? options[:height].to_s : '480'
|
31
31
|
|
32
32
|
stream = EMBED_STREAM
|
33
33
|
stream.gsub!('[PROTOCOL]', DmCloud.config[:protocol])
|
34
34
|
stream.gsub!('[USER_ID]', DmCloud.config[:user_key])
|
35
35
|
stream.gsub!('[MEDIA_ID]', media_id)
|
36
|
-
|
37
|
-
stream
|
36
|
+
signed_url = DmCloud::Signing.sign(stream)
|
37
|
+
signed_url = stream + "?auth=#{signed_url}"
|
38
38
|
|
39
39
|
frame = EMBED_IFRAME
|
40
40
|
frame.gsub!('[WIDTH]', width)
|
41
41
|
frame.gsub!('[HEIGHT]', height)
|
42
|
-
frame.gsub!('[EMBED_URL]',
|
43
|
-
|
42
|
+
frame.gsub!('[EMBED_URL]', signed_url)
|
43
|
+
|
44
|
+
frame.html_safe
|
44
45
|
end
|
45
46
|
|
46
47
|
# Get media url for direct link to the file on DailyMotion Cloud
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- README.md
|
140
140
|
- Rakefile
|
141
141
|
- VERSION
|
142
|
+
- dm_cloud.gemspec
|
142
143
|
- lib/dm_cloud.rb
|
143
144
|
- lib/dm_cloud/builder/media.rb
|
144
145
|
- lib/dm_cloud/media.rb
|
@@ -167,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
167
168
|
version: '0'
|
168
169
|
segments:
|
169
170
|
- 0
|
170
|
-
hash:
|
171
|
+
hash: 963216337890652206
|
171
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
173
|
none: false
|
173
174
|
requirements:
|