Fix error refreshing library counts when XML fails
* Also increase http request timeout to 20 seconds
This commit is contained in:
@@ -56,12 +56,12 @@ class HTTPHandler(object):
|
|||||||
if proto.upper() == 'HTTPS':
|
if proto.upper() == 'HTTPS':
|
||||||
if not self.ssl_verify and hasattr(ssl, '_create_unverified_context'):
|
if not self.ssl_verify and hasattr(ssl, '_create_unverified_context'):
|
||||||
context = ssl._create_unverified_context()
|
context = ssl._create_unverified_context()
|
||||||
handler = HTTPSConnection(host=self.host, port=self.port, timeout=10, context=context)
|
handler = HTTPSConnection(host=self.host, port=self.port, timeout=20, context=context)
|
||||||
logger.warn(u"PlexPy HTTP Handler :: Unverified HTTPS request made. This connection is not secure.")
|
logger.warn(u"PlexPy HTTP Handler :: Unverified HTTPS request made. This connection is not secure.")
|
||||||
else:
|
else:
|
||||||
handler = HTTPSConnection(host=self.host, port=self.port, timeout=10)
|
handler = HTTPSConnection(host=self.host, port=self.port, timeout=20)
|
||||||
else:
|
else:
|
||||||
handler = HTTPConnection(host=self.host, port=self.port, timeout=10)
|
handler = HTTPConnection(host=self.host, port=self.port, timeout=20)
|
||||||
|
|
||||||
token_string = ''
|
token_string = ''
|
||||||
if not no_token:
|
if not no_token:
|
||||||
|
@@ -1598,7 +1598,7 @@ class PmsConnect(object):
|
|||||||
try:
|
try:
|
||||||
xml_head = library_data.getElementsByTagName('MediaContainer')
|
xml_head = library_data.getElementsByTagName('MediaContainer')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn(u"PlexPy Pmsconnect :: Unable to parse XML for get_library_children: %s." % e)
|
logger.warn(u"PlexPy Pmsconnect :: Unable to parse XML for get_library_children_details: %s." % e)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
childern_list = []
|
childern_list = []
|
||||||
@@ -1689,7 +1689,7 @@ class PmsConnect(object):
|
|||||||
section_id = library['section_id']
|
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_count'] != '0':
|
if children_list and children_list['library_count'] != '0':
|
||||||
library_stats = {'section_id': library['section_id'],
|
library_stats = {'section_id': library['section_id'],
|
||||||
'section_name': library['section_name'],
|
'section_name': library['section_name'],
|
||||||
'section_type': section_type,
|
'section_type': section_type,
|
||||||
@@ -1700,28 +1700,34 @@ class PmsConnect(object):
|
|||||||
|
|
||||||
if section_type == 'show':
|
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']}
|
parent_stats = {'parent_count': parent_list['library_count']}
|
||||||
library_stats.update(parent_stats)
|
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']}
|
child_stats = {'child_count': child_list['library_count']}
|
||||||
library_stats.update(child_stats)
|
library_stats.update(child_stats)
|
||||||
|
|
||||||
if section_type == 'artist':
|
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']}
|
parent_stats = {'parent_count': parent_list['library_count']}
|
||||||
library_stats.update(parent_stats)
|
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']}
|
child_stats = {'child_count': child_list['library_count']}
|
||||||
library_stats.update(child_stats)
|
library_stats.update(child_stats)
|
||||||
|
|
||||||
if section_type == 'photo':
|
if section_type == 'photo':
|
||||||
parent_list = self.get_library_children_details(section_id=section_id, section_type='photoAlbum', count='1')
|
parent_list = self.get_library_children_details(section_id=section_id, section_type='photoAlbum', count='1')
|
||||||
|
if parent_list:
|
||||||
parent_stats = {'parent_count': parent_list['library_count']}
|
parent_stats = {'parent_count': parent_list['library_count']}
|
||||||
library_stats.update(parent_stats)
|
library_stats.update(parent_stats)
|
||||||
|
|
||||||
child_list = self.get_library_children_details(section_id=section_id, section_type='picture', count='1')
|
child_list = self.get_library_children_details(section_id=section_id, section_type='picture', count='1')
|
||||||
|
if child_list:
|
||||||
child_stats = {'child_count': child_list['library_count']}
|
child_stats = {'child_count': child_list['library_count']}
|
||||||
library_stats.update(child_stats)
|
library_stats.update(child_stats)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user