pili 1.5.0 → 1.5.2

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: 23353fd81b87b9123d66b1ae43ff0bcab17a1394
4
- data.tar.gz: 26c4b2efa6956cf2807c7980e41d109aca547a89
3
+ metadata.gz: 53ab7ac8e79f10070380910236ebe229c6d83813
4
+ data.tar.gz: 6f992c146547afb3f7f79ab5ee371969efad4fed
5
5
  SHA512:
6
- metadata.gz: 821ade8cbfb8aa4b98238d67d7dec341dded6825a6a522a46bb59032e93d64b7f07466eee0480477211fbfda1672daf50127d7c45114df5afe9bbfb3d40c703e
7
- data.tar.gz: afb135beccd5561a2919d0da9887fffa9b7fe6eae1278d181f65ca55f97438c6ac1322a9c534411a265193b282a71b6fd3197892c197466d170dab6a75bf5ccf
6
+ metadata.gz: dccbd1b051bfcbe11ba12b27eef7c293c069f7c3c25e8e11deb38f326c644b5470dfce255e8b67a2dfd731a8f3c926260d9f7b54f57b56146360d1f1b0c8bc94
7
+ data.tar.gz: 1fa536931e109076f5a9cc6f20ccb34dc3a24b60b0ce1bd461b326983712296deb6af30d627977f4391ca7b1278ff9a010807c5dc077a6735c4836f82ce63977
data/README.md CHANGED
@@ -76,9 +76,9 @@ SECRETE_KEY = 'Qiniu_SecretKey'
76
76
  HUB_NAME = 'Pili_Hub_Name' # The Hub must be exists before use
77
77
 
78
78
  # Change API host as necessary
79
- # pili.qiniuapi.com as deafult
79
+ # pili.qiniuapi.com as default
80
80
  # pili-lte.qiniuapi.com is the latest RC version
81
- Pili::Config.init api_host: 'pili-lte.qiniuapi.com'
81
+ # Pili::Config.init api_host: 'pili.qiniuapi.com' # default
82
82
  ```
83
83
 
84
84
 
@@ -122,11 +122,12 @@ end
122
122
  # "rtmp"=>"eksg7h.publish.z1.pili.qiniup.com"
123
123
  # },
124
124
  # "live"=>{
125
- # "http"=>"eksg7h.live1-http.z1.pili.qiniucdn.com",
125
+ # "hdl"=>"eksg7h.live1-hdl.z1.pili.qiniucdn.com",
126
+ # "hls"=>"eksg7h.live1-hls.z1.pili.qiniucdn.com",
126
127
  # "rtmp"=>"eksg7h.live1-rtmp.z1.pili.qiniucdn.com"
127
128
  # },
128
129
  # "playback"=>{
129
- # "http"=>"eksg7h.playback1.z1.pili.qiniucdn.com"
130
+ # "hls"=>"eksg7h.playback1.z1.pili.qiniucdn.com"
130
131
  # }
131
132
  # },
132
133
  # @created_at="2015-08-22T14:27:01.62Z",
@@ -158,11 +159,12 @@ end
158
159
  # "rtmp"=>"eksg7h.publish.z1.pili.qiniup.com"
159
160
  # },
160
161
  # "live"=>{
161
- # "http"=>"eksg7h.live1-http.z1.pili.qiniucdn.com",
162
+ # "hdl"=>"eksg7h.live1-hdl.z1.pili.qiniucdn.com",
163
+ # "hls"=>"eksg7h.live1-hls.z1.pili.qiniucdn.com",
162
164
  # "rtmp"=>"eksg7h.live1-rtmp.z1.pili.qiniucdn.com"
163
165
  # },
164
166
  # "playback"=>{
165
- # "http"=>"eksg7h.playback1.z1.pili.qiniucdn.com"
167
+ # "hls"=>"eksg7h.playback1.z1.pili.qiniucdn.com"
166
168
  # }
167
169
  # },
168
170
  # @created_at="2015-08-22T14:27:01.62Z",
@@ -175,10 +177,11 @@ end
175
177
 
176
178
  ```ruby
177
179
  begin
180
+ status = nil # optional, can be "connected"
178
181
  marker = nil # optional
179
182
  limit = nil # optional
180
183
  title = nil # optional
181
- streams = hub.list_streams(marker: marker, limit: limit, title: title)
184
+ streams = hub.list_streams(status: status, marker: marker, limit: limit, title: title)
182
185
  puts "Hub list_streams() =>\n#{streams.inspect}\n\n"
183
186
  rescue Exception => e
184
187
  puts "Hub list_streams() failed. Caught exception:\n#{e.http_body}\n\n"
@@ -257,11 +260,12 @@ end
257
260
  # "rtmp"=>"eksg7h.publish.z1.pili.qiniup.com"
258
261
  # },
259
262
  # "live"=>{
260
- # "http"=>"eksg7h.live1-http.z1.pili.qiniucdn.com",
263
+ # "hdl"=>"eksg7h.live1-hdl.z1.pili.qiniucdn.com",
264
+ # "hls"=>"eksg7h.live1-hls.z1.pili.qiniucdn.com",
261
265
  # "rtmp"=>"eksg7h.live1-rtmp.z1.pili.qiniucdn.com"
262
266
  # },
263
267
  # "playback"=>{
264
- # "http"=>"eksg7h.playback1.z1.pili.qiniucdn.com"
268
+ # "hls"=>"eksg7h.playback1.z1.pili.qiniucdn.com"
265
269
  # }
266
270
  # },
267
271
  # @created_at="2015-08-22T14:27:01.62Z",
@@ -292,11 +296,12 @@ end
292
296
  # "rtmp"=>"eksg7h.publish.z1.pili.qiniup.com"
293
297
  # },
294
298
  # "live"=>{
295
- # "http"=>"eksg7h.live1-http.z1.pili.qiniucdn.com",
299
+ # "hdl"=>"eksg7h.live1-hdl.z1.pili.qiniucdn.com",
300
+ # "hls"=>"eksg7h.live1-hls.z1.pili.qiniucdn.com",
296
301
  # "rtmp"=>"eksg7h.live1-rtmp.z1.pili.qiniucdn.com"
297
302
  # },
298
303
  # "playback"=>{
299
- # "http"=>"eksg7h.playback1.z1.pili.qiniucdn.com"
304
+ # "hls"=>"eksg7h.playback1.z1.pili.qiniucdn.com"
300
305
  # }
301
306
  # },
302
307
  # @created_at="2015-08-22T14:27:01.62Z",
@@ -328,11 +333,12 @@ end
328
333
  # "rtmp"=>"eksg7h.publish.z1.pili.qiniup.com"
329
334
  # },
330
335
  # "live"=>{
331
- # "http"=>"eksg7h.live1-http.z1.pili.qiniucdn.com",
336
+ # "hdl"=>"eksg7h.live1-hdl.z1.pili.qiniucdn.com",
337
+ # "hls"=>"eksg7h.live1-hls.z1.pili.qiniucdn.com",
332
338
  # "rtmp"=>"eksg7h.live1-rtmp.z1.pili.qiniucdn.com"
333
339
  # },
334
340
  # "playback"=>{
335
- # "http"=>"eksg7h.playback1.z1.pili.qiniucdn.com"
341
+ # "hls"=>"eksg7h.playback1.z1.pili.qiniucdn.com"
336
342
  # }
337
343
  # },
338
344
  # @created_at="2015-08-22T14:27:01.62Z",
@@ -352,6 +358,7 @@ rescue Exception => e
352
358
  end
353
359
 
354
360
  #{
361
+ # "startFrom"=>"2015-09-10T05:58:10.289+08:00",
355
362
  # "addr"=>"222.73.202.226:2572",
356
363
  # "status"=>"connected",
357
364
  # "bytesPerSecond"=>16870.200000000001,
@@ -393,7 +400,7 @@ urls = stream.hls_live_urls()
393
400
  puts "Stream hls_live_urls() =>\n#{urls.inspect}\n\n"
394
401
 
395
402
  # {
396
- # "ORIGIN"=>"http://eksg7h.live1-http.z1.pili.qiniucdn.com/hub1/55d886b5e3ba571322003121.m3u8"
403
+ # "ORIGIN"=>"http://eksg7h.live1-hls.z1.pili.qiniucdn.com/hub1/55d886b5e3ba571322003121.m3u8"
397
404
  # }
398
405
  ```
399
406
 
@@ -405,7 +412,7 @@ urls = stream.http_flv_live_urls()
405
412
  puts "Stream http_flv_live_urls() =>\n#{urls.inspect}\n\n"
406
413
 
407
414
  # {
408
- # "ORIGIN"=>"http://eksg7h.live1-http.z1.pili.qiniucdn.com/hub1/55d886b5e3ba571322003121.flv"
415
+ # "ORIGIN"=>"http://eksg7h.live1-hdl.z1.pili.qiniucdn.com/hub1/55d886b5e3ba571322003121.flv"
409
416
  # }
410
417
  ```
411
418
 
@@ -443,8 +450,8 @@ end
443
450
  ### Generate HLS playback URLs
444
451
 
445
452
  ```ruby
446
- start_time = 1440196065 # required, integer, in second, unix timestamp
447
- end_time = 1440196105 # required, integer, in second, unix timestamp
453
+ start_time = 1440196065 # optional, integer, in second, unix timestamp
454
+ end_time = 1440196105 # optional, integer, in second, unix timestamp
448
455
  urls = stream.hls_playback_urls(start_time, end_time)
449
456
  puts "Stream hls_playback_urls() =>\n#{urls.inspect}\n\n"
450
457
  # {
@@ -475,9 +482,9 @@ end
475
482
  # }
476
483
  ```
477
484
 
478
- While invoking `saveAs()` and `snapshot()`, you can get processing state via Qiniu FOP Service using `persistentId`.
479
- API: `curl -D GET http://api.qiniu.com/status/get/prefop?id={PersistentId}`
480
- Doc reference: <http://developer.qiniu.com/docs/v6/api/overview/fop/persistent-fop.html#pfop-status>
485
+ While invoking `saveAs()` and `snapshot()`, you can get processing state via Qiniu FOP Service using `persistentId`.
486
+ API: `curl -D GET http://api.qiniu.com/status/get/prefop?id={PersistentId}`
487
+ Doc reference: <http://developer.qiniu.com/docs/v6/api/overview/fop/persistent-fop.html#pfop-status>
481
488
 
482
489
 
483
490
  ### Snapshot Stream
data/example/example.rb CHANGED
@@ -8,9 +8,9 @@ SECRETE_KEY = 'Qiniu_SecretKey'
8
8
  HUB_NAME = 'Pili_Hub_Name' # The Hub must be exists before use
9
9
 
10
10
  # Change API host as necessary
11
- # pili.qiniuapi.com as deafult
11
+ # pili.qiniuapi.com as default
12
12
  # pili-lte.qiniuapi.com is the latest RC version
13
- Pili::Config.init api_host: 'pili-lte.qiniuapi.com'
13
+ # Pili::Config.init api_host: 'pili.qiniuapi.com' # default
14
14
 
15
15
 
16
16
  # Instantiate an Pili hub
@@ -47,10 +47,11 @@ end
47
47
 
48
48
  # List streams
49
49
  begin
50
+ status = nil # optional, can be "connected"
50
51
  marker = nil # optional
51
52
  limit = nil # optional
52
53
  title = nil # optional
53
- streams = hub.list_streams(marker: marker, limit: limit, title: title)
54
+ streams = hub.list_streams(status: status, marker: marker, limit: limit, title: title)
54
55
  puts "Hub list_streams() =>\n#{streams.inspect}\n\n"
55
56
  rescue Exception => e
56
57
  puts "Hub list_streams() failed. Caught exception:\n#{e.http_body}\n\n"
@@ -136,8 +137,8 @@ end
136
137
 
137
138
 
138
139
  # Generate HLS playback URLs
139
- start_time = 1440196065 # required, integer, in second, unix timestamp
140
- end_time = 1440196105 # required, integer, in second, unix timestamp
140
+ start_time = 1440196065 # optional, integer, in second, unix timestamp
141
+ end_time = 1440196105 # optional, integer, in second, unix timestamp
141
142
  urls = stream.hls_playback_urls(start_time, end_time)
