Skip to main content

A python3 reference implementation of an UbiCast MediaServer API client

Project description

PyPI - Python Version PyPI Travis (.org) branch

mediaserver-client

A python3 reference implementation of an UbiCast MediaServer API client.

Installation

To install the latest release of the mediaserver-client from PyPI :

pip install mediaserver-api-client

For development, the package can be installed in editable mode to allow changes on it :

git clone git@github.com:UbiCastTeam/mediaserver-client.git
cd mediaserver-client/
# there it's recommended to create/enable some virtualenv
pip install --editable .

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 is None, which means no configuration.
  • setup_logging: This argument must be a boolean. If set to True, the logging to console will be configured. The default value is True.

Configuration

You can see available parameters in the default configuration file : Default configuration

The local configuration should be a json file.

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 and config_path by local_conf in the MediaServerClient init.
  • Replace all occurences of MediaServerClient.config by MediaServerClient.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

mediaserver-api-client-3.11.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

mediaserver_api_client-3.11-py2.py3-none-any.whl (16.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file mediaserver-api-client-3.11.tar.gz.

File metadata

  • Download URL: mediaserver-api-client-3.11.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.2

File hashes

Hashes for mediaserver-api-client-3.11.tar.gz
Algorithm Hash digest
SHA256 77e7fb89784997ae7f9d98141d840cacd2fe29949bb99ffc4a5a945a3b644f6c
MD5 c6075c3006653310358ffe3549f41987
BLAKE2b-256 47419801f864dc41497c04bfbe7a243d1df7c04968e7c2f1f3d20a551572b574

See more details on using hashes here.

File details

Details for the file mediaserver_api_client-3.11-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for mediaserver_api_client-3.11-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d02e9a8ccf8212a8cf2326f9b1ded1f8d71287ba35bc2cfa58205e88bf17066b
MD5 cd75d75b9a1ffb922a29ec6608c0f84d
BLAKE2b-256 d3554ebcd5406ad9ce4d3ee21f0c3d26991648641c561f3922c93e8a46412f4c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page