<%doc> USAGE DOCUMENTATION :: PLEASE LEAVE THIS AT THE TOP OF THIS FILE For Mako templating syntax documentation please visit: http://docs.makotemplates.org/en/latest/ Filename: current_activity_instance.html Version: 0.1 Variable names: data {dict} data :: Usable parameters == Global keys == session_key Returns a unique session id for the active stream rating_key Returns the unique identifier for the media item. media_index Returns the index of the media item. parent_media_index Returns the index of the media item's parent. media_type Returns the type of session. Either 'track', 'episode' or 'movie'. thumb Returns the location of the item's thumbnail. Use with pms_image_proxy. bif_thumb Returns the location of the item's bif thumbnail. Use with pms_image_proxy. art Returns the location of the item's artwork progress_percent Returns the current progress of the item. 0 to 100. user Returns the name of the user owning the session. user_id Returns the Plex user id if available. machine_id Returns the machine id of the players being used. friendly_name Returns the friendlly name of the user owning the session. user_thumb Returns the profile picture of the user owning the session. state Returns the state of the current session. Either 'playing', 'paused' or 'buffering'. title Returns the name of the episode, movie or music track. year Returns the year of the episode, movie, or clip. ip_address Returns the ip address of the stream. player Returns the name of the platform used to play the stream. platform Returns the type of platform used to play the stream. transcode_throttled Returns true if the transcode session is throttled. transcode_progress Returns the current transcode progress of the item. 0 to 100. transcode_speed Returns the current transcode speed of the item. audio_decision Returns the audio transcode decision. Either 'transcode', 'copy' or 'direct play'. audio_codec Returns the name of the audio codec. audio_channels Returns the number of audio channels. grandparent_title Returns the title of the item's grandparent. parent_title Returns the title of the item's parent. video_decision Returns the video transcode decision. Either 'transcode', 'copy' or 'direct play'. video_codec Returns the name of the video codec. height Returns the value of the video height. width Returns the value of the video width. container Returns the value of the media container. bitrate Returns the value of the media bitrate. video_resolution Returns the value of the video resolution. video_framerate Returns the value of the video framerate. video_aspect_ratio Returns the value of the video aspect ratio. transcode_audio_channels Returns the amount of audio channels if there is a transcode session. transcode_audio_codec Returns the name of the audio codec if there is a transcode session. transcode_video_codec Returns the name of the video codec if there is a transcode session. transcode_width Returns the video width if there is a transcode session. transcode_height Returns the video height if there is a transcode session. transcode_container Returns the value of media container if there is a transcode session. transcode_protocol Returns the value of media protocol if there is a transcode session. indexes Returns true if the media has media indexes and are enabled DOCUMENTATION :: END % if session is not None: <% from collections import defaultdict from plexpy.helpers import cast_to_int, get_percent, page, short_season from plexpy.common import VIDEO_RESOLUTION_OVERRIDES, AUDIO_CODEC_OVERRIDES, EXTRA_TYPES import plexpy %> <% data = defaultdict(lambda: 'Unknown', **session) sk = data['session_key'] href = page('info', data['rating_key']) parent_href = page('info', data['parent_rating_key']) grandparent_href = page('info', data['grandparent_rating_key']) user_href = page('user', data['user_id']) if data['user_id'] else '#' library_href = page('library', data['section_id']) if data['section_id'] else '#' season = short_season(data['parent_title']) %>
<% if data['live']: background_url = page('pms_image_proxy', data['art'], data['rating_key'], 500, 280, 40, '282828', 3, fallback='art-live', refresh=True) elif data['channel_stream'] == 0: background_url = page('pms_image_proxy', data['art'], data['rating_key'], 500, 280, 40, '282828', 3, fallback='art', refresh=True) else: background_url = page('pms_image_proxy', data['art'] or data['thumb'], data['rating_key'], 500, 280, 40, '282828', 3, fallback='art', refresh=True, clip=True) %>
% if data['media_type'] == 'track':
% endif % if data['live']: % if data['media_type'] == 'movie':
% elif data['media_type'] == 'episode':
% else:
% endif % elif data['channel_stream'] == 0: % if data['media_type'] == 'movie':
% elif data['media_type'] == 'episode':
% elif data['media_type'] == 'track':
% elif data['media_type'] in ('photo', 'clip'): % if data['parent_thumb']:
% else:
% endif % else:
% endif % else:
% endif
<% if not _session['user_group'] == 'admin' or not data['session_id']: no_terminate = '-no-terminate' else: no_terminate = '' %>
% if _session['user_group'] == 'admin' and plexpy.CONFIG.PMS_PLEXPASS and data['session_id']:
% endif

- Product
  ${data['product']}
- Player
  ${data['player']}
- Quality
  % if data['media_type'] != 'photo' and data['quality_profile'] != 'Unknown': <% br = cast_to_int(data['stream_bitrate']) or '' if br: if br > 1000: br = '(' + str(round(br / 1000.0, 1)) + ' Mbps)' else: br = '(' + str(br) + ' kbps)' %> ${data['quality_profile']} ${br} % else: ${data['quality_profile']} % endif
% if data['optimized_version'] == 1:
- Optimized
  ${data['optimized_version_profile']} (${data['optimized_version_title']})
% endif % if data['synced_version'] == 1:
- Synced
  ${data['synced_version_profile']}
% endif

- % if _session['user_group'] == 'admin':
  Stream
  % else:
  Stream
  % endif
  % if data['transcode_decision'] == 'transcode': Transcode % if data['transcode_throttled'] == 1: (Throttled) % else: (Speed: ${data['transcode_speed']}) % endif % elif data['transcode_decision'] == 'copy': Direct Stream % else: Direct Play % endif
- Container
  % if data['stream_container_decision'] == 'transcode': Converting (${data['container'].upper()} ${data['stream_container'].upper()}) % else: Direct Play (${data['stream_container'].upper()}) % endif
% if data['media_type'] in ('movie', 'episode', 'clip', 'photo'):
- Video
  % if data['media_type'] in ('movie', 'episode', 'clip') and data['stream_video_decision']: <% if data['video_dynamic_range'] != 'SDR': video_dynamic_range = ' ' + data['video_dynamic_range'] else: video_dynamic_range = '' if data['stream_video_dynamic_range'] != 'SDR' or video_dynamic_range: stream_video_dynamic_range = ' ' + data['stream_video_dynamic_range'] else: stream_video_dynamic_range = '' %> % if data['stream_video_decision'] == 'transcode': <% hw_d = ' (HW)' if data['transcode_hw_decoding'] else '' hw_e = ' (HW)' if data['transcode_hw_encoding'] else '' %> Transcode (${data['video_codec'].upper()}${hw_d} ${data['video_full_resolution']}${video_dynamic_range} ${data['stream_video_codec'].upper()}${hw_e} ${data['stream_video_full_resolution']}${stream_video_dynamic_range}) % elif data['stream_video_decision'] == 'copy': Direct Stream (${data['stream_video_codec'].upper()} ${data['stream_video_full_resolution']}${stream_video_dynamic_range}) % else: Direct Play (${data['stream_video_codec'].upper()} ${data['stream_video_full_resolution']}${stream_video_dynamic_range}) % endif % elif data['media_type'] == 'photo': Direct Play (${data['width']}x${data['height']}) % endif
% endif % if data['media_type'] in ('movie', 'episode', 'clip', 'track'):
- Audio
  % if data['stream_audio_decision']: <% audio_language = (data['audio_language'] or 'Unknown') + ' - ' if data['media_type'] != 'track' else '' %> % if data['stream_audio_decision'] == 'transcode': Transcode (${audio_language}${AUDIO_CODEC_OVERRIDES.get(data['audio_codec'], data['audio_codec'].upper())} ${data['audio_channel_layout'].split('(')[0].capitalize()} ${AUDIO_CODEC_OVERRIDES.get(data['stream_audio_codec'], data['stream_audio_codec'].upper())} ${data['stream_audio_channel_layout'].split('(')[0].capitalize()}) % elif data['stream_audio_decision'] == 'copy': Direct Stream (${audio_language}${AUDIO_CODEC_OVERRIDES.get(data['stream_audio_codec'], data['stream_audio_codec'].upper())} ${data['stream_audio_channel_layout'].split('(')[0].capitalize()}) % else: Direct Play (${audio_language}${AUDIO_CODEC_OVERRIDES.get(data['stream_audio_codec'], data['stream_audio_codec'].upper())} ${data['stream_audio_channel_layout'].split('(')[0].capitalize()}) % endif % endif
% endif % if data['media_type'] in ('movie', 'episode', 'clip'):
- Subtitle
  % if data['subtitles'] == 1: <% subtitle_codec = 'None' if data['stream_subtitle_codec'] and data['stream_subtitle_transient'] else data['subtitle_codec'].upper() %> % if data['stream_subtitle_decision'] == 'transcode': Transcode (${data['subtitle_language'] or 'Unknown'} - ${subtitle_codec} ${data['stream_subtitle_codec'].upper()}) % elif data['stream_subtitle_decision'] == 'copy': Direct Stream (${data['subtitle_language'] or 'Unknown'} - ${subtitle_codec}) % elif data['stream_subtitle_decision'] == 'burn': Burn (${data['subtitle_language'] or 'Unknown'} - ${subtitle_codec}) % else: Direct Play (${data['subtitle_language'] or 'Unknown'} - ${subtitle_codec if data['synced_version'] else data['stream_subtitle_codec'].upper()}) % endif % else: None % endif
% endif

- Location
  % if data['secure'] is not None: % if data['secure']: % else: % endif % endif ${data['location'].upper()}: % if data['ip_address'] != 'N/A': % if len(data['ip_address']) > 20: ${data['ip_address']} % else: ${data['ip_address']} % endif % if data['relayed']: % else:
  % endif % else: N/A % endif
- Bandwidth
  % if data['media_type'] != 'photo' and data['bandwidth'] != 'Unknown': <% bw = cast_to_int(data['bandwidth']) if bw > 1000000: bw = str(round(bw / 1000000.0, 1)) + ' Gbps' elif bw > 1000: bw = str(round(bw / 1000.0, 1)) + ' Mbps' else: bw = str(bw) + ' kbps' %> ${bw} % elif data['synced_version'] == 1 or data['channel_stream'] == 1: None % else: Unknown % endif

% if data['media_type'] != 'photo':
% if data['live']:
${data['channel_title'] or (data['channel_vcn'] + ' ' + data['channel_call_sign'])} % elif data['view_offset']: ETA:
/
% else: ETA: Unknown
0:00 /
% endif
% endif
% if data['live']:
Live
% else: <% transcode_progress = get_percent(data['transcode_max_offset_available'] * 1000, data['duration']) or data['transcode_progress'] %>
${transcode_progress}%
${data['progress_percent']}%
% endif
% if data['state'] == 'playing': % elif data['state'] == 'paused': % elif data['state'] == 'buffering': % elif data['state'] == 'error': % else: % endif
% if data['live']: % if data['media_type'] == 'movie': ${data['title']} % elif data['media_type'] == 'episode': ${data['grandparent_title']} - ${data['title']} % else: ${data['title']} % endif % elif data['channel_stream'] == 0: % if data['media_type'] == 'movie': ${data['title']} % elif data['media_type'] == 'episode': ${data['grandparent_title']} - ${data['title']} % elif data['media_type'] == 'track': ${data['title']} - ${data['original_title'] or data['grandparent_title']} % elif data['media_type'] == 'photo': ${data['parent_title']} % elif data['media_type'] == 'clip': ${data['title']} % else: ${data['title']} % endif % elif data['media_type'] == 'episode' and data['grandparent_title']: ${data['grandparent_title']} - ${data['title']} % else: ${data['title']} % endif
% if data['live']:
% elif data['channel_stream'] == 0:
% if data['media_type'] == 'movie': % elif data['media_type'] == 'episode': % elif data['media_type'] == 'track': % elif data['media_type'] == 'photo': % elif data['media_type'] == 'clip': % else: % endif
% else:
% endif
% if data['live']: % if data['media_type'] == 'movie': ${data['year']} % elif data['media_type'] == 'episode': % if data['media_index']: ${season} · E${data['media_index']} % else: ${data['originally_available_at']} % endif % else: Live TV % endif % elif data['channel_stream'] == 0: % if data['media_type'] == 'movie': ${data['year']} % elif data['media_type'] == 'episode': ${season} · E${data['media_index']} % elif data['media_type'] == 'track': ${data['parent_title']} % elif data['media_type'] == 'photo': ${data['title']} % else: % if data['extra_type']: <% extra_type = EXTRA_TYPES.get(data['extra_type'], data['sub_type'].capitalize()) %> ${data['year']} (${extra_type}) % else: ${data['year']} % endif % endif % elif data['channel_title']: ${data['channel_title']} % if data['media_type'] == 'episode' and data['parent_media_index'] and data['media_index']: (${season} · E${data['media_index']}) % elif data['media_type'] == 'episode' and data['originally_available_at']: (${data['originally_available_at']}) % endif % else: Channel % if data['media_type'] == 'episode' and data['parent_media_index'] and data['media_index']: (${season} · E${data['media_index']}) % elif data['media_type'] == 'episode' and data['originally_available_at']: (${data['originally_available_at']}) % endif % endif
${data['friendly_name']}
% endif