From 91c647f9aef8297020c21786dd576425cc3acbc6 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Thu, 29 Mar 2018 19:54:43 -0700 Subject: [PATCH] Show extra type on activity cards --- .../default/current_activity_instance.html | 26 ++++++++++++------- data/interfaces/default/index.html | 16 +++++------- plexpy/common.py | 10 +++++++ plexpy/pmsconnect.py | 8 ++++-- 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/data/interfaces/default/current_activity_instance.html b/data/interfaces/default/current_activity_instance.html index 1aa409d9..1670077c 100644 --- a/data/interfaces/default/current_activity_instance.html +++ b/data/interfaces/default/current_activity_instance.html @@ -64,7 +64,7 @@ DOCUMENTATION :: END from collections import defaultdict from urllib import quote from plexpy import helpers - from plexpy.common import VIDEO_RESOLUTION_OVERRIDES, AUDIO_CODEC_OVERRIDES + from plexpy.common import VIDEO_RESOLUTION_OVERRIDES, AUDIO_CODEC_OVERRIDES, EXTRA_TYPES import plexpy %> <% @@ -108,7 +108,11 @@ DOCUMENTATION :: END
% elif data['media_type'] in ('photo', 'clip'): -
+ % if data['extra_type']: +
+ % else: +
+ % endif % else:
% endif @@ -301,14 +305,13 @@ DOCUMENTATION :: END
  • Bandwidth
    - % if data['media_type'] != 'photo' and helpers.cast_to_int(data['bandwidth']): + % if data['media_type'] != 'photo' and data['bandwidth'] != 'Unknown': <% bw = helpers.cast_to_int(data['bandwidth']) - if bw != "Unknown": - if bw > 1000: - bw = str(round(bw / 1000.0, 1)) + ' Mbps' - else: - bw = str(bw) + ' kbps' + if bw > 1000: + bw = str(round(bw / 1000.0, 1)) + ' Mbps' + else: + bw = str(bw) + ' kbps' %> ${bw} @@ -440,7 +443,12 @@ DOCUMENTATION :: END % elif data['media_type'] == 'photo': ${data['title']} % else: - ${data['year']} + % if data['extra_type']: + <% extra_type = EXTRA_TYPES.get(data['extra_type'], data['sub_type'].capitalize()) %> + ${data['year']} (${extra_type}) + % else: + ${data['year']} + % endif % endif % elif data['channel_title']: ${data['channel_title']} diff --git a/data/interfaces/default/index.html b/data/interfaces/default/index.html index c7bf5ba3..0df99af8 100644 --- a/data/interfaces/default/index.html +++ b/data/interfaces/default/index.html @@ -515,17 +515,15 @@ $('#location-' + key).html(s.location.toUpperCase()); - if (s.media_type !== 'photo' && parseInt(s.bandwidth)) { - var bw = parseInt(s.bandwidth); - if (bw !== "Unknown") { - if (bw > 1000) { - bw = (bw / 1000).toFixed(1) + ' Mbps'; - } else { - bw = bw + ' kbps' - } + if (s.media_type !== 'photo' && s.bandwidth !== 'Unknown') { + var bw = parseInt(s.bandwidth) || 0; + if (bw > 1000) { + bw = (bw / 1000).toFixed(1) + ' Mbps'; + } else { + bw = bw + ' kbps' } $('#stream-bandwidth-' + key).html(bw); - } + }; // Update the stream progress times $('#stream-eta-' + key).html(moment().add(parseInt(s.duration) - parseInt(s.view_offset), 'milliseconds').format(time_format)); diff --git a/plexpy/common.py b/plexpy/common.py index 553b85d9..0ffd3d65 100644 --- a/plexpy/common.py +++ b/plexpy/common.py @@ -171,6 +171,16 @@ HW_ENCODERS = [ 'nvenc' ] +EXTRA_TYPES = { + '1': 'Trailer', + '2': 'Deleted Scene', + '3': 'Interview', + '5': 'Behind the Scenes', + '6': 'Scene', + '10': 'Featurette', + '11': 'Short' +} + SCHEDULER_LIST = [ 'Check GitHub for updates', 'Check for server response', diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index b1de933b..21f8afdb 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -1096,7 +1096,9 @@ class PmsConnect(object): 'genres': genres, 'labels': labels, 'collections': collections, - 'full_title': helpers.get_xml_attr(metadata_main, 'title') + 'full_title': helpers.get_xml_attr(metadata_main, 'title'), + 'extra_type': helpers.get_xml_attr(metadata_main, 'extraType'), + 'sub_type': helpers.get_xml_attr(metadata_main, 'subtype') } else: @@ -1687,7 +1689,9 @@ class PmsConnect(object): 'audio_channel_layout': common.AUDIO_CHANNELS.get(audio_channels, audio_channels), 'channel_icon': helpers.get_xml_attr(session, 'sourceIcon'), 'channel_title': helpers.get_xml_attr(session, 'sourceTitle'), - 'live': int(helpers.get_xml_attr(session, 'live') == '1') + 'live': int(helpers.get_xml_attr(session, 'live') == '1'), + 'extra_type': helpers.get_xml_attr(session, 'extraType'), + 'sub_type': helpers.get_xml_attr(session, 'subtype') } else: channel_stream = 0