A python3 reference implementation of an UbiCast MediaServer API client
Project description
mediaserver-client
A python3 reference implementation of an UbiCast MediaServer API client.
Important
For production use, it is recommended to use the branch named "stable". The "master" branch is used for development.
Client class instantiation
The client class (ms_client
.client
.MediaServerClient
) takes two arguments:
local_conf
: This argument can be either a dict, a path (str
object) or a unix user (unix:msuser
for example). The default value isNone
, which means no configuration.setup_logging
: This argument must be a boolean. If set toTrue
, the logging to console will be configured. The default value isTrue
.
Notes about older client
If you are using the first version of this client (a single file named mediaserver_api_client.py), here are the steps to update your client:
- Remove the old client file (mediaserver_api_client.py).
- Install the new client using the setup.py.
- Replace the import path of
MediaServerClient
(see examples). - Replace the arguments named
config_dict
andconfig_path
bylocal_conf
in theMediaServerClient
init. - Replace all occurences of
MediaServerClient
.config
byMediaServerClient
.conf
.
Examples
Start/Stop a live
from ms_client.client import MediaServerClient
msc = MediaServerClient(local_conf='your-conf.json')
response = msc.api('/lives/prepare', method='post')
if response['success']:
oid = response['oid']
rtmp_uri = response['publish_uri']
print(oid, rtmp_uri)
print(msc.api('/lives/start', method='post', data={'oid': oid}))
print(msc.api('/lives/stop', method='post', data={'oid': oid}))
Remove all users function
from ms_client.client import MediaServerClient
msc = MediaServerClient(local_conf='your-conf.json')
def remove_all_users():
print('Remove all users')
users = msc.api('/users')['users']
for user in users:
msc.api('/users/delete', method='get', params={'id': user['id']})
Add media with a video, make it published at once
from ms_client.client import MediaServerClient
msc = MediaServerClient(local_conf='your-conf.json')
print(msc.add_media('Test multichunk upload mp4', file_path='test.mp4', validated='yes', speaker_email='user@domain.com'))
Create user personal channel and upload into it
from ms_client.client import MediaServerClient
msc = MediaServerClient(local_conf='your-conf.json')
personal_channel_oid = msc.api('/channels/personal/', method='get', params={'email': 'test@test.com'}).get('oid')
respone_like = {
'slug': 'testtestcom_05881',
'oid': 'c125855df7d36iudslp3',
'dbid': 113,
'title': 'test@test.com',
'success': True
}
if personal_channel_oid:
print('Uploading to personal channel %s' % personal_channel_oid)
print(msc.add_media('Test multichunk upload mp4', file_path='test.mp4', validated='yes', speaker_email='user@domain.com', channel=personal_channel_oid))
Add media with a zip
from ms_client.client import MediaServerClient
msc = MediaServerClient(local_conf='your-conf.json')
print(msc.add_media('Test multichunk upload zip', file_path='/tmp/test.zip'))
print(msc.add_media(file_path='test.mp4'))
Add a user
from ms_client.client import MediaServerClient
msc = MediaServerClient(local_conf='your-conf.json')
print(msc.api('users/add/', method='post', data={'email': 'test@test.com'}))
Add users with csv file; example file (header should be included):
users.csv :
Firstname;Lastname;Email;Company
Albert;Einstein;albert.einstein@test.com;Humanity
from ms_client.client import MediaServerClient
msc = MediaServerClient(local_conf='your-conf.json')
msc.import_users_csv('users.csv')
Add an annotation
from ms_client.client import MediaServerClient
msc = MediaServerClient(local_conf='your-conf.json')
print(msc.api('annotations/post', params={'oid': 'v125849d470d7v92kvtc', 'time': 1000}))
Get Chapters
from ms_client.client import MediaServerClient
msc = MediaServerClient(local_conf='your-conf.json')
print(msc.api('annotations/chapters/list', params={'oid': 'v125849d470d7v92kvtc'}))
Get annotations types list and print chapters id
from ms_client.client import MediaServerClient
msc = MediaServerClient(local_conf='your-conf.json')
response = msc.api('annotations/types/list', params={'oid': 'v125849d470d7v92kvtc'})
for a in response['types']:
if a['slug'] == 'chapter':
print(a['id'])
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mediaserver-api-client-3.0.tar.gz
.
File metadata
- Download URL: mediaserver-api-client-3.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f86809edc9c42f41f423640dd14be06dc4e91851cbc0ec7c098274bd584a2bea |
|
MD5 | 70cba2fc4bfdca77e7485670c769e648 |
|
BLAKE2b-256 | 20dd38e4430ea0eaef66bd9a6f398597ec89496c1c803ede2b6d44a91c9f7357 |
File details
Details for the file mediaserver_api_client-3.0-py2.py3-none-any.whl
.
File metadata
- Download URL: mediaserver_api_client-3.0-py2.py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90084cff5ececeb635c1d65bab12b02b8cba9beeb4decad167416111f12c427c |
|
MD5 | 4ca469e13b09925264eb21a9b3d03b98 |
|
BLAKE2b-256 | f808def359c0a2084d181eff1e2c28de69b2e72e7a063bb055d997c01ed52172 |