Skip to main content

PyPI - Python Version PyPI

UbiCast Nudgis API client

A python3 reference implementation of an UbiCast Nudgis API client.

The API documentation is available on each Nudgis portal at /static/mediaserver/docs/api/index.html.

Requirements

Optional:

  • python3-venv

Installation

Linux & OSX

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

git clone https://github.com/UbiCastTeam/nudgis-client.git
cd nudgis-client/
python3 -m venv .venv
source .venv/bin/activate  # remember to run this every time you enter the folder and need to restore the environment
python3 -m pip install --editable .

If you want to install it system-wide as dependency, the releases are available on pypi:

pip install nudgis-client

Windows

  • Open cmd.exe and check python is available with py --version which should display the Python version
>py --version
Python 3.13.13
  • From this project root path, run:
> py -m venv .venv
> ".venv/Scripts/activate.bat"
> pip install .
  • Check it works with:
>py -m examples.ping_server
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\User\src\nudgis-client\examples\ping_server.py", line 17, in <module>
    print(ngc.api('/'))
          ^^^^^^^^^^^^
  File "C:\Users\User\src\nudgis-client\nudgisclient\client.py", line 221, in api
    result = self.request(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\src\nudgis-client\nudgisclient\client.py", line 98, in request
    self.check_conf()
  File "C:\Users\User\src\nudgis-client\nudgisclient\client.py", line 71, in check_conf
    configuration_lib.check_conf(self.conf)
  File "C:\Users\User\src\nudgis-client\nudgisclient\lib\configuration.py", line 87, in check_conf
    raise ConfigurationError('The value of "SERVER_URL" is not set. Please configure it.')
nudgisclient.lib.configuration.ConfigurationError: The value of "SERVER_URL" is not set. Please configure it.

Despite the error above, it shows that the installation is complete.

Configuration

Copy the provided config.json.example file into e.g. myconfig.json, edit it with a text editor and fill the URL and API KEY.

  • Check it works with:

Linux:

$ python3 ./examples/ping.py myconfig.json
{'success': True, 'nudgis': '13.1.1'}

Windows:

$ py ./examples/ping.py myconfig.json
{'success': True, 'nudgis': '13.1.1'}

Client class instantiation

The client class (nudgisclient.client.NudgisClient) takes two arguments:

  • local_conf: This argument can be either a dict, a path (str object) or a unix user (unix:msuser for example) -- only aplicable from running scripts from within the server running nudgis (Nudgis). 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 must be a json file.

Examples

Start/Stop a live

from nudgisclient import NudgisClient
ngc = NudgisClient(local_conf='your-conf.json')

response = ngc.api('/lives/prepare', method='post')
if response['success']:
    oid = response['oid']
    rtmp_uri = response['publish_uri']

    print(oid, rtmp_uri)

    print(ngc.api('/lives/start', method='post', data={'oid': oid}))

    print(ngc.api('/lives/stop', method='post', data={'oid': oid}))

Remove all users function

from nudgisclient import NudgisClient
ngc = NudgisClient(local_conf='your-conf.json')


def remove_all_users():
    print('Remove all users')
    users = ngc.api('/users')['users']

    for user in users:
        ngc.api('/users/delete', method='get', params={'id': user['id']})

Add media with a video, make it published at once

from nudgisclient import NudgisClient
ngc = NudgisClient(local_conf='your-conf.json')

print(ngc.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 nudgisclient import NudgisClient
ngc = NudgisClient(local_conf='your-conf.json')

personal_channel_oid = ngc.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(ngc.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 nudgisclient import NudgisClient
ngc = NudgisClient(local_conf='your-conf.json')

print(ngc.add_media('Test multichunk upload zip', file_path='/tmp/test.zip'))
print(ngc.add_media(file_path='test.mp4'))

Add a user

from nudgisclient import NudgisClient
ngc = NudgisClient(local_conf='your-conf.json')

print(ngc.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 nudgisclient import NudgisClient
ngc = NudgisClient(local_conf='your-conf.json')

ngc.import_users_csv('users.csv')

Add an annotation

from nudgisclient import NudgisClient
ngc = NudgisClient(local_conf='your-conf.json')

print(ngc.api('annotations/post', params={'oid': 'v125849d470d7v92kvtc', 'time': 1000}))

Get Chapters

from nudgisclient import NudgisClient
ngc = NudgisClient(local_conf='your-conf.json')

print(ngc.api('annotations/chapters/list', params={'oid': 'v125849d470d7v92kvtc'}))

Get annotations types list and print chapters id

from nudgisclient import NudgisClient
ngc = NudgisClient(local_conf='your-conf.json')

response = ngc.api('annotations/types/list', params={'oid': 'v125849d470d7v92kvtc'})
for a in response['types']:
    if a['slug'] == 'chapter':
        print(a['id'])

Metadata

Release files for nudgis-client 1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nudgis-client 1.2
File Size Uploaded Provenance Actions
nudgis_client-1.2.tar.gz 20.8 kB Without provenance Details for nudgis_client-1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nudgis-client 1.2
File Interpreter ABI Platform Actions
nudgis_client-1.2-py3-none-any.whl Python 3 none any Details for nudgis_client-1.2-py3-none-any.whl

Total release size: 42.9 kB

Release files / nudgis_client-1.2.tar.gz

Download URL nudgis_client-1.2.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7ee68cc2f512a0c57b26282eb46a1de8e8e3a1caf346462cd9aff61aec5655a5
BLAKE2b-256 checksum
How to use checksums
180ae9bbbc231aec6a06371279a7a07c86404dd9c5fe9d1bb4c876a4b6d2275e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / nudgis_client-1.2-py3-none-any.whl

Download URL nudgis_client-1.2-py3-none-any.whl
Size 22.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b16dc34e26978feb6fb24817915d0f3222775f72776a9028313864b2c543771
BLAKE2b-256 checksum
How to use checksums
557deb61472abed3a979ee37c0c7c07e62a16f6cf3d8dcdcbaba7e6f1911fab9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Security for nudgis-client 1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page