diff --git a/data/interfaces/default/css/plexpy.css b/data/interfaces/default/css/plexpy.css index fedbf8d4..b736ffe1 100644 --- a/data/interfaces/default/css/plexpy.css +++ b/data/interfaces/default/css/plexpy.css @@ -1565,19 +1565,19 @@ a:hover .item-children-poster { top: 3px; left: 3px; } -.user-platforms ul { +.user-player ul { list-style: none; margin: 0; } -.user-platforms-instance { +.user-player-instance { float: left; width: 240px; height: 80px; margin-bottom: 25px; } -.user-platforms-instance li { +.user-player-instance li { } -.user-platforms-instance-box { +.user-player-instance-box { float: left; width: 75px; border-radius: 3px; @@ -1589,7 +1589,7 @@ a:hover .item-children-poster { height: 80px; width: 80px; } -.user-platforms-instance-name { +.user-player-instance-name { float: left; padding-top: 14px; color: #fff; @@ -1602,7 +1602,7 @@ a:hover .item-children-poster { width: 140px; margin-left: 10px; } -.user-platforms-instance-playcount h3 { +.user-player-instance-playcount h3 { font-size: 30px; font-weight: bold; color: #F9AA03; @@ -1612,7 +1612,7 @@ a:hover .item-children-poster { margin: 0 5px 0 10px; float: left; } -.user-platforms-instance-playcount p { +.user-player-instance-playcount p { color: #aaa; font-size: 12px; float: left; diff --git a/data/interfaces/default/history.html b/data/interfaces/default/history.html index 0615ea28..3f589390 100644 --- a/data/interfaces/default/history.html +++ b/data/interfaces/default/history.html @@ -30,6 +30,7 @@ User IP Address Platform + Player Title Started Paused @@ -84,7 +85,7 @@ } } history_table = $('#history_table').DataTable(history_table_options); - var colvis = new $.fn.dataTable.ColVis(history_table, { buttonText: ' Select columns', buttonClass: 'btn btn-dark', exclude: [0, 10] }); + var colvis = new $.fn.dataTable.ColVis(history_table, { buttonText: ' Select columns', buttonClass: 'btn btn-dark', exclude: [0, 11] }); $(colvis.button()).appendTo('div.colvis-button-bar'); clearSearchButton('history_table', history_table); diff --git a/data/interfaces/default/history_table_modal.html b/data/interfaces/default/history_table_modal.html index 58345fcf..19de1faf 100644 --- a/data/interfaces/default/history_table_modal.html +++ b/data/interfaces/default/history_table_modal.html @@ -16,7 +16,7 @@ Started Stopped User - Platform + Player Title diff --git a/data/interfaces/default/info.html b/data/interfaces/default/info.html index 0dd8012f..0c9ad3d8 100644 --- a/data/interfaces/default/info.html +++ b/data/interfaces/default/info.html @@ -333,6 +333,7 @@ DOCUMENTATION :: END User IP Address Platform + Player Title Started Paused @@ -550,7 +551,7 @@ DOCUMENTATION :: END $(document).ready(function () { get_history(); history_table = $('#history_table').DataTable(history_table_options); - var colvis = new $.fn.dataTable.ColVis(history_table, { buttonText: ' Select columns', buttonClass: 'btn btn-dark', exclude: [0, 10] }); + var colvis = new $.fn.dataTable.ColVis(history_table, { buttonText: ' Select columns', buttonClass: 'btn btn-dark', exclude: [0, 11] }); $(colvis.button()).appendTo('div.colvis-button-bar'); clearSearchButton('history_table', history_table); diff --git a/data/interfaces/default/js/tables/history_table.js b/data/interfaces/default/js/tables/history_table.js index ec086ba2..6ff1d674 100644 --- a/data/interfaces/default/js/tables/history_table.js +++ b/data/interfaces/default/js/tables/history_table.js @@ -100,7 +100,18 @@ history_table_options = { }, { "targets": [4], - "data":"player", + "data":"platform", + "createdCell": function (td, cellData, rowData, row, col) { + if (cellData !== '') { + $(td).html(cellData); + } + }, + "width": "8%", + "className": "no-wrap hidden-md hidden-sm hidden-xs modal-control" + }, + { + "targets": [5], + "data": "player", "createdCell": function (td, cellData, rowData, row, col) { if (cellData !== '') { var transcode_dec = ''; @@ -114,11 +125,11 @@ history_table_options = { $(td).html('
' + transcode_dec + ' ' + cellData + '
'); } }, - "width": "15%", + "width": "12%", "className": "no-wrap hidden-md hidden-sm hidden-xs modal-control" }, { - "targets": [5], + "targets": [6], "data":"full_title", "createdCell": function (td, cellData, rowData, row, col) { if (cellData !== '') { @@ -145,7 +156,7 @@ history_table_options = { "width": "35%" }, { - "targets": [6], + "targets": [7], "data":"started", "createdCell": function (td, cellData, rowData, row, col) { if (cellData === null) { @@ -159,7 +170,7 @@ history_table_options = { "className": "no-wrap hidden-sm hidden-xs" }, { - "targets": [7], + "targets": [8], "data":"paused_counter", "render": function (data, type, full) { if (data !== null) { @@ -173,7 +184,7 @@ history_table_options = { "className": "no-wrap hidden-md hidden-sm hidden-xs" }, { - "targets": [8], + "targets": [9], "data":"stopped", "createdCell": function (td, cellData, rowData, row, col) { if (cellData === null) { @@ -187,7 +198,7 @@ history_table_options = { "className": "no-wrap hidden-sm hidden-xs" }, { - "targets": [9], + "targets": [10], "data":"duration", "render": function (data, type, full) { if (data !== null) { @@ -201,7 +212,7 @@ history_table_options = { "className": "no-wrap hidden-xs" }, { - "targets": [10], + "targets": [11], "data": "watched_status", "render": function (data, type, full) { if (data == 1) { @@ -462,6 +473,7 @@ function childTableFormat(rowData) { 'User' + 'IP Address' + 'Platform' + + 'Player' + 'Title' + 'Started' + 'Paused' + diff --git a/data/interfaces/default/js/tables/sync_table.js b/data/interfaces/default/js/tables/sync_table.js index 3aa118c6..f560eac7 100644 --- a/data/interfaces/default/js/tables/sync_table.js +++ b/data/interfaces/default/js/tables/sync_table.js @@ -67,13 +67,13 @@ sync_table_options = { }, { "targets": [4], - "data": "device_name", - "className": "no-wrap hidden-xs" + "data": "platform", + "className": "no-wrap hidden-sm hidden-xs" }, { "targets": [5], - "data": "platform", - "className": "no-wrap hidden-sm hidden-xs" + "data": "device_name", + "className": "no-wrap hidden-xs" }, { "targets": [6], diff --git a/data/interfaces/default/js/tables/user_ips.js b/data/interfaces/default/js/tables/user_ips.js index de008320..506fe43a 100644 --- a/data/interfaces/default/js/tables/user_ips.js +++ b/data/interfaces/default/js/tables/user_ips.js @@ -49,7 +49,18 @@ user_ip_table_options = { }, { "targets": [2], - "data":"platform", + "data": "platform", + "createdCell": function (td, cellData, rowData, row, col) { + if (cellData !== '') { + $(td).html(cellData); + } + }, + "width": "15%", + "className": "no-wrap hidden-md hidden-sm hidden-xs modal-control" + }, + { + "targets": [3], + "data":"player", "createdCell": function (td, cellData, rowData, row, col) { if (cellData) { var transcode_dec = ''; @@ -69,7 +80,7 @@ user_ip_table_options = { "className": "no-wrap hidden-md hidden-sm hidden-xs modal-control" }, { - "targets": [3], + "targets": [4], "data":"last_watched", "createdCell": function (td, cellData, rowData, row, col) { if (cellData !== '') { @@ -94,10 +105,11 @@ user_ip_table_options = { } } }, + "width": "30%", "className": "hidden-sm hidden-xs" }, { - "targets": [4], + "targets": [5], "data":"play_count", "searchable": false, "width": "10%" diff --git a/data/interfaces/default/js/tables/users.js b/data/interfaces/default/js/tables/users.js index 04bf631b..78240a3e 100644 --- a/data/interfaces/default/js/tables/users.js +++ b/data/interfaces/default/js/tables/users.js @@ -64,7 +64,7 @@ users_list_table_options = { $(td).html(cellData); } }, - "width": "12%", + "width": "10%", "className": "edit-user-control no-wrap" }, { @@ -78,7 +78,7 @@ users_list_table_options = { } }, "searchable": false, - "width": "12%", + "width": "10%", "className": "no-wrap hidden-xs" }, { @@ -99,12 +99,25 @@ users_list_table_options = { $(td).html('n/a'); } }, - "width": "12%", + "width": "10%", "className": "no-wrap hidden-md hidden-sm hidden-xs modal-control-ip" }, { "targets": [5], - "data":"platform", + "data": "platform", + "createdCell": function (td, cellData, rowData, row, col) { + if (cellData !== '') { + $(td).html(cellData); + } else { + $(td).html('n/a'); + } + }, + "width": "10%", + "className": "no-wrap hidden-md hidden-sm hidden-xs modal-control" + }, + { + "targets": [6], + "data":"player", "createdCell": function (td, cellData, rowData, row, col) { if (cellData) { var transcode_dec = ''; @@ -120,11 +133,11 @@ users_list_table_options = { $(td).html('n/a'); } }, - "width": "12%", + "width": "15%", "className": "no-wrap hidden-md hidden-sm hidden-xs modal-control" }, { - "targets": [6], + "targets": [7], "data":"last_watched", "createdCell": function (td, cellData, rowData, row, col) { if (cellData !== '') { @@ -153,7 +166,7 @@ users_list_table_options = { "className": "hidden-sm hidden-xs" }, { - "targets": [7], + "targets": [8], "data": "plays", "searchable": false, "width": "10%" diff --git a/data/interfaces/default/sync.html b/data/interfaces/default/sync.html index 7378ad77..bad24c0c 100644 --- a/data/interfaces/default/sync.html +++ b/data/interfaces/default/sync.html @@ -29,8 +29,8 @@ Username Title Type - Device Platform + Device Total Size Total Items Converted diff --git a/data/interfaces/default/user.html b/data/interfaces/default/user.html index fa90d112..46babfaf 100644 --- a/data/interfaces/default/user.html +++ b/data/interfaces/default/user.html @@ -85,11 +85,11 @@ from plexpy import helpers
- Platform Stats + Player Stats
-
+
Loading data...

@@ -133,6 +133,7 @@ from plexpy import helpers Last Seen IP Address Last Platform + Last Player Last Watched Play Count @@ -170,6 +171,7 @@ from plexpy import helpers User IP Address Platform + Player Title Started Paused @@ -207,8 +209,8 @@ from plexpy import helpers Username Title Type - Device Platform + Device Total Size Total Items Converted @@ -309,11 +311,11 @@ from plexpy import helpers // Populate platform stats $.ajax({ - url: 'get_user_platform_stats', + url: 'get_user_player_stats', async: true, data: { user_id: user_id, user: '${data['username']}' }, complete: function(xhr, status) { - $("#user-platform-stats").html(xhr.responseText); + $("#user-player-stats").html(xhr.responseText); } }); @@ -332,7 +334,7 @@ from plexpy import helpers history_table = $('#history_table').DataTable(history_table_options); history_table.column(2).visible(false); - var colvis = new $.fn.dataTable.ColVis(history_table, { buttonText: ' Select columns', buttonClass: 'btn btn-dark', exclude: [0, 10] }); + var colvis = new $.fn.dataTable.ColVis(history_table, { buttonText: ' Select columns', buttonClass: 'btn btn-dark', exclude: [0, 11] }); $(colvis.button()).appendTo('#button-bar-history'); clearSearchButton('history_table', history_table); diff --git a/data/interfaces/default/user_platform_stats.html b/data/interfaces/default/user_player_stats.html similarity index 57% rename from data/interfaces/default/user_platform_stats.html rename to data/interfaces/default/user_player_stats.html index afd1d6b3..7aab53b6 100644 --- a/data/interfaces/default/user_platform_stats.html +++ b/data/interfaces/default/user_player_stats.html @@ -11,8 +11,9 @@ data[array_index] :: Usable parameters == Global keys == result_id Returns a unique identifier for the result. -platform_name Returns the name of the platform. -total_plays Returns the play count for the platform. +player_name Returns the name of the player. +platform_type Returns the name of the platform +total_plays Returns the play count for the player. DOCUMENTATION :: END @@ -20,13 +21,13 @@ DOCUMENTATION :: END % if data != None: % for a in data:
    -
    +
  • - -
    - ${a['platform_name']} + +
    + ${a['player_name']}
    -
    +

    ${a['total_plays']}

    plays

    @@ -34,7 +35,7 @@ DOCUMENTATION :: END
% endfor % else: diff --git a/data/interfaces/default/users.html b/data/interfaces/default/users.html index b493f997..f4bc65c2 100644 --- a/data/interfaces/default/users.html +++ b/data/interfaces/default/users.html @@ -29,6 +29,7 @@ Last Seen Last Known IP Last Platform + Last Player Last Watched Total Plays diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index 7718de11..d10dc7e0 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -42,6 +42,7 @@ class DataFactory(object): 'session_history.user_id', 'session_history.user', '(CASE WHEN users.friendly_name IS NULL THEN user ELSE users.friendly_name END) as friendly_name', + 'platform', 'player', 'ip_address', 'session_history_metadata.media_type', @@ -104,6 +105,12 @@ class DataFactory(object): else: watched_status = 0 + # Rename Mystery platform names + platform_names = {'Mystery 3': 'Playstation 3', + 'Mystery 4': 'Playstation 4', + 'Mystery 5': 'Xbox 360'} + platform = platform_names.get(item["platform"], item["platform"]) + row = {"reference_id": item["reference_id"], "id": item["id"], "date": item["date"], @@ -114,6 +121,7 @@ class DataFactory(object): "user_id": item["user_id"], "user": item["user"], "friendly_name": item["friendly_name"], + "platform": platform, "player": item["player"], "ip_address": item["ip_address"], "media_type": item["media_type"], diff --git a/plexpy/users.py b/plexpy/users.py index d6b32c5b..1983a290 100644 --- a/plexpy/users.py +++ b/plexpy/users.py @@ -32,7 +32,8 @@ class Users(object): 'MAX(session_history.started) as last_seen', 'session_history.ip_address as ip_address', 'COUNT(session_history.id) as plays', - 'session_history.player as platform', + 'session_history.platform as platform', + 'session_history.player as player', 'session_history_metadata.full_title as last_watched', 'session_history_metadata.thumb', 'session_history_metadata.parent_thumb', @@ -83,12 +84,19 @@ class Users(object): else: user_thumb = item['user_thumb'] + # Rename Mystery platform names + platform_names = {'Mystery 3': 'Playstation 3', + 'Mystery 4': 'Playstation 4', + 'Mystery 5': 'Xbox 360'} + platform = platform_names.get(item["platform"], item["platform"]) + row = {"id": item['id'], "plays": item['plays'], "last_seen": item['last_seen'], "friendly_name": item['friendly_name'], "ip_address": item['ip_address'], - "platform": item['platform'], + "platform": platform, + "player": item['player'], "last_watched": item['last_watched'], "thumb": thumb, "media_type": item['media_type'], @@ -121,7 +129,8 @@ class Users(object): 'session_history.started as last_seen', 'session_history.ip_address as ip_address', 'COUNT(session_history.id) as play_count', - 'session_history.player as platform', + 'session_history.platform as platform', + 'session_history.player as player', 'session_history_metadata.full_title as last_watched', 'session_history_metadata.thumb', 'session_history_metadata.parent_thumb', @@ -169,11 +178,18 @@ class Users(object): else: thumb = item["thumb"] + # Rename Mystery platform names + platform_names = {'Mystery 3': 'Playstation 3', + 'Mystery 4': 'Playstation 4', + 'Mystery 5': 'Xbox 360'} + platform = platform_names.get(item["platform"], item["platform"]) + row = {"id": item['id'], "last_seen": item['last_seen'], "ip_address": item['ip_address'], "play_count": item['play_count'], - "platform": item['platform'], + "platform": platform, + "player": item['player'], "last_watched": item['last_watched'], "thumb": thumb, "media_type": item['media_type'], @@ -490,10 +506,10 @@ class Users(object): return user_watch_time_stats - def get_user_platform_stats(self, user=None, user_id=None): + def get_user_player_stats(self, user=None, user_id=None): monitor_db = database.MonitorDatabase() - platform_stats = [] + player_stats = [] result_id = 0 try: @@ -522,12 +538,12 @@ class Users(object): 'Mystery 5': 'Xbox 360'} platform_type = platform_names.get(item[2], item[2]) - row = {'platform_name': item[0], + row = {'player_name': item[0], 'platform_type': platform_type, 'total_plays': item[1], 'result_id': result_id } - platform_stats.append(row) + player_stats.append(row) result_id += 1 - return platform_stats \ No newline at end of file + return player_stats \ No newline at end of file diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 3129e493..7cdee875 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -813,17 +813,17 @@ class WebInterface(object): return serve_template(templatename="user_watch_time_stats.html", data=None, title="Watch Stats") @cherrypy.expose - def get_user_platform_stats(self, user=None, user_id=None, **kwargs): + def get_user_player_stats(self, user=None, user_id=None, **kwargs): user_data = users.Users() - result = user_data.get_user_platform_stats(user_id=user_id, user=user) + result = user_data.get_user_player_stats(user_id=user_id, user=user) if result: - return serve_template(templatename="user_platform_stats.html", data=result, - title="Platform Stats") + return serve_template(templatename="user_player_stats.html", data=result, + title="Player Stats") else: logger.warn('Unable to retrieve data.') - return serve_template(templatename="user_platform_stats.html", data=None, title="Platform Stats") + return serve_template(templatename="user_player_stats.html", data=None, title="Player Stats") @cherrypy.expose def get_item_children(self, rating_key='', **kwargs):