142
143
  puts "Stream hls_playback_urls() =>\n#{urls.inspect}\n\n"
143
144
 
data/lib/pili/api.rb CHANGED
@@ -31,13 +31,15 @@ module Pili
31
31
  def list_streams(credentials, hub_name, options = {})
32
32
  url = "/streams?hub=#{hub_name}"
33
33
 
34
+ url += "&status=#{options[:status]}" if options[:status] == "connected"
34
35
  url += "&marker=#{options[:marker]}" unless Utils.blank?(options[:marker])
35
36
  url += "&limit=#{options[:limit]}" if options[:limit].is_a?(Fixnum)
36
37
  url += "&title=#{options[:title]}" unless Utils.blank?(options[:title])
37
38
 
38
39
  streams = []
39
40
 
40
- RPC.get(credentials, url)["items"].each do |item|
41
+ items = RPC.get(credentials, url)["items"]
42
+ items && items.each do |item|
41
43
  streams << Stream.new(credentials, item)
42
44
  end
43
45
 
data/lib/pili/stream.rb CHANGED
@@ -79,12 +79,12 @@ module Pili
79
79
 
80
80
 
81
81
  def http_flv_live_urls
82
- live_http_host = @hosts["live"]["http"]
82
+ live_hdl_host = @hosts["live"]["hdl"]
83
83
 
84
- urls = { Config.origin => "http://#{live_http_host}/#{@hub}/#{@title}.flv" }
84
+ urls = { Config.origin => "http://#{live_hdl_host}/#{@hub}/#{@title}.flv" }
85
85
 
86
86
  @profiles.each do |profile|
87
- urls[profile] = "http://#{live_http_host}/#{@hub}/#{@title}@#{profile}.flv"
87
+ urls[profile] = "http://#{live_hdl_host}/#{@hub}/#{@title}@#{profile}.flv"
88
88
  end
89
89
 
90
90
  urls
@@ -92,25 +92,25 @@ module Pili
92
92
 
93
93
 
94
94
  def hls_live_urls
95
- live_http_host = @hosts["live"]["http"]
95
+ live_hls_host = @hosts["live"]["hls"]
96
96
 
97
- urls = { Config.origin => "http://#{live_http_host}/#{@hub}/#{@title}.m3u8" }
97
+ urls = { Config.origin => "http://#{live_hls_host}/#{@hub}/#{@title}.m3u8" }
98
98
 
99
99
  @profiles.each do |profile|
100
- urls[profile] = "http://#{live_http_host}/#{@hub}/#{@title}@#{profile}.m3u8"
100
+ urls[profile] = "http://#{live_hls_host}/#{@hub}/#{@title}@#{profile}.m3u8"
101
101
  end
102
102
 
103
103
  urls
104
104
  end
105
105
 
106
106
 
107
- def hls_playback_urls(start_second, end_second)
108
- playback_http_host = @hosts["playback"]["http"]
107
+ def hls_playback_urls(start_second = -1, end_second = -1)
108
+ playback_hls_host = @hosts["playback"]["hls"]
109
109
 
110
- urls = { Config.origin => "http://#{playback_http_host}/#{@hub}/#{@title}.m3u8?start=#{start_second}&end=#{end_second}" }
110
+ urls = { Config.origin => "http://#{playback_hls_host}/#{@hub}/#{@title}.m3u8?start=#{start_second}&end=#{end_second}" }
111
111
 
112
112
  @profiles.each do |profile|
113
- urls[profile] = "http://#{playback_http_host}/#{@hub}/#{@title}@#{profile}.m3u8?start=#{start_second}&end=#{end_second}"
113
+ urls[profile] = "http://#{playback_hls_host}/#{@hub}/#{@title}@#{profile}.m3u8?start=#{start_second}&end=#{end_second}"
114
114
  end
115
115
 
116
116
  urls
data/lib/pili/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pili
2
- VERSION = "1.5.0"
2
+ VERSION = "1.5.2"
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.5.0
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miclle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-24 00:00:00.000000000 Z
11
+ date: 2015-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler