200 lines
11 KiB
HTML
200 lines
11 KiB
HTML
<%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: home_stats.html
|
|
Version: 0.1
|
|
Variable names: data [array]
|
|
|
|
data[array_index] :: Usable parameters
|
|
|
|
data['stat_id'] Returns the name of the stat. Either 'top_tv', 'top_movies', 'popular_tv', 'popular_movies', 'top_user' or 'top_platform'
|
|
data['stat_type'] Returns the type of the stat. Either 'total_plays' or 'total_duration'
|
|
data['rows'] Returns an array containing stat data
|
|
|
|
data[array_index]['rows'] :: Usable parameters
|
|
|
|
row_id Return the db row id for a metadata item if one exists
|
|
|
|
== Only if 'stat_id' is 'top_tv' or 'popular_tv' or 'top_movies' or 'popular_movies' or 'top_music' or 'popular_music' or 'last_watched' ==
|
|
thumb Return the thumb for the media item.
|
|
|
|
== Only if 'stat_id' is 'top_tv' or 'popular_tv' or 'top_music' or 'popular_music' ==
|
|
grandparent_thumb Returns location of the item's thumbnail. Use with pms_image_proxy.
|
|
rating_key Returns the unique identifier for the media item.
|
|
title Returns the title for the associated stat.
|
|
|
|
== Only if 'stat_id' is 'top_tv' or 'top_movies' or 'top_music' or 'top_user' or 'top_platform' ==
|
|
total_plays Returns the count for the associated stat.
|
|
total_duration Returns the total duration for the associated stat.
|
|
|
|
== Only of 'stat_id' is 'popular_tv' or 'popular_movies' or 'popular_music' ==
|
|
users_watched Returns the count for the associated stat.
|
|
|
|
== Only if 'stat_id' is 'top_user' or 'last_watched' ==
|
|
user_thumb Returns url of the user's gravatar. Returns '' if none exists.
|
|
user Returns the username for the associated stat.
|
|
user_id Returns the user id for the associated stat.
|
|
friendly_name Returns the friendly name of the user for the associated stat.
|
|
|
|
== Only if 'stat_id' is 'top_platform' or 'last_watched' ==
|
|
player Returns the player name for the associated stat.
|
|
|
|
== Only if 'stat_id' is 'last_watched' ==
|
|
last_watch Returns the time the media item was last watched.
|
|
|
|
== Only if 'stat_id' is 'most_concurrent' ==
|
|
count Returns the count of the most concurrent streams.
|
|
started Returns the start time of the most concurrent streams.
|
|
stopped Returns the stop time of the most concurrent streams.
|
|
|
|
DOCUMENTATION :: END
|
|
</%doc>
|
|
|
|
<%!
|
|
from plexpy import helpers
|
|
|
|
# Human readable duration
|
|
def hd(seconds):
|
|
m, s = divmod(helpers.cast_to_int(seconds), 60)
|
|
h, m = divmod(m, 60)
|
|
return str(h).zfill(1) + ':' + str(m).zfill(2)
|
|
%>
|
|
|
|
% if data and any(top_stat['rows'] for top_stat in data):
|
|
% for top_stat in data:
|
|
<% stat_id = top_stat['stat_id'] %>
|
|
<div class="dashboard-stats-instance" id="stats-instance-${stat_id}" data-id="${stat_id}">
|
|
<div class="dashboard-stats-container">
|
|
<div class="dashboard-stats-background-overlay">
|
|
% if stat_id in ('top_movies', 'popular_movies', 'top_tv', 'popular_tv', 'top_music', 'popular_music', 'last_watched'):
|
|
<div id="stats-background-${stat_id}" class="dashboard-stats-background" style="background-image: url(pms_image_proxy?img=${top_stat['rows'][0]['art']}&width=500&height=280&fallback=art);"></div>
|
|
% else:
|
|
<div id="stats-background-${stat_id}" class="dashboard-stats-background flat"></div>
|
|
% endif
|
|
% if stat_id in ('top_movies', 'popular_movies', 'top_tv', 'popular_tv', 'top_music', 'popular_music', 'last_watched'):
|
|
<a id="stats-poster-url-${stat_id}" href="info?rating_key=${top_stat['rows'][0]['rating_key']}" title="${top_stat['rows'][0]['title']}" class="hidden-xs">
|
|
% if stat_id in ('top_music', 'popular_music'):
|
|
<div id="stats-poster-${stat_id}" class="dashboard-stats-cover" style="background-image: url(pms_image_proxy?img=${top_stat['rows'][0]['thumb']}&width=300&height=300&fallback=cover);"></div>
|
|
% else:
|
|
<div id="stats-poster-${stat_id}" class="dashboard-stats-poster" style="background-image: url(pms_image_proxy?img=${top_stat['rows'][0]['thumb']}&width=300&height=450&fallback=poster);"></div>
|
|
% endif
|
|
</a>
|
|
% elif stat_id == 'top_users':
|
|
<a id="stats-poster-url-${stat_id}" href="user?user_id=${top_stat['rows'][0]['user_id']}" title="${top_stat['rows'][0]['friendly_name']}" class="hidden-xs">
|
|
<div id="stats-poster-${stat_id}" class="dashboard-stats-circle" style="background-image: url(${top_stat['rows'][0]['user_thumb'] or http_root + 'images/gravatar-default.png'})"></div>
|
|
</a>
|
|
% elif stat_id == 'top_platforms':
|
|
<div id="stats-poster-${stat_id}" class="dashboard-stats-square">
|
|
<script>
|
|
$("#stats-poster-${stat_id}").css("background-image", "url(" + getPlatformImagePath("${top_stat['rows'][0]['platform_type']}") + ")");
|
|
</script>
|
|
</div>
|
|
% elif stat_id == 'most_concurrent':
|
|
<div id="stats-poster-${stat_id}" class="dashboard-stats-square" style="background-image: url(${http_root}images/home-stat_most-concurrent.png)"></div>
|
|
% endif
|
|
<div class="dashboard-stats-info-container">
|
|
<div id="stats-title-${stat_id}" class="dashboard-stats-info-title">
|
|
<h4>${top_stat['stat_title']}</h4>
|
|
% if stat_id.startswith('top') and top_stat.get('stat_type') == 'total_plays':
|
|
<span class="dashboard-stats-stats-units">plays</span>
|
|
% elif stat_id.startswith('top') and top_stat.get('stat_type') == 'total_duration':
|
|
<span class="dashboard-stats-stats-units">hh:mm</span>
|
|
% elif stat_id.startswith('popular'):
|
|
<span class="dashboard-stats-stats-units">users</span>
|
|
% elif stat_id == 'most_concurrent':
|
|
<span class="dashboard-stats-stats-units">streams</span>
|
|
% endif
|
|
</div>
|
|
<div class="dashboard-stats-info-scroller scrollbar-macosx">
|
|
<div class="dashboard-stats-info">
|
|
<ul class="list-unstyled dashboard-stats-info-list">
|
|
% for row in top_stat['rows']:
|
|
<li class="dashboard-stats-info-item" data-stat_id="${stat_id}" data-art="${row.get('art')}" data-thumb="${row.get('thumb')}" data-platform="${row.get('platform_type')}">
|
|
<div class="sub-heading">${loop.index + 1}</div>
|
|
<!--<div class="sub-heading"></div>-->
|
|
<div class="sub-value">
|
|
% if stat_id in ('top_movies', 'popular_movies', 'top_tv', 'popular_tv', 'top_music', 'popular_music', 'last_watched'):
|
|
% if top_stat['rows'][loop.index]['rating_key']:
|
|
<a href="info?rating_key=${row['rating_key']}" title="${row['title']}">
|
|
${row['title']}
|
|
</a>
|
|
% else:
|
|
${row['title']}
|
|
% endif
|
|
% elif stat_id == 'top_users':
|
|
% if top_stat['rows'][loop.index]['user_id']:
|
|
<a href="user?user_id=${row['user_id']}" title="${row['friendly_name']}">
|
|
${row['friendly_name']}
|
|
</a>
|
|
% else:
|
|
${row['friendly_name']}
|
|
% endif
|
|
% elif stat_id == 'top_platforms':
|
|
${row['platform_type']}
|
|
% elif stat_id == 'most_concurrent':
|
|
${row['title']}
|
|
% endif
|
|
</div>
|
|
<div class="sub-count">
|
|
% if top_stat.get('stat_type') == 'total_plays':
|
|
${row['total_plays']}
|
|
% elif top_stat.get('stat_type') == 'total_duration':
|
|
${row['total_duration'] | hd}
|
|
% elif stat_id.startswith('popular'):
|
|
${row['users_watched']}
|
|
% elif stat_id == 'most_concurrent':
|
|
${row['count']}
|
|
% endif
|
|
</div>
|
|
</li>
|
|
% endfor
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
% endfor
|
|
<script>
|
|
$('.dashboard-stats-instance .dashboard-stats-info-scroller').scrollbar()
|
|
|
|
function changeImages(elem) {
|
|
var stat_id = $(elem).data('stat_id');
|
|
var art = $(elem).data('art');
|
|
var thumb = $(elem).data('thumb');
|
|
var height = ($.inArray(stat_id, ['top_music', 'popular_music'])) ? 450 : 300;
|
|
var fallback = ($.inArray(stat_id, ['top_music', 'popular_music'])) ? 'poster' : 'cover';
|
|
|
|
if (stat_id == 'most_concurrent') {
|
|
return
|
|
} else if (stat_id == 'top_users') {
|
|
$('#stats-poster-' + stat_id).css('background-image', 'url(' + (thumb || '${http_root}images/gravatar-default.png') + ')');
|
|
} else if (stat_id == 'top_platforms') {
|
|
$('#stats-poster-' + stat_id).css('background-image', 'url(' + getPlatformImagePath($(elem).data('platform')) + ')');
|
|
} else {
|
|
if (art) {
|
|
$('#stats-background-' + stat_id).css('background-image', 'url(pms_image_proxy?img=' + art + '&width=500&height=280&fallback=art)');
|
|
} else {
|
|
$('#stats-background-' + stat_id).css('background-image', 'url(${http_root}images/art.png)');
|
|
}
|
|
if (thumb) {
|
|
$('#stats-poster-' + stat_id).css('background-image', 'url(pms_image_proxy?img=' + thumb + '&width=300&height=' + height + '&fallback=' + fallback + ')');
|
|
} else {
|
|
$('#stats-background-' + stat_id).css('background-image', 'url(${http_root}images/' + fallback + '.png)');
|
|
}
|
|
}
|
|
}
|
|
|
|
$('.dashboard-stats-info-item').mouseenter(function () {
|
|
changeImages(this)
|
|
});
|
|
$('.dashboard-stats-instance').mouseleave(function () {
|
|
changeImages($(this).find('.dashboard-stats-info-item').first())
|
|
});
|
|
</script>
|
|
% else:
|
|
<div class="text-muted">No stats to show for the selected period.</div><br>
|
|
% endif |