'Get the current activity on the PMS.
Required parameters:
None
Optional parameters:
None
Returns:
json:
{"stream_count": 3,
"session":
[{"art": "/library/metadata/1219/art/1462175063",
"aspect_ratio": "1.78",
"audio_channels": "6",
"audio_codec": "ac3",
"audio_decision": "transcode",
"bif_thumb": "/library/parts/274169/indexes/sd/",
"bitrate": "10617",
"container": "mkv",
"content_rating": "TV-MA",
"duration": "2998290",
"friendly_name": "Mother of Dragons",
"grandparent_rating_key": "1219",
"grandparent_thumb": "/library/metadata/1219/thumb/1462175063",
"grandparent_title": "Game of Thrones",
"height": "1078",
"indexes": 1,
"ip_address": "xxx.xxx.xxx.xxx",
"labels": [],
"machine_id": "83f189w617623ccs6a1lqpby",
"media_index": "1",
"media_type": "episode",
"parent_media_index": "6",
"parent_rating_key": "153036",
"parent_thumb": "/library/metadata/153036/thumb/1462175062",
"parent_title": "",
"platform": "Chrome",
"player": "Plex Web (Chrome)",
"progress_percent": "0",
"rating_key": "153037",
"section_id": "2",
"session_key": "291",
"state": "playing",
"throttled": "1",
"thumb": "/library/metadata/153037/thumb/1462175060",
"title": "The Red Woman",
"transcode_audio_channels": "2",
"transcode_audio_codec": "aac",
"transcode_container": "mkv",
"transcode_height": "1078",
"transcode_key": "tiv5p524wcupe8nxegc26s9k9",
"transcode_progress": 2,
"transcode_protocol": "http",
"transcode_speed": "0.0",
"transcode_video_codec": "h264",
"transcode_width": "1920",
"user": "DanyKhaleesi69",
"user_id": 8008135,
"user_thumb": "https://plex.tv/users/568gwwoib5t98a3a/avatar",
"video_codec": "h264",
"video_decision": "copy",
"video_framerate": "24p",
"video_resolution": "1080",
"view_offset": "",
"width": "1920",
"year": "2016"'

@cherrypy.expose
@cherrypy.tools.json_out()
@requireAuth()
@addtoapi()
def get_activity(self, **kwargs):

    try:
        pms_connect = pmsconnect.PmsConnect(token=plexpy.CONFIG.PMS_TOKEN)
        result = pms_connect.get_current_activity()
        if result:
            data_factory = datafactory.DataFactory()
            for session in result['sessions']:
                if (not session['ip_address']):
                    ip_address = data_factory.get_session_ip(session['session_key'])
                    session['ip_address'] = ip_address
            return result
        else:
            logger.warn(u'Unable    to    retrieve    data    for    get_activity.')
    except Exception as e:
        logger.exception((u'Unable    to    retrieve    data    for    get_activity:    %s' % e))
