From c5ea50d480071c63025031ff89055f8978c20352 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Wed, 30 Sep 2020 15:54:18 -0700 Subject: [PATCH] Improve playlist view on info page --- data/interfaces/default/info.html | 4 +- .../default/info_children_list.html | 50 +++++++++++++++++-- .../default/js/tables/playlists_table.js | 2 +- plexpy/pmsconnect.py | 10 +++- plexpy/webserve.py | 4 +- 5 files changed, 58 insertions(+), 12 deletions(-) diff --git a/data/interfaces/default/info.html b/data/interfaces/default/info.html index e33e919f..08bd0df6 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'): + % elif data['media_type'] in ('movie', 'collection', 'playlist'):
  • ${data['library_name']}
  • ${data['title']}
  • @@ -152,8 +152,6 @@ DOCUMENTATION :: END
  • ${data['parent_title']}
  • Track ${data['media_index']} - ${data['title']}
  • - % elif data['media_type'] == 'playlist': -
  • ${data['title']}
  • % endif diff --git a/data/interfaces/default/info_children_list.html b/data/interfaces/default/info_children_list.html index 1fbd29ce..d63a1f0b 100644 --- a/data/interfaces/default/info_children_list.html +++ b/data/interfaces/default/info_children_list.html @@ -122,10 +122,10 @@ DOCUMENTATION :: END ${child['title']} - % elif data['children_type'] == 'track' or media_type == 'playlist': - <% i = 'even' if loop.index % 2 == 0 else 'odd' %> -
    -  ${child['media_index'] or loop.index + 1} + % elif data['children_type'] == 'track': + <% e = 'even' if loop.index % 2 == 0 else 'odd' %> +
    +  ${child['media_index']} ${child['title']} % if child['original_title']: @@ -137,12 +137,54 @@ DOCUMENTATION :: END
    + % elif media_type == 'playlist': + <% e = 'even' if loop.index % 2 == 0 else 'odd' %> +
    +  ${loop.index + 1} + + % if child['media_type'] == 'movie': +   + + ${child['title']} + + (${child['year']}) + % elif child['media_type'] == 'episode': +   + + ${child['grandparent_title']} + - + + ${child['title']} + + (S${child['parent_media_index']} · E${child['media_index']}) + % elif child['media_type'] == 'track': +   + + ${child['title']} + - + + ${child['grandparent_title']} + + (${child['parent_title']}) + % endif + + + <% f = 'h:mm:ss' if cast_to_int(child['duration']) >= 3600000 else 'm:ss' %> + + +
    % endif % endif % endfor
    + % endif % endif diff --git a/data/interfaces/default/js/tables/playlists_table.js b/data/interfaces/default/js/tables/playlists_table.js index a11f1452..4ed4216a 100644 --- a/data/interfaces/default/js/tables/playlists_table.js +++ b/data/interfaces/default/js/tables/playlists_table.js @@ -24,7 +24,7 @@ playlists_table_options = { "data": "title", "createdCell": function (td, cellData, rowData, row, col) { if (cellData !== '') { - $(td).html('' + cellData + ''); + $(td).html('' + cellData + ''); } }, "width": "50%", diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index 576f209f..05248ab7 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -31,6 +31,7 @@ if plexpy.PYTHON2: import common import helpers import http_handler + import libraries import logger import plextv import session @@ -40,6 +41,7 @@ else: from plexpy import common from plexpy import helpers from plexpy import http_handler + from plexpy import libraries from plexpy import logger from plexpy import plextv from plexpy import session @@ -610,7 +612,7 @@ class PmsConnect(object): return output - def get_metadata_details(self, rating_key='', sync_id='', plex_guid='', + def get_metadata_details(self, rating_key='', sync_id='', plex_guid='', section_id='', skip_cache=False, cache_key=None, return_cache=False, media_info=True): """ Return processed and validated metadata list for requested item. @@ -687,9 +689,13 @@ class PmsConnect(object): if metadata_main.nodeName == 'Directory' and metadata_type == 'photo': metadata_type = 'photo_album' - section_id = helpers.get_xml_attr(a, 'librarySectionID') + section_id = helpers.get_xml_attr(a, 'librarySectionID') or section_id library_name = helpers.get_xml_attr(a, 'librarySectionTitle') + if not library_name and section_id: + library_data = libraries.Libraries().get_details(section_id) + library_name = library_data['section_name'] + directors = [] writers = [] actors = [] diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 609c77dd..d692f26a 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -4399,7 +4399,7 @@ class WebInterface(object): @cherrypy.expose @requireAuth() - def info(self, rating_key=None, guid=None, source=None, **kwargs): + def info(self, rating_key=None, guid=None, source=None, section_id=None, **kwargs): if rating_key and not str(rating_key).isdigit(): raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT) @@ -4413,7 +4413,7 @@ class WebInterface(object): # Try to get metadata from the Plex server first if rating_key: pms_connect = pmsconnect.PmsConnect() - metadata = pms_connect.get_metadata_details(rating_key=rating_key) + metadata = pms_connect.get_metadata_details(rating_key=rating_key, section_id=section_id) # If the item is not found on the Plex server, get the metadata from history if not metadata and source == 'history':