Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.2.0 #65

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e9f6bf0
fix historyactivity
bernieyangmh Mar 21, 2018
7535dca
fix convert
bernieyangmh Mar 21, 2018
a1e6712
fix bandwidth
bernieyangmh Mar 21, 2018
6f69941
change example
bernieyangmh Mar 21, 2018
b4b1460
create stream
bernieyangmh Mar 21, 2018
803b6a6
fix saveas
bernieyangmh Mar 22, 2018
d6030be
fix url..
bernieyangmh Mar 22, 2018
3711d37
add list stream
bernieyangmh Mar 22, 2018
5ea2923
add stream
bernieyangmh Mar 22, 2018
7587e46
add live stream and streams
bernieyangmh Mar 22, 2018
9e11457
disable
bernieyangmh Mar 22, 2018
10a14af
add snapshot
bernieyangmh Mar 22, 2018
e9ad23d
fix snapshot
bernieyangmh Mar 22, 2018
5208d7e
forget aksk
bernieyangmh Mar 22, 2018
ceb810b
delete surplus api add test batch and create
bernieyangmh Mar 23, 2018
b854caa
fix refresh and test disable
bernieyangmh Mar 23, 2018
7dde48a
add stream test
bernieyangmh Mar 25, 2018
43148bf
fix save_as
bernieyangmh Mar 28, 2018
0225b03
delete room
bernieyangmh Mar 28, 2018
5140f09
add kick,query
bernieyangmh Mar 28, 2018
028c1ee
arrange dir
bernieyangmh Mar 28, 2018
30a2fbd
add wm
bernieyangmh Mar 28, 2018
535169c
add wm query,list
bernieyangmh Mar 28, 2018
d1aacb2
add room test
bernieyangmh Mar 29, 2018
78e3798
Update README.md
bernieyangmh Mar 29, 2018
2d36861
add readme
bernieyangmh Mar 29, 2018
d916cf3
Update README.md
bernieyangmh Mar 29, 2018
93c179d
adjust style
bernieyangmh Mar 29, 2018
7ba5f8c
test adjust
bernieyangmh Mar 29, 2018
e29439b
adjust python2
bernieyangmh Mar 29, 2018
50d8e1b
test hub
bernieyangmh Mar 30, 2018
868725d
test pili
bernieyangmh Mar 30, 2018
d7deff7
test room
bernieyangmh Mar 30, 2018
fd0d267
fix aksk
bernieyangmh Mar 30, 2018
c0164e8
annotation
bernieyangmh Mar 30, 2018
ea4b114
add document and link
bernieyangmh Apr 2, 2018
aeef24a
pep8
bernieyangmh Apr 6, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 95 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@
- Stream
- [x] 流信息: stream.refresh()
- [x] 禁用流: stream.disable(till)
- [x] 启用流: stream.enable()
- [x] 查询直播状态: stream.status()
- [x] 保存直播回放: stream.saveas(start, end, options)
- [x] 保存直播截图: stream.snapshot(options)
- [x] 更改流的实时转码规格: stream.update_converts(profiles)
- [x] 查询直播历史: stream.history(start, end)

- Room
- [x] 创建房间: room.create_room(options)
- [x] 生成token: room.roomToken(options)
- [x] 删除房间: room.deleteRoom(roomName)
- [x] 踢除用户: room.kickUser(roomName, userId)
- [x] 查询房间: room.getRoom(roomName)
- [x] 查询在线用户: room.getUser(roomName)


## Contents

