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

data[array_index] :: Usable parameters

== Global keys ==
rating_key              Returns the unique identifier for the media item.
row_id                  Returns the unique row id for the media item in the database.
media_type              Returns the type of media. Either 'movie' or 'episode' or 'album'.
thumb                   Returns the location of the item's thumbnail. Use with pms_image_proxy.
time                    Returns the last watched time of the media.
user                    Returns the name of the user that watched the item.
title                   Returns the name of the movie, episode, album.
parent_title            Returns the name of the artist.
grandparent_title       Returns the name of the show.
media_index             Returns the index number of the episode.
parent_media_index      Returns the index number of the season.
year                    Returns the release year of the movie, episode, or album.

DOCUMENTATION :: END
</%doc>

% if data:
<%
    from plexpy.helpers import page, short_season
%>
<div class="dashboard-recent-media-row">
    <div id="recently-watched-row-scroller">
        <ul class="dashboard-recent-media list-unstyled">
            % for item in data:
            <li>
                % if item['media_type'] == 'episode' or item['media_type'] == 'movie':
                % if item['rating_key']:
                % if item['media_type'] == 'movie':
                <a href="${page('info', item['rating_key'], history=True, live=item['live'])}" title="${item['title']}">
                % elif item['media_type'] == 'episode':
                <a href="${page('info', item['rating_key'], history=True, live=item['live'])}" title="${item['grandparent_title']}">
                % endif
                    <div class="dashboard-recent-media-poster">
                        <div class="dashboard-recent-media-poster-face" style="background-image: url(${page('pms_image_proxy', item['thumb'], item['rating_key'], 300, 450, fallback='poster')});">
                            <div class="dashboard-recent-media-overlay">
                                <div class="dashboard-recent-media-overlay-text" id="time-${item['time']}">
                                    <script>
                                        $('#time-${item['time']}').text('Watched ' + moment(${item['time']}, "X").fromNow())
                                    </script>
                                </div>
                            </div>
                        </div>
                        % if _session['user_group'] == 'admin':
                        <span class="overlay-refresh-image" title="Refresh image"><i class="fa fa-refresh refresh_pms_image"></i></span>
                        % endif
                    </div>
                </a>
                <div class="dashboard-recent-media-metacontainer">
                    % if item['media_type'] == 'episode':
                    % if item['live']:
                    <h3>
                        <a href="${page('info', item['rating_key'], history=True, live=item['live'])}" title="${item['grandparent_title']}">${item['grandparent_title']}</a>
                    </h3>
                    <h3 class="text-muted" title="${item['title']}">
                        <a href="${page('info', item['rating_key'], history=True, live=item['live'])}" title="${item['title']}">${item['title']}</a>
                    </h3>
                    % if item['media_index']:
                    <h3 class="text-muted">
                        <a href="${page('info', item['rating_key'], history=True, live=item['live'])}" title="${item['parent_title']}">${short_season(item['parent_title'])}</a>
                         &middot; <a href="${page('info', item['rating_key'], history=True, live=item['live'])}" title="Episode ${item['media_index']}">E${item['media_index']}</a>
                    </h3>
                    % else:
                    <h3 class="text-muted">
                        <a href="${page('info', item['rating_key'], history=True, live=item['live'])}" title="${item['originally_available_at']}">${item['originally_available_at']}</a>
                    </h3>
                    % endif
                    % else:
                    <h3>
                        <a href="${page('info', item['grandparent_rating_key'])}" title="${item['grandparent_title']}">${item['grandparent_title']}</a>
                    </h3>
                    <h3 class="text-muted" title="${item['title']}">
                        <a href="${page('info', item['rating_key'], history=True, live=item['live'])}" title="${item['title']}">${item['title']}</a>
                    </h3>
                    <h3 class="text-muted">
                        <a href="${page('info', item['parent_rating_key'])}" title="${item['parent_title']}">${short_season(item['parent_title'])}</a>
                         &middot; <a href="${page('info', item['rating_key'], history=True, live=item['live'])}" title="Episode ${item['media_index']}">E${item['media_index']}</a>
                    </h3>
                    % endif
                    % elif item['media_type'] == 'movie':
                    <h3 title="${item['title']}">
                        <a href="${page('info', item['rating_key'], history=True, live=item['live'])}" title="${item['title']}">${item['title']}</a>
                    </h3>
                    <h3 class="text-muted">${item['year']}</h3>
                    <h3 class="text-muted">&nbsp;</h3>
                    % endif
                </div>
                % else:
                <div class="dashboard-recent-media-poster">
                    <div class="dashboard-recent-media-poster-face" style="background-image: url(${http_root}images/poster.png);">
                        <div class="dashboard-recent-media-overlay">
                            <div class="dashboard-recent-media-overlay-text" id="time-${item['time']}">
                                <script>
                                        $('#time-${item['time']}').text('Watched ' + moment(${item['time']}, "X").fromNow())
                                </script>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="dashboard-recent-media-metacontainer">
                    <h3 title="${item['title']}">
                        ${item['title']}
                    </h3>
                </div>
                % endif
                % elif item['media_type'] == 'track':
                % if item['rating_key']:
                <a href="${page('info', item['rating_key'], history=True, live=item['live'])}" title="${item['parent_title']}">
                    <div class="dashboard-recent-media-cover">
                        <div class="dashboard-recent-media-cover-face" style="background-image: url(${page('pms_image_proxy', item['thumb'], item['rating_key'], 300, 300, fallback='cover')});">
                            <div class="dashboard-recent-media-overlay">
                                <div class="dashboard-recent-media-overlay-text" id="time-${item['time']}">
                                    <script>
                                        $('#time-${item['time']}').text('Played ' + moment(${item['time']}, "X").fromNow())
                                    </script>
                                </div>
                            </div>
                        </div>
                    </div>
                </a>
                <div class="dashboard-recent-media-metacontainer">
                    <h3 title="${item['original_title'] or item['grandparent_title']}">
                        <a href="${page('info', item['grandparent_rating_key'])}" title="${item['original_title'] or item['grandparent_title']}">${item['original_title'] or item['grandparent_title']}</a>
                    </h3>
                    <h3 class="text-muted" title="${item['title']}">
                        <a href="${page('info', item['rating_key'], history=True, live=item['live'])}" title="${item['title']}">${item['title']}</a>
                    </h3>
                    <h3 class="text-muted">
                        <a href="${page('info', item['parent_rating_key'])}" title="${item['parent_title']}">${item['parent_title']}</a>
                    </h3>
                </div>
                % else:
                <div class="dashboard-recent-media-cover">
                    <div class="dashboard-recent-media-cover-face" style="background-image: url(${http_root}images/cover.png);">
                        <div class="dashboard-recent-media-overlay">
                            <div class="dashboard-recent-media-overlay-text" id="time-${item['time']}">
                                <script>
                                        $('#time-${item['time']}').text('Played ' + moment(${item['time']}, "X").fromNow())
                                </script>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="dashboard-recent-media-metacontainer">
                    <h3 title="${item['title']}">
                        ${item['title']}
                    </h3>
                </div>
                % endif
                % endif
            </li>
            % endfor
        </ul>
    </div>
</div>
% else:
<div class="text-muted">No stats to show.</div><br>
% endif