Improve playlist view on info page

This commit is contained in:
JonnyWong16 2020-09-30 15:54:18 -07:00
parent 84207effab
commit c5ea50d480
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
5 changed files with 58 additions and 12 deletions

View file

@ -112,7 +112,7 @@ DOCUMENTATION :: END
<li class="active metadata-xml">${data['title']}</li> <li class="active metadata-xml">${data['title']}</li>
% endif % endif
% endif % endif
% elif data['media_type'] in ('movie', 'collection'): % elif data['media_type'] in ('movie', 'collection', 'playlist'):
<li><a href="${page('library', data['section_id'])}">${data['library_name']}</a></li> <li><a href="${page('library', data['section_id'])}">${data['library_name']}</a></li>
<span class="breadcrumb-arrow"><i class="fa fa-chevron-right"></i></span> <span class="breadcrumb-arrow"><i class="fa fa-chevron-right"></i></span>
<li class="active metadata-xml">${data['title']}</li> <li class="active metadata-xml">${data['title']}</li>
@ -152,8 +152,6 @@ DOCUMENTATION :: END
<li><a href="${page('info', data['parent_rating_key'])}">${data['parent_title']}</a></li> <li><a href="${page('info', data['parent_rating_key'])}">${data['parent_title']}</a></li>
<span class="breadcrumb-arrow"><i class="fa fa-chevron-right"></i></span> <span class="breadcrumb-arrow"><i class="fa fa-chevron-right"></i></span>
<li class="active metadata-xml">Track ${data['media_index']} - ${data['title']}</li> <li class="active metadata-xml">Track ${data['media_index']} - ${data['title']}</li>
% elif data['media_type'] == 'playlist':
<li class="active metadata-xml">${data['title']}</li>
% endif % endif
</ul> </ul>
</div> </div>

View file

@ -122,10 +122,10 @@ DOCUMENTATION :: END
<a href="${page('info', child['rating_key'])}" title="${child['title']}">${child['title']}</a> <a href="${page('info', child['rating_key'])}" title="${child['title']}">${child['title']}</a>
</h3> </h3>
</div> </div>
% elif data['children_type'] == 'track' or media_type == 'playlist': % elif data['children_type'] == 'track':
<% i = 'even' if loop.index % 2 == 0 else 'odd' %> <% e = 'even' if loop.index % 2 == 0 else 'odd' %>
<div class="item-children-list-item-${i}"> <div class="item-children-list-item-${e}">
<span class="item-children-list-item-index">&nbsp;${child['media_index'] or loop.index + 1}</span> <span class="item-children-list-item-index">&nbsp;${child['media_index']}</span>
<span class="item-children-list-item-title"> <span class="item-children-list-item-title">
<a href="${page('info', child['rating_key'])}" title="${child['title']}">${child['title']}</a> <a href="${page('info', child['rating_key'])}" title="${child['title']}">${child['title']}</a>
% if child['original_title']: % if child['original_title']:
@ -137,12 +137,54 @@ DOCUMENTATION :: END
<script>$('#item-children-list-item-duration-${loop.index + 1}').text(moment.utc(${child['duration']}).format("${f}"));</script> <script>$('#item-children-list-item-duration-${loop.index + 1}').text(moment.utc(${child['duration']}).format("${f}"));</script>
</span> </span>
</div> </div>
% elif media_type == 'playlist':
<% e = 'even' if loop.index % 2 == 0 else 'odd' %>
<div class="item-children-list-item-${e}">
<span class="item-children-list-item-index">&nbsp;${loop.index + 1}</span>
<span class="item-children-list-item-title">
% if child['media_type'] == 'movie':
<span class="media-type-tooltip" data-toggle="tooltip" title="Movie"><i class="fa fa-film fa-fw"></i></span>&nbsp;
<a href="${page('info', child['rating_key'])}" title="${child['title']}">
${child['title']}
</a>
<span class="text-muted"> (${child['year']})</span>
% elif child['media_type'] == 'episode':
<span class="media-type-tooltip" data-toggle="tooltip" title="Episode"><i class="fa fa-television fa-fw"></i></span>&nbsp;
<a href="${page('info', child['grandparent_rating_key'])}" title="${child['grandparent_title']}">
${child['grandparent_title']}
</a> -
<a href="${page('info', child['rating_key'])}" title="${child['title']}">
${child['title']}
</a>
<span class="text-muted"> (<a class="no-highlight" href="${page('info', child['parent_rating_key'])}" title="${child['parent_title']}">S${child['parent_media_index']}</a> &middot; <a class="no-highlight" href="${page('info', child['rating_key'])}" title="${child['title']}">E${child['media_index']}</a>)</span>
% elif child['media_type'] == 'track':
<span class="media-type-tooltip" data-toggle="tooltip" title="Track"><i class="fa fa-music fa-fw"></i></span>&nbsp;
<a href="${page('info', child['rating_key'])}" title="${child['title']}">
${child['title']}
</a> -
<a href="${page('info', child['grandparent_rating_key'])}" title="${child['grandparent_title']}">
${child['grandparent_title']}
</a>
<span class="text-muted"> (<a class="no-highlight" href="${page('info', child['parent_rating_key'])}" title="${child['parent_title']}">${child['parent_title']}</a>)</span>
% endif
</span>
<span class="item-children-list-item-duration" id="item-children-list-item-duration-${loop.index + 1}">
<% f = 'h:mm:ss' if cast_to_int(child['duration']) >= 3600000 else 'm:ss' %>
<script>$('#item-children-list-item-duration-${loop.index + 1}').text(moment.utc(${child['duration']}).format("${f}"));</script>
</span>
</div>
% endif % endif
</li> </li>
% endif % endif
% endfor % endfor
</ul> </ul>
</div> </div>
<script>
$('body').tooltip({
selector: '[data-toggle="tooltip"]',
container: 'body'
});
</script>
% endif % endif
% endif % endif

View file

@ -24,7 +24,7 @@ playlists_table_options = {
"data": "title", "data": "title",
"createdCell": function (td, cellData, rowData, row, col) { "createdCell": function (td, cellData, rowData, row, col) {
if (cellData !== '') { if (cellData !== '') {
$(td).html('<a href="' + page('info', rowData['ratingKey']) + '">' + cellData + '</a>'); $(td).html('<a href="' + page('info', rowData['ratingKey']) + '&section_id=' + rowData['librarySectionID'] +'">' + cellData + '</a>');
} }
}, },
"width": "50%", "width": "50%",

View file

@ -31,6 +31,7 @@ if plexpy.PYTHON2:
import common import common
import helpers import helpers
import http_handler import http_handler
import libraries
import logger import logger
import plextv import plextv
import session import session
@ -40,6 +41,7 @@ else:
from plexpy import common from plexpy import common
from plexpy import helpers from plexpy import helpers
from plexpy import http_handler from plexpy import http_handler
from plexpy import libraries
from plexpy import logger from plexpy import logger
from plexpy import plextv from plexpy import plextv
from plexpy import session from plexpy import session
@ -610,7 +612,7 @@ class PmsConnect(object):
return output 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): skip_cache=False, cache_key=None, return_cache=False, media_info=True):
""" """
Return processed and validated metadata list for requested item. 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': if metadata_main.nodeName == 'Directory' and metadata_type == 'photo':
metadata_type = 'photo_album' 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') 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 = [] directors = []
writers = [] writers = []
actors = [] actors = []

View file

@ -4399,7 +4399,7 @@ class WebInterface(object):
@cherrypy.expose @cherrypy.expose
@requireAuth() @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(): if rating_key and not str(rating_key).isdigit():
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT) raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
@ -4413,7 +4413,7 @@ class WebInterface(object):
# Try to get metadata from the Plex server first # Try to get metadata from the Plex server first
if rating_key: if rating_key:
pms_connect = pmsconnect.PmsConnect() 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 the item is not found on the Plex server, get the metadata from history
if not metadata and source == 'history': if not metadata and source == 'history':