Expand All @@ -46,12 +53,19 @@
- [Stream](#stream)
- [Get Stream info](#get-stream-info)
- [Disable a Stream](#disable-a-stream)
- [Enable a Stream](#enable-a-stream)
- [Get Stream live status](#get-stream-live-status)
- [Save Stream live playback](#save-stream-live-playback)
- [Save Stream snapshot](#save-stream-snapshot)
- [Update Stream converts](#update-stream-converts)
- [Get Stream history activity](#get-stream-history-activity)
- [Room](#stream)
- [Create Room](#create-room)
- [Create Token](#create-token)
- [Delete Room](#delete-room)
- [Kick User](#kick-user)
- [Query Room](#query-room)
- [Query User](#query-user)


## Installation

Expand All @@ -75,7 +89,6 @@ secret_key = "<QINIU SECRET KEY>" # 替换成自己 Qiniu 账号的 SecretKey
hub_name = "<PILI HUB NAME>" # Hub 必须事先存在

mac = pili.Mac(AccessKey, SecretKey)
client = pili.Client(mac)
# ...
```

Expand Down Expand Up @@ -127,8 +140,7 @@ print pili.snapshot_play_url("live-snapshot.test.com", hub_name, "streamtitle")

```python
mac = pili.Mac(AccessKey, SecretKey)
client = pili.Client(mac)
hub = client.hub("PiliSDKTest")
hub = Hub(mac, hub_name)
```

#### Create a new Stream
Expand Down Expand Up @@ -198,19 +210,6 @@ print "after sleep 5 seconds:", stream.refresh(), stream.disabled()
# after sleep 5 seconds: {"disabledTill": 1488378022, "converts": [], "hub": "PiliSDKTest", "key": "stream23126041129_1"} False
```

#### Enable a Stream

```python
stream.disable()
stream = hub.get(stream_title1)
stream.disable()
print "before enable:", stream.refresh(), stream.disabled()
stream.enable()
print "after enable:", stream.refresh(), stream.disabled()
# before enable: {"disabledTill": -1, "converts": [], "hub": "PiliSDKTest", "key": "stream23126041129_1"} True
# after enable: {"disabledTill": 0, "converts": [], "hub": "PiliSDKTest", "key": "stream23126041129_1"} False
```

#### Get Stream live status

```python
Expand Down Expand Up @@ -252,7 +251,84 @@ print "after update converts:", stream.refresh()

```python
now = int(time.time())
print "get publish history:"
print "get publish history
print stream.history(start_second=now-86400)
# [{u'start': 1488359927, u'end': 1488367483}, {u'start': 1488348110, u'end': 1488358759}, {u'start': 1488338678, u'end': 1488340383}, {u'start': 1488333270, u'end': 1488337953}, {u'start': 1488282646, u'end': 1488288321}]
```


### Room

#### Instantiate a Pili Room

```python
mac = pili.Mac(AccessKey, SecretKey)
room = RoomClient(mac)
```

#### Create Room

```python
resp = room.create_room('admin_user', 'roomname')
print(resp.status_code)
print(resp.headers)
print(resp.text)
#200
#{'Content-Length': '24', 'X-Whom': 'bc196', 'Vary': 'Accept-Encoding', 'Server': 'nginx/1.8.0', 'X-Log': 'PILI-RTC:1', 'Connection': 'keep-alive', 'X-Reqid': 'bccmalhRqam8WsO_', 'Date': 'Thu, 29 Mar 2018 08:54:01 GMT', 'Content-Type': 'application/json'}
#{"room_name":"roomname"}
```

#### Create Token

````python
print(room.roomToken('roomname', 'admin_user', 'admin', 3600))
````

#### Delete Room

````python
resp = room.deleteRoom('roomname')
print(resp.status_code)
print(resp.headers)
print(resp.text)
#200
#{'Content-Length': '2', 'X-Whom': 'bc197', 'Vary': 'Accept-Encoding', 'Server': 'nginx/1.8.0', 'X-Log': 'PILI-RTC:1', 'Connection': 'keep-alive', 'X-Reqid': 'GRkeCnQZB6q8WkvM', 'Date': 'Thu, 29 Mar 2018 08:55:35 GMT', 'Content-Type': 'application/json'}
#{}
````

#### Kick User

````python
resp = room.kickUser('roomname', 'admin_user')
print(resp.status_code)
print(resp.headers)
print(resp.text)
#200
#{'Content-Length': '33', 'Server': 'nginx/1.8.0', 'X-Log': 'PILI-RTC:169/500', 'Connection': 'keep-alive', 'X-Reqid': 'DT87e9Y39qq8WrN7, DT87e9Y39qq8WrN7', 'Date': 'Thu, 29 Mar 2018 08:59:34 GMT', 'Content-Type': 'application/json'}
#{}
````

#### Query Room

````python
resp = room.getRoom('roomname')
print(resp.status_code)
print(resp.headers)
print(resp.text)
#200
#{'Content-Length': '73', 'X-Whom': 'bc197', 'Vary': 'Accept-Encoding', 'Server': 'nginx/1.8.0', 'X-Log': 'PILI-RTC:213', 'Connection': 'keep-alive', 'X-Reqid': 'GRkeCnQZRqu8Wp3R, GRkeCnQZRqu8Wp3R', 'Date': 'Thu, 29 Mar 2018 09:00:55 GMT', 'Content-Type': 'application/json'}
#{"owner_id":"admin","room_name":"roomname","room_status":0,"user_max":10}
````
#### Query User

````python
resp = room.getUser('roomname')
print(resp.status_code)
print(resp.headers)
print(resp.text)
#200
#{'Content-Length': '19', 'X-Whom': 'bc197', 'Vary': 'Accept-Encoding', 'Server': 'nginx/1.8.0', 'X-Log': 'PILI-RTC:197', 'Connection': 'keep-alive', 'X-Reqid': 'bccmalhRdqu8WnnH, bccmalhRdqu8WnnH', 'Date': 'Thu, 29 Mar 2018 09:01:43 GMT', 'Content-Type': 'application/json'}
#{"active_users":[]}
````


113 changes: 0 additions & 113 deletions example.py

This file was deleted.

7 changes: 4 additions & 3 deletions interact_micro_example/create_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
# 替换成自己 Qiniu 账号的 SecretKey
secret_key = "..."


mac = Mac(access_key, secret_key)

room = RoomClient(mac)

print room.createRoom('admin_user', 'roomname')
resp = room.create_room('admin_user', 'room_name')

# print room.roomToken('roomname', 'admin_user', 'admin', 36000)
print(resp.status_code)
print(resp.headers)
print(resp.text)
15 changes: 15 additions & 0 deletions interact_micro_example/create_token.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-

from pili import RoomClient, Mac

# 替换成自己 Qiniu 账号的 AccessKey
access_key = "..."

# 替换成自己 Qiniu 账号的 SecretKey
secret_key = "..."

mac = Mac(access_key, secret_key)

room = RoomClient(mac)

print(room.roomToken('room_name', 'admin_user', 'admin', 3600))
6 changes: 5 additions & 1 deletion interact_micro_example/delete_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@

room = RoomClient(mac)

print room.deleteRoom('roomname')
resp = room.deleteRoom('room_name')

print(resp.status_code)
print(resp.headers)
print(resp.text)
6 changes: 5 additions & 1 deletion interact_micro_example/kick_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@

room = RoomClient(mac)

print room.kickUser('roomname', 'admin_user')
resp = room.kickUser('room_name', 'admin_user')

print(resp.status_code)
print(resp.headers)
print(resp.text)
6 changes: 5 additions & 1 deletion interact_micro_example/query_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@

room = RoomClient(mac)

print room.getRoom('roomname')
resp = room.getRoom('room_name')

print(resp.status_code)
print(resp.headers)
print(resp.text)
6 changes: 5 additions & 1 deletion interact_micro_example/query_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@

room = RoomClient(mac)

print room.getUser('roomname')
resp = room.getUser('room_name')

print(resp.status_code)
print(resp.headers)
print(resp.text)
22 changes: 0 additions & 22 deletions live_examples/bandwidth_count.py

This file was deleted.

Loading