mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-21 05:43:22 -07:00
Merge pull request #328 from JonnyWong16/miscellaneous-fixes
Fix recently added
This commit is contained in:
commit
3b8f9f5892
6 changed files with 50 additions and 34 deletions
|
@ -39,7 +39,7 @@ user_id Returns the user id for the associated stat.
|
||||||
friendly_name Returns the friendly name of the user 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' ==
|
== Only if 'stat_id' is 'top_platform' or 'last_watched' ==
|
||||||
platform_type Returns the platform name for the associated stat.
|
player Returns the player name for the associated stat.
|
||||||
|
|
||||||
== Only if 'stat_id' is 'last_watched' ==
|
== Only if 'stat_id' is 'last_watched' ==
|
||||||
last_watch Returns the time the media item was last watched.
|
last_watch Returns the time the media item was last watched.
|
||||||
|
@ -709,7 +709,7 @@ DOCUMENTATION :: END
|
||||||
<script>
|
<script>
|
||||||
$('#last-watch-stat').text(moment(${top_stat['rows'][0]['last_watch']},"X").format(date_format));
|
$('#last-watch-stat').text(moment(${top_stat['rows'][0]['last_watch']},"X").format(date_format));
|
||||||
</script>
|
</script>
|
||||||
</span> - ${top_stat['rows'][0]['platform_type']}
|
</span> - ${top_stat['rows'][0]['player']}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -755,7 +755,7 @@ DOCUMENTATION :: END
|
||||||
<script>
|
<script>
|
||||||
$('#home-platforms-instance-list-last-watch-${loop.index + 1}').text(moment(${top_stat['rows'][loop.index]['last_watch']},"X").format(date_format));
|
$('#home-platforms-instance-list-last-watch-${loop.index + 1}').text(moment(${top_stat['rows'][loop.index]['last_watch']},"X").format(date_format));
|
||||||
</script>
|
</script>
|
||||||
</span> - ${top_stat['rows'][loop.index]['platform_type']}
|
</span> - ${top_stat['rows'][loop.index]['player']}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -22,7 +22,6 @@ import time
|
||||||
monitor_lock = threading.Lock()
|
monitor_lock = threading.Lock()
|
||||||
ext_ping_count = 0
|
ext_ping_count = 0
|
||||||
int_ping_count = 0
|
int_ping_count = 0
|
||||||
prev_keys = [0] * 10
|
|
||||||
|
|
||||||
|
|
||||||
def check_active_sessions(ws_request=False):
|
def check_active_sessions(ws_request=False):
|
||||||
|
@ -192,16 +191,12 @@ def check_recently_added():
|
||||||
recently_added_list = pms_connect.get_recently_added_details(count='10')
|
recently_added_list = pms_connect.get_recently_added_details(count='10')
|
||||||
|
|
||||||
if recently_added_list:
|
if recently_added_list:
|
||||||
new_recently_added = recently_added_list['recently_added']
|
recently_added = recently_added_list['recently_added']
|
||||||
|
|
||||||
global prev_keys
|
|
||||||
new_keys = [item['rating_key'] for item in new_recently_added]
|
|
||||||
recently_added = [new_recently_added[i] for i, x in enumerate(new_keys) if x != prev_keys[i]]
|
|
||||||
prev_keys = new_keys
|
|
||||||
|
|
||||||
for item in recently_added:
|
for item in recently_added:
|
||||||
metadata = []
|
metadata = []
|
||||||
|
|
||||||
|
if 0 < time_threshold - int(item['added_at']) <= time_interval:
|
||||||
if item['media_type'] == 'movie':
|
if item['media_type'] == 'movie':
|
||||||
metadata_list = pms_connect.get_metadata_details(item['rating_key'])
|
metadata_list = pms_connect.get_metadata_details(item['rating_key'])
|
||||||
if metadata_list:
|
if metadata_list:
|
||||||
|
|
|
@ -108,6 +108,9 @@ class DataFactory(object):
|
||||||
# Rename Mystery platform names
|
# Rename Mystery platform names
|
||||||
platform = common.PLATFORM_NAME_OVERRIDES.get(item["platform"], item["platform"])
|
platform = common.PLATFORM_NAME_OVERRIDES.get(item["platform"], item["platform"])
|
||||||
|
|
||||||
|
# Sanitize player name
|
||||||
|
player = helpers.sanitize(item["player"])
|
||||||
|
|
||||||
row = {"reference_id": item["reference_id"],
|
row = {"reference_id": item["reference_id"],
|
||||||
"id": item["id"],
|
"id": item["id"],
|
||||||
"date": item["date"],
|
"date": item["date"],
|
||||||
|
@ -119,7 +122,7 @@ class DataFactory(object):
|
||||||
"user": item["user"],
|
"user": item["user"],
|
||||||
"friendly_name": item["friendly_name"],
|
"friendly_name": item["friendly_name"],
|
||||||
"platform": platform,
|
"platform": platform,
|
||||||
"player": item["player"],
|
"player": player,
|
||||||
"ip_address": item["ip_address"],
|
"ip_address": item["ip_address"],
|
||||||
"media_type": item["media_type"],
|
"media_type": item["media_type"],
|
||||||
"rating_key": item["rating_key"],
|
"rating_key": item["rating_key"],
|
||||||
|
@ -545,7 +548,7 @@ class DataFactory(object):
|
||||||
'session_history_metadata.thumb, ' \
|
'session_history_metadata.thumb, ' \
|
||||||
'session_history_metadata.grandparent_thumb, ' \
|
'session_history_metadata.grandparent_thumb, ' \
|
||||||
'MAX(session_history.started) as last_watch, ' \
|
'MAX(session_history.started) as last_watch, ' \
|
||||||
'session_history.player as platform, ' \
|
'session_history.player, ' \
|
||||||
'((CASE WHEN session_history.view_offset IS NULL THEN 0.1 ELSE \
|
'((CASE WHEN session_history.view_offset IS NULL THEN 0.1 ELSE \
|
||||||
session_history.view_offset * 1.0 END) / \
|
session_history.view_offset * 1.0 END) / \
|
||||||
(CASE WHEN session_history_metadata.duration IS NULL THEN 1.0 ELSE \
|
(CASE WHEN session_history_metadata.duration IS NULL THEN 1.0 ELSE \
|
||||||
|
@ -572,6 +575,9 @@ class DataFactory(object):
|
||||||
else:
|
else:
|
||||||
thumb = item[8]
|
thumb = item[8]
|
||||||
|
|
||||||
|
# Sanitize player name
|
||||||
|
player = helpers.sanitize(item["player"])
|
||||||
|
|
||||||
row = {'row_id': item[0],
|
row = {'row_id': item[0],
|
||||||
'user': item[1],
|
'user': item[1],
|
||||||
'friendly_name': item[2],
|
'friendly_name': item[2],
|
||||||
|
@ -582,7 +588,7 @@ class DataFactory(object):
|
||||||
'thumb': thumb,
|
'thumb': thumb,
|
||||||
'grandparent_thumb': item[8],
|
'grandparent_thumb': item[8],
|
||||||
'last_watch': item[9],
|
'last_watch': item[9],
|
||||||
'platform_type': item[10],
|
'player': player,
|
||||||
}
|
}
|
||||||
last_watched.append(row)
|
last_watched.append(row)
|
||||||
|
|
||||||
|
|
|
@ -430,3 +430,9 @@ def process_json_kwargs(json_kwargs):
|
||||||
params = json.loads(json_kwargs)
|
params = json.loads(json_kwargs)
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
def sanitize(string):
|
||||||
|
if string:
|
||||||
|
return str(string).replace('<','<').replace('>','>')
|
||||||
|
else:
|
||||||
|
return ''
|
|
@ -89,13 +89,16 @@ class Users(object):
|
||||||
# Rename Mystery platform names
|
# Rename Mystery platform names
|
||||||
platform = common.PLATFORM_NAME_OVERRIDES.get(item["platform"], item["platform"])
|
platform = common.PLATFORM_NAME_OVERRIDES.get(item["platform"], item["platform"])
|
||||||
|
|
||||||
|
# Sanitize player name
|
||||||
|
player = helpers.sanitize(item["player"])
|
||||||
|
|
||||||
row = {"id": item['id'],
|
row = {"id": item['id'],
|
||||||
"plays": item['plays'],
|
"plays": item['plays'],
|
||||||
"last_seen": item['last_seen'],
|
"last_seen": item['last_seen'],
|
||||||
"friendly_name": item['friendly_name'],
|
"friendly_name": item['friendly_name'],
|
||||||
"ip_address": item['ip_address'],
|
"ip_address": item['ip_address'],
|
||||||
"platform": platform,
|
"platform": platform,
|
||||||
"player": item['player'],
|
"player": player,
|
||||||
"last_watched": item['last_watched'],
|
"last_watched": item['last_watched'],
|
||||||
"thumb": thumb,
|
"thumb": thumb,
|
||||||
"media_type": item['media_type'],
|
"media_type": item['media_type'],
|
||||||
|
@ -180,12 +183,15 @@ class Users(object):
|
||||||
# Rename Mystery platform names
|
# Rename Mystery platform names
|
||||||
platform = common.PLATFORM_NAME_OVERRIDES.get(item["platform"], item["platform"])
|
platform = common.PLATFORM_NAME_OVERRIDES.get(item["platform"], item["platform"])
|
||||||
|
|
||||||
|
# Sanitize player name
|
||||||
|
player = helpers.sanitize(item["player"])
|
||||||
|
|
||||||
row = {"id": item['id'],
|
row = {"id": item['id'],
|
||||||
"last_seen": item['last_seen'],
|
"last_seen": item['last_seen'],
|
||||||
"ip_address": item['ip_address'],
|
"ip_address": item['ip_address'],
|
||||||
"play_count": item['play_count'],
|
"play_count": item['play_count'],
|
||||||
"platform": platform,
|
"platform": platform,
|
||||||
"player": item['player'],
|
"player": player,
|
||||||
"last_watched": item['last_watched'],
|
"last_watched": item['last_watched'],
|
||||||
"thumb": thumb,
|
"thumb": thumb,
|
||||||
"media_type": item['media_type'],
|
"media_type": item['media_type'],
|
||||||
|
@ -531,7 +537,10 @@ class Users(object):
|
||||||
# Rename Mystery platform names
|
# Rename Mystery platform names
|
||||||
platform_type = common.PLATFORM_NAME_OVERRIDES.get(item[2], item[2])
|
platform_type = common.PLATFORM_NAME_OVERRIDES.get(item[2], item[2])
|
||||||
|
|
||||||
row = {'player_name': item[0],
|
# Sanitize player name
|
||||||
|
player = helpers.sanitize(item[0])
|
||||||
|
|
||||||
|
row = {'player_name': player,
|
||||||
'platform_type': platform_type,
|
'platform_type': platform_type,
|
||||||
'total_plays': item[1],
|
'total_plays': item[1],
|
||||||
'result_id': result_id
|
'result_id': result_id
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
#!/usr/bin/env python
|
# This file is part of PlexPy.
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# This file is part of PlexPy.
|
|
||||||
#
|
#
|
||||||
# PlexPy is free software: you can redistribute it and/or modify
|
# PlexPy is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,7 +13,7 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with PlexPy. If not, see <http://www.gnu.org/licenses/>.
|
# along with PlexPy. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from plexpy import logger, notifiers, plextv, pmsconnect, common, log_reader, datafactory, graphs, users
|
from plexpy import logger, notifiers, plextv, pmsconnect, common, log_reader, datafactory, graphs, users, helpers
|
||||||
from plexpy.helpers import checked, radio
|
from plexpy.helpers import checked, radio
|
||||||
|
|
||||||
from mako.lookup import TemplateLookup
|
from mako.lookup import TemplateLookup
|
||||||
|
@ -738,6 +735,9 @@ class WebInterface(object):
|
||||||
if not session['ip_address']:
|
if not session['ip_address']:
|
||||||
ip_address = data_factory.get_session_ip(session['session_key'])
|
ip_address = data_factory.get_session_ip(session['session_key'])
|
||||||
session['ip_address'] = ip_address
|
session['ip_address'] = ip_address
|
||||||
|
# Sanitize player name
|
||||||
|
session['player'] = helpers.sanitize(session['player'])
|
||||||
|
|
||||||
except:
|
except:
|
||||||
return serve_template(templatename="current_activity.html", data=None)
|
return serve_template(templatename="current_activity.html", data=None)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue