Session API

Manage Playlists, Clips and Clip-Attributes.

The Session API works with Ids to manipulate respective Playlists, Clips and Attrs.

class rpa.api.session_api.SessionApi(logger)[source]

Bases: QObject

SIG_ACTIVE_CLIPS_CHANGED
SIG_ATTR_VALUES_CHANGED
SIG_BG_PLAYLIST_CHANGED
SIG_CURRENT_CLIP_CHANGED
SIG_FG_PLAYLIST_CHANGED
SIG_PLAYLISTS_MODIFIED
SIG_PLAYLIST_MODIFIED
clear() bool[source]

Clear the session by permanently deleting all the Playlists and their corresponding clips in the entire Session tree.

Returns:

True if success False otherwise

Return type:

(bool)

clear_attr_values_at(attr_values_at: List[Tuple]) bool[source]

Clear the value of the keyable attributes from the list at the given frame.

Example of how attr_values_at should look like,

[
    (playlist_id_1, clip_id_1, attr_id_1, key),
    (playlist_id_1, clip_id_1, attr_id_2, key),
    (playlist_id_1, clip_id_2, attr_id_1, key),
    (playlist_id_2, clip_id_3, attr_id_1, key),
    (playlist_id_2, clip_id_4, attr_id_2, key)
]
Parameters:

attr_values_at (List[Tuple]) – List of tuples containing playlist id, clip id, attr id, and key (frame).

Returns:

True if cleared False otherwise

Return type:

(bool)

create_clips(playlist_id: str, paths: List[str | Tuple[str, str]], index: int | None = None, ids: List[str] | None = None) List[str][source]

Creates clips with the given paths in the playlist of the given playlist id. The paths can also be data-base ids or web-urls as long as mechanisms for the core application to find the media file from the given paths are in place. The created playlists will be inserted into the given index if provided otherwise the clips will be inserted at the bottom of the playlist. If ids are provided, they will be used to identify the playlists. Make sure the provided ids are uniqiue. Recommended to use the following to generate these ids,

import uuid;
paths = ["path/to/clip_1", ("path/to/clip_2", "path/to/audio_clip_2"), "path/to/clip_3"]
ids = [uuid.uuid4().hex for _ in paths]

If no ids are provided, unique ids will be autogenerated. Eitherways the ids of the created clips will be retured in the same order of the given paths. Note that all the attributes (attrs) of the clips will also be fetched and available in the session as clips are created.

Parameters:
  • playlist_id (str) – Id of the playlist into which the clips needs to be created.

  • paths (List[Union[str, Tuple[str, str]]) – Paths to media for which clips need to be created. The path can be of a string, or a tuple of two strings. If given as a tuple, first string represents the video media path, and second string is the audio media path.

Kwargs:
index (Optional[int]):

Optional positional index where the clips need to be inserted.

ids (Optional[List[str]]):

Optional unique ids that need to be used for each of the created clips.

Returns:

Ids of the created clips

Return type:

list[str]

create_playlists(names: List[str], index: int | None = None, ids: List[str] | None = None) List[str][source]

Creates new playlists with the given names. If index is provided, the new playlists will be inserted into it, otherwise they will be inserted at the end. If unique ids are provided, they will used to identify each of the created playlists otherwise unique ids will be auto-generated and returned once the playlists are created.

Parameters:

names (List[str]) – Names for the playlists to be created

Kwargs:
index (Optional[int]):

Positional index of where the playlists are to be inserted.

ids (Optional[List(str)]):

Ids to be used to indentify playlists once they are created. Make sure to provide unique ids for each of the playlists. The list must be the same length as that of the names. Recommended to use the following to generate these ids, import uuid; names = [“playlist_1”, “playlist_2”, “playlist_3”] ids = [uuid.uuid4().hex for _ in names]

Returns:

Ids of the playlists created in the same order of the names provided.

Return type:

List[str]

property delegate_mngr
delete_clips_permanently(ids: List[str]) bool[source]

Permanently delete clips with the given ids.

Parameters:

ids (List[str]) – Ids of clips that need to be permanently deleted

Returns:

True if deleted permanently False otherwise

Return type:

(bool)

delete_playlists(ids: List[str]) bool[source]

Playlists with the given respective ids will be temporarily deleted along with the clips they hold. Note that this method will only temporarily delete the playlists, these temporarily deleted playlists can be restored.

Parameters:

Ids (List[str]) – Ids of Playlists.

Returns:

True if success False otherwise

Return type:

(bool)

delete_playlists_permanently(ids: List[str]) bool[source]

Playlists with the given respective ids, will be permanently deleted along with the clips they hold. Permanently deleted playlists cannot be restored.

Parameters:

Ids (List[str]) – Ids of Playlists.

Returns:

True if success False otherwise

Return type:

(bool)

get_active_clips(id: str) List[str][source]

Get the ids of the clips that have been activated in the playlist of the given id.

Note that only active clips will be considered in the sequence of clips constructed for any given playlist.

If no particular list of clips were activated by the user, then all the clips in the playlists will be activated and returned.

Parameters:

id (str) – Id of the Playlist

Returns:

Ids of the clips

Return type:

list[str]

get_attr_data_type(id: str) str[source]

Gets the data-type of the attr with the given id. Note that the data-type of the various attrs are represented as the following strings, “int” - integer “float” - float “str” - string “bool” - boolean “path” - file path

Parameters:

id (str) – Id of the attr

Returns:

String name of the data-type as mentioned in description

Return type:

str

get_attr_keys(clip_id: str, attr_id: str) List[int][source]

Get the list of key frames of the keyable attribute within the clip. For non-keyable attributes, the list returned will be empty.

Parameters:
  • clip_id (str) – Id of the Clip

  • attr_id (str) – Id of the Attr

Returns:

List of clip key frames

Return type:

List[int]

get_attr_name(id: str) str[source]

Get the name of attr with the given id

Parameters:

id (str) – Id of the attr

Returns:

Name of the attr

Return type:

str

get_attr_value(clip_id: str, attr_id: str) object[source]

Get the value of the attribute of the clip of the playlist whose respective ids are given.

Parameters:
  • clip_id (str) – Id of the Clip

  • attr_id (str) – Id of the Attr

Returns:

Value of the attribute

Return type:

object

get_attr_value_at(clip_id: str, attr_id: str, key: int)[source]

Get the value of the keyable attribute for the clip at the given key (frame) with respective ids.

Parameters:
  • clip_id (str) – Id of the Clip

  • attr_id (str) – Id of the Attr

  • key (int) – Frame of the Clip

Returns:

Value of the attribute at given key

Return type:

object

get_attrs() List[str][source]

Get ids of all the attrs in the session

Returns:

Ids of all attrs in the session

Return type:

List[str]

get_attrs_metadata() dict[source]

Get the metadata of all the attributes (attrs) in the current Session.

Returns:

Dict of the metadata of all attrs

Return type:

dict

Example

Here is an example of how the returned dict will look like,

{
    'play_order':
    {
        'name': 'Play Order',
        'data_type': 'int',
        'is_read_only': True,
        'is_keyable': False,
        'default_value': None
    },
    'media_path':
    {
        'name': 'Media Path',
        'data_type': 'str',
        'is_read_only': True,
        'is_keyable': False,
        'default_value': '',
    }
}
get_bg_mode() int[source]

Get the integer that represents the current Background Mode that is set. Note that BG modes are relevant only if a BG playlist is currently present in the Session. Based on the current BG Mode, one of the following integers will be returned, 1 - Wipe Mode 2 - Side by Side Mode 3 - Top to Bottom Mode 4 - Picture in Picture Mode

Returns:

Integer representing the current BG mode.

Return type:

int

get_bg_playlist() str | None[source]

Returns the id of the Back-Ground(BG) playlist. If there is no BG playlist currently, then None is returned.

Returns:

Optional id of Back-Ground playlist.

Return type:

Optional[str]

get_clips(id: str) List[str][source]

Get the ids of the clips in the playlist of the given id.

Parameters:

id (str) – Id of the playlist

Returns:

Ids of the clips

Return type:

list[str]

get_current_clip() str[source]

Get the id of the current clip of the session.

Returns:

Id of the current clip

Return type:

str

get_current_frame_mode() int[source]

Get the behavior mode of the current frame when changing playlists.

The following are the available modes,

0 : Same Across Playlists

Current frame will be synced across all playlists. In the case when a single clip is selected in a playlist, current frame defaults to first frame of the clip.

1 : First Frame

Current frame will default to first frame of a selected clip or sequence of clips within a playlist or among playlists. Only in the case when BG playlist exist, current frame will be synced across FG and BG playlists.

2 : Remember Last

Current frame will be set to last frame it was at for the playlist. Only in the case when BG playlist exist, current frame will be synced across FG and BG playlists.

Returns:

Behavior mode of current frame

Return type:

int

get_custom_clip_attr(clip_id, attr_id) Any[source]

Get custom attributes that are associated with the clip of the given clip Id.

Parameters:
  • clip_id (str) – Id of the clip

  • attr_id (str) – Id of the attribute

Returns:

Value of the given Id

Return type:

Any

get_custom_clip_attr_ids(clip_id) List[str][source]

Get custom attribute ids that are associated with the clip of the given clip Id.

Parameters:

clip_id (str) – Id of the clip

Returns:

Ids of attributes

Return type:

List[str]

get_custom_playlist_attr(playlist_id, attr_id) Any[source]

Get custom attributes that are associated with the playlist of the given playlist Id.

Parameters:
  • playlist_id (str) – Id of the playlist

  • attr_id (str) – Id of the attribute

Returns:

Value of the given Id

Return type:

Any

get_custom_playlist_attr_ids(playlist_id) List[str][source]

Get custom attribute ids that are associated with the playlist of the given playlist Id.

Parameters:

playlist_id (str) – Id of the playlist

Returns:

Ids of attributes

Return type:

List[str]

get_custom_session_attr(attr_id) Any[source]

Get custom attributes that are associated with the RPA session.

Parameters:

attr_id (str) – Id of the attribute

Returns:

Value of the given Id

Return type:

Any

get_custom_session_attr_ids() List[str][source]

Get custom attribute ids that are associated with the RPA session.

Returns:

Ids of attributes

Return type:

List[str]

get_default_attr_value(id: str) object[source]

Get the default value which is metadata of the attribute with the given id

Parameters:

id (str) – Id of the attribute

Returns:

Default value of attribute

Return type:

object

get_deleted_playlists() List[str][source]

Returns ids of all the playlists that have been deleted temporarily.

Returns:

Ids of all temporarily deleted playlists.

Return type:

List[str]

get_fg_playlist() str[source]

Return the id of the Fore-Ground(FG) playlist. Note that a Session will always have a FG playlist.

Returns:

Id of the playlist to set as Fore-Ground.

Return type:

str

get_keyable_attrs() List[str][source]

Get the ids of all the attrs that are keyable.

Returns:

Ids of attrs that are keyable

Return type:

List[str]

get_playlist_name(id: str) str[source]

Returns name of the playlist whose id is provided.

Parameters:

id (str) – Id of Playlist

Returns:

Name of Playlist

Return type:

str

get_playlist_of_clip(id: str) str[source]

Get the id of the playlist in which the clip of the given id is currently present.

Parameters:

id (str) – Id of the clip

Returns:

Id of the playlist

Return type:

str

get_playlists() List[str][source]

Returns ids of all playlist in the session.

Returns:

Ids of playlists.

Return type:

list[str]

get_read_only_attrs() List[str][source]

Get the ids of all the attrs that are non-editable that is read-only.

Returns:

Ids of attrs that are non-editable

Return type:

List[str]

get_read_write_attrs() List[str][source]

Get the ids of all the attrs that are editable that is both readable and writable.

Returns:

Ids of attrs that are editable

Return type:

List[str]

get_session_str() str | Tuple[str][source]

Get the string representation of the session object. This method might return a pair of strings (skin, core) when running in multi-process mode.

Returns:

string representation of the session object

tuple[str]:

Pair of string representations of the session objects (skin, core) when running in multi-process mode

Return type:

str

is_attr_keyable(id: str) bool[source]

Returns True if the attr of the given id is keyable.

Parameters:

id (str) – Id of the attr.

Returns:

True if attr of given id is keyable else False.

Return type:

bool

is_attr_read_only(id: str) bool[source]

Returns True if the attr of the given id is non-editable that is read-only.

Parameters:

id (str) – Id of the attr.

Returns:

True if attr of given id is read-only else False.

Return type:

bool

move_clips_by_offset(offset: int, ids: List[str]) bool[source]

Move clips with the given ids in their respective playlists up or down based on the offset. Positive offset moves clips down and negative offset moves clips up. If offset is greater than total number of clips in the playlist, then clips are moved to the bottom. And if offset is less than 0 then clips are moved to the top.

Parameters:
  • offset (int) – The number of indexes the selected clips’s respective movement must be offsetted by. Note negative is up and positive is down.

  • ids (List[str]) – Ids of clips that need to be moved.

Returns:

True if moved False otherwise

Return type:

(bool)

move_clips_to_index(index: int, ids: List[str]) bool[source]

Move clips with the given ids in their respective playlist to the given index. Note that all clips must be part of the same playlist in order to perform this operation.

Parameters:
  • index (int) – Index to which clips are moved to in the current playlist.

  • ids (List[str]) – Ids of clips.

Returns:

True if success False otherwise

Return type:

(bool)

move_playlists_by_offset(offset: int, ids: List[str]) bool[source]

Playlists with the given respective ids will be moved up or down based on the given offset.A positive offset will move them down and a negative offset will move them up. If the offset is greater than the total number of playlists in the list, then they will be moved to the end of the list and if the offset is less than 0 then the playlists will be moved to the very top.

Parameters:
  • offset (int) – The number of indexes the selected playlists’s respective movement must be offsetted by. Note negative is up and positive is down.

  • Ids (List[str]) – Ids of Playlists.

Returns:

True if moved False otherwise

Return type:

(bool)

move_playlists_to_index(index: int, ids: List[str]) bool[source]

Playlists with the given respective ids will be moved to the given index.

Parameters:
  • index (int) – Index to which playlists are moved to in the current session.

  • ids (List[str]) – Ids of Playlists.

Returns:

True if success False otherwise

Return type:

(bool)

refresh_attrs(ids: List[Tuple[str]]) bool[source]

Refresh session cache with the latest values for attrs of clips of playlists with the given ids.

Example of how ids should look like,

[
    (playlist_id_1, clip_id_1, attr_id_1),
    (playlist_id_1, clip_id_1, attr_id_2),
    (playlist_id_1, clip_id_2, attr_id_1),
    (playlist_id_2, clip_id_3, attr_id_1),
    (playlist_id_2, clip_id_4, attr_id_2)
]
Parameters:

ids (List[Tuple[str]]) – List of tuples containing playlist id, clip id and attr id.

Returns:

True if refreshed False otherwise

Return type:

(bool)

restore_playlists(ids, index=None) bool[source]

Restores playlists with the given ids that were previouly deleted back into the session. If index is provided the playlists will be restored into it otherwise will restore playlists to the end of the playlist.

Parameters:

ids (List[str]) – Ids of playlists to restore from being deleted.

Kwargs:
index (Optional[str]):

Optioanl position index where the playlists need to be restored to.

Returns:

True if success False otherwise

Return type:

(bool)

set_active_clips(playlist_id: str, clip_ids: List[str]) None[source]

Set the clips whose ids have been provided to be actove in the playlist with the given id. Note that each time this method is used the previously activated clips are replaced. If an empty list is provided all the clips in the playlist are activated.

Note that only active clips will be considered in the sequence of clips constructed for any given playlist.

Parameters:
  • playlist_id (str) – Id of the playlist

  • clip_ids (List[str]) – Ids of clips.

Returns:

None

set_attr_values(attr_values: List[Tuple]) bool[source]

Set the value of the attributes from the given list. Example of how attr_values should look like,

[
    (playlist_id_1, clip_id_1, attr_id_1, value),
    (playlist_id_1, clip_id_1, attr_id_2, value),
    (playlist_id_1, clip_id_2, attr_id_1, value),
    (playlist_id_2, clip_id_3, attr_id_1, value),
    (playlist_id_2, clip_id_4, attr_id_2, value)
]
Parameters:

attr_values (List[Tuple]) – List of tuples containing playlist id, clip id, attr id and value.

Returns:

True if set False otherwise

Return type:

(bool)

set_attr_values_at(attr_values_at: List[Tuple]) bool[source]

Set the value of the keyable attributes at the given frame.

Example of how attr_values_at should look like,

[
    (playlist_id_1, clip_id_1, attr_id_1, key, value),
    (playlist_id_1, clip_id_1, attr_id_2, key, value),
    (playlist_id_1, clip_id_2, attr_id_1, key, value),
    (playlist_id_2, clip_id_3, attr_id_1, key, value),
    (playlist_id_2, clip_id_4, attr_id_2, key, value)
]
Parameters:

attr_values_at (List[Tuple]) – List of tuples containing playlist id, clip id, attr id, key (frame) and value.

Returns:

True if set False otherwise

Return type:

(bool)

set_bg_mode(mode: int) bool[source]

Set the Background-Mode(BG Mode) to be used in the session. The BG Mode is relevant only if a BG playlist is set. The various BG Modes can be set using integers to identify them. The following are the integers which can be used to set the various available BG modes, 1 - Wipe Mode 2 - Side by Side Mode 3 - Top to Bottom Mode 4 - Picture in Picture Mode

Parameters:

mode (int) – The integer that represents the BG Mode that needs to be set.

Returns:

True if set False otherwise

Return type:

(bool)

set_bg_playlist(id: str) bool[source]

Set the playlist with given id to be the Back-Ground(BG) playlist.

Parameters:

id (str) – Id of Playlist to set as Back-Ground.

Returns:

True if success False otherwise

Return type:

(bool)

set_clip_path(id: str, path: object) bool[source]

Set the path of the media for the clip with the given id. The path can also be a data-base id or web url as long mechanisms for the core application to find the media file from the given path are in place.

Parameters:
  • id (str) – Id of the clip whose path needs to be set.

  • path (str) – Path to the media

Returns:

True if set False otherwise

Return type:

(bool)

set_current_clip(id: str) bool[source]

Set the clip with the given id to be current clip of the Session.

Parameters:

id (str) – Id of clip to set as current clip.

Returns:

True if set False otherwise

Return type:

(bool)

set_current_frame_mode(mode: int) bool[source]

Set the behavior of the current-frame when changing playlists.

The following are the available modes,

0 : Same Across Playlists

Current frame will be synced across all playlists. In the case when a single clip is selected in a playlist, current frame defaults to first frame of the clip.

1 : First Frame

Current frame will default to first frame of a selected clip or sequence of clips within a playlist or among playlists. Only in the case when BG playlist exist, current frame will be synced across FG and BG playlists.

2 : Remember Last

Current frame will be set to last frame it was at for the playlist. Only in the case when BG playlist exist, current frame will be synced across FG and BG playlists.

Parameters:

mode (int) – Mode to set.

Returns:

True of set False otherwise

Return type:

(bool)

set_custom_clip_attr(clip_id, attr_id, value) bool[source]

Set custom attributes that will be associated with the clip of the given clip Id.

Parameters:
  • clip_id (str) – Id of the clip

  • attr_id (str) – Id of the attribute

  • value (Any) – Value to be set

Returns:

True if successfully set

Return type:

bool

set_custom_playlist_attr(playlist_id, attr_id, value) bool[source]

Set custom attributes that will be associated with the playlist of the given playlist Id.

Parameters:
  • playlist_id (str) – Id of the playlist

  • attr_id (str) – Id of the attribute

  • value (Any) – Value to be set

Returns:

True if successfully set

Return type:

bool

set_custom_session_attr(attr_id: str, value: Any) bool[source]

Set custom attributes that will be associated with the RPA session.

Parameters:
  • attr_id (str) – Id of the attribute

  • value (Any) – Value to be set

Returns:

True if successfully set

Return type:

bool

set_fg_playlist(id: str) bool[source]

Set the playlist with the given id to be the Fore-Ground(FG) playlist.

Parameters:

id (str) – Id of playlist

Returns:

True if success False otherwise

Return type:

(bool)

set_playlist_name(id: str, name: str) bool[source]

Set the name of the playlist with the given id.

Parameters:
  • id (str) – Id of the playlist whose name needs to be set

  • name (str) – Name that needs to be set to the playlist

Returns:

True if set False otherwise

Return type:

(bool)

staticMetaObject = <PySide2.QtCore.QMetaObject object>