mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-14 01:02:59 -07:00
Merge pull request #1389 from herby2212/nightly
Add most active libraries card and total plays to home stats
This commit is contained in:
commit
3dd9dfa48b
6 changed files with 105 additions and 4 deletions
|
@ -25,7 +25,7 @@ grandparent_thumb Returns location of the item's thumbnail. Use with pms_i
|
||||||
rating_key Returns the unique identifier for the media item.
|
rating_key Returns the unique identifier for the media item.
|
||||||
title Returns the title for the associated stat.
|
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' ==
|
== Only if 'stat_id' is 'top_tv' or 'top_movies' or 'top_music' or 'top_user' or 'top_platform' or 'top_libraries' ==
|
||||||
total_plays Returns the count for the associated stat.
|
total_plays Returns the count for the associated stat.
|
||||||
total_duration Returns the total duration for the associated stat.
|
total_duration Returns the total duration for the associated stat.
|
||||||
|
|
||||||
|
@ -76,6 +76,8 @@ DOCUMENTATION :: END
|
||||||
<div id="stats-background-${stat_id}" class="dashboard-stats-background" style="background-image: url(${page('pms_image_proxy', row0['art'], row0['rating_key'], 500, 280, 40, '282828', 3, fallback=fallback)});">
|
<div id="stats-background-${stat_id}" class="dashboard-stats-background" style="background-image: url(${page('pms_image_proxy', row0['art'], row0['rating_key'], 500, 280, 40, '282828', 3, fallback=fallback)});">
|
||||||
% elif stat_id == 'top_platforms':
|
% elif stat_id == 'top_platforms':
|
||||||
<div id="stats-background-${stat_id}" class="dashboard-stats-background platform-${row0['platform_name']}-rgba no-image">
|
<div id="stats-background-${stat_id}" class="dashboard-stats-background platform-${row0['platform_name']}-rgba no-image">
|
||||||
|
% elif stat_id == 'top_libraries':
|
||||||
|
<div id="stats-background-${stat_id}" class="dashboard-stats-background" style="background-image: url(${page('pms_image_proxy', row0['art'], None, 500, 280, 40, '282828', 3, fallback='art')});">
|
||||||
% else:
|
% else:
|
||||||
<div id="stats-background-${stat_id}" class="dashboard-stats-background flat">
|
<div id="stats-background-${stat_id}" class="dashboard-stats-background flat">
|
||||||
% endif
|
% endif
|
||||||
|
@ -111,6 +113,12 @@ DOCUMENTATION :: END
|
||||||
<div id="stats-thumb-${stat_id}" class="dashboard-stats-flat svg-icon platform-${row0['platform_name']} transparent hidden-xs"></div>
|
<div id="stats-thumb-${stat_id}" class="dashboard-stats-flat svg-icon platform-${row0['platform_name']} transparent hidden-xs"></div>
|
||||||
% elif stat_id == 'most_concurrent':
|
% elif stat_id == 'most_concurrent':
|
||||||
<div id="stats-thumb-${stat_id}" class="dashboard-stats-flat svg-icon stats-${stat_id} transparent hidden-xs"></div>
|
<div id="stats-thumb-${stat_id}" class="dashboard-stats-flat svg-icon stats-${stat_id} transparent hidden-xs"></div>
|
||||||
|
% elif stat_id == 'top_libraries':
|
||||||
|
% if row0['thumb'].startswith('http'):
|
||||||
|
<div id="stats-thumb-${stat_id}" class="dashboard-stats-flat hidden-xs" style="background-image: url(${page('pms_image_proxy', row0['thumb'], None, 80, 80)});"></div>
|
||||||
|
% else:
|
||||||
|
<div id="stats-thumb-${stat_id}" class="dashboard-stats-flat svg-icon library-${row0['section_type']} hidden-xs"></div>
|
||||||
|
% endif
|
||||||
% endif
|
% endif
|
||||||
<div class="dashboard-stats-info-container">
|
<div class="dashboard-stats-info-container">
|
||||||
<div id="stats-title-${stat_id}" class="dashboard-stats-info-title">
|
<div id="stats-title-${stat_id}" class="dashboard-stats-info-title">
|
||||||
|
@ -133,7 +141,7 @@ DOCUMENTATION :: END
|
||||||
% for row in top_stat['rows']:
|
% for row in top_stat['rows']:
|
||||||
<li class="dashboard-stats-info-item ${'expanded' if loop.index == 0 else ''}" data-stat_id="${stat_id}"
|
<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-guid="${row.get('guid')}" data-title="${row.get('title')}"
|
data-rating_key="${row.get('rating_key')}" data-guid="${row.get('guid')}" data-title="${row.get('title')}"
|
||||||
data-art="${row.get('art')}" data-thumb="${row.get('thumb')}" data-platform="${row.get('platform_name')}"
|
data-art="${row.get('art')}" data-thumb="${row.get('thumb')}" data-platform="${row.get('platform_name')}" data-library-type="${row.get('section_type')}"
|
||||||
data-user_id="${row.get('user_id')}" data-user="${row.get('user')}" data-friendly_name="${row.get('friendly_name')}" data-user_thumb="${row.get('user_thumb')}"
|
data-user_id="${row.get('user_id')}" data-user="${row.get('user')}" 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-live="${row.get('live')}">
|
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-list">${loop.index + 1}</div>
|
||||||
|
@ -159,6 +167,11 @@ DOCUMENTATION :: END
|
||||||
${row['platform']}
|
${row['platform']}
|
||||||
% elif stat_id == 'most_concurrent':
|
% elif stat_id == 'most_concurrent':
|
||||||
${row['title']}
|
${row['title']}
|
||||||
|
% elif stat_id == 'top_libraries':
|
||||||
|
<% library_href = page('library', row['section_id']) %>
|
||||||
|
<a href="${library_href}" title="${row['section_name']}">
|
||||||
|
${row['section_name']}
|
||||||
|
</a>
|
||||||
% endif
|
% endif
|
||||||
</div>
|
</div>
|
||||||
<div class="sub-count">
|
<div class="sub-count">
|
||||||
|
|
|
@ -783,6 +783,7 @@
|
||||||
var art = $(elem).data('art');
|
var art = $(elem).data('art');
|
||||||
var thumb = $(elem).data('thumb');
|
var thumb = $(elem).data('thumb');
|
||||||
var user_id = $(elem).data('user_id');
|
var user_id = $(elem).data('user_id');
|
||||||
|
var library_type = $(elem).data('library-type');
|
||||||
var user_thumb = $(elem).data('user_thumb');
|
var user_thumb = $(elem).data('user_thumb');
|
||||||
var rating_key = $(elem).data('rating_key');
|
var rating_key = $(elem).data('rating_key');
|
||||||
var guid = $(elem).data('guid');
|
var guid = $(elem).data('guid');
|
||||||
|
@ -810,6 +811,16 @@
|
||||||
$('#stats-background-' + stat_id).removeClass(function (index, className) {
|
$('#stats-background-' + stat_id).removeClass(function (index, className) {
|
||||||
return (className.match (/(^|\s)platform-\S+/g) || []).join(' ');
|
return (className.match (/(^|\s)platform-\S+/g) || []).join(' ');
|
||||||
}).addClass('platform-' + $(elem).data('platform') + '-rgba');
|
}).addClass('platform-' + $(elem).data('platform') + '-rgba');
|
||||||
|
} else if (stat_id === 'top_libraries') {
|
||||||
|
$('#stats-background-' + stat_id).css('background-image', 'url(' + page('pms_image_proxy', art, null, 500, 280, 40, '282828', 3, fallback_art) + ')');
|
||||||
|
$('#stats-thumb-' + stat_id).removeClass(function (index, className) {
|
||||||
|
return (className.match (/(^|\s)svg-icon library-\S+/g) || []).join(' ')});
|
||||||
|
if (thumb.startsWith('http')) {
|
||||||
|
$('#stats-thumb-' + stat_id).css('background-image', 'url(' + page('pms_image_proxy', thumb, null, 300, 300, null, null, null, 'cover') + ')');
|
||||||
|
} else {
|
||||||
|
$('#stats-thumb-' + stat_id).css('background-image', '')
|
||||||
|
.addClass('svg-icon library-' + library_type);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (rating_key) {
|
if (rating_key) {
|
||||||
if (live) {
|
if (live) {
|
||||||
|
|
|
@ -403,6 +403,12 @@
|
||||||
<input type="checkbox" id="hscard-last_watched" name="hscard-last_watched" value="last_watched"> Last Watched
|
<input type="checkbox" id="hscard-last_watched" name="hscard-last_watched" value="last_watched"> Last Watched
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="card card-sortable">
|
||||||
|
<div class="card-handle"><i class="fa fa-bars"></i></div>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" id="hscard-top_libraries" name="hscard-top_libraries" value="top_libraries"> Most Active Libraries
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
<li class="card card-sortable">
|
<li class="card card-sortable">
|
||||||
<div class="card-handle"><i class="fa fa-bars"></i></div>
|
<div class="card-handle"><i class="fa fa-bars"></i></div>
|
||||||
<label>
|
<label>
|
||||||
|
|
|
@ -114,7 +114,7 @@ _CONFIG_DEFINITIONS = {
|
||||||
'HOME_SECTIONS': (list, 'General', ['current_activity', 'watch_stats', 'library_stats', 'recently_added']),
|
'HOME_SECTIONS': (list, 'General', ['current_activity', 'watch_stats', 'library_stats', 'recently_added']),
|
||||||
'HOME_LIBRARY_CARDS': (list, 'General', ['first_run']),
|
'HOME_LIBRARY_CARDS': (list, 'General', ['first_run']),
|
||||||
'HOME_STATS_CARDS': (list, 'General', ['top_movies', 'popular_movies', 'top_tv', 'popular_tv', 'top_music',
|
'HOME_STATS_CARDS': (list, 'General', ['top_movies', 'popular_movies', 'top_tv', 'popular_tv', 'top_music',
|
||||||
'popular_music', 'last_watched', 'top_users', 'top_platforms', 'most_concurrent']),
|
'popular_music', 'last_watched', 'top_libraries', 'top_users', 'top_platforms', 'most_concurrent']),
|
||||||
'HOME_REFRESH_INTERVAL': (int, 'General', 10),
|
'HOME_REFRESH_INTERVAL': (int, 'General', 10),
|
||||||
'HTTPS_CREATE_CERT': (int, 'General', 1),
|
'HTTPS_CREATE_CERT': (int, 'General', 1),
|
||||||
'HTTPS_CERT': (str, 'General', ''),
|
'HTTPS_CERT': (str, 'General', ''),
|
||||||
|
@ -546,3 +546,15 @@ class Config(object):
|
||||||
self.PLEXPY_AUTO_UPDATE = 0
|
self.PLEXPY_AUTO_UPDATE = 0
|
||||||
|
|
||||||
self.CONFIG_VERSION = 17
|
self.CONFIG_VERSION = 17
|
||||||
|
|
||||||
|
if self.CONFIG_VERSION == 17:
|
||||||
|
home_stats_cards = self.HOME_STATS_CARDS
|
||||||
|
if 'top_users' in home_stats_cards:
|
||||||
|
top_users_index = home_stats_cards.index('top_users')
|
||||||
|
home_stats_cards.insert(top_users_index, 'top_libraries')
|
||||||
|
else:
|
||||||
|
home_stats_cards.add('top_libaries')
|
||||||
|
self.HOME_STATS_CARDS = home_stats_cards
|
||||||
|
|
||||||
|
self.CONFIG_VERSION = 18
|
||||||
|
|
|
@ -29,11 +29,13 @@ if plexpy.PYTHON2:
|
||||||
import common
|
import common
|
||||||
import database
|
import database
|
||||||
import datatables
|
import datatables
|
||||||
|
import libraries
|
||||||
import helpers
|
import helpers
|
||||||
import logger
|
import logger
|
||||||
import pmsconnect
|
import pmsconnect
|
||||||
import session
|
import session
|
||||||
else:
|
else:
|
||||||
|
from plexpy import libraries
|
||||||
from plexpy import common
|
from plexpy import common
|
||||||
from plexpy import database
|
from plexpy import database
|
||||||
from plexpy import datatables
|
from plexpy import datatables
|
||||||
|
@ -888,6 +890,63 @@ class DataFactory(object):
|
||||||
'stat_title': 'Most Concurrent Streams',
|
'stat_title': 'Most Concurrent Streams',
|
||||||
'rows': most_concurrent})
|
'rows': most_concurrent})
|
||||||
|
|
||||||
|
elif stat == 'top_libraries':
|
||||||
|
top_libraries = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
query = 'SELECT section_id, section_name, section_type, thumb AS library_thumb, ' \
|
||||||
|
'custom_thumb_url AS custom_thumb, art AS library_art, custom_art_url AS custom_art ' \
|
||||||
|
'FROM library_sections ' \
|
||||||
|
'WHERE deleted_section = 0'
|
||||||
|
|
||||||
|
result = monitor_db.select(query)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warn("Tautulli DataFactory :: Unable to execute database query for get_home_stats: top_libraries: %s." % e)
|
||||||
|
return None
|
||||||
|
|
||||||
|
library_data = libraries.Libraries()
|
||||||
|
|
||||||
|
for item in result:
|
||||||
|
library_item = library_data.get_watch_time_stats(section_id=item['section_id'],
|
||||||
|
query_days=time_range)
|
||||||
|
|
||||||
|
if not library_item or library_item[0]['total_plays'] == 0 and library_item[0]['total_time'] == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if item['custom_thumb'] and item['custom_thumb'] != item['library_thumb']:
|
||||||
|
library_thumb = item['custom_thumb']
|
||||||
|
elif item['library_thumb']:
|
||||||
|
library_thumb = item['library_thumb']
|
||||||
|
else:
|
||||||
|
library_thumb = common.DEFAULT_COVER_THUMB
|
||||||
|
|
||||||
|
if item['custom_art'] and item['custom_art'] != item['library_art']:
|
||||||
|
library_art = item['custom_art']
|
||||||
|
else:
|
||||||
|
library_art = item['library_art']
|
||||||
|
|
||||||
|
row = {
|
||||||
|
'total_plays': library_item[0]['total_plays'],
|
||||||
|
'total_duration': library_item[0]['total_time'],
|
||||||
|
'section_type': item['section_type'],
|
||||||
|
'section_name': item['section_name'],
|
||||||
|
'section_id': item['section_id'],
|
||||||
|
'last_play': '',
|
||||||
|
'thumb': library_thumb,
|
||||||
|
'art': library_art
|
||||||
|
}
|
||||||
|
|
||||||
|
top_libraries.append(row)
|
||||||
|
|
||||||
|
home_stats.append({
|
||||||
|
'stat_id': stat,
|
||||||
|
'stat_type': sort_type,
|
||||||
|
'stat_title': 'Most Active Libraries',
|
||||||
|
'rows': session.mask_session_info(
|
||||||
|
sorted(top_libraries, key=lambda k: k[sort_type], reverse=True)[:10],
|
||||||
|
mask_metadata=False)
|
||||||
|
})
|
||||||
|
|
||||||
if stat_id and home_stats:
|
if stat_id and home_stats:
|
||||||
return home_stats[0]
|
return home_stats[0]
|
||||||
return home_stats
|
return home_stats
|
||||||
|
|
|
@ -4665,7 +4665,7 @@ class WebInterface(object):
|
||||||
else:
|
else:
|
||||||
img = '/library/metadata/{}/thumb'.format(rating_key)
|
img = '/library/metadata/{}/thumb'.format(rating_key)
|
||||||
|
|
||||||
if img:
|
if img and not img.startswith('http'):
|
||||||
parts = 5
|
parts = 5
|
||||||
if img.startswith('/playlists'):
|
if img.startswith('/playlists'):
|
||||||
parts -= 1
|
parts -= 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue