mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-14 10:36:57 -07:00
Fallback to Live TV art/poster for watch statistics
This commit is contained in:
parent
f3d42e7b53
commit
075f9f8cbd
2 changed files with 47 additions and 27 deletions
|
@ -73,7 +73,8 @@ DOCUMENTATION :: END
|
|||
<div class="dashboard-stats-container">
|
||||
% if stat_id in ('top_movies', 'popular_movies', 'top_tv', 'popular_tv', 'top_music', 'popular_music', 'last_watched'):
|
||||
% if row0['art']:
|
||||
<div id="stats-background-${stat_id}" class="dashboard-stats-background" style="background-image: url(pms_image_proxy?img=${row0['art']}&rating_key=${row0['rating_key']}&width=500&height=280&opacity=40&background=282828&blur=3&fallback=art);">
|
||||
<% fallback = 'art-live' if row0['live'] else 'art' %>
|
||||
<div id="stats-background-${stat_id}" class="dashboard-stats-background" style="background-image: url(pms_image_proxy?img=${row0['art']}&rating_key=${row0['rating_key']}&width=500&height=280&opacity=40&background=282828&blur=3&fallback=${fallback});">
|
||||
% else:
|
||||
<div id="stats-background-${stat_id}" class="dashboard-stats-background" style="background-image: url(images/art.png);">
|
||||
% endif
|
||||
|
@ -87,7 +88,13 @@ DOCUMENTATION :: END
|
|||
% if stat_id in ('top_music', 'popular_music'):
|
||||
<div id="stats-thumb-${stat_id}-bg" class="dashboard-stats-poster" style="background-image: url(pms_image_proxy?img=${row0['thumb']}&rating_key=${row0['rating_key']}&width=300&height=300&opacity=60&background=282828&blur=3&fallback=cover);"></div>
|
||||
% endif
|
||||
<% height, type = ('300', 'cover') if stat_id in ('top_music', 'popular_music') else ('450', 'poster') %>
|
||||
<%
|
||||
height, type = ('450', 'poster')
|
||||
if stat_id in ('top_music', 'popular_music'):
|
||||
height, type = ('300', 'cover')
|
||||
elif row0['live']:
|
||||
height, type = ('450', 'poster-live')
|
||||
%>
|
||||
<% href = 'info?rating_key={}'.format(row0['rating_key']) if row0['rating_key'] else '#' %>
|
||||
<a id="stats-thumb-url-${stat_id}" href="${href}" title="${row0['title']}">
|
||||
% if row0['thumb']:
|
||||
|
@ -129,7 +136,7 @@ DOCUMENTATION :: END
|
|||
<li class="dashboard-stats-info-item ${'expanded' if loop.index == 0 else ''}" data-stat_id="${stat_id}" data-rating_key="${row.get('rating_key')}" data-title="${row.get('title')}"
|
||||
data-art="${row.get('art')}" data-thumb="${row.get('thumb')}" data-platform="${row.get('platform_name')}"
|
||||
data-user_id="${row.get('user_id')}" data-friendly_name="${row.get('friendly_name')}" data-user_thumb="${row.get('user_thumb')}"
|
||||
data-last_watch="${row.get('last_watch')}" data-started="${row.get('started')}">
|
||||
data-last_watch="${row.get('last_watch')}" data-started="${row.get('started')}" data-live="${row.get('live')}">
|
||||
<div class="sub-list">${loop.index + 1}</div>
|
||||
<div class="sub-value">
|
||||
% if stat_id in ('top_movies', 'popular_movies', 'top_tv', 'popular_tv', 'top_music', 'popular_music', 'last_watched'):
|
||||
|
@ -171,7 +178,7 @@ DOCUMENTATION :: END
|
|||
% endif
|
||||
% endfor
|
||||
<script>
|
||||
$('.dashboard-stats-instance .dashboard-stats-info-scroller').scrollbar()
|
||||
$('.dashboard-stats-instance .dashboard-stats-info-scroller').scrollbar();
|
||||
|
||||
function changeImages(elem) {
|
||||
var stat_id = $(elem).data('stat_id');
|
||||
|
@ -180,12 +187,18 @@ DOCUMENTATION :: END
|
|||
var user_id = $(elem).data('user_id');
|
||||
var user_thumb = $(elem).data('user_thumb');
|
||||
var rating_key = $(elem).data('rating_key');
|
||||
var [height, fallback] = ($.inArray(stat_id, ['top_music', 'popular_music']) > -1) ? [300, 'cover'] : [450, 'poster'];
|
||||
var live = $(elem).data('live');
|
||||
var [height, fallback_poster, fallback_art] = [450, 'poster', 'art'];
|
||||
if ($.inArray(stat_id, ['top_music', 'popular_music']) > -1) {
|
||||
[height, fallback_poster, fallback_art] = [300, 'cover', 'art'];
|
||||
} else if (live) {
|
||||
[height, fallback_poster, fallback_art] = [450, 'poster-live', 'art-live'];
|
||||
}
|
||||
var href;
|
||||
|
||||
if (stat_id == 'most_concurrent') {
|
||||
if (stat_id === 'most_concurrent') {
|
||||
return
|
||||
} else if (stat_id == 'top_users') {
|
||||
} else if (stat_id === 'top_users') {
|
||||
$('#stats-thumb-' + stat_id).css('background-image', 'url(' + (user_thumb || 'images/gravatar-default.png') + ')');
|
||||
if (user_id) {
|
||||
href = 'user?user_id=' + user_id;
|
||||
|
@ -193,7 +206,7 @@ DOCUMENTATION :: END
|
|||
href = '#';
|
||||
}
|
||||
$('#stats-thumb-url-' + stat_id).attr('href', href).prop('title', $(elem).data('friendly_name'));
|
||||
} else if (stat_id == 'top_platforms') {
|
||||
} else if (stat_id === 'top_platforms') {
|
||||
$('#stats-thumb-' + stat_id).removeClass(function (index, className) {
|
||||
return (className.match (/(^|\s)platform-\S+/g) || []).join(' ');
|
||||
}).addClass('platform-' + $(elem).data('platform'));
|
||||
|
@ -208,36 +221,36 @@ DOCUMENTATION :: END
|
|||
}
|
||||
$('#stats-thumb-url-' + stat_id).attr('href', href).prop('title', $(elem).data('title'));
|
||||
if (art) {
|
||||
$('#stats-background-' + stat_id).css('background-image', 'url(pms_image_proxy?img=' + art + '&rating_key=' + rating_key + '&width=500&height=280&opacity=40&background=282828&blur=3&fallback=art)');
|
||||
$('#stats-background-' + stat_id).css('background-image', 'url(pms_image_proxy?img=' + art + '&rating_key=' + rating_key + '&width=500&height=280&opacity=40&background=282828&blur=3&fallback=' + fallback_art + ')');
|
||||
} else {
|
||||
$('#stats-background-' + stat_id).css('background-image', 'url(images/art.png)');
|
||||
$('#stats-background-' + stat_id).css('background-image', 'url(images/' + fallback_art + '.png)');
|
||||
}
|
||||
if (thumb) {
|
||||
$('#stats-thumb-' + stat_id).css('background-image', 'url(pms_image_proxy?img=' + thumb + '&rating_key=' + rating_key + '&width=300&height=' + height + '&fallback=' + fallback + ')');
|
||||
$('#stats-thumb-' + stat_id + '-bg').css('background-image', 'url(pms_image_proxy?img=' + thumb + '&rating_key=' + rating_key + '&width=300&height=' + height + '&opacity=60&background=282828&blur=3&fallback=' + fallback + ')');
|
||||
$('#stats-thumb-' + stat_id).css('background-image', 'url(pms_image_proxy?img=' + thumb + '&rating_key=' + rating_key + '&width=300&height=' + height + '&fallback=' + fallback_poster + ')');
|
||||
$('#stats-thumb-' + stat_id + '-bg').css('background-image', 'url(pms_image_proxy?img=' + thumb + '&rating_key=' + rating_key + '&width=300&height=' + height + '&opacity=60&background=282828&blur=3&fallback=' + fallback_poster + ')');
|
||||
} else {
|
||||
$('#stats-thumb-' + stat_id).css('background-image', 'url(images/' + fallback + '.png)');
|
||||
$('#stats-thumb-' + stat_id + '-bg').css('background-image', 'url(images/' + fallback + '.png)');
|
||||
$('#stats-thumb-' + stat_id).css('background-image', 'url(images/' + fallback_poster + '.png)');
|
||||
$('#stats-thumb-' + stat_id + '-bg').css('background-image', 'url(images/' + fallback_poster + '.png)');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$('.dashboard-stats-info-item').mouseenter(function () {
|
||||
changeImages(this)
|
||||
if ($(this).data('stat_id') == 'last_watched') {
|
||||
changeImages(this);
|
||||
if ($(this).data('stat_id') === 'last_watched') {
|
||||
var friendly_name = $(this).data('friendly_name');
|
||||
var last_watch = moment($(this).data('last_watch'), 'X').format(date_format);
|
||||
$('#last-watched-header-info').html(friendly_name);
|
||||
} else if ($(this).data('stat_id') == 'most_concurrent') {
|
||||
} else if ($(this).data('stat_id') === 'most_concurrent') {
|
||||
var started = moment($(this).data('started'), 'X').format(date_format + ' ' + time_format);
|
||||
$('#most-concurrent-header-info').html(started);
|
||||
}
|
||||
});
|
||||
$('.dashboard-stats-instance').mouseleave(function () {
|
||||
changeImages($(this).find('.dashboard-stats-info-item').first())
|
||||
if ($(this).data('stat_id') == 'last_watched') {
|
||||
changeImages($(this).find('.dashboard-stats-info-item').first());
|
||||
if ($(this).data('stat_id') === 'last_watched') {
|
||||
$('#last-watched-header-info').text($(this).find('.dashboard-stats-info-item').first().data('friendly_name'));
|
||||
} else if ($(this).data('stat_id') == 'most_concurrent') {
|
||||
} else if ($(this).data('stat_id') === 'most_concurrent') {
|
||||
$('#most-concurrent-header-info').text('streams');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -294,7 +294,7 @@ class DataFactory(object):
|
|||
top_movies = []
|
||||
try:
|
||||
query = 'SELECT t.id, t.full_title, t.rating_key, t.thumb, t.section_id, ' \
|
||||
't.art, t.media_type, t.content_rating, t.labels, t.started, ' \
|
||||
't.art, t.media_type, t.content_rating, t.labels, t.started, t.live, ' \
|
||||
'MAX(t.started) AS last_watch, COUNT(t.id) AS total_plays, SUM(t.d) AS total_duration ' \
|
||||
'FROM (SELECT *, SUM(CASE WHEN stopped > 0 THEN (stopped - started) - ' \
|
||||
' (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) ' \
|
||||
|
@ -331,6 +331,7 @@ class DataFactory(object):
|
|||
'friendly_name': '',
|
||||
'platform': '',
|
||||
'platform': '',
|
||||
'live': item['live'],
|
||||
'row_id': item['id']
|
||||
}
|
||||
top_movies.append(row)
|
||||
|
@ -344,7 +345,7 @@ class DataFactory(object):
|
|||
popular_movies = []
|
||||
try:
|
||||
query = 'SELECT t.id, t.full_title, t.rating_key, t.thumb, t.section_id, ' \
|
||||
't.art, t.media_type, t.content_rating, t.labels, t.started, ' \
|
||||
't.art, t.media_type, t.content_rating, t.labels, t.started, t.live, ' \
|
||||
'COUNT(DISTINCT t.user_id) AS users_watched, ' \
|
||||
'MAX(t.started) AS last_watch, COUNT(t.id) as total_plays, SUM(t.d) AS total_duration ' \
|
||||
'FROM (SELECT *, SUM(CASE WHEN stopped > 0 THEN (stopped - started) - ' \
|
||||
|
@ -380,6 +381,7 @@ class DataFactory(object):
|
|||
'user': '',
|
||||
'friendly_name': '',
|
||||
'platform': '',
|
||||
'live': item['live'],
|
||||
'row_id': item['id']
|
||||
}
|
||||
popular_movies.append(row)
|
||||
|
@ -392,7 +394,7 @@ class DataFactory(object):
|
|||
top_tv = []
|
||||
try:
|
||||
query = 'SELECT t.id, t.grandparent_title, t.grandparent_rating_key, t.grandparent_thumb, t.section_id, ' \
|
||||
't.art, t.media_type, t.content_rating, t.labels, t.started, ' \
|
||||
't.art, t.media_type, t.content_rating, t.labels, t.started, t.live, ' \
|
||||
'MAX(t.started) AS last_watch, COUNT(t.id) AS total_plays, SUM(t.d) AS total_duration ' \
|
||||
'FROM (SELECT *, SUM(CASE WHEN stopped > 0 THEN (stopped - started) - ' \
|
||||
' (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) ' \
|
||||
|
@ -428,6 +430,7 @@ class DataFactory(object):
|
|||
'user': '',
|
||||
'friendly_name': '',
|
||||
'platform': '',
|
||||
'live': item['live'],
|
||||
'row_id': item['id']
|
||||
}
|
||||
top_tv.append(row)
|
||||
|
@ -441,7 +444,7 @@ class DataFactory(object):
|
|||
popular_tv = []
|
||||
try:
|
||||
query = 'SELECT t.id, t.grandparent_title, t.grandparent_rating_key, t.grandparent_thumb, t.section_id, ' \
|
||||
't.art, t.media_type, t.content_rating, t.labels, t.started, ' \
|
||||
't.art, t.media_type, t.content_rating, t.labels, t.started, t.live, ' \
|
||||
'COUNT(DISTINCT t.user_id) AS users_watched, ' \
|
||||
'MAX(t.started) AS last_watch, COUNT(t.id) as total_plays, SUM(t.d) AS total_duration ' \
|
||||
'FROM (SELECT *, SUM(CASE WHEN stopped > 0 THEN (stopped - started) - ' \
|
||||
|
@ -477,6 +480,7 @@ class DataFactory(object):
|
|||
'user': '',
|
||||
'friendly_name': '',
|
||||
'platform': '',
|
||||
'live': item['live'],
|
||||
'row_id': item['id']
|
||||
}
|
||||
popular_tv.append(row)
|
||||
|
@ -490,7 +494,7 @@ class DataFactory(object):
|
|||
try:
|
||||
query = 'SELECT t.id, t.grandparent_title, t.original_title, ' \
|
||||
't.grandparent_rating_key, t.grandparent_thumb, t.section_id, ' \
|
||||
't.art, t.media_type, t.content_rating, t.labels, t.started, ' \
|
||||
't.art, t.media_type, t.content_rating, t.labels, t.started, t.live, ' \
|
||||
'MAX(t.started) AS last_watch, COUNT(t.id) AS total_plays, SUM(t.d) AS total_duration ' \
|
||||
'FROM (SELECT *, SUM(CASE WHEN stopped > 0 THEN (stopped - started) - ' \
|
||||
' (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) ' \
|
||||
|
@ -526,6 +530,7 @@ class DataFactory(object):
|
|||
'user': '',
|
||||
'friendly_name': '',
|
||||
'platform': '',
|
||||
'live': item['live'],
|
||||
'row_id': item['id']
|
||||
}
|
||||
top_music.append(row)
|
||||
|
@ -540,7 +545,7 @@ class DataFactory(object):
|
|||
try:
|
||||
query = 'SELECT t.id, t.grandparent_title, t.original_title, ' \
|
||||
't.grandparent_rating_key, t.grandparent_thumb, t.section_id, ' \
|
||||
't.art, t.media_type, t.content_rating, t.labels, t.started, ' \
|
||||
't.art, t.media_type, t.content_rating, t.labels, t.started, t.live, ' \
|
||||
'COUNT(DISTINCT t.user_id) AS users_watched, ' \
|
||||
'MAX(t.started) AS last_watch, COUNT(t.id) as total_plays, SUM(t.d) AS total_duration ' \
|
||||
'FROM (SELECT *, SUM(CASE WHEN stopped > 0 THEN (stopped - started) - ' \
|
||||
|
@ -576,6 +581,7 @@ class DataFactory(object):
|
|||
'user': '',
|
||||
'friendly_name': '',
|
||||
'platform': '',
|
||||
'live': item['live'],
|
||||
'row_id': item['id']
|
||||
}
|
||||
popular_music.append(row)
|
||||
|
@ -692,7 +698,7 @@ class DataFactory(object):
|
|||
try:
|
||||
query = 'SELECT t.id, t.full_title, t.rating_key, t.thumb, t.grandparent_thumb, ' \
|
||||
't.user, t.user_id, t.custom_avatar_url as user_thumb, t.player, t.section_id, ' \
|
||||
't.art, t.media_type, t.content_rating, t.labels, ' \
|
||||
't.art, t.media_type, t.content_rating, t.labels, t.live, ' \
|
||||
'(CASE WHEN t.friendly_name IS NULL THEN t.username ELSE t.friendly_name END) ' \
|
||||
' AS friendly_name, ' \
|
||||
'MAX(t.started) AS last_watch, ' \
|
||||
|
@ -738,6 +744,7 @@ class DataFactory(object):
|
|||
'content_rating': item['content_rating'],
|
||||
'labels': item['labels'].split(';') if item['labels'] else (),
|
||||
'last_watch': item['last_watch'],
|
||||
'live': item['live'],
|
||||
'player': item['player']
|
||||
}
|
||||
last_watched.append(row)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue