pili 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb22831f58fe2ba275e403086a5d6f582db1b276
4
- data.tar.gz: 666a132c978cca3be0e787d7e5ce71c408019d52
3
+ metadata.gz: 4c9ad3f0d7a527077a1be8337686196970d09b3c
4
+ data.tar.gz: fe80a2ee4d91cc42d3304f9cb3e9ad719f97a816
5
5
  SHA512:
6
- metadata.gz: 2f502768f7388d7bff3fa9af451282fcdc3080266ca13581cb3c51e4c8592e71fde7bde1be864d081cb4038c235b82596ee4f339acc6b33a049124925be3f55d
7
- data.tar.gz: 185233ddbda8853da59537e5ce5f87f720cc40e33b05c71ac1fa3cb713d3db4eca2ceaf970a4e6de02e87faba0483fe1f6823bed6fcfcc97098d88d35fb1f2b3
6
+ metadata.gz: 93e45a37baf9469419688a4a3d2271f146d0d80f1cb2820e8651938bf5db7720ff155ee5b7b2e7d706f86fc89317cd29f5b8f5759691287e8ad32de55023ab7e
7
+ data.tar.gz: 05c23c3493dc459abc033a8f8c1cf9f064591cd43d4b34c2da6388753c8a1cc338c5de50985c09bd2fe4ae28a254888240443bf79a17e38a9ad5ee9587de97aa
data/README.md CHANGED
@@ -26,10 +26,11 @@
26
26
  - [Get stream segments](#get-stream-segments)
27
27
  - [Get stream status](#get-stream-status)
28
28
  - [Generate RTMP publish URL](#generate-rtmp-publish-url)
29
- - [Generate RTMP live play URL](#generate-rtmp-live-play-urls)
30
- - [Generate HLS live play URL](#generate-hls-live-play-url)
31
- - [Generate HLS playback URL](#generate-hls-playback-url)
29
+ - [Generate RTMP live play URLs](#generate-rtmp-live-play-urls)
30
+ - [Generate HLS live play URLs](#generate-hls-live-play-urls)
31
+ - [Generate HLS playback URLs](#generate-hls-playback-urls)
32
32
  - [To JSON String](#to-json-string)
33
+ - [Save Stream as](#save-stream-as)
33
34
  - [History](#history)
34
35
 
35
36
  ## Installation
@@ -75,6 +76,8 @@ client = Pili::Client.new(ACCESS_KEY, SECRETE_KEY, HUB_NAME)
75
76
  # title: optional, default is auto-generated
76
77
  # publish_key: optional, a secret key for signing the <publishToken>
77
78
  # publish_security: optional, can be "dynamic" or "static", default is "dynamic"
79
+ client.create_stream()
80
+ # or
78
81
  client.create_stream(title: "title", publish_key: "publish_key", publish_security: "static")
79
82
  # return stream object...
80
83
  ```
@@ -116,9 +119,11 @@ stream.delete()
116
119
  #### Get stream segments
117
120
 
118
121
  ```ruby
119
- # start_second: integer, optional
120
- # end_second: integer, optional
121
- stream.segments(start_second, end_second)
122
+ # start_time: optional, integer, in second, unix timestamp
123
+ # end_time: optional, integer, in second, unix timestamp
124
+ stream.segments()
125
+ # or
126
+ stream.segments(start_time, end_time)
122
127
 
123
128
  # [
124
129
  # {
@@ -153,13 +158,16 @@ stream.rtmp_publish_url()
153
158
  #### Generate RTMP live play URLs
154
159
 
155
160
  ```ruby
156
- stream.rtmp_live_urls()
161
+ urls = stream.rtmp_live_urls()
157
162
  # return rtmp live play urls, eg.
158
163
  # {
159
164
  # "ORIGIN" => "rtmp://test.qiniucdn.com/hubname/test",
160
165
  # "240p" => "rtmp://test.qiniucdn.com/hubname/test@240p",
161
166
  # ...
162
167
  # }
168
+
169
+ # Get original RTMP live url
170
+ original_url = urls['ORIGIN']
163
171
  ```
164
172
 
165
173
  #### Generate HLS live play URLs
@@ -172,18 +180,26 @@ stream.hls_live_urls()
172
180
  # "240p" => "http://test.qiniucdn.com/hubname/test@240p.m3u8"
173
181
  # ...
174
182
  # }
183
+
184
+ # Get original HLS live url
185
+ original_url = urls['ORIGIN']
175
186
  ```
176
187
 
177
188
  #### Generate HLS playback URLs
178
189
 
179
190
  ```ruby
180
- stream.hls_playback_urls(start_second, end_second)
191
+ # start_time: optional, integer, in second, unix timestamp
192
+ # end_time: optional, integer, in second, unix timestamp
193
+ stream.hls_playback_urls(start_time, end_time)
181
194
  # return hls playback urls, eg.
182
195
  # {
183
196
  # "ORIGIN" => "http://test.qiniucdn.com/hubname/test.m3u8?start=1436843430&end=1436846938",
184
197
  # "240p" => "http://test.qiniucdn.com/hubname/test@240p.m3u8?start=1436843430&end=1436846938"
185
198
  # ...
186
199
  # }
200
+
201
+ # Get original HLS playback url
202
+ original_url = urls['ORIGIN']
187
203
  ```
188
204
 
189
205
  #### To JSON String
@@ -191,9 +207,35 @@ stream.hls_playback_urls(start_second, end_second)
191
207
  stream.to_json()
192
208
  ```
193
209
 
194
- ## History
210
+ #### Save Stream as
211
+ ```ruby
212
+ # name = "fileName" # required, string
213
+ # format = "mp4" # required, string
214
+ # start_time = 1439121809 # required, int64, in second, unix timestamp
215
+ # end_time = 1439125409 # required, int64, in second, unix timestamp
216
+ # options = {
217
+ # :notify_url => "http://remote_callback_url"
218
+ # } #optional
219
+
220
+ stream.save_as(name, format, start_time, end_time, options)
195
221
 
196
- - 2.0.0
222
+ # return a dictionary:
223
+ # {
224
+ # "url": "<m3u8Url>",
225
+ # "targetUrl": "<TargetFileUrl>",
226
+ # "persistentId": <PersistentId>
227
+ # }
228
+ #
229
+ # You can get saving state via Qiniu fop service using persistentId.
230
+ # API: `curl -D GET http://api.qiniu.com/status/get/prefop?id=<PersistentId>`
231
+ # Doc reference: `http://developer.qiniu.com/docs/v6/api/overview/fop/persistent-fop.html#pfop-status`
232
+ ```
233
+
234
+
235
+ ## History
236
+ - 1.3.0
237
+ - Add stream saveas function
238
+ - 1.2.0
197
239
  - Add Client, Stream class
198
240
  - 1.0.1
199
241
  - Add get stream status method.
data/lib/pili/stream.rb CHANGED
@@ -137,5 +137,21 @@ module Pili
137
137
  }.to_json
138
138
  end
139
139
 
140
+
141
+ def save_as(name, format, start_time, end_time, options = {})
142
+ url = Config.api_base_url + "/streams/" + @id + "/saveas"
143
+
144
+ body = {}
145
+ body[:name] = name
146
+ body[:start] = start_time
147
+ body[:end] = end_time
148
+ body[:format] = format
149
+ body[:notifyUrl] = options[:notify_url]
150
+
151
+ body.delete_if { |k, v| v.nil? }
152
+
153
+ API.post(@client.access_key, @client.secret_key, url, body)
154
+ end
155
+
140
156
  end
141
157
  end
data/lib/pili/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pili
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pili
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miclle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-15 00:00:00.000000000 Z
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler