<%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:           stream_data.html
Version:            0.1
Variable names:     data [list]

data :: Usable parameters

== Global keys ==
media_type                  Returns the type of session. Either 'episode' or 'movie'.
title                       Returns the name of the episode or movie.
user                        Returns the name of the user.
transcode_video_dec         Returns the video transcode decision. Either 'transcode', 'copy' or 'direct play'.
transcode_video_codec       Returns the name of the video codec for any transcode session.
transcode_height            Returns the value of the video height for any transcode session.
transcode_width             Returns the value of the video width for any transcode session.
transcode_audio_dec         Returns the audio transcode decision. Either 'transcode', 'copy' or 'direct play'.
transcode_audio_codec       Returns the name of the audio codec for any transcode session.
transcode_audio_channels    Returns the number of audio channels for any transcode session.
transcode_container         Returns the type of container for any transcode session.
container                   Returns the type of container for the original media.
height                      Returns the value of the video height for the original media.
bitrate                     Returns the value of the video bitrate for the original media.
width                       Returns the value of the video width for the original media.
aspect_ratio                Returns the value of the video aspect ratio for the original media.
video_framerate             Returns the value of the video framerate for the original media.
video_codec                 Returns the name of the video codec for the original media.
audio_codec                 Returns the name of the audio codec for the original media.
audio_channels              Returns the number of audio channels for the original media.

== Only if 'media_type' is 'episode' ==
grandparent_title       Returns the name of the TV Show.

DOCUMENTATION :: END
</%doc>

% if data:
<%
    from plexpy.common import VIDEO_RESOLUTION_OVERRIDES, AUDIO_CODEC_OVERRIDES
%>
<div class="modal-dialog" role="document">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="info-modal-title">
                % if data['media_type'] == 'episode':
                Stream Info: <strong>${data['grandparent_title']} - ${data['title']} (${user})</strong>
                % elif data['media_type'] == 'track':
                Stream Info: <strong>${data['original_title'] or data['grandparent_title']} - ${data['title']} (${user})</strong>
                % else:
                Stream Info: <strong>${data['title']} (${user})</strong>
                % endif
            </h4>
        </div>
        <div class="modal-body">
            % if data['current_session']:
            <div class="col-sm-12 text-muted stream-info-current">
                <i class="fa fa-exclamation-circle"></i> Current session. Updated stream details below may be delayed.
            </div>
            % elif data['pre_tautulli']:
            <div class="col-sm-12 text-muted stream-info-current">
                <i class="fa fa-exclamation-circle"></i> Pre-Tautulli history. Stream details below may be incorrect.
            </div>
            % endif
            <table class="stream-info" style="margin-top: 0;">
                <thead>
                    <tr>
                        <th>
                        </th>
                        <th class="heading">
                            Stream Details
                        </th>
                        <th class="heading">
                            Source Details
                        </th>
                    </tr>
                </thead>
            </table>
            <table class="stream-info">
                <thead>
                    <tr>
                        <th>
                            Media
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Bitrate</td>
                        <td>${data['stream_bitrate']} ${'kbps' if data['stream_bitrate'] else ''}</td>
                        <td>${data['bitrate']} ${'kbps' if data['bitrate'] else ''}</td>
                    </tr>
                    % if data['media_type'] != 'track':
                    <tr>
                        <td>Resolution</td>
                        <td>${data['stream_video_full_resolution']}</td>
                        <td>${data['video_full_resolution']}</td>
                    </tr>
                    % endif
                    <tr>
                        <td>Quality</td>
                        <td>${data['quality_profile']}</td>
                        <td>-</td>
                    </tr>
                    % if data['optimized_version'] == 1:
                    <tr>
                        <td>Optimized Version</td>
                        <td>-</td>
                        <td>${data['optimized_version_profile']}<br>(${data['optimized_version_title']})</td>
                    </tr>
                    % endif
                    % if data['synced_version'] == 1:
                    <tr>
                        <td>Synced Version</td>
                        <td>-</td>
                        <td>${data['synced_version_profile']}</td>
                    </tr>
                    % endif
                </tbody>
            </table>
            <table class="stream-info">
                <thead>
                    <tr>
                        <th>
                            Container
                        </th>
                        <th>
                            ${data['stream_container_decision']}
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Container</td>
                        <td>${data['stream_container'].upper()}</td>
                        <td>${data['container'].upper()}</td>
                    </tr>
                </tbody>
            </table>
            % if data['media_type'] != 'track':
            <table class="stream-info">
                <thead>
                    <tr>
                        <th>
                            Video
                        </th>
                        <th>
                            ${data['stream_video_decision']}
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Codec</td>
                        <td>${data['stream_video_codec'].upper()} ${'(HW)' if data['transcode_hw_encoding'] else ''}</td>
                        <td>${data['video_codec'].upper()} ${'(HW)' if data['transcode_hw_decoding'] else ''}</td>
                    </tr>
                    <tr>
                        <td>Bitrate</td>
                        <td>${data['stream_video_bitrate']} ${'kbps' if data['stream_video_bitrate'] else ''}</td>
                        <td>${data['video_bitrate']} ${'kbps' if data['video_bitrate'] else ''}</td>
                    </tr>
                    <tr>
                        <td>Width</td>
                        <td>${data['stream_video_width']}</td>
                        <td>${data['video_width']}</td>
                    </tr>
                    <tr>
                        <td>Height</td>
                        <td>${data['stream_video_height']}</td>
                        <td>${data['video_height']}</td>
                    </tr>
                    <tr>
                        <td>Framerate</td>
                        <td>${data['stream_video_framerate']}</td>
                        <td>${data['video_framerate']}</td>
                    </tr>
                    <tr>
                        <td>Dynamic Range</td>
                        <td>${data['stream_video_dynamic_range']}</td>
                        <td>${data['video_dynamic_range']}</td>
                    </tr>
                    <tr>
                        <td>Aspect Ratio</td>
                        <td>-</td>
                        <td>${data['aspect_ratio']}</td>
                    </tr>
                </tbody>
            </table>
            % endif
            <table class="stream-info">
                <thead>
                    <tr>
                        <th>
                            Audio
                        </th>
                        <th>
                            ${data['stream_audio_decision']}
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Codec</td>
                        <td>${AUDIO_CODEC_OVERRIDES.get(data['stream_audio_codec'], data['stream_audio_codec'].upper())}</td>
                        <td>${AUDIO_CODEC_OVERRIDES.get(data['audio_codec'], data['audio_codec'].upper())}</td>
                    </tr>
                    <tr>
                        <td>Bitrate</td>
                        <td>${data['stream_audio_bitrate']} ${'kbps' if data['stream_audio_bitrate'] else ''}</td>
                        <td>${data['audio_bitrate']} ${'kbps' if data['audio_bitrate'] else ''}</td>
                    </tr>
                    <tr>
                        <td>Channels</td>
                        <td>${data['stream_audio_channels']}</td>
                        <td>${data['audio_channels']}</td>
                    </tr>
                    <tr>
                        <td>Language</td>
                        <td>-</td>
                        <td>${data['audio_language'] or 'Unknown'}</td>
                    </tr>

                </tbody>
            </table>
            % if data['subtitles'] == 1:
            <table class="stream-info">
                <thead>
                    <tr>
                        <th>
                            Subtitles
                        </th>
                        <th>
                            ${'direct play' if data['stream_subtitle_decision'] not in ('transcode', 'copy', 'burn') else data['stream_subtitle_decision']}
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Codec</td>
                        <td>${data['stream_subtitle_codec'].upper() or '-'}</td>
                        <td>${data['subtitle_codec'].upper()}</td>
                    </tr>
                    <tr>
                        <td>Language</td>
                        <td>-</td>
                        <td>${data['subtitle_language'] or 'Unknown'}</td>
                    </tr>
                    % if data['subtitle_forced']:
                    <tr>
                        <td>Forced</td>
                        <td>-</td>
                        <td>${bool(data['subtitle_forced'])}</td>
                    </tr>
                    % endif
                </tbody>
            </table>
            % endif
        </div>
        <div class="modal-footer">
        </div>
    </div>
</div>
% endif