Skip to content
Snippets Groups Projects
Commit 36becdfe authored by Tommy Persson's avatar Tommy Persson
Browse files

Example

parent 3a0b0170
No related branches found
No related tags found
No related merge requests found
import json
import requests
from optparse import OptionParser
parser = OptionParser()
parser.add_option ("-p", "--print-pushes", action="store_true", dest="print_pushes", help="Print pushes.")
parser.add_option ("", "--start-push", action="store_true", dest="start_push", help="Start pushing of stream.")
parser.add_option ("", "--stop-push", action="store_true", dest="stop_push", help="Stop pushing of stream.")
parser.add_option ("", "--stream-name", action="store", type="string", dest="stream_name", help="Name of stream to start or stop.")
(options, args) = parser.parse_args()
def show_pushes():
r = requests.get('https://ome.waraps.org:8081/v1/vhosts/default/apps/app:pushes', headers={"authorization":"Basic aGFoYV9oZW1saWdfbnlja2Vs"})
# print(json.dumps(r.json(), sort_keys=True, indent=4, separators=(',', ': ')))
for jobj in r.json()["response"]:
print("PUSHING:", jobj["stream"]["name"])
def start_push(streamName):
# Start push
startPushUrl = "https://ome.waraps.org:8081/v1/vhosts/default/apps/app:startPush"
startPushBody = {
"id": streamName,
"stream": {
"name": streamName
},
"protocol": "rtmp",
"url": "rtmp://10.0.0.77/live",
"streamKey": streamName
}
r = requests.post(startPushUrl, json=startPushBody ,headers={"authorization":"Basic aGFoYV9oZW1saWdfbnlja2Vs"})
print(json.dumps(r.json(), sort_keys=True, indent=4, separators=(',', ': ')))
def stop_push(streamName):
# Stop push
stopPushUrl = "https://ome.waraps.org:8081/v1/vhosts/default/apps/app:stopPush"
stopPushBody = {
"id": streamName
}
r = requests.post(stopPushUrl, json=stopPushBody ,headers={"authorization":"Basic aGFoYV9oZW1saWdfbnlja2Vs"})
print(json.dumps(r.json(), sort_keys=True, indent=4, separators=(',', ': ')))
if __name__ == '__main__':
if options.print_pushes:
show_pushes()
if options.stream_name:
if options.start_push:
start_push(options.stream_name)
if options.stop_push:
stop_push(options.stream_name)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment