More rename, more -python2

This commit is contained in:
2021-02-05 17:29:23 +01:00
parent b867dc9be2
commit 1df28243c3
40 changed files with 1424 additions and 1412 deletions

View File

@@ -15,38 +15,21 @@
# You should have received a copy of the GNU General Public License
# along with Tautulli. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from future.builtins import next
from future.builtins import str
from future.builtins import object
import json
import os
import time
from future.moves.urllib.parse import quote, quote_plus, urlencode
from urllib.parse import quote_plus, quote, urlencode
from xml.dom.minidom import Node
import jellypy
if jellypy.PYTHON2:
import activity_processor
import common
import helpers
import http_handler
import libraries
import logger
import plextv
import session
import users
else:
from jellypy import activity_processor
from jellypy import common
from jellypy import helpers
from jellypy import http_handler
from jellypy import libraries
from jellypy import logger
from jellypy import plextv
from jellypy import session
from jellypy import users
from jellypy import activity_processor
from jellypy import common
from jellypy import helpers
from jellypy import http_handler
from jellypy import libraries
from jellypy import logger
from jellypy import plextv
from jellypy import session
from jellypy import users
def get_server_friendly_name():
@@ -217,7 +200,8 @@ class PmsConnect(object):
Output: array
"""
uri = '/library/sections/%s/recentlyAdded?X-Plex-Container-Start=%s&X-Plex-Container-Size=%s' % (section_id, start, count)
uri = '/library/sections/%s/recentlyAdded?X-Plex-Container-Start=%s&X-Plex-Container-Size=%s' % (
section_id, start, count)
request = self.request_handler.make_request(uri=uri,
request_type='GET',
output_format=output_format)
@@ -474,7 +458,7 @@ class PmsConnect(object):
return request
def get_recently_added_details(self, start='0', count='0', media_type='', section_id=''):
def get_recently_added_details(self, start='0', count='0', media_type='', section_id=''):
"""
Return processed and validated list of recently added items.
@@ -889,7 +873,7 @@ class PmsConnect(object):
'collections': show_details.get('collections', []),
'guids': show_details.get('guids', []),
'full_title': '{} - {}'.format(helpers.get_xml_attr(metadata_main, 'parentTitle'),
helpers.get_xml_attr(metadata_main, 'title')),
helpers.get_xml_attr(metadata_main, 'title')),
'children_count': helpers.cast_to_int(helpers.get_xml_attr(metadata_main, 'leafCount')),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
}
@@ -962,7 +946,7 @@ class PmsConnect(object):
'collections': show_details.get('collections', []),
'guids': show_details.get('guids', []),
'full_title': '{} - {}'.format(helpers.get_xml_attr(metadata_main, 'grandparentTitle'),
helpers.get_xml_attr(metadata_main, 'title')),
helpers.get_xml_attr(metadata_main, 'title')),
'children_count': helpers.cast_to_int(helpers.get_xml_attr(metadata_main, 'leafCount')),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
}
@@ -1063,7 +1047,7 @@ class PmsConnect(object):
'collections': collections,
'guids': guids,
'full_title': '{} - {}'.format(helpers.get_xml_attr(metadata_main, 'parentTitle'),
helpers.get_xml_attr(metadata_main, 'title')),
helpers.get_xml_attr(metadata_main, 'title')),
'children_count': helpers.cast_to_int(helpers.get_xml_attr(metadata_main, 'leafCount')),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
}
@@ -1117,7 +1101,7 @@ class PmsConnect(object):
'collections': album_details.get('collections', []),
'guids': album_details.get('guids', []),
'full_title': '{} - {}'.format(helpers.get_xml_attr(metadata_main, 'title'),
track_artist),
track_artist),
'children_count': helpers.cast_to_int(helpers.get_xml_attr(metadata_main, 'leafCount')),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
}
@@ -1217,8 +1201,9 @@ class PmsConnect(object):
'labels': photo_album_details.get('labels', []),
'collections': photo_album_details.get('collections', []),
'guids': photo_album_details.get('guids', []),
'full_title': '{} - {}'.format(helpers.get_xml_attr(metadata_main, 'parentTitle') or library_name,
helpers.get_xml_attr(metadata_main, 'title')),
'full_title': '{} - {}'.format(
helpers.get_xml_attr(metadata_main, 'parentTitle') or library_name,
helpers.get_xml_attr(metadata_main, 'title')),
'children_count': helpers.cast_to_int(helpers.get_xml_attr(metadata_main, 'leafCount')),
'live': int(helpers.get_xml_attr(metadata_main, 'live') == '1')
}
@@ -1385,7 +1370,8 @@ class PmsConnect(object):
'video_codec_level': helpers.get_xml_attr(stream, 'level'),
'video_bitrate': helpers.get_xml_attr(stream, 'bitrate'),
'video_bit_depth': helpers.get_xml_attr(stream, 'bitDepth'),
'video_chroma_subsampling': helpers.get_xml_attr(stream, 'chromaSubsampling'),
'video_chroma_subsampling': helpers.get_xml_attr(stream,
'chromaSubsampling'),
'video_color_primaries': helpers.get_xml_attr(stream, 'colorPrimaries'),
'video_color_range': helpers.get_xml_attr(stream, 'colorRange'),
'video_color_space': helpers.get_xml_attr(stream, 'colorSpace'),
@@ -1423,7 +1409,8 @@ class PmsConnect(object):
'subtitle_container': helpers.get_xml_attr(stream, 'container'),
'subtitle_format': helpers.get_xml_attr(stream, 'format'),
'subtitle_forced': int(helpers.get_xml_attr(stream, 'forced') == '1'),
'subtitle_location': 'external' if helpers.get_xml_attr(stream, 'key') else 'embedded',
'subtitle_location': 'external' if helpers.get_xml_attr(stream,
'key') else 'embedded',
'subtitle_language': helpers.get_xml_attr(stream, 'language'),
'subtitle_language_code': helpers.get_xml_attr(stream, 'languageCode'),
'selected': int(helpers.get_xml_attr(stream, 'selected') == '1')
@@ -1673,7 +1660,8 @@ class PmsConnect(object):
platform_name = next((v for k, v in common.PLATFORM_NAMES.items() if k in platform.lower()), 'default')
player_details = {'ip_address': helpers.get_xml_attr(player_info, 'address').split('::ffff:')[-1],
'ip_address_public': helpers.get_xml_attr(player_info, 'remotePublicAddress').split('::ffff:')[-1],
'ip_address_public':
helpers.get_xml_attr(player_info, 'remotePublicAddress').split('::ffff:')[-1],
'device': helpers.get_xml_attr(player_info, 'device'),
'platform': platform,
'platform_name': platform_name,
@@ -1681,7 +1669,8 @@ class PmsConnect(object):
'product': helpers.get_xml_attr(player_info, 'product'),
'product_version': helpers.get_xml_attr(player_info, 'version'),
'profile': helpers.get_xml_attr(player_info, 'profile'),
'player': helpers.get_xml_attr(player_info, 'title') or helpers.get_xml_attr(player_info, 'product'),
'player': helpers.get_xml_attr(player_info, 'title') or helpers.get_xml_attr(player_info,
'product'),
'machine_id': helpers.get_xml_attr(player_info, 'machineIdentifier'),
'state': helpers.get_xml_attr(player_info, 'state'),
'local': int(helpers.get_xml_attr(player_info, 'local') == '1'),
@@ -1731,20 +1720,27 @@ class PmsConnect(object):
'transcode_audio_channels': helpers.get_xml_attr(transcode_info, 'audioChannels'),
'transcode_audio_codec': helpers.get_xml_attr(transcode_info, 'audioCodec'),
'transcode_video_codec': helpers.get_xml_attr(transcode_info, 'videoCodec'),
'transcode_width': helpers.get_xml_attr(transcode_info, 'width'), # Blank but keep for backwards compatibility
'transcode_height': helpers.get_xml_attr(transcode_info, 'height'), # Blank but keep backwards compatibility
'transcode_width': helpers.get_xml_attr(transcode_info, 'width'),
# Blank but keep for backwards compatibility
'transcode_height': helpers.get_xml_attr(transcode_info, 'height'),
# Blank but keep backwards compatibility
'transcode_container': helpers.get_xml_attr(transcode_info, 'container'),
'transcode_protocol': helpers.get_xml_attr(transcode_info, 'protocol'),
'transcode_hw_requested': int(helpers.get_xml_attr(transcode_info, 'transcodeHwRequested') == '1'),
'transcode_hw_requested': int(
helpers.get_xml_attr(transcode_info, 'transcodeHwRequested') == '1'),
'transcode_hw_decode': helpers.get_xml_attr(transcode_info, 'transcodeHwDecoding'),
'transcode_hw_decode_title': helpers.get_xml_attr(transcode_info, 'transcodeHwDecodingTitle'),
'transcode_hw_decode_title': helpers.get_xml_attr(transcode_info,
'transcodeHwDecodingTitle'),
'transcode_hw_encode': helpers.get_xml_attr(transcode_info, 'transcodeHwEncoding'),
'transcode_hw_encode_title': helpers.get_xml_attr(transcode_info, 'transcodeHwEncodingTitle'),
'transcode_hw_full_pipeline': int(helpers.get_xml_attr(transcode_info, 'transcodeHwFullPipeline') == '1'),
'transcode_hw_encode_title': helpers.get_xml_attr(transcode_info,
'transcodeHwEncodingTitle'),
'transcode_hw_full_pipeline': int(
helpers.get_xml_attr(transcode_info, 'transcodeHwFullPipeline') == '1'),
'audio_decision': helpers.get_xml_attr(transcode_info, 'audioDecision'),
'video_decision': helpers.get_xml_attr(transcode_info, 'videoDecision'),
'subtitle_decision': helpers.get_xml_attr(transcode_info, 'subtitleDecision'),
'throttled': '1' if helpers.get_xml_attr(transcode_info, 'throttled') == '1' else '0' # Keep for backwards compatibility
'throttled': '1' if helpers.get_xml_attr(transcode_info, 'throttled') == '1' else '0'
# Keep for backwards compatibility
}
else:
transcode_session = False
@@ -1773,8 +1769,10 @@ class PmsConnect(object):
}
# Check HW decoding/encoding
transcode_details['transcode_hw_decoding'] = int(transcode_details['transcode_hw_decode'].lower() in common.HW_DECODERS)
transcode_details['transcode_hw_encoding'] = int(transcode_details['transcode_hw_encode'].lower() in common.HW_ENCODERS)
transcode_details['transcode_hw_decoding'] = int(
transcode_details['transcode_hw_decode'].lower() in common.HW_DECODERS)
transcode_details['transcode_hw_encoding'] = int(
transcode_details['transcode_hw_encode'].lower() in common.HW_ENCODERS)
# Determine if a synced version is being played
sync_id = synced_session_data = synced_item_details = None
@@ -1788,7 +1786,8 @@ class PmsConnect(object):
grandparent_rating_key = helpers.get_xml_attr(session, 'grandparentRatingKey')
synced_items = plex_tv.get_synced_items(client_id_filter=player_details['machine_id'],
rating_key_filter=[rating_key, parent_rating_key, grandparent_rating_key])
rating_key_filter=[rating_key, parent_rating_key,
grandparent_rating_key])
if synced_items:
synced_item_details = synced_items[0]
sync_id = synced_item_details['sync_id']
@@ -1810,9 +1809,11 @@ class PmsConnect(object):
media_info_all = synced_session_data.getElementsByTagName('Media')
else:
media_info_all = session.getElementsByTagName('Media')
stream_media_info = next((m for m in media_info_all if helpers.get_xml_attr(m, 'selected') == '1'), media_info_all[0])
stream_media_info = next((m for m in media_info_all if helpers.get_xml_attr(m, 'selected') == '1'),
media_info_all[0])
part_info_all = stream_media_info.getElementsByTagName('Part')
stream_media_parts_info = next((p for p in part_info_all if helpers.get_xml_attr(p, 'selected') == '1'), part_info_all[0])
stream_media_parts_info = next((p for p in part_info_all if helpers.get_xml_attr(p, 'selected') == '1'),
part_info_all[0])
# Get the stream details
video_stream_info = audio_stream_info = subtitle_stream_info = None
@@ -1834,7 +1835,8 @@ class PmsConnect(object):
video_id = helpers.get_xml_attr(video_stream_info, 'id')
video_details = {'stream_video_bitrate': helpers.get_xml_attr(video_stream_info, 'bitrate'),
'stream_video_bit_depth': helpers.get_xml_attr(video_stream_info, 'bitDepth'),
'stream_video_chroma_subsampling': helpers.get_xml_attr(video_stream_info, 'chromaSubsampling'),
'stream_video_chroma_subsampling': helpers.get_xml_attr(video_stream_info,
'chromaSubsampling'),
'stream_video_color_primaries': helpers.get_xml_attr(video_stream_info, 'colorPrimaries'),
'stream_video_color_range': helpers.get_xml_attr(video_stream_info, 'colorRange'),
'stream_video_color_space': helpers.get_xml_attr(video_stream_info, 'colorSpace'),
@@ -1844,7 +1846,8 @@ class PmsConnect(object):
'stream_video_language': helpers.get_xml_attr(video_stream_info, 'language'),
'stream_video_language_code': helpers.get_xml_attr(video_stream_info, 'languageCode'),
'stream_video_scan_type': helpers.get_xml_attr(video_stream_info, 'scanType'),
'stream_video_decision': helpers.get_xml_attr(video_stream_info, 'decision') or 'direct play'
'stream_video_decision': helpers.get_xml_attr(video_stream_info,
'decision') or 'direct play'
}
else:
video_details = {'stream_video_bitrate': '',
@@ -1867,10 +1870,12 @@ class PmsConnect(object):
audio_details = {'stream_audio_bitrate': helpers.get_xml_attr(audio_stream_info, 'bitrate'),
'stream_audio_bitrate_mode': helpers.get_xml_attr(audio_stream_info, 'bitrateMode'),
'stream_audio_sample_rate': helpers.get_xml_attr(audio_stream_info, 'samplingRate'),
'stream_audio_channel_layout_': helpers.get_xml_attr(audio_stream_info, 'audioChannelLayout'),
'stream_audio_channel_layout_': helpers.get_xml_attr(audio_stream_info,
'audioChannelLayout'),
'stream_audio_language': helpers.get_xml_attr(audio_stream_info, 'language'),
'stream_audio_language_code': helpers.get_xml_attr(audio_stream_info, 'languageCode'),
'stream_audio_decision': helpers.get_xml_attr(audio_stream_info, 'decision') or 'direct play'
'stream_audio_decision': helpers.get_xml_attr(audio_stream_info,
'decision') or 'direct play'
}
else:
audio_details = {'stream_audio_bitrate': '',
@@ -1888,12 +1893,15 @@ class PmsConnect(object):
subtitle_details = {'stream_subtitle_codec': helpers.get_xml_attr(subtitle_stream_info, 'codec'),
'stream_subtitle_container': helpers.get_xml_attr(subtitle_stream_info, 'container'),
'stream_subtitle_format': helpers.get_xml_attr(subtitle_stream_info, 'format'),
'stream_subtitle_forced': int(helpers.get_xml_attr(subtitle_stream_info, 'forced') == '1'),
'stream_subtitle_forced': int(
helpers.get_xml_attr(subtitle_stream_info, 'forced') == '1'),
'stream_subtitle_location': helpers.get_xml_attr(subtitle_stream_info, 'location'),
'stream_subtitle_language': helpers.get_xml_attr(subtitle_stream_info, 'language'),
'stream_subtitle_language_code': helpers.get_xml_attr(subtitle_stream_info, 'languageCode'),
'stream_subtitle_language_code': helpers.get_xml_attr(subtitle_stream_info,
'languageCode'),
'stream_subtitle_decision': helpers.get_xml_attr(subtitle_stream_info, 'decision'),
'stream_subtitle_transient': int(helpers.get_xml_attr(subtitle_stream_info, 'transient') == '1')
'stream_subtitle_transient': int(
helpers.get_xml_attr(subtitle_stream_info, 'transient') == '1')
}
else:
subtitle_selected = None
@@ -1913,7 +1921,8 @@ class PmsConnect(object):
view_offset = helpers.get_xml_attr(session, 'viewOffset')
if indexes == 'sd':
part_id = helpers.get_xml_attr(stream_media_parts_info, 'id')
bif_thumb = '/library/parts/{part_id}/indexes/sd/{view_offset}'.format(part_id=part_id, view_offset=view_offset)
bif_thumb = '/library/parts/{part_id}/indexes/sd/{view_offset}'.format(part_id=part_id,
view_offset=view_offset)
else:
bif_thumb = ''
@@ -1930,14 +1939,19 @@ class PmsConnect(object):
'stream_aspect_ratio': helpers.get_xml_attr(stream_media_info, 'aspectRatio'),
'stream_audio_codec': helpers.get_xml_attr(stream_media_info, 'audioCodec'),
'stream_audio_channels': stream_audio_channels,
'stream_audio_channel_layout': audio_details.get('stream_audio_channel_layout_') or common.AUDIO_CHANNELS.get(stream_audio_channels, stream_audio_channels),
'stream_audio_channel_layout': audio_details.get(
'stream_audio_channel_layout_') or common.AUDIO_CHANNELS.get(stream_audio_channels,
stream_audio_channels),
'stream_video_codec': helpers.get_xml_attr(stream_media_info, 'videoCodec'),
'stream_video_framerate': helpers.get_xml_attr(stream_media_info, 'videoFrameRate'),
'stream_video_resolution': stream_video_resolution,
'stream_video_height': helpers.get_xml_attr(stream_media_info, 'height'),
'stream_video_width': helpers.get_xml_attr(stream_media_info, 'width'),
'stream_duration': helpers.get_xml_attr(stream_media_info, 'duration') or helpers.get_xml_attr(session, 'duration'),
'stream_container_decision': 'direct play' if sync_id else helpers.get_xml_attr(stream_media_parts_info, 'decision').replace('directplay', 'direct play'),
'stream_duration': helpers.get_xml_attr(stream_media_info,
'duration') or helpers.get_xml_attr(session,
'duration'),
'stream_container_decision': 'direct play' if sync_id else helpers.get_xml_attr(
stream_media_parts_info, 'decision').replace('directplay', 'direct play'),
'optimized_version': int(helpers.get_xml_attr(stream_media_info, 'proxyType') == '42'),
'optimized_version_title': helpers.get_xml_attr(stream_media_info, 'title'),
'synced_version': 1 if sync_id else 0,
@@ -2004,7 +2018,8 @@ class PmsConnect(object):
'aspect_ratio': helpers.get_xml_attr(stream_media_info, 'aspectRatio'),
'video_codec': helpers.get_xml_attr(stream_media_info, 'videoCodec'),
'video_resolution': helpers.get_xml_attr(stream_media_info, 'videoResolution').lower(),
'video_full_resolution': helpers.get_xml_attr(stream_media_info, 'videoResolution').lower(),
'video_full_resolution': helpers.get_xml_attr(stream_media_info,
'videoResolution').lower(),
'video_framerate': helpers.get_xml_attr(stream_media_info, 'videoFrameRate'),
'video_profile': helpers.get_xml_attr(stream_media_info, 'videoProfile'),
'audio_codec': helpers.get_xml_attr(stream_media_info, 'audioCodec'),
@@ -2031,9 +2046,11 @@ class PmsConnect(object):
# Get the media info, fallback to first item if match id is not found
source_medias = metadata_details.pop('media_info', [])
source_media_details = next((m for m in source_medias if m['id'] == media_id), next((m for m in source_medias), {}))
source_media_details = next((m for m in source_medias if m['id'] == media_id),
next((m for m in source_medias), {}))
source_media_parts = source_media_details.pop('parts', [])
source_media_part_details = next((p for p in source_media_parts if p['id'] == part_id), next((p for p in source_media_parts), {}))
source_media_part_details = next((p for p in source_media_parts if p['id'] == part_id),
next((p for p in source_media_parts), {}))
source_media_part_streams = source_media_part_details.pop('streams', [])
source_video_details = {'id': '',
@@ -2080,13 +2097,16 @@ class PmsConnect(object):
}
if video_id:
source_video_details = next((p for p in source_media_part_streams if p['id'] == video_id),
next((p for p in source_media_part_streams if p['type'] == '1'), source_video_details))
next((p for p in source_media_part_streams if p['type'] == '1'),
source_video_details))
if audio_id:
source_audio_details = next((p for p in source_media_part_streams if p['id'] == audio_id),
next((p for p in source_media_part_streams if p['type'] == '2'), source_audio_details))
next((p for p in source_media_part_streams if p['type'] == '2'),
source_audio_details))
if subtitle_id:
source_subtitle_details = next((p for p in source_media_part_streams if p['id'] == subtitle_id),
next((p for p in source_media_part_streams if p['type'] == '3'), source_subtitle_details))
next((p for p in source_media_part_streams if p['type'] == '3'),
source_subtitle_details))
# Override the thumb for clips
if media_type == 'clip' and metadata_details.get('extra_type') and metadata_details['art']:
@@ -2107,7 +2127,8 @@ class PmsConnect(object):
transcode_details['transcode_audio_channels'], transcode_details['transcode_audio_channels'])
# Generate a combined transcode decision value
if video_details['stream_video_decision'] == 'transcode' or audio_details['stream_audio_decision'] == 'transcode':
if video_details['stream_video_decision'] == 'transcode' or audio_details[
'stream_audio_decision'] == 'transcode':
transcode_decision = 'transcode'
elif video_details['stream_video_decision'] == 'copy' or audio_details['stream_audio_decision'] == 'copy':
transcode_decision = 'copy'
@@ -2198,7 +2219,8 @@ class PmsConnect(object):
stream_bitrate = helpers.cast_to_int(stream_details['stream_bitrate'])
source_bitrate = helpers.cast_to_int(source_media_details.get('bitrate'))
try:
quailtiy_bitrate = min(b for b in common.AUDIO_QUALITY_PROFILES if stream_bitrate <= b <= source_bitrate)
quailtiy_bitrate = min(
b for b in common.AUDIO_QUALITY_PROFILES if stream_bitrate <= b <= source_bitrate)
quality_profile = common.AUDIO_QUALITY_PROFILES[quailtiy_bitrate]
except ValueError:
quality_profile = 'Original'
@@ -2463,7 +2485,7 @@ class PmsConnect(object):
'thumb': helpers.get_xml_attr(result, 'thumb'),
'parent_thumb': helpers.get_xml_attr(a, 'thumb'),
'duration': helpers.get_xml_attr(result, 'duration')
}
}
children_results_list[media_type].append(children_output)
output = {'results_count': sum(len(v) for k, v in children_results_list.items()),
@@ -2630,11 +2652,13 @@ class PmsConnect(object):
sort_type = ''
if str(section_id).isdigit():
library_data = self.get_library_list(str(section_id), list_type, count, sort_type, label_key, output_format='xml')
library_data = self.get_library_list(str(section_id), list_type, count, sort_type, label_key,
output_format='xml')
elif str(rating_key).isdigit():
library_data = self.get_metadata_children(str(rating_key), output_format='xml')
else:
logger.warn("Tautulli Pmsconnect :: get_library_children called by invalid section_id or rating_key provided.")
logger.warn(
"Tautulli Pmsconnect :: get_library_children called by invalid section_id or rating_key provided.")
return []
try:
@@ -2735,7 +2759,8 @@ class PmsConnect(object):
for library in libraries_list:
section_type = library['section_type']
section_id = library['section_id']
children_list = self.get_library_children_details(section_id=section_id, section_type=section_type, count='1')
children_list = self.get_library_children_details(section_id=section_id, section_type=section_type,
count='1')
if children_list:
library_stats = {'section_id': section_id,
@@ -2749,34 +2774,40 @@ class PmsConnect(object):
}
if section_type == 'show':
parent_list = self.get_library_children_details(section_id=section_id, section_type='season', count='1')
parent_list = self.get_library_children_details(section_id=section_id, section_type='season',
count='1')
if parent_list:
parent_stats = {'parent_count': parent_list['library_count']}
library_stats.update(parent_stats)
child_list = self.get_library_children_details(section_id=section_id, section_type='episode', count='1')
child_list = self.get_library_children_details(section_id=section_id, section_type='episode',
count='1')
if child_list:
child_stats = {'child_count': child_list['library_count']}
library_stats.update(child_stats)
if section_type == 'artist':
parent_list = self.get_library_children_details(section_id=section_id, section_type='album', count='1')
parent_list = self.get_library_children_details(section_id=section_id, section_type='album',
count='1')
if parent_list:
parent_stats = {'parent_count': parent_list['library_count']}
library_stats.update(parent_stats)
child_list = self.get_library_children_details(section_id=section_id, section_type='track', count='1')
child_list = self.get_library_children_details(section_id=section_id, section_type='track',
count='1')
if child_list:
child_stats = {'child_count': child_list['library_count']}
library_stats.update(child_stats)
if section_type == 'photo':
parent_list = self.get_library_children_details(section_id=section_id, section_type='picture', count='1')
parent_list = self.get_library_children_details(section_id=section_id, section_type='picture',
count='1')
if parent_list:
parent_stats = {'parent_count': parent_list['library_count']}
library_stats.update(parent_stats)
child_list = self.get_library_children_details(section_id=section_id, section_type='clip', count='1')
child_list = self.get_library_children_details(section_id=section_id, section_type='clip',
count='1')
if child_list:
child_stats = {'child_count': child_list['library_count']}
library_stats.update(child_stats)
@@ -2896,7 +2927,7 @@ class PmsConnect(object):
for h in hubs:
if helpers.get_xml_attr(h, 'size') == '0' or \
helpers.get_xml_attr(h, 'type') not in search_results_list:
helpers.get_xml_attr(h, 'type') not in search_results_list:
continue
if h.getElementsByTagName('Video'):
@@ -2971,7 +3002,8 @@ class PmsConnect(object):
section_id = metadata['section_id']
library_name = metadata['library_name']
except Exception as e:
logger.warn("Tautulli Pmsconnect :: Unable to get grandparent_rating_key for get_rating_keys_list: %s." % e)
logger.warn(
"Tautulli Pmsconnect :: Unable to get grandparent_rating_key for get_rating_keys_list: %s." % e)
return {}
# get parent_rating_keys
@@ -3035,8 +3067,8 @@ class PmsConnect(object):
key = int(parent_index) if match_type == 'index' else parent_title
parents.update({key:
{'rating_key': int(parent_rating_key),
'children': children}
{'rating_key': int(parent_rating_key),
'children': children}
})
key = 0 if match_type == 'index' else title
@@ -3097,7 +3129,8 @@ class PmsConnect(object):
# Catch the malformed XML on certain PMX version.
# XML parser helper returns empty list if there is an error parsing XML
if updater_status == []:
logger.warn("Plex API updater XML is broken on the current PMS version. Please update your PMS manually.")
logger.warn(
"Plex API updater XML is broken on the current PMS version. Please update your PMS manually.")
logger.info("Tautulli is unable to check for Plex updates. Disabling check for Plex updates.")
# Disable check for Plex updates