dm_cloud 0.0.5 → 0.0.55
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +59 -7
- data/dm_cloud.gemspec +0 -1
- data/lib/dm_cloud/builder/media.rb +4 -2
- data/lib/dm_cloud/media.rb +3 -1
- data/lib/dm_cloud/request.rb +11 -10
- data/lib/dm_cloud/signing.rb +5 -0
- data/lib/dm_cloud/version.rb +1 -1
- metadata +2 -18
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# DMCloud
|
2
2
|
|
3
|
-
I created this gem to simplify request and responses from DailyMotion Cloud API.
|
4
|
-
With this gem, you can :
|
5
|
-
- get generated embed code as a string
|
6
|
-
- get direct access url to your files (I used this to provide video flux to TV-connected application)
|
7
|
-
- (
|
8
|
-
- (I'm working on ) CRUD on videos' meta-data
|
3
|
+
I created this gem to simplify request and responses from DailyMotion Cloud API.
|
4
|
+
With this gem, you can :
|
5
|
+
- get generated embed code as a string
|
6
|
+
- get direct access url to your files (I used this to provide video flux to TV-connected application)
|
7
|
+
- (Lists works, others on the way) create, delete, paginated lists of videos; with video informations (a/v encodings, bitrate, video lenght...)
|
8
|
+
- (I'm working on ) CRUD on videos' meta-data
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
@@ -39,7 +39,7 @@ You can note the securitylevel, for more information about it, take a look at `l
|
|
39
39
|
:security_level => DMC_SECURITY_LEVEL
|
40
40
|
})
|
41
41
|
|
42
|
-
Description of security levels :
|
42
|
+
Description of security levels :
|
43
43
|
|
44
44
|
* **None:**
|
45
45
|
The signed URL will be valid for everyone
|
@@ -88,6 +88,58 @@ It will return a string containing the direct link to your file.
|
|
88
88
|
The next parts will come soon, just need some time to finish it
|
89
89
|
and create corresponding tests.
|
90
90
|
|
91
|
+
---
|
92
|
+
### Video explorer :
|
93
|
+
|
94
|
+
If you need to list your video you can use this method :
|
95
|
+
|
96
|
+
DMCloud::Media.list({:page => 1, :per_page => 10})
|
97
|
+
It will return videos information and more :
|
98
|
+
|
99
|
+
result to yaml :
|
100
|
+
|
101
|
+
'{"result": {
|
102
|
+
"list": [{
|
103
|
+
"embed_url": "http://api.dmcloud.net/player/embed/:your_id/:media_id",
|
104
|
+
"assets": {
|
105
|
+
"source": {
|
106
|
+
"status": "ready",
|
107
|
+
"video_fps": 25.0,
|
108
|
+
"file_extension": "mp4",
|
109
|
+
"video_fps_mode": "CFR",
|
110
|
+
"container": "MPEG-4",
|
111
|
+
"audio_samplerate": 44100,
|
112
|
+
"video_interlaced": false,
|
113
|
+
"video_rotation": 0.0,
|
114
|
+
"video_bitrate": 1000618,
|
115
|
+
"created": 1347641702,
|
116
|
+
"audio_nbr_channel": 2,
|
117
|
+
"download_url": "http://cdn.dmcloud.net/route/http/:your_id/:media_id/source-1347634502.mp4?filename=my_video_name-source-1347634502.mp4&auth=1351277028-3-672hcu1m-3fcab065b9bf103e70d3883aa8c657be",
|
118
|
+
"video_aspect": 1.7777777777777777,
|
119
|
+
"video_height": 576,
|
120
|
+
"audio_bitrate": 128017,
|
121
|
+
"audio_codec": "AAC LC",
|
122
|
+
"file_size": 119133958,
|
123
|
+
"duration": 839,
|
124
|
+
"video_codec": "AVC",
|
125
|
+
"video_width": 1024,
|
126
|
+
"global_bitrate": 1134696}},
|
127
|
+
"created": 1347641696,
|
128
|
+
"meta": { "title": "my video 1 title"},
|
129
|
+
"frame_ratio": 1.7740740740740739,
|
130
|
+
"id": "5053616094739936ec0006af" }],
|
131
|
+
"pages": 1,
|
132
|
+
"on_this_page": 3,
|
133
|
+
"per_page": 10,
|
134
|
+
"total": 3,
|
135
|
+
"page": 1}}'
|
136
|
+
|
137
|
+
As you can see, this give many information, you can submit a hash like this :
|
138
|
+
|
139
|
+
DMCloud::Media.list({:page => 1, :per_page => 10, :fields => {:meta => :title }, :assets => [:download_url, :created ]})
|
140
|
+
|
141
|
+
|
142
|
+
|
91
143
|
## Contributing
|
92
144
|
|
93
145
|
Your welcome to share and enhance this gem.
|
data/dm_cloud.gemspec
CHANGED
@@ -40,7 +40,7 @@ module DMCloud
|
|
40
40
|
|
41
41
|
assets_names = ['source'] if assets_names.nil?
|
42
42
|
if not fields[:assets]
|
43
|
-
|
43
|
+
request = all_assets_fields(request, assets_names)
|
44
44
|
else
|
45
45
|
assets_names.each do |name|
|
46
46
|
fields[:assets].each { |value| request << "assets.#{name}.#{value.to_s}" }
|
@@ -71,7 +71,7 @@ module DMCloud
|
|
71
71
|
|
72
72
|
assets_names = ['source'] if assets_names.nil?
|
73
73
|
if not fields[:assets]
|
74
|
-
|
74
|
+
request = all_assets_fields(request, assets_names)
|
75
75
|
else
|
76
76
|
assets_names.each do |name|
|
77
77
|
fields[:assets].each { |value| request['fields'] << "assets.#{name}.#{value.to_s}" }
|
@@ -84,6 +84,8 @@ module DMCloud
|
|
84
84
|
|
85
85
|
protected
|
86
86
|
# This method exclude stats, but return all information for a media (video or images)
|
87
|
+
# NOTE: This is outside the methods because : too long and recurent.
|
88
|
+
# It's also used as default if no fields params is submitted.
|
87
89
|
def self.all_assets_fields(request, assets_names)
|
88
90
|
assets_names.each do |name|
|
89
91
|
request['fields'] << "assets.#{name}.download_url"
|
data/lib/dm_cloud/media.rb
CHANGED
data/lib/dm_cloud/request.rb
CHANGED
@@ -6,10 +6,17 @@ module DMCloud
|
|
6
6
|
DAILYMOTION_API = 'http://api.dmcloud.net/api'
|
7
7
|
DAILYMOTION_STATIC = 'http://api.dmcloud.net/api'
|
8
8
|
|
9
|
+
# This method control signing for Media calls and handle request and response.
|
10
|
+
def self.execute(call, params = {})
|
11
|
+
url = define(call)
|
12
|
+
params['auth'] = DMCloud::Signing.identify(params)
|
13
|
+
|
14
|
+
result = send_request(params)
|
15
|
+
parse_response(result)
|
16
|
+
end
|
17
|
+
|
9
18
|
|
10
19
|
def self.send_request(params)
|
11
|
-
puts 'body request params : ' + params.to_json + "\n" + '-' * 80
|
12
|
-
|
13
20
|
@uri = URI.parse(DAILYMOTION_API)
|
14
21
|
|
15
22
|
http = Net::HTTP.new(@uri.host, @uri.port)
|
@@ -21,19 +28,13 @@ module DMCloud
|
|
21
28
|
puts 'request (YAML format ): ' + request.to_yaml + "\n" + '-' * 80
|
22
29
|
|
23
30
|
http.request(request).body
|
24
|
-
|
25
31
|
end
|
26
32
|
|
27
|
-
def self.execute(call, params = {})
|
28
|
-
url = define(call)
|
29
|
-
params['auth'] = DMCloud::Signing.identify(params)
|
30
33
|
|
31
|
-
result = send_request(params)
|
32
|
-
parse_response(result)
|
33
|
-
end
|
34
34
|
|
35
35
|
def self.parse_response(result)
|
36
|
-
puts 'result : ' + result.to_yaml
|
36
|
+
puts 'result : ' + result.to_yaml # For debugging, will be remove when test will exists
|
37
|
+
JSON.parse(result)
|
37
38
|
end
|
38
39
|
|
39
40
|
def self.define(action)
|
data/lib/dm_cloud/signing.rb
CHANGED
@@ -164,6 +164,11 @@ module DMCloud
|
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
|
+
|
168
|
+
# This block comes from Cloudkey gem.
|
169
|
+
# I discovered this gem far after I start this one
|
170
|
+
# and I will try to add file upload from http or ftp.
|
171
|
+
# (Missing in their gem)
|
167
172
|
def self.normalize params
|
168
173
|
case params
|
169
174
|
when Array
|
data/lib/dm_cloud/version.rb
CHANGED
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.0.
|
4
|
+
version: 0.0.55
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,23 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-10-26 00:00:00.000000000 Z
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: curb
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 0.8.0
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 0.8.0
|
13
|
+
dependencies: []
|
30
14
|
description: This gem will simplify usage of DailyMotion Cloud API, it represent api
|
31
15
|
in ruby style, with automated handler for search and upload files
|
32
16
|
email:
|