diff --git a/data/interfaces/default/info.html b/data/interfaces/default/info.html
index 7187840e..3e57ecef 100644
--- a/data/interfaces/default/info.html
+++ b/data/interfaces/default/info.html
@@ -112,7 +112,7 @@ DOCUMENTATION :: END
${data['title']}
% endif
% endif
- % elif data['media_type'] in ('movie', 'collection', 'playlist'):
+ % elif data['media_type'] in ('movie', 'collection'):
${data['library_name']}
${data['title']}
@@ -166,6 +166,14 @@ DOCUMENTATION :: END
${data['parent_title']}
${data['title']}
+ % elif data['media_type'] == 'playlist':
+ % if user_info.get('user_id'):
+ ${user_info.get('friendly_name')}
+ % else:
+ ${data['library_name']}
+ % endif
+
+ ${data['title']}
% endif
diff --git a/data/interfaces/default/js/tables/playlists_table.js b/data/interfaces/default/js/tables/playlists_table.js
index 1942060d..25474040 100644
--- a/data/interfaces/default/js/tables/playlists_table.js
+++ b/data/interfaces/default/js/tables/playlists_table.js
@@ -28,7 +28,13 @@ playlists_table_options = {
if (rowData['smart']) {
smart = ' '
}
- $(td).html('' + smart + cellData + '');
+ var breadcrumb = '';
+ if (rowData['userID']) {
+ breadcrumb = '&user_id=' + rowData['userID'];
+ } else if (rowData['librarySectionID']) {
+ breadcrumb = '§ion_id=' + rowData['librarySectionID'];
+ }
+ $(td).html('' + smart + cellData + '');
}
},
"width": "60%",
diff --git a/data/interfaces/default/library.html b/data/interfaces/default/library.html
index 61da8457..55233e2a 100644
--- a/data/interfaces/default/library.html
+++ b/data/interfaces/default/library.html
@@ -331,12 +331,12 @@ DOCUMENTATION :: END
Export collections
+ % endif
- % endif
@@ -379,12 +379,12 @@ DOCUMENTATION :: END
Export playlists
+ % endif
- % endif
@@ -546,9 +546,9 @@ DOCUMENTATION :: END
-
+
+
@@ -420,6 +471,8 @@ DOCUMENTATION :: END
$.fn.dataTable.tables({ visible: true, api: true }).columns.adjust();
});
+ $(".inactive-user-tooltip").tooltip();
+
function loadHistoryTable(media_type) {
// Build watch history table
history_table_options.ajax = {
@@ -451,6 +504,49 @@ DOCUMENTATION :: END
});
}
+ $('a[href="#tabs-history"]').on('shown.bs.tab', function() {
+ if (typeof(history_table) === 'undefined') {
+ var media_type = getLocalStorage('user_' + user_id + '-history_media_type', 'all');
+ $('#history-' + media_type).prop('checked', true);
+ $('#history-' + media_type).closest('label').addClass('active');
+ loadHistoryTable(media_type);
+ }
+ });
+
+ $("#refresh-history-list").click(function () {
+ history_table.draw();
+ });
+
+ function loadPlaylistsTable() {
+ // Build playlists table
+ playlists_table_options.ajax = {
+ url: 'get_playlists_list',
+ type: 'POST',
+ data: function ( d ) {
+ return {
+ json_data: JSON.stringify( d ),
+ user_id: user_id
+ };
+ }
+ };
+ playlists_table = $('#playlists_table-SID-${data["user_id"]}').DataTable(playlists_table_options);
+
+ var colvis = new $.fn.dataTable.ColVis(playlists_table, { buttonText: ' Select columns', buttonClass: 'btn btn-dark' });
+ $(colvis.button()).appendTo('#button-bar-playlists');
+
+ clearSearchButton('playlists_table-SID-${data["user_id"]}', playlists_table);
+ }
+
+ $('a[href="#tabs-playlists"]').on('shown.bs.tab', function() {
+ if (typeof(playlists_table) === 'undefined') {
+ loadPlaylistsTable();
+ }
+ });
+
+ $("#refresh-playlists-table").click(function () {
+ playlists_table.draw();
+ });
+
function loadSyncTable() {
// Build user sync table
sync_table_options.ajax = {
@@ -466,6 +562,16 @@ DOCUMENTATION :: END
clearSearchButton('sync_table-UID-${data["user_id"]}', sync_table);
}
+ $('a[href="#tabs-synceditems"]').on('shown.bs.tab', function() {
+ if (typeof(sync_table) === 'undefined') {
+ loadSyncTable(user_id);
+ }
+ });
+
+ $("#refresh-syncs-list").click(function() {
+ sync_table.ajax.reload();
+ });
+
function loadIPAddressTable() {
// Build user IP table
user_ip_table_options.ajax = {
@@ -483,6 +589,16 @@ DOCUMENTATION :: END
clearSearchButton('user_ip_table-UID-${data["user_id"]}', user_ip_table);
}
+ $('a[href="#tabs-ipaddresses"]').on('shown.bs.tab', function() {
+ if (typeof(user_ip_table) === 'undefined') {
+ loadIPAddressTable(user_id);
+ }
+ });
+
+ $("#refresh-ip-address-list").click(function () {
+ user_ip_table.draw();
+ });
+
function loadLoginTable() {
// Build user login table
login_log_table_options.ajax = {
@@ -504,51 +620,16 @@ DOCUMENTATION :: END
clearSearchButton('login_log_table-UID-${data["user_id"]}', login_log_table);
}
- $('a[href="#tabs-history"]').on('shown.bs.tab', function() {
- if (typeof(history_table) === 'undefined') {
- var media_type = getLocalStorage('user_' + user_id + '-history_media_type', 'all');
- $('#history-' + media_type).prop('checked', true);
- $('#history-' + media_type).closest('label').addClass('active');
- loadHistoryTable(media_type);
- }
- });
-
- $('a[href="#tabs-synceditems"]').on('shown.bs.tab', function() {
- if (typeof(sync_table) === 'undefined') {
- loadSyncTable(user_id);
- }
- });
-
- $('a[href="#tabs-ipaddresses"]').on('shown.bs.tab', function() {
- if (typeof(user_ip_table) === 'undefined') {
- loadIPAddressTable(user_id);
- }
- });
-
$('a[href="#tabs-tautullilogins"]').on('shown.bs.tab', function() {
if (typeof(login_log_table) === 'undefined') {
loadLoginTable(user_id);
}
});
- $("#refresh-history-list").click(function () {
- history_table.draw();
- });
-
- $("#refresh-syncs-list").click(function() {
- sync_table.ajax.reload();
- });
-
- $("#refresh-ip-address-list").click(function () {
- user_ip_table.draw();
- });
-
$("#refresh-login-list").click(function () {
login_log_table.draw();
});
- $(".inactive-user-tooltip").tooltip();
-
function recentlyWatched() {
// Populate recently watched
$.ajax({
diff --git a/plexpy/libraries.py b/plexpy/libraries.py
index 27dff12b..d30f71d6 100644
--- a/plexpy/libraries.py
+++ b/plexpy/libraries.py
@@ -142,7 +142,7 @@ def has_library_type(section_type):
return bool(result)
-def get_collections(section_id):
+def get_collections(section_id=None):
plex = Plex(plexpy.CONFIG.PMS_URL, session.get_session_user_token())
library = plex.get_library(section_id)
@@ -196,7 +196,7 @@ def get_collections_list(section_id=None, **kwargs):
'error': 'Unable to get collections: missing section_id.'}
return default_return
- collections = get_collections(section_id)
+ collections = get_collections(section_id=section_id)
# Get datatables JSON data
json_data = helpers.process_json_kwargs(json_kwargs=kwargs['json_data'])
@@ -230,20 +230,21 @@ def get_collections_list(section_id=None, **kwargs):
return data
-def get_playlists(section_id):
- plex = Plex(plexpy.CONFIG.PMS_URL, session.get_session_user_token())
-
- library = Libraries().get_details(section_id=section_id)
-
- if library['section_type'] == 'artist':
- playlist_type = 'audio'
- elif library['section_type'] == 'photo':
- playlist_type = 'photo'
+def get_playlists(section_id=None, user_id=None):
+ if user_id and not session.get_session_user_id():
+ import users
+ user_tokens = users.Users().get_tokens(user_id=user_id)
+ plex_token = user_tokens['server_token']
else:
- playlist_type = 'video'
+ plex_token = session.get_session_user_token()
- playlists = plex.plex.fetchItems(
- '/playlists?type=15&playlistType={}§ionID={}'.format(playlist_type, section_id))
+ plex = Plex(plexpy.CONFIG.PMS_URL, plex_token)
+
+ if user_id:
+ playlists = plex.plex.playlists()
+ else:
+ library = plex.get_library(section_id)
+ playlists = library.playlist()
playlists_list = []
for playlist in playlists:
@@ -254,22 +255,22 @@ def get_playlists(section_id):
'guid': playlist.guid,
'leafCount': playlist.leafCount,
'librarySectionID': section_id,
- 'librarySectionTitle': library['section_name'],
'playlistType': playlist.playlistType,
'ratingKey': playlist.ratingKey,
'smart': playlist.smart,
'summary': playlist.summary,
'title': playlist.title,
'type': playlist.type,
- 'updatedAt': helpers.datetime_to_iso(playlist.updatedAt)
+ 'updatedAt': helpers.datetime_to_iso(playlist.updatedAt),
+ 'userID': user_id
}
playlists_list.append(playlist_dict)
return playlists_list
-def get_playlists_list(section_id=None, **kwargs):
- if not section_id:
+def get_playlists_list(section_id=None, user_id=None, **kwargs):
+ if not section_id and not user_id:
default_return = {'recordsFiltered': 0,
'recordsTotal': 0,
'draw': 0,
@@ -277,7 +278,7 @@ def get_playlists_list(section_id=None, **kwargs):
'error': 'Unable to get playlists: missing section_id.'}
return default_return
- playlists = get_playlists(section_id)
+ playlists = get_playlists(section_id=section_id, user_id=user_id)
# Get datatables JSON data
json_data = helpers.process_json_kwargs(json_kwargs=kwargs['json_data'])
diff --git a/plexpy/webserve.py b/plexpy/webserve.py
index 84e203c0..36a9bd94 100644
--- a/plexpy/webserve.py
+++ b/plexpy/webserve.py
@@ -852,7 +852,7 @@ class WebInterface(object):
```
Required parameters:
- section_id (str): The id of the Plex library section, OR
+ section_id (str): The id of the Plex library section
Optional parameters:
None
@@ -884,12 +884,13 @@ class WebInterface(object):
@cherrypy.tools.json_out()
@requireAuth()
@addtoapi("get_playlists_table")
- def get_playlists_list(self, section_id=None, **kwargs):
+ def get_playlists_list(self, section_id=None, user_id=None, **kwargs):
""" Get the data on the Tautulli playlists tables.
```
Required parameters:
- section_id (str): The id of the Plex library section, OR
+ section_id (str): The section id of the Plex library, OR
+ user_id (str): The user id of the Plex user
Optional parameters:
None
@@ -912,7 +913,9 @@ class WebInterface(object):
("duration", True, True)]
kwargs['json_data'] = build_datatables_json(kwargs, dt_columns, "title")
- result = libraries.get_playlists_list(section_id=section_id, **kwargs)
+ result = libraries.get_playlists_list(section_id=section_id,
+ user_id=user_id,
+ **kwargs)
return result
@@ -4372,7 +4375,7 @@ class WebInterface(object):
@cherrypy.expose
@requireAuth()
- def info(self, rating_key=None, guid=None, source=None, section_id=None, **kwargs):
+ def info(self, rating_key=None, guid=None, source=None, section_id=None, user_id=None, **kwargs):
if rating_key and not str(rating_key).isdigit():
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
@@ -4383,6 +4386,12 @@ class WebInterface(object):
"pms_web_url": plexpy.CONFIG.PMS_WEB_URL
}
+ if user_id:
+ user_data = users.Users()
+ user_info = user_data.get_details(user_id=user_id)
+ else:
+ user_info = {}
+
# Try to get metadata from the Plex server first
if rating_key:
pms_connect = pmsconnect.PmsConnect()
@@ -4405,7 +4414,7 @@ class WebInterface(object):
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
return serve_template(templatename="info.html", metadata=metadata, title="Info",
- config=config, source=source)
+ config=config, source=source, user_info=user_info)
else:
if get_session_user_id():
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)